/* ═══════════════════════════════════════════════════════════════
   Phylactery — Neural Dashboard Design System
   Dark-first, navy + blue primary, Inter font
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables — Dark (default) ── */
:root {
    --bg:             #0f1115;
    --surface:        #181b21;
    --surface-active: #22262e;
    --surface-hover:  #282d37;
    --border:         #2d3442;
    --border-hi:      #3d4656;
    --text:           #e2e8f0;
    --text-muted:     #94a3b8;
    --text-subtle:    #64748b;
    --primary:        #3b82f6;
    --primary-hover:  #2563eb;
    --primary-dim:    rgba(59,130,246,0.10);
    --primary-glow:   rgba(59,130,246,0.15);
    --success:        #22c55e;
    --success-dim:    rgba(34,197,94,0.10);
    --error:          #ef4444;
    --error-dim:      rgba(239,68,68,0.10);
    --warning:        #f59e0b;
    --warning-dim:    rgba(245,158,11,0.10);

    --type-thought:         #a855f7;
    --type-thought-bg:      rgba(168,85,247,0.12);
    --type-thought-border:  rgba(168,85,247,0.20);
    --type-decision:        #f59e0b;
    --type-decision-bg:     rgba(245,158,11,0.12);
    --type-decision-border: rgba(245,158,11,0.20);
    --type-task:            #22c55e;
    --type-task-bg:         rgba(34,197,94,0.12);
    --type-task-border:     rgba(34,197,94,0.20);
    --type-reference:       #94a3b8;
    --type-reference-bg:    rgba(148,163,184,0.12);
    --type-reference-border:rgba(148,163,184,0.20);
    --type-note:            #6366f1;
    --type-note-bg:         rgba(99,102,241,0.12);
    --type-note-border:     rgba(99,102,241,0.20);
    --type-conversation:    #ec4899;
    --type-conversation-bg: rgba(236,72,153,0.12);
    --type-conversation-border: rgba(236,72,153,0.20);
    --type-preference:      #14b8a6;
    --type-preference-bg:   rgba(20,184,166,0.12);
    --type-preference-border: rgba(20,184,166,0.20);

    --radius:         12px;
    --radius-sm:      8px;
    --radius-xs:      4px;
    --font:           'Inter', system-ui, -apple-system, sans-serif;
    --mono:           'JetBrains Mono', 'SF Mono', monospace;
    --topnav-height:  56px;
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.25);
    --shadow:         0 1px 3px rgba(0,0,0,0.35);
    --shadow-md:      0 4px 6px rgba(0,0,0,0.35);
    --shadow-lg:      0 10px 20px rgba(0,0,0,0.4);
}

/* ── Light theme ── */
[data-theme="light"] {
    --bg:             #f6f6f8;
    --surface:        #ffffff;
    --surface-active: #f1f5f9;
    --surface-hover:  #e2e8f0;
    --border:         #e2e8f0;
    --border-hi:      #cbd5e1;
    --text:           #0f172a;
    --text-muted:     #64748b;
    --text-subtle:    #94a3b8;
    --primary:        #3b82f6;
    --primary-hover:  #2563eb;
    --primary-dim:    rgba(59,130,246,0.08);
    --primary-glow:   rgba(59,130,246,0.12);
    --success:        #16a34a;
    --success-dim:    rgba(22,163,74,0.08);
    --error:          #dc2626;
    --error-dim:      rgba(220,38,38,0.08);
    --warning:        #d97706;
    --warning-dim:    rgba(217,119,6,0.08);
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
    --shadow:         0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:      0 4px 6px rgba(0,0,0,0.08);
    --shadow-lg:      0 10px 15px rgba(0,0,0,0.1);

    --type-thought:         #9333ea;
    --type-thought-bg:      rgba(147,51,234,0.08);
    --type-thought-border:  rgba(147,51,234,0.15);
    --type-decision:        #d97706;
    --type-decision-bg:     rgba(217,119,6,0.08);
    --type-decision-border: rgba(217,119,6,0.15);
    --type-task:            #16a34a;
    --type-task-bg:         rgba(22,163,74,0.08);
    --type-task-border:     rgba(22,163,74,0.15);
    --type-reference:       #64748b;
    --type-reference-bg:    rgba(100,116,139,0.08);
    --type-reference-border:rgba(100,116,139,0.15);
    --type-note:            #4f46e5;
    --type-note-bg:         rgba(79,70,229,0.08);
    --type-note-border:     rgba(79,70,229,0.15);
    --type-conversation:    #db2777;
    --type-conversation-bg: rgba(219,39,119,0.08);
    --type-conversation-border: rgba(219,39,119,0.15);
    --type-preference:      #0d9488;
    --type-preference-bg:   rgba(13,148,136,0.08);
    --type-preference-border: rgba(13,148,136,0.15);
}

/* ── Alpine cloak ── */
[x-cloak] { display: none !important; }

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Body ── */
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4, h5, h6 { line-height: 1.3; font-weight: 600; }

mark, .highlight {
    background: var(--primary-dim);
    color: var(--primary);
    border-radius: 2px;
    padding: 0 2px;
}

/* ═══════════════════════════════════════════════════════════════
   App Shell — topnav + main (no sidebar)
   ═══════════════════════════════════════════════════════════════ */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Top Navigation ── */
.topnav {
    height: var(--topnav-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    padding: 0 1.25rem;
    flex-shrink: 0;
    z-index: 30;
    gap: 1rem;
}

.topnav-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.topnav-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.topnav-brand-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.topnav-brand-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    text-decoration: none;
    margin-right: 0.5rem;
}

/* Nav links in topnav (replaces sidebar nav) */
.topnav-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}
.topnav-nav-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    white-space: nowrap;
}
.topnav-nav-link:hover {
    color: var(--text);
    background: var(--surface-active);
}
.topnav-nav-link.active {
    background: var(--primary-dim);
    color: var(--primary);
}

/* Focus indicator in topnav (compact inline) */
.topnav-focus {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    background: var(--primary-dim);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: var(--radius-sm);
    margin-left: 0.25rem;
}
.topnav-focus-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}
.topnav-focus-duration {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--mono);
}
.topnav-focus-end {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.topnav-focus-end:hover { background: var(--error-dim); color: var(--error); border-color: var(--error); }

.topnav-center {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    max-width: 400px;
    margin-left: auto;
}

.topnav-search {
    width: 100%;
    position: relative;
}

.topnav-search-shell {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: border-color 0.15s, background 0.15s;
}
.topnav-search-shell:hover,
.topnav-search-shell.open {
    border-color: var(--border-hi);
    background: var(--surface-hover);
    color: var(--text-muted);
}
.topnav-search svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.topnav-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    outline: none;
}
.topnav-search-input::placeholder { color: var(--text-muted); }
.topnav-search-clear {
    border: none;
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}
.topnav-search-kbd {
    font-family: var(--mono);
    font-size: 0.7rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    color: var(--text-subtle);
}
.topnav-search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    z-index: 45;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.topnav-search-advanced-link {
    display: inline-flex;
    align-items: center;
    margin-top: 0.4rem;
    padding-left: 0.25rem;
    font-size: 0.74rem;
    color: var(--text-subtle);
    text-decoration: none;
}
.topnav-search-advanced-link:hover { color: var(--primary); }
.topnav-search-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.15rem;
}
.topnav-search-panel-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-subtle);
}
.topnav-search-panel-count {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.topnav-search-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.topnav-search-item,
.topnav-search-suggestion {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    text-align: left;
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.topnav-search-item:hover,
.topnav-search-suggestion:hover {
    border-color: var(--border-hi);
    background: var(--surface-hover);
    transform: translateY(-1px);
}
.topnav-search-item-title,
.topnav-search-suggestion-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.topnav-search-item-snippet {
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.topnav-search-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-subtle);
}
.topnav-search-item-meta strong {
    color: var(--text-muted);
    font-weight: 600;
}
.topnav-search-empty {
    padding: 0.85rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.topnav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.topnav-btn:hover {
    background: var(--surface-active);
    color: var(--text);
}
.topnav-btn svg { width: 20px; height: 20px; }

@media (max-width: 980px) {
    .topnav-center {
        max-width: 320px;
    }
}

@media (max-width: 768px) {
    .topnav-center {
        display: none;
    }
}

/* ── Focus dot (shared by topnav + mobile drawer) ── */
.focus-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: focusPulse 2s infinite;
    flex-shrink: 0;
}
@keyframes focusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Focus indicator (mobile drawer) ── */
.focus-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--primary-dim);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: var(--radius-sm);
}
.focus-info { flex: 1; min-width: 0; }
.focus-label { font-size: 0.8rem; color: var(--text); display: block; }
.focus-label strong { color: var(--primary); }
.focus-duration { font-size: 0.7rem; color: var(--text-muted); font-family: var(--mono); }
.focus-end-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.focus-end-btn:hover { background: var(--error-dim); color: var(--error); border-color: var(--error); }

