/* ========================================================================
   Segretario — modern minimal
   Inter everywhere. Zinc monochrome + single accent. Dark-first.
   ======================================================================== */

:root {
    color-scheme: light dark;

    /* Light palette */
    --bg:         #FFFFFF;
    --bg-subtle:  #FAFAFA;
    --bg-muted:   #F4F4F5;
    --bg-hover:   #F4F4F5;
    --bg-active:  #E4E4E7;
    --border:     #E4E4E7;
    --border-strong: #D4D4D8;
    --fg:         #09090B;
    --fg-muted:   #52525B;
    --fg-subtle:  #71717A;
    --fg-disabled:#A1A1AA;

    /* Accent (used sparingly: CTAs, unread, errors) */
    --accent:     #B5462A;
    --accent-bg:  rgba(181, 70, 42, 0.08);
    --accent-border: rgba(181, 70, 42, 0.25);

    /* Status */
    --success:    #16A34A;
    --warning:    #D97706;
    --danger:     #DC2626;

    /* Shape */
    --radius-sm: 4px;
    --radius:    6px;
    --radius-lg: 8px;
}

.dark {
    --bg:         #09090B;
    --bg-subtle:  #0C0C0E;
    --bg-muted:   #18181B;
    --bg-hover:   #18181B;
    --bg-active:  #27272A;
    --border:     #27272A;
    --border-strong: #3F3F46;
    --fg:         #FAFAFA;
    --fg-muted:   #A1A1AA;
    --fg-subtle:  #71717A;
    --fg-disabled:#52525B;

    --accent:     #E26B47;
    --accent-bg:  rgba(226, 107, 71, 0.12);
    --accent-border: rgba(226, 107, 71, 0.30);
}

/* ------------------------------------------------------------------------ */
/* Reset / base                                                              */
/* ------------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    font-size: 14px;
    font-variant-ligatures: common-ligatures;
    font-feature-settings: "cv11", "ss01", "ss03";  /* Inter stylistic sets */
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

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

button, input, select, textarea {
    font: inherit;
    color: inherit;
}
button { cursor: pointer; background: transparent; border: 0; padding: 0; }

::selection { background: var(--accent-bg); color: var(--fg); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ------------------------------------------------------------------------ */
/* Numbers: tabular                                                          */
/* ------------------------------------------------------------------------ */
.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------------ */
/* Layout shell                                                              */
/* ------------------------------------------------------------------------ */

.shell {
    display: grid;
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
}

/* ------------------------------------------------------------------------ */
/* Sidebar                                                                   */
/* ------------------------------------------------------------------------ */

.sidebar {
    border-right: 1px solid var(--border);
    background: var(--bg-subtle);
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.brand-logo {
    width: 22px; height: 22px;
    background: var(--fg);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--bg);
    font-size: 12px;
    font-weight: 700;
}
.mobile-nav-close {
    display: none;
    margin-left: auto;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    color: var(--fg-muted);
    border-radius: var(--radius);
}
.mobile-nav-close:hover { background: var(--bg-hover); color: var(--fg); }
.mobile-nav-close svg { width: 18px; height: 18px; }

.cmdk-btn {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 7px 10px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg-subtle);
    background: var(--bg);
    font-size: 13px;
    transition: border-color .15s, color .15s;
}
.cmdk-btn:hover { border-color: var(--border-strong); color: var(--fg-muted); }
.cmdk-btn .kbd { margin-left: auto; }

.nav-section {
    padding: 6px 10px;
    margin-top: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--fg-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: var(--radius);
    color: var(--fg-muted);
    font-size: 13px;
    font-weight: 500;
    margin: 1px 0;
    position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--fg); }
.nav-item.active { background: var(--bg-active); color: var(--fg); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item .count {
    margin-left: auto;
    font-size: 11px;
    color: var(--fg-subtle);
    font-variant-numeric: tabular-nums;
}
.nav-item.active .count { color: var(--fg-muted); }

.nav-item-wrap {
    position: relative;
    display: block;
}
.nav-item-wrap.has-children .nav-item {
    padding-right: 30px;
}
.nav-caret {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--fg-subtle);
    cursor: pointer;
    padding: 0;
}
.nav-caret:hover { background: var(--bg-hover); color: var(--fg); }
.nav-caret svg {
    width: 12px;
    height: 12px;
    transition: transform 0.15s ease;
}
.nav-caret.expanded svg { transform: rotate(90deg); }

