:root {
    --bg: #0f1120;
    --bg2: #161a2e;
    --card: #1b2038;
    --card2: #212745;
    --line: #2c3358;
    --text: #eef0fb;
    --muted: #9aa3c9;
    --accent: #7c5cff;
    --accent2: #4f46e5;
    --emerald: #34d399;
    --error: #fb7185;
    --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Outfit', system-ui, sans-serif;
    background: radial-gradient(1200px 600px at 50% -10%, #1a1f3a 0%, var(--bg) 55%);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100%;
}
.screen { min-height: 100vh; }
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; padding: 24px; }

/* ---- Auth ---- */
.auth-box {
    width: 100%; max-width: 380px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 34px 28px;
    box-shadow: 0 30px 80px rgba(0,0,0,.45);
    text-align: center;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.brand img, .brand-sm img { border-radius: 8px; }
.subtitle { color: var(--muted); margin: 8px 0 22px; }
.auth-box input, .toolbar input, .editor textarea, .modal input {
    width: 100%; background: var(--bg2); color: var(--text);
    border: 1px solid var(--line); border-radius: 12px;
    padding: 13px 15px; font-size: 15px; font-family: inherit;
    margin-bottom: 12px; outline: none; transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--accent); }
button { cursor: pointer; font-family: inherit; font-weight: 600; border: none; }
.btn-primary { width: 100%; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-radius: 12px; padding: 13px; font-size: 15px; transition: transform .1s, filter .15s; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { width: 100%; background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--accent); padding: 10px; }
.btn-ghost:hover { text-decoration: underline; }
.btn-accent { background: rgba(124,92,255,.14); color: #c3b6ff; border: 1px solid rgba(124,92,255,.4); border-radius: 12px; padding: 11px 16px; white-space: nowrap; }
.btn-accent:hover { background: rgba(124,92,255,.24); }
.btn-text { background: transparent; color: var(--muted); padding: 6px 10px; font-size: 14px; }
.btn-text:hover { color: var(--text); }
.sm { padding: 9px 14px !important; font-size: 14px !important; width: auto; }
.or { color: var(--muted); font-size: 13px; margin: 12px 0 4px; position: relative; }
.privacy { color: var(--muted); font-size: 12.5px; margin-top: 18px; line-height: 1.5; }
.privacy b { color: var(--emerald); }
.error { background: rgba(251,113,133,.12); color: var(--error); border: 1px solid rgba(251,113,133,.3); border-radius: 10px; padding: 10px; font-size: 14px; margin-bottom: 14px; }

/* ---- App shell ---- */
.header {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; background: rgba(15,17,32,.82);
    backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand-sm { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; }
.header-actions { display: flex; gap: 4px; }
.container { max-width: 720px; margin: 0 auto; padding: 22px 18px 80px; }

/* ---- Editor ---- */
.editor { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.editor textarea { margin-bottom: 8px; resize: vertical; line-height: 1.5; }
.editor-actions { display: flex; align-items: center; justify-content: space-between; }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---- Toolbar ---- */
.toolbar { display: flex; gap: 10px; margin: 18px 0 6px; }
.search { position: relative; flex: 1; }
.search input { margin-bottom: 0; padding-right: 38px; }
.clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; color: var(--muted); font-size: 20px; padding: 4px 8px; }

/* ---- Tag cloud ---- */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.tag-cloud .chip { background: var(--card2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; transition: .15s; }
.tag-cloud .chip:hover { border-color: var(--accent); color: var(--text); }
.tag-cloud .chip b { color: var(--accent); font-weight: 600; margin-left: 4px; }
.tag-cloud .chip.active { background: rgba(124,92,255,.2); border-color: var(--accent); color: #fff; }

/* ---- Notes ---- */
.notes-feed { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.note-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 13px; position: relative; transition: border-color .15s; }
.note-card:hover { border-color: #3a4272; }
.note-card.pinned { border-color: rgba(124,92,255,.5); background: linear-gradient(180deg, rgba(124,92,255,.06), var(--card)); }
.note-summary { font-weight: 600; font-size: 15.5px; margin-bottom: 6px; padding-right: 60px; }
.note-content { color: var(--muted); font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.note-content.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.note-more { color: var(--accent); font-size: 13px; background: none; padding: 4px 0; }
.note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; align-items: center; }
.tag { background: rgba(124,92,255,.13); color: #b9abff; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.tag:hover { background: rgba(124,92,255,.25); }
.edit-tags { color: var(--muted); font-size: 12px; background: none; padding: 3px 6px; border: 1px dashed var(--line); border-radius: 999px; }
.edit-tags:hover { color: var(--text); border-color: var(--accent); }
.note-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 2px; }
.icon-btn { background: transparent; color: var(--muted); font-size: 16px; padding: 4px 7px; border-radius: 8px; line-height: 1; }
.icon-btn:hover { background: var(--card2); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.note-date { color: #5f688f; font-size: 11.5px; margin-top: 9px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .5; }

/* ---- Modals ---- */
.modal { position: fixed; inset: 0; background: rgba(6,7,15,.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20; }
.modal-content { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; width: 100%; max-width: 440px; max-height: 86vh; overflow-y: auto; }
.modal-content.wide { max-width: 600px; }
.modal-content h3 { font-size: 20px; margin-bottom: 6px; }
.muted { color: var(--muted); }
.modal-content .muted { margin-bottom: 16px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.tags-editor { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; min-height: 20px; }
.tags-editor .tag { display: inline-flex; align-items: center; gap: 6px; }
.tags-editor .tag button { background: none; color: #b9abff; font-size: 15px; line-height: 1; padding: 0; }
.synth-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.synth-input-row input { margin-bottom: 0; }

/* ---- Synthesis result ---- */
.synth-result { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.synth-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; flex: 1; min-width: 90px; text-align: center; }
.stat .n { font-size: 22px; font-weight: 800; color: var(--accent); }
.stat .l { font-size: 12px; color: var(--muted); }
.synth-timeline { display: flex; flex-direction: column; gap: 12px; }
.synth-item { background: var(--bg2); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; padding: 11px 14px; }
.synth-item .s { font-weight: 600; font-size: 14.5px; }
.synth-item .c { color: var(--muted); font-size: 13.5px; margin-top: 4px; white-space: pre-wrap; }
.synth-item .d { color: #5f688f; font-size: 11px; margin-top: 6px; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--card2); border: 1px solid var(--line); color: var(--text); padding: 12px 20px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 40; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
    .toolbar { flex-direction: column; }
    .btn-accent { width: 100%; }
    .note-summary { padding-right: 54px; }
}
