:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e2e5ea;
    --text: #1a1d24;
    --muted: #6b7280;
    --accent: #4f46e5;
    --accent-contrast: #ffffff;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #d97706;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #171a21;
        --surface-2: #1e222b;
        --border: #2a2f3a;
        --text: #e6e8ee;
        --muted: #9aa3b2;
        --accent: #7c7bff;
        --accent-contrast: #0f1115;
        --shadow: none;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand span { color: var(--accent); }
.topnav { display: flex; align-items: center; gap: 16px; }
.who { color: var(--muted); font-size: .9rem; }
.navlink { color: var(--muted); font-size: .92rem; }
.navlink:hover { color: var(--text); }
.navlink.is-active { color: var(--accent); font-weight: 600; }

.container { max-width: 820px; margin: 0 auto; padding: 28px 22px; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 18px;
}
.card h1, .card h2 { margin-top: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent); color: var(--accent-contrast);
    border: none; border-radius: 10px; padding: 11px 18px;
    font-size: .95rem; font-weight: 600; cursor: pointer;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 8px; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; justify-content: center; }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { color: var(--text); }

/* Forms */
label { display: block; font-size: .85rem; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password] {
    width: 100%; padding: 11px 13px; font-size: 1rem;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 10px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-error { color: var(--danger); font-size: .82rem; margin-top: 5px; }
.flash-ok { background: #d9f2e0; color: var(--success); border-radius: 8px; padding: 10px 12px; font-size: .88rem; margin: 12px 0; }
@media (prefers-color-scheme: dark) { .flash-ok { background: #12321f; } }
.form-actions { margin-top: 20px; }
.auth-wrap { max-width: 400px; margin: 8vh auto 0; }
.auth-alt { text-align: center; margin-top: 16px; color: var(--muted); font-size: .9rem; }

/* Status pills */
.pill {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .75rem; font-weight: 600; text-transform: capitalize;
    background: var(--surface-2); color: var(--muted);
}
.pill.draft { background: var(--surface-2); color: var(--muted); }
.pill.uploaded, .pill.transcribing, .pill.normalizing, .pill.validating, .pill.diarizing,
.pill.matching_speakers, .pill.extracting_summary { background: #fff3d6; color: var(--warn); }
.pill.ready_for_review { background: #d9f2e0; color: var(--success); }
.pill.upload_failed, .pill.processing_failed, .pill.transcription_failed,
.pill.validation_failed, .pill.ai_extraction_failed, .pill.diarization_failed { background: #fbe0e0; color: var(--danger); }
@media (prefers-color-scheme: dark) {
    .pill.uploaded, .pill.transcribing { background: #3a2f12; }
    .pill.ready_for_review { background: #12321f; }
    .pill.upload_failed, .pill.processing_failed { background: #3a1717; }
}

/* Meeting list */
.mlist { list-style: none; margin: 0; padding: 0; }
.mrow {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 4px; border-bottom: 1px solid var(--border);
}
.mrow:last-child { border-bottom: none; }
.mrow .title { font-weight: 600; }
.mrow .meta { color: var(--muted); font-size: .82rem; }
.mrow-actions { display: flex; align-items: center; gap: 10px; }
.iconbtn {
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 1rem; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.iconbtn:hover { color: var(--danger); background: var(--surface-2); }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }

/* Recorder */
.recorder { text-align: center; padding: 10px 0 4px; }
.timer { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.reclabel { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.levelbar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 18px auto; max-width: 320px; }
.levelbar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); margin-right: 8px; vertical-align: middle; }
.dot.live { animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.controls { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

/* Progress */
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 14px 0 6px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.status-line { font-size: .88rem; color: var(--muted); }
.hidden { display: none !important; }

.steps { list-style: none; padding: 0; margin: 16px 0 0; }
.steps li { padding: 9px 0; padding-left: 26px; position: relative; color: var(--muted); border-bottom: 1px solid var(--border); }
.steps li:last-child { border-bottom: none; }
.steps li::before { content: "○"; position: absolute; left: 4px; }
.steps li.done { color: var(--text); }
.steps li.done::before { content: "●"; color: var(--success); }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active::before { content: "◉"; color: var(--accent); }

/* Click-to-rename title */
.editable-title { cursor: pointer; display: inline-block; }
.editable-title:hover { text-decoration: underline dotted; text-underline-offset: 4px; }

/* Collapsible cards */
.card.collapsible > h2 { cursor: pointer; display: flex; align-items: center; gap: 8px; user-select: none; }
.card.collapsible > h2:hover { color: var(--accent); }
.card.collapsible > h2 .chev {
    flex: 0 0 auto; width: 0; height: 0;
    border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 7px solid var(--muted);
    transform: rotate(90deg); transition: transform .15s ease;
}
.card.collapsed > h2 .chev { transform: rotate(0deg); }
.card.collapsed > h2 { margin-bottom: 0; }
.card.collapsed > :not(h2) { display: none; }

/* Speaker assignment */
.speakers { display: flex; flex-direction: column; gap: 10px; }
.speaker-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.speaker-row .pill { min-width: 92px; text-align: center; }
.spk-sample {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
    cursor: pointer; border-radius: 999px; width: 26px; height: 26px; line-height: 1;
    font-size: .64rem; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.spk-sample:hover { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.speaker-input { flex: 1; min-width: 160px; }
.speaker-note { font-size: .8rem; color: var(--success); }
.suggest { font-size: .8rem; color: var(--muted); }
.suggest strong { color: var(--text); font-weight: 600; }
.suggest .linkbtn { color: var(--accent); text-decoration: underline; margin-left: 2px; }
.auto-note { font-size: .78rem; color: var(--muted); font-style: italic; }

/* People picker (combobox) */
.ppick { position: relative; flex: 1; min-width: 200px; display: flex; align-items: center; }
.ppick .speaker-input { width: 100%; padding-right: 28px; }
.ppick-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: .9rem; line-height: 1; padding: 4px;
}
.ppick-clear:hover { color: var(--text); }
.ppick-menu {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow); max-height: 260px; overflow-y: auto;
}
.ppick-item, .ppick-add {
    display: block; width: 100%; text-align: left; background: none; border: none;
    padding: 8px 11px; cursor: pointer; font: inherit; color: var(--text);
}
.ppick-item { display: flex; flex-direction: column; gap: 1px; }
.ppick-item:hover, .ppick-add:hover { background: var(--surface-2); }
.ppick-name { color: var(--text); }
.ppick-sub { font-size: .76rem; color: var(--muted); }
.ppick-add { border-top: 1px solid var(--border); color: var(--accent); }
.ppick-form { padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.ppick-form input { width: 100%; }
.pf-actions { display: flex; align-items: center; gap: 10px; }
.pf-err { font-size: .78rem; }

/* People directory */
.person-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.person-form input { flex: 1; min-width: 140px; }
.person-form .form-err { font-size: .82rem; flex-basis: 100%; }
.plist { list-style: none; margin: 0; padding: 0; }
.prow { border-bottom: 1px solid var(--border); padding: 12px 0; }
.prow:last-child { border-bottom: none; }
.prow-view { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pname { font-weight: 600; color: var(--text); }
.pmeta { font-size: .82rem; margin-top: 2px; }
.prow-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.prow-edit { padding: 4px 0; }

/* Nav dropdown menus (workspace switcher, user menu) */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; color: var(--muted); font-size: .92rem; padding: 4px 8px; border-radius: 8px; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::after { content: "▾"; font-size: .7em; margin-left: 5px; vertical-align: middle; }
details.menu > summary:hover, details.menu[open] > summary { color: var(--text); background: var(--surface-2); }
.wsmenu > summary { color: var(--text); font-weight: 600; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.menu-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 5px 9px 3px; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 8px 10px; border-radius: 8px; color: var(--text); cursor: pointer; font: inherit; text-decoration: none; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.is-active { color: var(--accent); font-weight: 600; }
.menu-foot { border-top: 1px solid var(--border); margin-top: 4px; color: var(--accent); }
.renamemenu .menu-panel { padding: 10px; min-width: 240px; }

/* Stacked forms (profile) */
.stack-form { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.stack-form label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--muted); }
.stack-form input { width: 100%; }
.field-err { color: var(--danger); font-size: .82rem; margin: -6px 0 0; }
.move-form { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; font-size: .85rem; }
.move-form select { padding: 6px 9px; border-radius: 8px; }
.approval-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: .86rem; }
.approved-note { margin: 12px 0 0; color: var(--success); font-size: .84rem; }
.pill.pending { background: #fdecc8; color: #92600a; }
@media (prefers-color-scheme: dark) { .pill.pending { background: #3b2f12; color: #f0c674; } }

/* Invite link row */
.invite-link { display: flex; gap: 6px; margin-top: 6px; max-width: 460px; }
.invite-link input { flex: 1; min-width: 0; font-size: .82rem; color: var(--muted); }
.person-form select, .prow-actions select { padding: 7px 10px; border-radius: 8px; }

/* Intelligence (decisions, actions) */
.ilist { list-style: none; margin: 0; padding: 0; }
.ilist > li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.ilist > li:last-child { border-bottom: none; }
.imeta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 5px; color: var(--muted); font-size: .8rem; }

/* Transcript */
.transcript { margin-top: 8px; }
.tseg { padding: 12px 0; border-bottom: 1px solid var(--border); }
.tseg:last-child { border-bottom: none; }
.tmeta { display: flex; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.tmeta .spk { font-weight: 600; font-size: .9rem; }
.tmeta .ts { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.ttext { color: var(--text); }
.playseg {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
    cursor: pointer; border-radius: 999px; width: 24px; height: 24px; line-height: 1;
    font-size: .62rem; padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.playseg:hover { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.tseg.playing { background: var(--surface-2); border-radius: 8px; margin: 0 -10px; padding: 12px 10px; }
.tseg.playing .ttext { font-weight: 500; }

/* ---- Workspace search ------------------------------------------------ */
.navsearch { position: relative; margin-right: 4px; }
.navsearch-input {
    width: 230px; max-width: 40vw; padding: 7px 12px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface-2); color: var(--text); font-size: .9rem;
    transition: width .15s ease, border-color .15s ease;
}
.navsearch-input:focus { outline: none; width: 320px; border-color: var(--accent); background: var(--surface); }
.navsearch-panel {
    position: absolute; top: calc(100% + 8px); right: 0; width: 460px; max-width: 92vw;
    max-height: 70vh; overflow-y: auto; z-index: 60;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.navsearch-group {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); padding: 8px 10px 4px; font-weight: 700;
}
.navsearch-item { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.navsearch-item:hover { background: var(--surface-2); }
.navsearch-item-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.navsearch-item-title { font-weight: 600; font-size: .9rem; }
.navsearch-ts, .searchrow-ts { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.navsearch-item-snip, .searchrow-snippet { color: var(--muted); font-size: .84rem; margin-top: 2px; line-height: 1.35; }
.navsearch-empty { padding: 14px; color: var(--muted); font-size: .88rem; }
.navsearch-all { display: block; padding: 9px 10px; margin-top: 4px; border-top: 1px solid var(--border);
    color: var(--accent); font-weight: 600; font-size: .85rem; text-decoration: none; }
.navsearch-all:hover { background: var(--surface-2); }
mark { background: rgba(124, 123, 255, .28); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Full search page */
.searchpage-form { display: flex; gap: 8px; margin: 4px 0 14px; }
.searchpage-input { flex: 1; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--surface); color: var(--text); font-size: 1rem; }
.searchpage-input:focus { outline: none; border-color: var(--accent); }
.searchlist { list-style: none; margin: 0; padding: 0; }
.searchlist li + li { border-top: 1px solid var(--border); }
.searchrow { display: block; padding: 10px 4px; text-decoration: none; color: var(--text); border-radius: 8px; }
.searchrow:hover { background: var(--surface-2); }
.searchrow-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.searchrow-title { font-weight: 600; }

/* Deep-link flash when arriving from a search result */
@keyframes searchHitFlash {
    0% { background: rgba(124, 123, 255, .30); }
    100% { background: transparent; }
}
.search-hit { animation: searchHitFlash 2.2s ease-out; border-radius: 8px; }

/* ---- Send action item to a task app --------------------------------- */
.ai-todo { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.todo-send { color: var(--accent); font-weight: 600; font-size: .82rem; }
.todo-send:hover { text-decoration: underline; }
.todo-send:disabled { opacity: .6; cursor: default; }
.todo-done { color: var(--success); font-weight: 600; font-size: .82rem; }