.nav-item.nav-sub {
    padding-left: 34px;
    font-size: 12px;
    font-weight: 400;
    color: var(--fg-subtle);
    margin: 0;
    position: relative;
}
.nav-item.nav-sub:hover { color: var(--fg); }
.nav-item.nav-sub.active { background: var(--bg-active); color: var(--fg); }
.nav-item.nav-sub .nav-sub-bullet {
    position: absolute;
    left: 19px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--fg-subtle);
    opacity: 0.5;
}
.nav-item.nav-sub.active .nav-sub-bullet { background: var(--accent); opacity: 1; }
.nav-item.nav-sub .nav-sub-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-item.nav-sub .nav-sub-status {
    margin-left: auto;
    color: var(--fg-subtle);
    font-size: 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    gap: 8px;
}

/* ------------------------------------------------------------------------ */
/* Main area                                                                 */
/* ------------------------------------------------------------------------ */

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 20;
    backdrop-filter: saturate(180%) blur(8px);
}
.topbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.topbar h1 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}
.topbar .toolbar { display: flex; align-items: center; gap: 4px; }
.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    color: var(--fg-muted);
}
.mobile-nav-toggle:hover { background: var(--bg-hover); color: var(--fg); }
.mobile-nav-toggle svg { width: 18px; height: 18px; }

.content {
    flex: 1;
    padding: 20px 20px 60px;
    max-width: 920px;
    width: 100%;
    margin: 0 auto;
}

/* ------------------------------------------------------------------------ */
/* Controls                                                                  */
/* ------------------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--fg);
    background: var(--bg);
    transition: background .12s, border-color .12s;
    white-space: nowrap;
    line-height: 1;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--fg); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); border-color: var(--border); }
.btn.ghost.active { background: var(--bg-active); color: var(--fg); }
.btn.primary {
    background: var(--fg); color: var(--bg); border-color: var(--fg);
}
.btn.primary:hover { background: var(--fg-muted); border-color: var(--fg-muted); color: var(--bg); }
.btn.accent {
    background: var(--accent); color: white; border-color: var(--accent);
}
.btn.accent:hover { filter: brightness(0.92); color: white; }
.btn.danger {
    color: var(--danger); border-color: var(--border);
}
.btn.danger:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* Varianti "soft": stile sidebar — niente bordo, background muto, sensazione
   più leggera. Usata nelle toolbar (contatti, ecc.) per integrarsi coi nav-item. */
.btn.soft {
    border-color: transparent;
    background: var(--bg-subtle);
    color: var(--fg-muted);
    font-weight: 500;
    gap: 8px;
}
.btn.soft:hover { background: var(--bg-hover); color: var(--fg); border-color: transparent; }
.btn.soft.active {
    background: var(--bg-active);
    color: var(--fg);
}
.btn.soft svg { width: 14px; height: 14px; opacity: 0.85; flex-shrink: 0; }

/* Inline rename: input + pulsanti ✓/✗ allineati al card-title */
.label-edit { display: inline-flex; align-items: center; gap: 6px; }
.label-edit-pencil {
    opacity: 0;
    transition: opacity .12s;
    width: 22px; height: 22px;
}
.label-edit:hover .label-edit-pencil { opacity: 0.6; }
.label-edit-pencil:hover { opacity: 1 !important; color: var(--fg); }
.label-edit-pencil svg { width: 13px; height: 13px; }
.label-edit-box {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.label-edit-box input[type="text"] {
    font-size: 14px;
    padding: 3px 8px;
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--fg);
    width: auto;
    min-width: 140px;
    font-weight: 500;
    line-height: 1.4;
}
.label-edit-box input[type="text"]:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-border);
}
.label-edit-ok, .label-edit-cancel { width: 24px; height: 24px; }
.label-edit-ok svg, .label-edit-cancel svg { width: 14px; height: 14px; }
.label-edit-ok { color: var(--success); }
.label-edit-ok:hover { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.label-edit-cancel { color: var(--danger); }
.label-edit-cancel:hover { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

/* Pill media per thread WhatsApp/Telegram: file/immagini/audio mostrati in
   una striscia senza ricorrere alla bolla di testo. */
.media-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
}
.media-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--fg-muted);
    max-width: 360px;
    min-width: 0;
}
.media-pill svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.7; }
.media-pill-name {
    color: var(--fg);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.media-pill-size { color: var(--fg-subtle); flex-shrink: 0; }
.thread-message.me .media-pill { background: var(--accent-bg); border-color: var(--accent-border); }

.btn.sm { padding: 3px 7px; font-size: 12px; border-radius: var(--radius-sm); }
.btn.lg { padding: 8px 14px; font-size: 14px; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: var(--radius);
    color: var(--fg-muted);
    transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn svg { width: 16px; height: 16px; }

.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    padding: 1px 5px;
    font-size: 11px;
    font-family: "Inter", ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    color: var(--fg-subtle);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    line-height: 1;
    height: 18px;
}

input[type="text"], input[type="search"], input[type="email"], textarea, select {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 10px;
    font-size: 13px;
    line-height: 1.4;
    transition: border-color .12s, box-shadow .12s;
    width: 100%;
}
input:focus, textarea:focus, select:focus {
    outline: 0;
    border-color: var(--fg);
    box-shadow: 0 0 0 2px var(--bg-active);
}
input::placeholder, textarea::placeholder { color: var(--fg-disabled); }
input[type="file"] { padding: 5px; }
input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }

/* ------------------------------------------------------------------------ */
/* Dot / status indicators                                                   */
/* ------------------------------------------------------------------------ */

.dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--fg-disabled);
    flex-shrink: 0;
}
.dot.active { background: var(--success); }
.dot.pending { background: var(--warning); }
.dot.error { background: var(--danger); }
.dot.paused { background: var(--fg-disabled); }
.dot.pulse { animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.src {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--fg-muted);
    background: var(--bg-muted);
    flex-shrink: 0;
}
.src.gmail     { background: #EF444415; color: #EF4444; }
.src.gcal      { background: #3B82F615; color: #3B82F6; }
.src.whatsapp  { background: #22C55E15; color: #22C55E; }
.src.telegram  { background: #0EA5E915; color: #0EA5E9; }
.src.manual    { background: var(--bg-muted); color: var(--fg-muted); }

.dark .src.gmail    { background: #EF444420; }
.dark .src.gcal     { background: #3B82F620; }
.dark .src.whatsapp { background: #22C55E20; }
.dark .src.telegram { background: #0EA5E920; }

/* ------------------------------------------------------------------------ */
/* List (Inbox / Tasks / Accounts)                                           */
/* ------------------------------------------------------------------------ */

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    align-items: start;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    transition: background .1s;
}
.list-item:hover { background: var(--bg-hover); }
.list-item.active { background: var(--bg-active); }
.list-item:focus { outline: 0; background: var(--bg-hover); }
.list-item:focus::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 2px;
    background: var(--accent);
}

.list-item .meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--fg-muted);
    margin-bottom: 2px;
    min-width: 0;
}
.list-item .meta .actor {
    color: var(--fg);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40%;
}
.list-item .meta .actor.me { color: var(--accent); }
.list-item .meta .label {
    font-size: 11px;
    color: var(--fg-subtle);
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.list-item .title {
    font-size: 14px;
    font-weight: 500;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}
.list-item .excerpt {
    font-size: 13px;
    color: var(--fg-muted);
    margin-top: 2px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.list-item .time {
    font-size: 12px;
    color: var(--fg-subtle);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 1px;
}
.list-item .actions {
    display: none;
    align-items: center;
    gap: 2px;
    position: absolute;
    right: 12px;
    top: 8px;
    background: linear-gradient(90deg, transparent, var(--bg-hover) 30%);
    padding-left: 24px;
}
.list-item:hover .actions { display: inline-flex; }
.list-item:hover .time { display: none; }

/* ------------------------------------------------------------------------ */
/* Captures / Tasks                                                          */
/* ------------------------------------------------------------------------ */

.task-toolbar,
.task-filters {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}
.task-filters {
    margin: 8px 0 14px;
    padding-bottom: 2px;
}
.task-list-wrap { margin-top: 0; }
.task-list > li { border-bottom: 1px solid var(--border); }
.task-list > li:last-child { border-bottom: 0; }

.capture-composer {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    padding: 12px;
    margin-bottom: 12px;
}
.capture-composer:focus-within {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 2px var(--bg-active);
}
.capture-composer-text {
    border: 0;
    padding: 4px;
    resize: none;
    background: transparent;
    min-height: 28px;
    box-shadow: none !important;
}
.capture-composer-text:focus { border-color: transparent; box-shadow: none; }
.capture-composer-controls {
    display: grid;
    grid-template-columns: auto minmax(160px, 220px) minmax(140px, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.segmented {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
}
.segmented label {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 9px;
    font-size: 12px;
    color: var(--fg-muted);
    border-right: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}
.segmented label:last-child { border-right: 0; }
.segmented label.active {
    background: var(--bg-active);
    color: var(--fg);
    font-weight: 600;
}
.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.capture-item {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 11px 12px;
    background: var(--bg);
}
.capture-item:hover { background: var(--bg-hover); }
.capture-check {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    margin-top: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.capture-check:hover { background: var(--accent-bg); border-color: var(--accent-border); }
.capture-check svg { width: 12px; height: 12px; }
.capture-body { min-width: 0; }
.capture-title {
    font-size: 14px;
    font-weight: 520;
    line-height: 1.35;
    color: var(--fg);
    word-break: break-word;
}
.capture-item.done .capture-title {
    text-decoration: line-through;
    color: var(--fg-muted);
}
.capture-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--fg-subtle);
}
.capture-tag { color: var(--accent); }
.capture-reminder {
    color: var(--warning);
    font-weight: 600;
}

@media (max-width: 860px) {
    .capture-composer-controls {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    .segmented { width: 100%; }
    .segmented label { flex: 1; }
}

/* Day group separator */
.day-header {
    padding: 20px 12px 6px;
    font-size: 11px;
    color: var(--fg-subtle);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 49px;  /* topbar height */
    background: var(--bg);
    z-index: 5;
}
.day-header:first-child { padding-top: 0; }

/* ------------------------------------------------------------------------ */
/* Sections (Admin)                                                          */
/* ------------------------------------------------------------------------ */

.section { margin-bottom: 40px; }
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 12px;
}
.section-header h2 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--fg);
    letter-spacing: -0.01em;
}
.section-desc {
    font-size: 13px;
    color: var(--fg-muted);
    margin: 0 0 16px 0;
    line-height: 1.5;
}

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
/* Use on cards that host popovers/dropdowns that need to escape the card bounds. */
.card.popover-host { overflow: visible; }
.card.popover-host > .card-row:first-child {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}
.card.popover-host > .card-row:last-child {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}
.card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}
.card-row:last-child { border-bottom: 0; }
.card-row:hover { background: var(--bg-hover); }

.card-body {
    flex: 1; min-width: 0;
}
.card-title {
    font-size: 14px; font-weight: 500;
    color: var(--fg);
    line-height: 1.35;
    display: flex; align-items: center; gap: 6px;
}
.card-subtitle {
    font-size: 12px; color: var(--fg-muted);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.card-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
    word-break: break-word;
}

.empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--fg-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}
.empty-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--fg);
    margin-bottom: 4px;
}
.empty-hint { font-size: 13px; }

.notice {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid transparent;
}
.notice.success {
    background: color-mix(in srgb, var(--success) 12%, transparent);
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 24%, transparent);
}
.notice.warning {
    background: color-mix(in srgb, var(--warning) 14%, transparent);
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 26%, transparent);
}