/* ── Mobile nav drawer (replaces sidebar on small screens) ── */
.mobile-nav-drawer {
    display: none;
    position: fixed;
    top: var(--topnav-height);
    left: 0;
    right: 0;
    z-index: 40;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    max-height: calc(100vh - var(--topnav-height));
    overflow-y: auto;
}
.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mobile-nav-link {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s;
}
.mobile-nav-link:hover { background: var(--surface-active); color: var(--text); }
.mobile-nav-link.active { background: var(--primary-dim); color: var(--primary); }

.mobile-nav-overlay {
    position: fixed;
    top: var(--topnav-height);
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0,0,0,0.6);
    z-index: 39;
    backdrop-filter: blur(4px);
}

/* ── Main pane ── */
.main-pane {
    flex: 1;
    overflow-y: auto;
    background: var(--bg);
}

.page-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Dashboard breaks out of page-content constraints */
.page-content:has(.dashboard) {
    max-width: none;
    margin: 0;
    padding: 0;
}

/* ═══════════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════════ */
button, .btn {
    font-family: var(--font);
    cursor: pointer;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(59,130,246,0.25);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-active);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-hi); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-ghost:hover { background: var(--surface-active); color: var(--text); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--error-dim);
    color: var(--error);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-danger:hover { background: var(--error); color: #fff; }

.btn-small { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--surface-active); color: var(--text); }
.btn-icon svg { width: 20px; height: 20px; }

kbd {
    font-family: var(--mono);
    font-size: 0.7rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    color: var(--text-subtle);
}

/* ═══════════════════════════════════════════════════════════════
   Form Inputs
   ═══════════════════════════════════════════════════════════════ */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    font-family: var(--font);
    font-size: 0.875rem;
    background: var(--surface-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}
textarea { resize: vertical; line-height: 1.6; }
::placeholder { color: var(--text-subtle); }

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 2rem;
}

input[type="file"] {
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.375rem; text-transform: uppercase; letter-spacing: 0.04em; }
.form-hint { font-size: 0.8rem; color: var(--text-subtle); margin-top: 0.375rem; }
.form-hint code { font-family: var(--mono); font-size: 0.75rem; background: var(--surface-active); padding: 0.15rem 0.4rem; border-radius: 3px; }
.form-input { width: 100%; }

/* ═══════════════════════════════════════════════════════════════
   Flash Messages / Toast
   ═══════════════════════════════════════════════════════════════ */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin: 0.75rem 0;
}
.flash.success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.flash.error   { background: var(--error-dim);   color: var(--error);   border: 1px solid rgba(239,68,68,0.2); }

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}
.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    white-space: nowrap;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--error); }
.toast-undo {
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-xs);
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--primary-dim);
    color: var(--primary);
    border: none;
    cursor: pointer;
}
.toast-undo:hover { background: var(--primary-glow); }
.toast-close {
    font-size: 1.1rem;
    border: none;
    background: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}
.toast-close:hover { color: var(--text); }

.toast-enter { animation: toastIn 0.25s ease; }
.toast-leave { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ═══════════════════════════════════════════════════════════════
   Memory Cards
   ═══════════════════════════════════════════════════════════════ */
.memory-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.memory-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.memory-card:hover {
    border-color: rgba(59,130,246,0.5);
    box-shadow: 0 4px 16px rgba(59,130,246,0.1);
}

.memory-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

/* ── Type badges ── */
.memory-type {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
}

.badge-thought      { background: var(--type-thought-bg); color: var(--type-thought); border: 1px solid var(--type-thought-border); }
.badge-decision     { background: var(--type-decision-bg); color: var(--type-decision); border: 1px solid var(--type-decision-border); }
.badge-task         { background: var(--type-task-bg); color: var(--type-task); border: 1px solid var(--type-task-border); }
.badge-reference    { background: var(--type-reference-bg); color: var(--type-reference); border: 1px solid var(--type-reference-border); }
.badge-note         { background: var(--type-note-bg); color: var(--type-note); border: 1px solid var(--type-note-border); }
.badge-conversation { background: var(--type-conversation-bg); color: var(--type-conversation); border: 1px solid var(--type-conversation-border); }
.badge-preference   { background: var(--type-preference-bg); color: var(--type-preference); border: 1px solid var(--type-preference-border); }
.badge-auto-classifying { background: var(--surface-active); color: var(--text-subtle); border: 1px solid var(--border); font-style: italic; }

/* Generic badge (used standalone in admin, project pages) */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    letter-spacing: 0.03em;
}

/* Priority dots */
.memory-priority-dot {
    width: 8px; height: 8px; border-radius: 50%;
}
.priority-dot-1 { background: var(--text-subtle); }
.priority-dot-2 { background: var(--warning); }
.priority-dot-3 { background: var(--error); }

.memory-project {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.memory-project::before { content: ''; }

.memory-date {
    font-size: 0.75rem;
    color: var(--text-subtle);
    margin-left: auto;
}

.memory-score {
    font-size: 0.7rem;
    font-family: var(--mono);
    color: var(--success);
    background: var(--success-dim);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-xs);
}

.memory-deadline {
    font-size: 0.7rem;
    font-family: var(--mono);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-xs);
}
.deadline-overdue { background: var(--error-dim); color: var(--error); }
.deadline-soon { background: var(--warning-dim); color: var(--warning); }
.deadline-ok { background: var(--success-dim); color: var(--success); }

.memory-summary {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.memory-content {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.memory-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.tag {
    display: inline-flex;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
    transition: all 0.15s;
}
.tag:hover { border-color: var(--primary); color: var(--primary); }

.search-result-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.empty {
    text-align: center;
    color: var(--text-subtle);
    padding: 2rem;
    font-size: 0.9rem;
}

.loading {
    text-align: center;
    color: var(--text-subtle);
    padding: 2rem;
}

/* Load more */
.load-more-container {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0;
}
.btn-load-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-active);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-load-more:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-hi); }

/* ═══════════════════════════════════════════════════════════════
   Dashboard
   ═══════════════════════════════════════════════════════════════ */

.dashboard {
    display: flex;
    min-height: calc(100vh - var(--topnav-height));
}