/* ------------------------------------------------------------------------ */
/* Briefing                                                                  */
/* ------------------------------------------------------------------------ */

.briefing-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}
.briefing-date {
    font-size: 12px;
    color: var(--fg-muted);
    white-space: nowrap;
}
.briefing-banner-wrap { margin-bottom: 16px; }
.briefing-body {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 760px;
    line-height: 1.65;
}
.briefing-empty { padding: 48px 20px; }
.briefing-body h1 { font-size: 22px; font-weight: 700; margin: 0 0 20px; }
.briefing-body h2 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; color: var(--fg); }
.briefing-body h3 { font-size: 14px; font-weight: 600; margin: 16px 0 4px; }
.briefing-body p  { margin: 0 0 12px; }
.briefing-body ul,
.briefing-body ol { margin: 0 0 12px; padding-left: 22px; }
.briefing-body li { margin-bottom: 4px; }
.briefing-body strong { font-weight: 600; }
.briefing-body em { font-style: italic; }
.briefing-history { margin-top: 32px; max-width: 760px; }
.briefing-history h3 {
    font-size: 12px;
    font-weight: 700;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 10px;
}
.briefing-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.briefing-history-list li { margin-bottom: 6px; }
.briefing-history-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.briefing-history-list a:hover { background: var(--bg-hover); color: var(--fg); }
.briefing-history-list span:first-child {
    font-size: 13px;
    font-weight: 500;
}
.briefing-history-list span:last-child {
    font-size: 11px;
    color: var(--fg-muted);
}

/* ------------------------------------------------------------------------ */
/* Memory                                                                    */
/* ------------------------------------------------------------------------ */

.memory-page { max-width: 800px; }
.memory-intro {
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 18px;
    font-size: 12px;
    color: var(--fg-muted);
}
.memory-intro a { color: var(--accent); }
.memory-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg);
}
.memory-editor-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
}
.memory-editor-head h2 {
    font-size: 14px;
    font-weight: 650;
    margin: 0;
}
.memory-editor-head p {
    font-size: 12px;
    color: var(--fg-muted);
    margin: 2px 0 0;
}
.memory-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
}
.memory-textarea {
    width: 100%;
    padding: 12px 14px;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 13px;
    line-height: 1.55;
    min-height: 360px;
}
.memory-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.memory-actions span {
    font-size: 11px;
    color: var(--fg-muted);
}
.memory-feedback { margin-top: 8px; }
.memory-roadmap {
    margin-top: 24px;
    color: var(--fg-muted);
}
.memory-roadmap summary {
    cursor: pointer;
    font-size: 13px;
}
.memory-roadmap div {
    padding: 12px 0;
    font-size: 12px;
    line-height: 1.6;
}

/* ------------------------------------------------------------------------ */
/* Dashboard                                                                 */
/* ------------------------------------------------------------------------ */

.dash-metrics {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
}
.dash-metric {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    padding: 4px 8px;
    border-radius: var(--radius);
    color: var(--fg-muted);
    background: var(--bg-subtle);
    white-space: nowrap;
}
.dash-metric:hover { background: var(--bg-hover); color: var(--fg); }
.dash-metric.hot { color: var(--accent); background: var(--accent-bg); }
.dash-metric-value {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.dash-metric-label { font-size: 11px; }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 14px;
    margin-bottom: 14px;
}
.dash-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg);
    overflow: hidden;
}
.dash-panel.wide { margin-top: 14px; }
.dash-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
}
.dash-panel-head h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 650;
    letter-spacing: 0;
}
.dash-panel-head p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--fg-muted);
}
.dash-count {
    min-width: 28px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: 700;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.dash-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--fg-muted);
}
.dash-empty.compact { padding: 22px 16px; }