.dash-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.dash-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.dash-date-text { font-size: 0.875rem; color: var(--text-muted); }

.dash-stats { display: flex; gap: 1rem; }
.dash-stat {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--mono);
}
.dash-stat-warn { color: var(--warning); }

/* Dashboard grid — main scrollable + right sidebar panel */
.dashboard-grid {
    display: flex;
    flex: 1;
    min-width: 0;
}

.dashboard-main {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Right sidebar — full-height panel like Stitch */
.dashboard-sidebar {
    width: 320px;
    flex-shrink: 0;
    border-left: 1px solid var(--border);
    background: var(--surface);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - var(--topnav-height));
    position: sticky;
    top: 0;
}

/* ── Quick Capture (Stitch-style with accent bar) ── */
.quick-capture {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.quick-capture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
}

.qc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.qc-header-left {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.qc-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}
.qc-header-left h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.qc-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}
.qc-header-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.qc-header-right select {
    width: auto;
    min-width: 110px;
    font-size: 0.8rem;
    padding: 0.35rem 2rem 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-active);
    color: var(--text-muted);
}

.qc-textarea-wrap {
    position: relative;
}
.qc-textarea-wrap textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    padding-bottom: 2.5rem;
    color: var(--text);
    font-size: 0.875rem;
    resize: none;
}
.qc-textarea-wrap textarea::placeholder { color: var(--text-subtle); }
.qc-textarea-wrap textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
    outline: none;
}

.qc-textarea-actions {
    position: absolute;
    bottom: 0.6rem;
    right: 0.6rem;
    display: flex;
    gap: 0.375rem;
    align-items: center;
}
.qc-save-btn {
    padding: 0.35rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
    box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}
.qc-save-btn:hover { background: var(--primary-hover); }

/* ── Recent memories section ── */
.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.recent-header h2, .recent h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.recent #recent-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* ── Dashboard Sidebar Sections ── */

/* Briefing with gradient border (like Stitch) */
.ds-briefing-wrap {
    border-radius: 12px;
    padding: 1px;
    background: linear-gradient(to bottom, rgba(59,130,246,0.4), transparent);
}
.ds-briefing {
    background: var(--surface-active);
    border-radius: 11px;
    padding: 1.25rem;
}
.ds-briefing-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.ds-briefing-icon {
    width: 18px;
    height: 18px;
    color: var(--primary);
}
.ds-briefing-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}
.ds-briefing-content {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.65;
    white-space: pre-wrap;
}

/* Generic sidebar section */
.ds-section { }
.ds-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.ds-section-header h3 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
}

/* Sidebar alerts */
.ds-alerts-list { display: flex; flex-direction: column; gap: 0.6rem; }
.ds-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
}
.ds-alert-overdue {
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.12);
}
.ds-alert-upcoming {
    background: rgba(245,158,11,0.06);
    border: 1px solid rgba(245,158,11,0.12);
}
.ds-alert-info {
    background: rgba(59,130,246,0.06);
    border: 1px solid rgba(59,130,246,0.12);
}
.ds-alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}
.ds-alert-overdue .ds-alert-icon { color: #ef4444; }
.ds-alert-upcoming .ds-alert-icon { color: #f59e0b; }
.ds-alert-info .ds-alert-icon { color: var(--primary); }
.ds-alert-text { flex: 1; min-width: 0; }
.ds-alert-message {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
}
.ds-alert-overdue .ds-alert-message { color: #ef4444; }
.ds-alert-upcoming .ds-alert-message { color: #f59e0b; }
.ds-alert-info .ds-alert-message { color: var(--primary); }
.ds-alert-type {
    display: block;
    font-size: 0.7rem;
}
.ds-alert-overdue .ds-alert-type { color: rgba(239,68,68,0.7); }
.ds-alert-upcoming .ds-alert-type { color: rgba(245,158,11,0.7); }
.ds-alert-info .ds-alert-type { color: rgba(59,130,246,0.7); }
.ds-alert .btn-dismiss { opacity: 0; transition: opacity 0.15s; }
.ds-alert:hover .btn-dismiss { opacity: 1; }

/* Sidebar projects */
.ds-projects { display: flex; flex-direction: column; gap: 1rem; }
.ds-project-item {
    display: block;
    text-decoration: none;
    transition: all 0.15s;
}
.ds-project-item:hover .ds-project-name { color: var(--primary); }
.ds-project-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}
.ds-project-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    transition: color 0.15s;
}
.ds-project-count {
    font-size: 0.75rem;
    font-family: var(--mono);
    color: var(--text-subtle);
}
.ds-project-meta {
    font-size: 0.7rem;
    color: var(--text-subtle);
    display: block;
    margin-top: 0.25rem;
}
/* Project progress bar (visual indicator) */
.ds-project-bar {
    width: 100%;
    height: 5px;
    background: var(--surface-active);
    border-radius: 3px;
    overflow: hidden;
}
.ds-project-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Sidebar saved searches */
.ds-searches { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.ds-search-pill {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s;
}
.ds-search-pill:hover { border-color: var(--primary); color: var(--primary); }

/* Sidebar footer */
.ds-footer {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.ds-footer-link {
    font-size: 0.75rem;
    color: var(--text-subtle);
    text-decoration: none;
}
.ds-footer-link:hover { color: var(--primary); }

/* Keep old class names for backward compat (used in other templates) */
.alerts-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}
.alerts-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.alerts-header h2 { font-size: 0.8rem; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.btn-dismiss-all {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
}
.btn-dismiss-all:hover { color: var(--primary); }
.alert-list { display: flex; flex-direction: column; gap: 0.5rem; list-style: none; }
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.alert-overdue { background: var(--error-dim); border: 1px solid rgba(239,68,68,0.15); }
.alert-upcoming { background: var(--warning-dim); border: 1px solid rgba(245,158,11,0.15); }
.alert-info { background: var(--primary-dim); border: 1px solid rgba(59,130,246,0.15); }
.alert-type {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--mono);
    text-transform: uppercase;
    color: var(--text-muted);
    flex-shrink: 0;
}
.alert-message { flex: 1; color: var(--text); }
.btn-dismiss {
    font-size: 0.85rem;
    color: var(--text-subtle);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.btn-dismiss:hover { color: var(--text); }

/* Daily briefing (old class names, still used by other views) */
.daily-briefing {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}
.daily-briefing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #a855f7);
}
.daily-briefing h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.briefing-content {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.7;
}

/* Old capture-controls (used by dashboard old compat, still needed) */
.capture-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.capture-controls select {
    width: auto;
    min-width: 120px;
    font-size: 0.8rem;
    padding: 0.35rem 2rem 0.35rem 0.5rem;
}
.capture-controls button[type="submit"] {
    margin-left: auto;
    padding: 0.45rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
    box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}
.capture-controls button[type="submit"]:hover { background: var(--primary-hover); }

/* Projects section (dashboard sidebar old compat) */
.projects h2, .saved-searches h2 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
    margin-bottom: 0.75rem;
}
.project-list { display: flex; flex-direction: column; gap: 0.5rem; }
.project-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.project-list-item:hover { border-color: var(--border-hi); }
.project-list-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    min-width: 0;
}
.project-list-name { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.project-list-meta { font-size: 0.7rem; color: var(--text-subtle); }
.btn-focus-start {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.btn-focus-start:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }

/* Staleness indicators */
.staleness-item-fresh .project-list-name::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--success); margin-right: 0.5rem; vertical-align: middle; }
.staleness-item-recent .project-list-name::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); margin-right: 0.5rem; vertical-align: middle; }
.staleness-item-stale .project-list-name::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text-subtle); margin-right: 0.5rem; vertical-align: middle; }