.agenda-list,
.dash-list,
.ai-review-list,
.signal-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.agenda-item {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.agenda-item:last-child { border-bottom: 0; }
.agenda-time {
    font-size: 13px;
    font-weight: 650;
    color: var(--fg);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.agenda-main { min-width: 0; }
.agenda-title {
    display: block;
    font-size: 13px;
    font-weight: 550;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.agenda-meta {
    margin-top: 2px;
    font-size: 11px;
    color: var(--fg-muted);
}

.dash-task {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 10px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}
.dash-task:last-child { border-bottom: 0; }
.task-time {
    color: var(--accent);
    font-size: 12px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
.task-main { min-width: 0; }
.task-title {
    font-size: 13px;
    color: var(--fg);
    line-height: 1.35;
}
.task-meta {
    margin-top: 2px;
    font-size: 11px;
    color: var(--fg-muted);
}

.ai-review-item {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.ai-review-item:last-child { border-bottom: 0; }
.ai-review-item:hover { background: var(--bg-hover); }
.ai-review-kind {
    justify-self: start;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    color: var(--fg-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ai-review-item.overdue .ai-review-kind {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.ai-review-main { min-width: 0; }
.ai-review-title {
    font-size: 13px;
    font-weight: 550;
    color: var(--fg);
    line-height: 1.35;
}
.ai-review-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--fg-muted);
}
.ai-review-meta details { display: inline-block; }
.ai-review-meta summary {
    cursor: pointer;
    color: var(--fg-muted);
}
.ai-review-meta details[open] div {
    margin-top: 4px;
    max-width: 520px;
    color: var(--fg-muted);
}
.ai-review-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.signal-item {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}
.signal-list li:last-child .signal-item { border-bottom: 0; }
.signal-item:hover { background: var(--bg-hover); color: var(--fg); }
.signal-main { min-width: 0; }
.signal-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--fg-muted);
    font-size: 11px;
}
.signal-meta span,
.signal-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.signal-title {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 520;
    color: var(--fg);
}

/* ------------------------------------------------------------------------ */
/* Chat                                                                      */
/* ------------------------------------------------------------------------ */

.inline-form { display: inline-flex; }
.chat-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 18px;
    height: calc(100vh - 140px);
    min-height: 520px;
}
.chat-sidebar {
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding-right: 12px;
    min-width: 0;
}
.chat-sidebar-title {
    font-size: 11px;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}
.chat-session-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.chat-session-list li { margin-bottom: 2px; }
.chat-session {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: inherit;
}
.chat-session:hover { background: var(--bg-hover); color: var(--fg); }
.chat-session.active { background: var(--bg-active); color: var(--fg); }
.chat-session.empty-session { color: var(--fg-subtle); }
.chat-session-title {
    font-size: 13px;
    line-height: 1.3;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-session-meta {
    font-size: 10px;
    color: var(--fg-muted);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.chat-sidebar-empty {
    font-size: 12px;
    color: var(--fg-muted);
}
.chat-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}
.chat-empty {
    margin: auto;
    max-width: 360px;
    text-align: center;
    color: var(--fg-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 18px;
}
.chat-empty form { margin-top: 14px; }
.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 16px;
    min-height: 0;
}
.chat-starters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}
.chat-starter {
    min-height: 58px;
    padding: 10px 12px;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
    color: var(--fg-muted);
    font-size: 13px;
    line-height: 1.35;
}
.chat-starter:hover { background: var(--bg-hover); color: var(--fg); }
.chat-message { margin-bottom: 20px; }
.chat-message-meta {
    font-size: 11px;
    color: var(--fg-muted);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}
.msg-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    line-height: 1.55;
    font-size: 13px;
    max-width: 760px;
    word-break: break-word;
}
.msg-user { background: var(--bg-active); }
.msg-assistant { background: var(--bg); border: 1px solid var(--border); }
.msg-assistant p { margin: 0 0 8px 0; }
.msg-assistant p:last-child { margin-bottom: 0; }
.msg-assistant ul,
.msg-assistant ol { margin: 0 0 8px 0; padding-left: 18px; }
.msg-assistant li { margin-bottom: 2px; }
.msg-assistant strong { font-weight: 600; }
.msg-assistant code {
    background: var(--bg-active);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 12px;
}
.chat-sources {
    margin-top: 6px;
    font-size: 11px;
    color: var(--fg-muted);
}
.chat-sources summary { cursor: pointer; }
.chat-sources ul {
    margin: 6px 0 0 16px;
    padding: 0;
    font-size: 11px;
}
.chat-inputbar {
    border-top: 1px solid var(--border);
    padding: 12px 8px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    min-height: 42px;
    max-height: 160px;
    resize: vertical;
}

@media (max-width: 900px) {
    .chat-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }
    .chat-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 0 0 10px;
        max-height: 190px;
    }
    .chat-main { min-height: 560px; }
    .chat-starters { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------------ */
/* Command palette                                                           */
/* ------------------------------------------------------------------------ */

.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}
.dark .cmdk-overlay { background: rgba(0, 0, 0, 0.55); }

.cmdk-panel {
    width: 100%;
    max-width: 560px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}
.dark .cmdk-panel { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }

.cmdk-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--fg);
}
.cmdk-input:focus { outline: 0; box-shadow: none; border-color: var(--border); }

.cmdk-results { max-height: 340px; overflow-y: auto; padding: 4px; }
.cmdk-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--fg);
    font-size: 13px;
}
.cmdk-item.selected { background: var(--bg-active); }
.cmdk-item .cmdk-hint { margin-left: auto; font-size: 11px; color: var(--fg-subtle); }
.cmdk-item svg { width: 14px; height: 14px; color: var(--fg-muted); flex-shrink: 0; }