/* Saved searches */
.saved-search-list { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.saved-search-pill {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--surface-active);
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-xs);
    text-decoration: none;
    transition: all 0.15s;
}
.saved-search-pill:hover { border-color: var(--primary); color: var(--primary); }

/* Data tools */
.sidebar-data-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}
.data-tool-link {
    font-size: 0.75rem;
    color: var(--text-subtle);
    text-decoration: none;
}
.data-tool-link:hover { color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════
   Capture Page
   ═══════════════════════════════════════════════════════════════ */
.capture-page { max-width: 700px; }

.capture-focus-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: var(--primary-dim);
    border: 1px solid rgba(59,130,246,0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text);
}
.capture-focus-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: focusPulse 2s infinite;
}
.capture-focus-dur { margin-left: auto; font-size: 0.75rem; color: var(--text-muted); font-family: var(--mono); }

.capture-header { margin-bottom: 1rem; }
.capture-header-label { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.capture-header-hint { font-size: 0.75rem; color: var(--text-subtle); display: block; margin-top: 0.25rem; }

.capture-type-toggle-row { margin-bottom: 0.75rem; }

/* Type pill bar */
.type-pill-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}

.type-pill {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.type-pill:hover { border-color: var(--border-hi); color: var(--text); }

.type-pill-active-all          { background: var(--primary-dim);          color: var(--primary);               border-color: rgba(59,130,246,0.3); }
.type-pill-active-thought      { background: var(--type-thought-bg);      color: var(--type-thought);      border-color: var(--type-thought-border); }
.type-pill-active-decision     { background: var(--type-decision-bg);     color: var(--type-decision);     border-color: var(--type-decision-border); }
.type-pill-active-task         { background: var(--type-task-bg);         color: var(--type-task);         border-color: var(--type-task-border); }
.type-pill-active-reference    { background: var(--type-reference-bg);    color: var(--type-reference);    border-color: var(--type-reference-border); }
.type-pill-active-note         { background: var(--type-note-bg);         color: var(--type-note);         border-color: var(--type-note-border); }
.type-pill-active-conversation { background: var(--type-conversation-bg); color: var(--type-conversation); border-color: var(--type-conversation-border); }
.type-pill-active-preference   { background: var(--type-preference-bg); color: var(--type-preference); border-color: var(--type-preference-border); }

/* Capture textarea wrapper */
.capture-textarea-wrapper {
    position: relative;
    margin-bottom: 0.75rem;
}
.capture-textarea-wrapper textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-size: 0.9rem;
    color: var(--text);
    resize: vertical;
    min-height: 160px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.capture-textarea-wrapper textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Type-colored left border on capture area */
.capture-type-thought      { border-left: 3px solid var(--type-thought); }
.capture-type-decision     { border-left: 3px solid var(--type-decision); }
.capture-type-task         { border-left: 3px solid var(--type-task); }
.capture-type-reference    { border-left: 3px solid var(--type-reference); }
.capture-type-note         { border-left: 3px solid var(--type-note); }
.capture-type-conversation { border-left: 3px solid var(--type-conversation); }
.capture-type-preference   { border-left: 3px solid var(--type-preference); }
.capture-type-auto         { border-left: 3px solid var(--border); }

.char-counter {
    position: absolute;
    bottom: 0.5rem;
    right: 0.75rem;
    font-size: 0.7rem;
    font-family: var(--mono);
    color: var(--text-subtle);
}
.char-warn { color: var(--warning); }
.char-crit { color: var(--error); }

.capture-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.project-select-inline {
    width: auto;
    min-width: 160px;
    font-size: 0.8rem;
    padding: 0.35rem 2rem 0.35rem 0.5rem;
}
.capture-actions-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.btn-capture-mic {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-capture-mic:hover { background: var(--surface-active); color: var(--text); }
.btn-capture-mic.recording { background: var(--error-dim); color: var(--error); border-color: var(--error); animation: focusPulse 1s infinite; }

.btn-capture-submit {
    padding: 0.45rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
    box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}
.btn-capture-submit:hover { background: var(--primary-hover); }

/* Session ghost log */
.session-log { margin-top: 1.5rem; }
.session-log-header { margin-bottom: 0.75rem; }
.session-log-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
}
.session-log-list { display: flex; flex-direction: column; gap: 0.375rem; }
.session-log-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}
.session-log-badge {
    font-size: 0.6rem;
    font-weight: 700;
    font-family: var(--mono);
    text-transform: uppercase;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    flex-shrink: 0;
}
.session-log-type-thought .session-log-badge   { background: var(--type-thought-bg); color: var(--type-thought); }
.session-log-type-decision .session-log-badge  { background: var(--type-decision-bg); color: var(--type-decision); }
.session-log-type-task .session-log-badge      { background: var(--type-task-bg); color: var(--type-task); }
.session-log-type-reference .session-log-badge { background: var(--type-reference-bg); color: var(--type-reference); }
.session-log-type-note .session-log-badge      { background: var(--type-note-bg); color: var(--type-note); }
.session-log-type-conversation .session-log-badge { background: var(--type-conversation-bg); color: var(--type-conversation); }
.session-log-type-preference .session-log-badge   { background: var(--type-preference-bg); color: var(--type-preference); }
.session-log-type-auto .session-log-badge      { background: var(--surface-active); color: var(--text-subtle); }
.session-log-snippet { flex: 1; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-log-time { font-size: 0.7rem; color: var(--text-subtle); font-family: var(--mono); flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   Search Page — 2-Column Layout
   ═══════════════════════════════════════════════════════════════ */

/* Break out of page-content constraints for full-width layout */
.page-content:has(.search-page) {
    max-width: none;
    margin: 0;
    padding: 0;
}

.search-page { }

.search-layout {
    display: flex;
    flex: 1;
    min-width: 0;
}

/* ── Sidebar ── */
.search-sidebar {
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    padding: 1.5rem 1.25rem;
    overflow-y: auto;
    max-height: calc(100vh - var(--topnav-height));
    position: sticky;
    top: 0;
}

.ss-section {
    margin-bottom: 1.5rem;
}

.ss-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
    margin-bottom: 0.75rem;
}
.ss-section-title svg { color: var(--text-subtle); flex-shrink: 0; }

.ss-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.ss-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0.625rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}
.ss-item:hover {
    background: var(--surface-active);
    color: var(--text);
}
.ss-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ss-item-arrow {
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--text-subtle);
}
.ss-item:hover .ss-item-arrow { opacity: 1; }

.ss-manage-link {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--primary);
    text-decoration: none;
    margin-top: 0.5rem;
    padding-left: 0.625rem;
}
.ss-manage-link:hover { text-decoration: underline; }

/* Sidebar tag cloud */
.ss-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.ss-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.ss-tag:hover { border-color: var(--primary); color: var(--primary); }
.ss-tag-active { background: var(--primary-dim); color: var(--primary); border-color: rgba(59,130,246,0.3); }
.ss-tag-count {
    font-size: 0.6rem;
    color: var(--text-subtle);
    font-family: var(--mono);
    margin-left: 0.1rem;
}

/* ── Main area ── */
.search-main {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 2.5rem 2rem;
}

/* ── Search input (large, with icon) ── */
.search-input-wrap {
    position: relative;
    margin-bottom: 1.25rem;
}

.search-input-icon {
    position: absolute;
    left: 1.125rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    pointer-events: none;
}

.search-input-lg {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 3rem 1rem 3.5rem;
    font-size: 1.05rem;
    color: var(--text);
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.search-input-lg:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow), 0 4px 16px rgba(0,0,0,0.15);
}
.search-input-lg::placeholder { color: var(--text-subtle); }

.search-input-clear {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
.search-input-clear:hover { color: var(--text); }

/* ── Filter bar ── */
.search-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-filter-chip {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    transition: all 0.15s;
}
.search-filter-chip:hover { border-color: var(--border-hi); }

.search-filter-chip-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-subtle);
    font-family: var(--mono);
    pointer-events: none;
    white-space: nowrap;
}

.search-filter-chip select {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.8rem;
    font-family: var(--font);
    cursor: pointer;
    padding: 0.15rem 1.25rem 0.15rem 0.125rem;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.125rem center;
}
.search-filter-chip select:focus { outline: none; }
.search-filter-chip select option { background: var(--surface); color: var(--text); }

/* Filter chip as button */
.search-filter-chip-btn {
    cursor: pointer;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.search-filter-chip-btn span:not(.search-filter-chip-label) {
    font-size: 0.8rem;
    color: var(--text);
}
.search-filter-chip-active {
    background: var(--primary-dim);
    border-color: rgba(59,130,246,0.3);
}
.search-filter-chip-active .search-filter-chip-label { color: var(--primary); }

/* Ask AI chip */
.search-filter-chip-ask {
    color: var(--primary);
    margin-left: auto;
}
.search-filter-chip-ask svg { color: var(--primary); }

/* Reset link */
.search-filter-reset {
    font-size: 0.75rem;
    color: var(--text-subtle);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.search-filter-reset:hover { color: var(--text); }

/* ── Kept: btn-search-action for date clear ── */
.btn-search-action {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-active);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-search-action:hover { border-color: var(--border-hi); color: var(--text); }

/* Date range */
.search-date-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.search-date-label { font-size: 0.65rem; font-weight: 700; color: var(--text-subtle); letter-spacing: 0.06em; font-family: var(--mono); }
.search-date-input { width: auto; min-width: 140px; font-size: 0.8rem; padding: 0.3rem 0.5rem; }
.search-date-sep { color: var(--text-subtle); }

.search-date-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}
.date-preset-pill {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.date-preset-pill:hover { background: var(--primary-dim); color: var(--primary); border-color: rgba(59,130,246,0.3); }

/* Active filter chips */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}
.active-filters-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
    margin-right: 0.25rem;
}
.active-filter-chip {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-xs);
    background: var(--primary-dim);
    color: var(--primary);
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
.active-filter-chip:hover { background: var(--primary-glow); }
.active-filter-chip-clear { background: var(--surface-active); color: var(--text-muted); }
.active-filter-chip-clear:hover { color: var(--text); }

/* Ask AI */
.ask-answer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.ask-answer-header { margin-bottom: 0.75rem; }
.ask-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    font-family: var(--mono);
}
.ask-loading { font-size: 0.85rem; color: var(--text-muted); animation: focusPulse 1.5s infinite; }
.ask-answer-text { font-size: 0.9rem; color: var(--text); line-height: 1.7; }
.ask-sources-label { font-size: 0.75rem; color: var(--text-subtle); margin-top: 0.75rem; display: block; }

/* Search suggestions (mobile only — sidebar has them on desktop) */
.search-suggestions { margin-bottom: 1rem; }
.search-suggestions-mobile { display: none; }
.suggestions-label { font-size: 0.75rem; color: var(--text-subtle); margin-bottom: 0.5rem; }
.suggestions-list { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.suggestion-pill {
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.suggestion-pill:hover { border-color: var(--primary); color: var(--primary); }

/* ── Search results ── */
#search-results {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Results header */
.search-results-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.search-results-heading {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.search-results-count {
    font-size: 0.75rem;
    color: var(--text-subtle);
    font-family: var(--mono);
}

/* ── Result cards ── */
.sr-card {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    cursor: pointer;
    outline: none; /* Let box-shadow handle focus */
}
.sr-card:hover, .sr-card:focus {
    border-color: rgba(59,130,246,0.4);
    box-shadow: 0 4px 16px rgba(59,130,246,0.08), 0 0 0 2px var(--primary-dim);
    transform: translateY(-1px);
}

/* Type icon */
.sr-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0.125rem;
}
.sr-icon svg { width: 20px; height: 20px; }

.sr-icon-thought      { background: var(--type-thought-bg); color: var(--type-thought); }
.sr-icon-decision     { background: var(--type-decision-bg); color: var(--type-decision); }
.sr-icon-task         { background: var(--type-task-bg); color: var(--type-task); }
.sr-icon-reference    { background: var(--type-reference-bg); color: var(--type-reference); }
.sr-icon-note         { background: var(--type-note-bg); color: var(--type-note); }
.sr-icon-conversation { background: var(--type-conversation-bg); color: var(--type-conversation); }
.sr-icon-preference   { background: var(--type-preference-bg); color: var(--type-preference); }

/* Card body */
.sr-body {
    flex: 1;
    min-width: 0;
}

.sr-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
}

.sr-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sr-type-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.6rem;
    font-weight: 700;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.125rem 0.4rem;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Meta row */
.sr-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.sr-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-subtle);
}
.sr-meta-item svg { flex-shrink: 0; color: var(--text-subtle); }
.sr-match {
    color: var(--success);
    font-weight: 600;
    font-family: var(--mono);
}

.sr-signals {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto; /* Push to the right edge of .sr-meta if space permits, or let it flow naturally */
}

.sr-signals .btn-ghost {
    padding: 2px 4px; /* Make the buttons smaller to fit inline */
}

/* Content snippet */
.sr-snippet {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

/* Tags row */
.sr-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.5rem;
}
.sr-tags .tag { font-size: 0.7rem; padding: 0.1rem 0.4rem; }

/* ═══════════════════════════════════════════════════════════════
   Memory Detail Page — 2-Panel Layout
   ═══════════════════════════════════════════════════════════════ */

/* Break out of page-content constraints (mirrors dashboard pattern) */
.page-content:has(.memory-detail-page) {
    max-width: none;
    margin: 0;
    padding: 0;
}

.memory-detail-page { }

/* 2-panel flex grid (mirrors .dashboard-grid) */
.md-grid {
    display: flex;
    flex: 1;
    min-width: 0;
}

/* ── Left sidebar ── */
.md-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    max-height: calc(100vh - var(--topnav-height));
    position: sticky;
    top: 0;
}

.md-sidebar-nav { margin-bottom: 0.25rem; }
.md-back-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.md-back-link:hover { color: var(--primary); }

.md-sidebar-card {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}
.md-sidebar-card-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
}

/* ── Right main area ── */
.md-main {
    flex: 1;
    min-width: 0;
    padding: 0 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Toolbar (sticky) ── */
.md-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 5;
    border-bottom: 1px solid var(--border);
}
.md-toolbar-left { display: flex; align-items: center; gap: 0.5rem; }
.md-toolbar-right { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ── Content card ── */
.md-content-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.md-content-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.md-time { font-size: 0.8rem; color: var(--text-subtle); }

.md-archived-badge {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--mono);
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
    background: var(--warning-dim);
    color: var(--warning);
}

.processing-pill {
    font-size: 0.65rem;
    font-weight: 600;
    font-family: var(--mono);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
}
.processing-active  { background: var(--primary-dim); color: var(--primary); animation: focusPulse 1.5s infinite; }
.processing-complete { background: var(--success-dim); color: var(--success); }
.processing-failed  { background: var(--error-dim); color: var(--error); cursor: pointer; }
.processing-pending { background: var(--surface-active); color: var(--text-subtle); }