.cmdk-section {
    padding: 6px 12px 4px;
    font-size: 11px; font-weight: 500;
    color: var(--fg-subtle);
    text-transform: uppercase; letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------------ */
/* Toast                                                                     */
/* ------------------------------------------------------------------------ */

.toasts {
    position: fixed;
    bottom: 20px; right: 20px;
    display: flex; flex-direction: column;
    gap: 8px;
    z-index: 50;
}
.toast {
    padding: 10px 14px;
    background: var(--fg);
    color: var(--bg);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: slidein .2s ease-out;
    max-width: 320px;
}
.toast.error { background: var(--danger); color: white; }
@keyframes slidein {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ------------------------------------------------------------------------ */
/* Modal                                                                     */
/* ------------------------------------------------------------------------ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
    animation: slidein .2s ease-out;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-body { padding: 16px; }

/* ------------------------------------------------------------------------ */
/* Thread view                                                               */
/* ------------------------------------------------------------------------ */

.thread-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}
.thread-message.me { flex-direction: row-reverse; }
.thread-message .bubble {
    background: var(--bg-muted);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    max-width: 560px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.thread-message.me .bubble {
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
}
.thread-message .sender {
    font-size: 12px; color: var(--fg-subtle);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------------ */
/* Misc                                                                      */
/* ------------------------------------------------------------------------ */

[x-cloak] { display: none !important; }
.hidden-scroll { scrollbar-width: none; }
.hidden-scroll::-webkit-scrollbar { display: none; }

/* links inline styling */
.link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
.link:hover { color: var(--accent); filter: brightness(0.85); }

/* ------------------------------------------------------------------------ */
/* Responsive overrides                                                       */
/* Keep this last: several base rules above intentionally define desktop
   defaults and would otherwise override the mobile shell.                    */
/* ------------------------------------------------------------------------ */

@media (max-width: 900px) {
    .content {
        padding: 16px 12px 48px;
        max-width: none;
    }
    .topbar {
        padding: 8px 12px;
    }
    .topbar .toolbar {
        overflow-x: auto;
        justify-content: flex-end;
        min-width: 0;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .ai-review-item {
        grid-template-columns: 1fr;
        align-items: start;
    }
    .ai-review-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none;
    }
    .sidebar.open {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: var(--bg);
    }
    .mobile-nav-toggle,
    .mobile-nav-close {
        display: inline-flex;
    }
    .dash-metrics {
        max-width: 58vw;
    }
    .agenda-item,
    .dash-task {
        grid-template-columns: 1fr;
    }
    .agenda-time,
    .task-time {
        font-size: 12px;
    }
    .signal-meta {
        display: block;
    }
    .briefing-body {
        padding: 18px;
    }
    .briefing-date {
        display: none;
    }
    .memory-editor-head,
    .memory-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Secretary question bar */
.question-bar { background: linear-gradient(135deg, #fff8e1, #fff); border-left: 3px solid #f0a500; }
.question-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.question-card { padding: 12px 14px; background: #fff; border-radius: 8px;
                  border: 1px solid var(--border, #e6e6e6); position: relative; }
.question-prompt { font-weight: 500; margin-bottom: 8px; }
.question-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.question-chips .chip { padding: 4px 10px; border-radius: 999px;
                         border: 1px solid #ddd; background: #f7f7f8; cursor: pointer; }
.question-chips .chip:hover { background: #ececef; }
.question-free { display: flex; gap: 6px; }
.question-input { flex: 1; padding: 6px 10px; border-radius: 6px;
                   border: 1px solid #ddd; }
.question-dismiss { position: absolute; top: 6px; right: 6px; }

/* AI proposal — priority badge and details slot */
.ai-review-prio { font-weight: 700; min-width: 32px; text-align: center;
                   padding: 2px 8px; border-radius: 4px; background: #f4f4f5;
                   align-self: flex-start; }
.ai-details-slot:empty { display: none; }
.ai-proposal-details { margin-top: 6px; padding: 8px; background: #fafafa;
                        border-radius: 6px; font-size: 0.92em; }
.link-btn { background: none; border: none; padding: 0; color: var(--accent, #2563eb);
             cursor: pointer; text-decoration: underline; font-size: inherit; }

/* AI proposal — context line (source / account / actor / bundle summary) */
.ai-review-context { display: flex; flex-wrap: wrap; gap: 6px;
                      align-items: baseline; margin-top: 4px; margin-bottom: 4px;
                      font-size: 0.85em; color: var(--fg-muted, #6b7280); }
.ai-review-context .ctx-source { padding: 1px 6px; border-radius: 3px;
                                   background: #f4f4f5; color: #555;
                                   font-weight: 500; text-transform: uppercase;
                                   letter-spacing: 0.04em; font-size: 0.78em; }
.ai-review-context .ctx-account { padding: 1px 6px; border-radius: 3px;
                                    background: #eef2ff; color: #4338ca;
                                    font-weight: 600; font-size: 0.92em; }
.ai-review-context .ctx-actor { color: #555; }
.ai-review-context .ctx-summary { color: #777; font-style: italic;
                                    flex-basis: 100%; line-height: 1.4; }