/* Content block (inside content card) */
.md-content-block {
    padding: 1.25rem;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    border-left: 3px solid var(--border);
}
.md-content-block:hover { background: var(--surface-active); }
.md-content-block[data-type="thought"]      { border-left-color: var(--type-thought); }
.md-content-block[data-type="decision"]     { border-left-color: var(--type-decision); }
.md-content-block[data-type="task"]         { border-left-color: var(--type-task); }
.md-content-block[data-type="reference"]    { border-left-color: var(--type-reference); }
.md-content-block[data-type="note"]         { border-left-color: var(--type-note); }
.md-content-block[data-type="conversation"] { border-left-color: var(--type-conversation); }
.md-content-block[data-type="preference"]   { border-left-color: var(--type-preference); }

.md-content-text {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}
.md-edit-hint {
    font-size: 0.7rem;
    color: var(--text-subtle);
    opacity: 0;
    transition: opacity 0.15s;
    position: absolute;
    bottom: 0.5rem;
    right: 0.75rem;
}
.md-content-block:hover .md-edit-hint { opacity: 1; }

/* Editor */
.md-editor-block {
    padding: 1.25rem;
    border-left: 3px solid var(--border);
}
.md-editor-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* AI Summary */
.md-ai-summary {
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--primary-dim), var(--surface-active));
    border-top: 1px solid var(--border);
}
.md-ai-summary-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary);
    font-family: var(--mono);
    margin-bottom: 0.5rem;
    display: block;
}
.md-summary { font-size: 0.875rem; color: var(--text-muted); line-height: 1.7; font-style: italic; }

/* ── Sidebar field styles ── */
.md-field { }
.md-field-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
    margin-bottom: 0.4rem;
    display: block;
}

/* Pill bars wrap in narrow sidebar */
.md-sidebar .type-pill-bar { flex-wrap: wrap; }
.md-priority-pills { display: flex; gap: 0.375rem; flex-wrap: wrap; }
.priority-pill-0 { background: var(--surface-active); color: var(--text-muted); border-color: var(--border); }
.priority-pill-1 { background: var(--primary-dim); color: var(--primary); border-color: rgba(59,130,246,0.2); }
.priority-pill-2 { background: var(--warning-dim); color: var(--warning); border-color: rgba(245,158,11,0.2); }
.priority-pill-3 { background: var(--error-dim); color: var(--error); border-color: rgba(239,68,68,0.2); }

.md-project-select {
    width: 100%;
    font-size: 0.85rem;
}

.md-date-mono {
    font-size: 0.75rem;
    font-family: var(--mono);
    color: var(--text-muted);
}

.md-deadline-row { display: flex; align-items: center; gap: 0.5rem; }
.md-deadline-input { width: auto; min-width: 140px; flex: 1; }

/* Tags in memory detail */
.md-tags-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
}
.md-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text);
    background: var(--surface-active);
    border: 1px solid var(--border);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-xs);
}
.md-tag-remove {
    font-size: 0.85rem;
    line-height: 1;
    border: none;
    background: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 0 0.1rem;
}
.md-tag-remove:hover { color: var(--error); }
.md-tag-input {
    width: 100px;
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    background: transparent;
    border: 1px solid transparent;
}
.md-tag-input:focus { border-color: var(--primary); background: var(--surface-active); }

/* Tag suggestions */
.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 20;
    max-height: 200px;
    overflow-y: auto;
}
.tag-suggestion-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.1s;
}
.tag-suggestion-item:hover, .tag-suggestion-active { background: var(--primary-dim); color: var(--primary); }

/* Linked memories */
.md-links-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.md-link-card { padding: 0.5rem; font-size: 0.8rem; }
.md-link-rel { font-size: 0.65rem; color: var(--text-subtle); font-family: var(--mono); }
.md-link-content { font-size: 0.75rem; color: var(--text-muted); text-decoration: none; display: block; margin-top: 0.2rem; }
.md-link-content:hover { color: var(--primary); }
.md-link-remove {
    font-size: 0.8rem;
    border: none;
    background: none;
    color: var(--text-subtle);
    cursor: pointer;
    margin-left: auto;
}
.md-link-remove:hover { color: var(--error); }

/* Link search */
.md-link-search { margin-bottom: 0.5rem; }
.md-link-search-input { margin-bottom: 0.5rem; font-size: 0.8rem; }
.md-link-search-results { display: flex; flex-direction: column; gap: 0.25rem; }
.md-link-search-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    background: var(--surface-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
}
.md-link-search-item:hover { border-color: var(--primary); color: var(--text); }

/* Task completion */
.task-completion-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.task-completion-label { font-size: 0.85rem; color: var(--text-muted); }
.task-completed { border-color: rgba(34,197,94,0.3); }
.task-completed .task-completion-label { color: var(--success); }

/* Action button (toolbar) */
.md-action-btn {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-xs);
    transition: all 0.15s;
}
.md-action-btn:hover { background: var(--surface-active); color: var(--text); }

/* Deadline display classes */
.deadline-display-overdue { color: var(--error); }
.deadline-display-soon { color: var(--warning); }
.deadline-display-ok { color: var(--success); }

/* ═══════════════════════════════════════════════════════════════
   Timeline
   ═══════════════════════════════════════════════════════════════ */
.timeline-page { }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header-left { }
.page-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
    display: block;
    margin-bottom: 0.25rem;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.timeline-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.timeline-day { }

.timeline-day-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.timeline-date {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--mono);
}

.timeline-count-badge {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text-subtle);
    background: var(--surface-active);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.timeline-day-memories {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.memory-card-compact {
    padding: 0.75rem 1rem;
}
.memory-card-compact .memory-content {
    font-size: 0.85rem;
    -webkit-line-clamp: 2;
}

.memory-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.memory-card-link:hover .memory-card { border-color: var(--primary); }

.load-more-row {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0;
}

/* Keep old class names as aliases */
.timeline-group { margin-bottom: 2rem; }
.timeline-date-heading {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
    font-family: var(--mono);
}
.timeline-items { display: flex; flex-direction: column; gap: 0.5rem; }

/* ═══════════════════════════════════════════════════════════════
   Tags Page
   ═══════════════════════════════════════════════════════════════ */
.tags-page { }

.tags-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.tags-page-label {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.tags-header-count {
    font-size: 0.8rem;
    color: var(--text-subtle);
    font-family: var(--mono);
}

/* Consolidation panel */
.consolidation-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.consolidation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.consolidation-header-actions {
    display: flex;
    gap: 0.375rem;
}
.consolidation-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.consolidation-arrow {
    color: var(--text-subtle);
    font-size: 0.85rem;
}
.consolidation-reason {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-left: auto;
}

/* Tag pill (used in consolidation) */
.tag-pill {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--mono);
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: var(--primary-dim);
    color: var(--primary);
}

/* Tags toolbar */
.tags-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.tags-filter-input {
    flex: 1;
    min-width: 150px;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--body);
}
.tags-filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-dim);
}
.tags-sort-pills {
    display: flex;
    gap: 0.25rem;
}

/* Tag card */
.tag-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    transition: border-color 0.15s;
}
.tag-card:hover {
    border-color: var(--border-hi);
}
.tag-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.375rem;
}
.tag-card-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    font-family: var(--mono);
}
.tag-card-name:hover { text-decoration: underline; }
.tag-card-count {
    font-size: 0.75rem;
    color: var(--text-subtle);
    font-family: var(--mono);
}
.tag-card-actions {
    display: flex;
    gap: 0.25rem;
}
.tag-card-form {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.tag-form-input {
    flex: 1;
    min-width: 100px;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--mono);
}
.tag-form-input:focus {
    outline: none;
    border-color: var(--primary);
}
.tag-form-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.tag-form-select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
}

.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.tag-grid-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.tag-grid-card:hover { border-color: var(--primary); }
.tag-grid-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
}
.tag-grid-name:hover { color: var(--primary); }
.tag-grid-count { font-size: 0.75rem; color: var(--text-subtle); font-family: var(--mono); }
.tag-grid-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.tag-grid-card:hover .tag-grid-actions { opacity: 1; }
.tag-grid-action-btn {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
}
.tag-grid-action-btn:hover { background: var(--surface-active); color: var(--text); }
.tag-grid-action-btn.danger:hover { color: var(--error); }

/* Tag merge section */
.tag-merge-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.tag-merge-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════
   Archived Page
   ═══════════════════════════════════════════════════════════════ */
.archived-page { }
.archived-list { display: flex; flex-direction: column; gap: 0.75rem; }

.archived-type-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.memory-card-archived {
    opacity: 0.85;
}
.memory-card-archived .memory-summary {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-style: italic;
}
.archived-card-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   Admin Page
   ═══════════════════════════════════════════════════════════════ */
.admin-page { }

/* Admin tabs */
.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.admin-tab {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}
.admin-section h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.admin-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-subtle);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
}
.admin-table td {
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface-active); }
.admin-table code {
    font-family: var(--mono);
    font-size: 0.8rem;
    background: var(--bg);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.admin-btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* Admin section header */
.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.admin-section-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.admin-subtitle {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-subtle);
}

/* Admin cards (health status) */
.admin-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}
.admin-card {
    background: var(--surface-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
}
.admin-card-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-subtle);
    font-family: var(--mono);
    margin-bottom: 0.25rem;
}
.admin-card-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--mono);
}
.admin-card-note {
    font-size: 0.75rem;
    color: var(--text-subtle);
    margin-top: 0.25rem;
}
.admin-card-note a {
    color: var(--primary);
    text-decoration: none;
}
.admin-card-note a:hover { text-decoration: underline; }

/* Admin section footer */
.admin-section-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}
.admin-note {
    font-size: 0.75rem;
    color: var(--text-subtle);
}
.admin-note code {
    font-family: var(--mono);
    font-size: 0.7rem;
    background: var(--surface-active);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

/* Admin table wrap */
.admin-table-wrap {
    overflow-x: auto;
}
.admin-error-cell {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--error);
}

/* Admin checkbox */
.admin-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}
.admin-checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Admin select */
.admin-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg);
    color: var(--text);
    font-size: 0.8rem;
}

/* Admin bulk form */
.admin-bulk-form {
    max-width: 600px;
}

/* API key reveal box */
.admin-key-reveal {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--success-dim);
    border: 1px solid rgba(34,197,94,0.3);
    border-radius: 6px;
}
.admin-key-reveal-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 0.5rem;
}
.admin-key-input {
    font-family: var(--mono);
    font-size: 0.85rem;
    flex: 1;
    cursor: text;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    color: var(--text);
}

/* Status indicators */
.loading-inline {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 1rem 0;
}
.status-ok { color: var(--success); }
.status-error { color: var(--error); }
.status-warn { color: var(--warning); }

/* Mono link */
.mono-link {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
}
.mono-link:hover { text-decoration: underline; }
.mono-cell {
    font-family: var(--mono);
    font-size: 0.8rem;
}

/* Muted text */
.muted { color: var(--text-muted); }

/* Project link (admin table) */
.project-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.project-link:hover { text-decoration: underline; }

/* Status badge (project status) */
.status-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.status-active { background: rgba(34,197,94,0.15); color: var(--success); }
.status-paused { background: rgba(234,179,8,0.15); color: var(--warning); }
.status-completed { background: rgba(59,130,246,0.15); color: var(--primary); }
.status-archived { background: var(--surface-active); color: var(--text-subtle); }

/* Badge stale */
.badge-stale {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: rgba(234,179,8,0.15);
    color: var(--warning);
    margin-left: 0.375rem;
}
.row-stale { opacity: 0.7; }

/* Badge variants (migration status, etc.) */
.badge-green {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(34,197,94,0.15);
    color: var(--success);
}
.badge-yellow {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(234,179,8,0.15);
    color: var(--warning);
}

/* Focus bar (admin focus stats) */
.focus-bar-wrap {
    width: 100%;
    height: 8px;
    background: var(--surface-active);
    border-radius: 4px;
    overflow: hidden;
}
.focus-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Form textarea & select (bulk ops) */
.form-textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--mono);
    resize: vertical;
}
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-dim);
}
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}
.stat-card {
    background: var(--surface-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
}
.stat-label { font-size: 0.7rem; color: var(--text-subtle); margin-bottom: 0.25rem; text-transform: uppercase; letter-spacing: 0.04em; font-family: var(--mono); }
.stat-value { font-size: 1.25rem; font-weight: 700; color: var(--text); font-family: var(--mono); }

/* ═══════════════════════════════════════════════════════════════
   Import Page
   ═══════════════════════════════════════════════════════════════ */
.import-page { max-width: 600px; }

.import-form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.import-format-pills { display: flex; gap: 0.375rem; }

.btn-row { display: flex; gap: 0.5rem; margin-top: 1rem; }

.import-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.import-info pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 0.5rem;
    overflow-x: auto;
    font-size: 0.8rem;
    font-family: var(--mono);
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════
   Saved Searches Page
   ═══════════════════════════════════════════════════════════════ */
.searches-page { }
.searches-list { display: flex; flex-direction: column; gap: 0.75rem; }

/* Search item (used in searches.gohtml) */
.search-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s;
}
.search-item:hover { border-color: var(--border-hi); }
.search-item-info {
    flex: 1;
    min-width: 0;
}
.search-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    display: block;
}
.search-item-query {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--mono);
}
.search-item-actions {
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

/* Delete confirmation inline */
.delete-confirm {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.empty-state p { margin-bottom: 0.5rem; }
.empty-state a { color: var(--primary); text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

.saved-search-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s;
}
.saved-search-card:hover { border-color: var(--border-hi); }
.saved-search-card-info { flex: 1; min-width: 0; }
.saved-search-card-name { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.saved-search-card-query { font-size: 0.8rem; color: var(--text-muted); }
.saved-search-card-actions { display: flex; gap: 0.375rem; }

/* ═══════════════════════════════════════════════════════════════
   Project Page
   ═══════════════════════════════════════════════════════════════ */
.project-page { }

/* Breadcrumb */
.breadcrumb {
    font-size: 0.8rem;
    color: var(--text-subtle);
    margin-bottom: 1rem;
}
.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}
.breadcrumb a:hover { color: var(--primary); }

.project-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.project-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

/* Project status badge */
.badge-status-planning { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.badge-status-active { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-status-paused { background: rgba(234,179,8,0.15); color: var(--warning); }
.badge-status-blocked { background: rgba(239,68,68,0.15); color: #ef4444; }
.badge-status-completed { background: rgba(59,130,246,0.15); color: var(--primary); }
.badge-status-archived { background: var(--surface-active); color: var(--text-subtle); }

.project-status-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
    font-size: 0.8rem;
}

/* Project description */
.project-description-block {
    margin-bottom: 1.25rem;
}
.project-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.project-description:hover { background: var(--surface-active); }
.project-description-empty {
    font-style: italic;
    color: var(--text-subtle);
}
.project-desc-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.project-desc-editor textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    resize: vertical;
}
.project-desc-editor textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.project-desc-actions {
    display: flex;
    gap: 0.375rem;
}

/* Project stats */
.project-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.stat {
    display: flex;
    flex-direction: column;
}
.stat .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--mono);
}
.stat .stat-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-subtle);
    font-family: var(--mono);
}

/* Project capture */
.project-capture {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.project-capture h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}
.project-capture textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    resize: vertical;
    margin-bottom: 0.5rem;
}
.project-capture textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.capture-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Type filter (project page) */
.type-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
}
.type-tab {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
}
.type-tab:hover { border-color: var(--border-hi); color: var(--text); }
.type-tab.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
}

.project-header-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.project-stat {
    display: flex;
    flex-direction: column;
}
.project-stat-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); font-family: var(--mono); }
.project-stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); font-family: var(--mono); }

.project-type-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.project-memories { display: flex; flex-direction: column; gap: 0.75rem; }

/* ═══════════════════════════════════════════════════════════════
   Modal
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.modal p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.modal-enter { animation: modalIn 0.2s ease; }
.modal-leave { animation: modalOut 0.15s ease forwards; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } }
@keyframes modalOut { to { opacity: 0; transform: scale(0.95); } }

/* ═══════════════════════════════════════════════════════════════
   FAB (Floating Action Button)
   ═══════════════════════════════════════════════════════════════ */
.fab-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 40;
}
.fab-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(59,130,246,0.35);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fab-btn:hover { background: var(--primary-hover); transform: scale(1.05); }

.fab-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.fab-form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.fab-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.fab-form-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.fab-close {
    font-size: 1.3rem;
    border: none;
    background: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
.fab-close:hover { color: var(--text); }

.fab-project-select {
    width: 100%;
    font-size: 0.85rem;
}

.fab-form-card textarea {
    width: 100%;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    resize: vertical;
    min-height: 100px;
}

.fab-form-footer {
    display: flex;
    justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════
   Keyboard Shortcuts Overlay
   ═══════════════════════════════════════════════════════════════ */
.shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.shortcuts-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}
.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.shortcuts-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.shortcuts-close {
    font-size: 1.3rem;
    border: none;
    background: none;
    color: var(--text-subtle);
    cursor: pointer;
    line-height: 1;
}
.shortcuts-close:hover { color: var(--text); }

.shortcuts-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    align-items: center;
}
.shortcut-row {
    display: contents;
}
.shortcut-row kbd { justify-self: end; }
.shortcut-row span { font-size: 0.85rem; color: var(--text-muted); }
.shortcut-section-header {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-family: var(--mono);
    padding-top: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   Spinner
   ═══════════════════════════════════════════════════════════════ */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

/* ═══════════════════════════════════════════════════════════════
   Login Page (standalone)
   ═══════════════════════════════════════════════════════════════ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 1rem;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}
.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.5rem;
    text-align: center;
}
.login-card .form-group { margin-bottom: 1rem; }
.login-card input { width: 100%; }
.login-card button[type="submit"] {
    width: 100%;
    padding: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    margin-top: 0.5rem;
}
.login-card button[type="submit"]:hover { background: var(--primary-hover); }

/* ═══════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .dashboard { flex-direction: column; }
    .dashboard-grid { flex-direction: column; }
    .dashboard-main { max-width: none; padding: 1.5rem 1rem; }
    .dashboard-sidebar {
        width: 100%;
        max-height: none;
        position: static;
        border-left: none;
        border-top: 1px solid var(--border);
        padding: 1.5rem 1rem;
    }
    .recent #recent-list { grid-template-columns: 1fr; }

    /* Memory detail — collapse to single column */
    .md-grid { flex-direction: column; }
    .md-sidebar {
        width: 100%;
        max-height: none;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1.25rem 1rem;
    }
    .md-main { padding: 1.5rem 1rem; }

    /* Search page — collapse sidebar to top */
    .search-layout { flex-direction: column; }
    .search-sidebar {
        width: 100%;
        max-height: none;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1.25rem 1rem;
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
    }
    .search-sidebar .ss-section { margin-bottom: 0; }
    .search-main { padding: 1.5rem 1rem; }
    .search-suggestions-mobile { display: block; }

    /* Simplify result cards on tablet */
    .sr-icon { width: 36px; height: 36px; }
}

@media (max-width: 768px) {
    /* Hide desktop nav + search, show hamburger + mobile drawer */
    .topnav-nav { display: none; }
    .topnav-center { display: none; }
    .topnav-focus { display: none; }
    .mobile-nav-drawer.open { display: flex; }

    .hamburger {
        display: flex;
        flex-direction: column;
        gap: 4px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px;
        margin-left: auto;
    }
    .hamburger span {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--text-muted);
        border-radius: 1px;
        transition: all 0.15s;
    }

    .page-content { padding: 1rem; }
    .recent #recent-list { grid-template-columns: 1fr; }
    .fab-container { bottom: 1rem; right: 1rem; }

    /* Search page mobile */
    .search-sidebar { display: none; }
    .search-suggestions-mobile { display: block; }
    .search-main { padding: 1rem; }
    .search-input-lg { padding: 0.875rem 2.5rem 0.875rem 3.25rem; font-size: 0.95rem; }
    .search-filter-bar { gap: 0.375rem; }
    .search-filter-chip { font-size: 0.75rem; }
    .sr-card { padding: 0.875rem; gap: 0.75rem; }
    .sr-icon { width: 32px; height: 32px; }
    .sr-icon svg { width: 16px; height: 16px; }
    .sr-title { font-size: 0.85rem; }
}

@media (min-width: 769px) {
    .hamburger { display: none; }
    .mobile-nav-drawer { display: none !important; }
    .mobile-nav-overlay { display: none !important; }
}

/* Analytics dashboard */
.analytics-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.analytics-header {
    align-items: flex-start;
    gap: 1rem;
}

.analytics-intro {
    color: var(--text-muted);
    max-width: 40rem;
}

.analytics-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.analytics-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(59,130,246,0.08), rgba(15,17,21,0.12)), var(--surface);
    box-shadow: var(--shadow);
}

.analytics-control {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 12rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.analytics-control select {
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-active);
    color: var(--text);
    padding: 0.75rem 0.9rem;
    font: inherit;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.analytics-shell,
.analytics-panel {
    min-height: 22rem;
}

.analytics-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background:
        radial-gradient(circle at top right, rgba(59,130,246,0.14), transparent 28%),
        linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0)),
        var(--surface);
    box-shadow: var(--shadow);
}

.analytics-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.analytics-panel-header h2 {
    font-size: 1rem;
}

.analytics-panel-subtitle {
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.analytics-kpis {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem;
}

.analytics-kpi {
    min-width: 6rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(15,17,21,0.34);
}

.analytics-kpi-label {
    display: block;
    color: var(--text-subtle);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analytics-kpi-value {
    display: block;
    margin-top: 0.15rem;
    font-size: 1rem;
}

.analytics-chart-wrap {
    position: relative;
    min-height: 15rem;
}

.analytics-chart-wrap-secondary {
    min-height: 10rem;
}

.analytics-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 1024px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .analytics-controls {
        flex-direction: column;
    }

    .analytics-control {
        min-width: 0;
    }

    .analytics-header {
        flex-direction: column;
    }

    .analytics-header-actions {
        margin-left: 0;
    }

    .analytics-panel-header {
        flex-direction: column;
    }

    .analytics-kpis {
        justify-content: flex-start;
    }
}
