/* =============================================================================
   Vishwamitra console — design system
   Single stylesheet, two themes driven by data-theme on <html>.
   Dark is the default (:root); light overrides the same tokens.
   Accent family: teal / emerald.
   ========================================================================== */

/* ---- Tokens: dark (default) ---------------------------------------------- */
:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2430;
    --surface-3: #232d3b;
    --border: #2a3441;
    --border-strong: #3a4757;
    --text: #e6edf3;
    --muted: #8b97a7;

    --accent: #2dd4bf;
    --accent-strong: #14b8a6;
    --accent-soft: rgba(45, 212, 191, 0.14);
    --accent-contrast: #04211d;
    --ring: rgba(45, 212, 191, 0.45);

    /* semantic (badges, flashes, status) */
    --ok-bg: #102a1d;     --ok-fg: #6ee7a8;     --ok-bd: #1f6b40;
    --warn-bg: #2b2410;   --warn-fg: #e3b341;   --warn-bd: #6b551f;
    --err-bg: #2d1718;    --err-fg: #f6a6a6;    --err-bd: #7a2b2b;
    --info-bg: #11233f;   --info-fg: #79b0ff;   --info-bd: #2b4a7a;
    --neutral-bg: var(--surface-2); --neutral-fg: var(--muted); --neutral-bd: var(--border);

    --radius: 10px;
    --radius-sm: 7px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    color-scheme: dark;
}

/* ---- Tokens: light ------------------------------------------------------- */
:root[data-theme="light"] {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f0f3f7;
    --surface-3: #e6ebf1;
    --border: #dce2e9;
    --border-strong: #c4ccd6;
    --text: #1a2330;
    --muted: #5e6976;

    --accent: #0d9488;
    --accent-strong: #0f766e;
    --accent-soft: rgba(13, 148, 136, 0.10);
    --accent-contrast: #ffffff;
    --ring: rgba(13, 148, 136, 0.35);

    --ok-bg: #e7f7ee;     --ok-fg: #1a7a44;     --ok-bd: #a8e0c0;
    --warn-bg: #fbf2dc;   --warn-fg: #9a6a06;   --warn-bd: #ecd197;
    --err-bg: #fdeaea;    --err-fg: #b3261e;    --err-bd: #f2bcbc;
    --info-bg: #e8f0fe;   --info-fg: #1a55c0;   --info-bd: #bcd2f5;
    --neutral-bg: var(--surface-2); --neutral-fg: var(--muted); --neutral-bd: var(--border);

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.10);
    --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.16);
    color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

::selection { background: var(--accent-soft); }

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

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; margin-top: 0.25rem; }
h3 { font-size: 1rem; font-weight: 650; }
.muted { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 0.86em; }

/* ---- Top progress bar ---------------------------------------------------- */
#progress-bar {
    position: fixed; top: 0; left: 0; height: 3px; width: 0;
    background: linear-gradient(90deg, var(--accent-strong), var(--accent));
    box-shadow: 0 0 10px var(--accent);
    z-index: 1000; opacity: 0;
    transition: width 0.2s var(--ease), opacity 0.3s var(--ease);
}
#progress-bar.active { opacity: 1; }

/* ---- Top navigation ------------------------------------------------------ */
.topnav {
    display: flex; align-items: center; gap: 1.25rem;
    padding: 0.7rem 1.5rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(150%) blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topnav .brand {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-weight: 750; color: var(--text); letter-spacing: -0.01em; font-size: 1.02rem;
}
.topnav .brand .brand-mark {
    width: 22px; height: 22px; border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    display: inline-block; flex: none;
    box-shadow: 0 0 0 1px var(--border) inset;
}
.topnav .nav-tools { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.topnav .user { display: flex; align-items: center; gap: 0.55rem; }
.user-email { color: var(--muted); font-size: 0.88rem; }
.avatar {
    width: 30px; height: 30px; border-radius: var(--radius-pill); flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.78rem; font-weight: 700; color: var(--accent-contrast);
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

/* theme toggle button */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--muted); cursor: pointer; transition: all 0.15s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }
.theme-toggle .moon { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }

/* ---- Layout -------------------------------------------------------------- */
.container { max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.container.wide { max-width: 1240px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head { margin-bottom: 1.5rem; }
.page-head p { margin: 0.35rem 0 0; }

/* ---- Buttons ------------------------------------------------------------- */
.btn,
button[type=submit],
button.secondary {
    --btn-bg: var(--accent);
    --btn-fg: var(--accent-contrast);
    --btn-bd: transparent;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
    border-radius: var(--radius-sm); padding: 0.5rem 0.95rem;
    font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
    text-decoration: none; line-height: 1.2; white-space: nowrap;
    transition: transform 0.08s var(--ease), box-shadow 0.15s var(--ease),
                background 0.15s var(--ease), border-color 0.15s var(--ease), opacity 0.15s var(--ease);
}
button[type=submit] { align-self: flex-start; }
.btn:hover,
button[type=submit]:hover,
button.secondary:hover { box-shadow: var(--shadow-sm); filter: brightness(1.05); }
.btn:active,
button[type=submit]:active,
button.secondary:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible,
button[type=submit]:focus-visible,
button.secondary:focus-visible,
button.link:focus-visible,
a.btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none; box-shadow: 0 0 0 3px var(--ring);
}

.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--accent-contrast); }
.btn--secondary,
button.secondary { --btn-bg: var(--surface-2); --btn-fg: var(--text); --btn-bd: var(--border); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--text); --btn-bd: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
/* Doubled selector outweighs button[type=submit]'s custom-prop defaults (0-1-1). */
.btn--danger,
button[type=submit].btn--danger { --btn-bg: var(--err-bg); --btn-fg: var(--err-fg); --btn-bd: var(--err-bd); }
.btn--sm { padding: 0.32rem 0.6rem; font-size: 0.82rem; }

.btn[disabled], button[disabled], .btn.is-loading, button.is-loading {
    opacity: 0.6; cursor: progress; pointer-events: none;
}
.btn.is-loading, button.is-loading { color: transparent !important; position: relative; }
.btn.is-loading::after, button.is-loading::after {
    content: ""; position: absolute; width: 15px; height: 15px;
    top: calc(50% - 7.5px); left: calc(50% - 7.5px);
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    color: var(--accent-contrast); animation: spin 0.6s linear infinite;
}
button.secondary.is-loading::after, .btn--secondary.is-loading::after,
.btn--ghost.is-loading::after, .btn--danger.is-loading::after { color: var(--text); }

/* link-style buttons */
button.link, a.link {
    background: none; border: none; color: var(--accent); cursor: pointer; padding: 0;
    font: inherit; font-size: 0.86rem; font-weight: 600;
    transition: color 0.15s var(--ease);
}
button.link:hover, a.link:hover { color: var(--accent-strong); text-decoration: underline; }
button.link.danger { color: var(--err-fg); }
.inline-form { display: inline; }
form.inline-form button.x { background: none; border: none; color: var(--muted); cursor: pointer; }
.row-actions { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* spinner */
.spinner {
    display: inline-block; width: 15px; height: 15px;
    border: 2px solid var(--border-strong); border-right-color: var(--accent);
    border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* HTMX in-flight indicator (hidden until request active) */
.htmx-indicator { opacity: 0; transition: opacity 0.2s var(--ease); }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ---- Cards / panels / tiles ---------------------------------------------- */
.card, .panel, .provider-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.1rem;
    box-shadow: var(--shadow-sm);
}
.panel h3 { margin: 0 0 0.6rem; }

.tiles {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem; margin-top: 1.75rem;
}
.tile {
    display: flex; flex-direction: column; gap: 0.3rem;
    padding: 1.25rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); text-decoration: none; color: var(--text);
    box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
    transition: transform 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.tile::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--accent); opacity: 0; transition: opacity 0.15s var(--ease);
}
.tile:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.tile:hover::before { opacity: 1; }
.tile-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -0.02em; }
.tile-label { color: var(--text); font-size: 0.92rem; font-weight: 600; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }

/* ---- Sub navigation / pill tabs ------------------------------------------ */
.subnav { display: flex; gap: 0.4rem; margin-bottom: 1.5rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 0.1rem; }
.subnav a {
    color: var(--muted); text-decoration: none; padding: 0.45rem 0.8rem;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-bottom: 2px solid transparent; transition: all 0.15s var(--ease); font-size: 0.92rem;
}
.subnav a:hover { color: var(--text); background: var(--surface-2); }
.subnav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- Flash messages ------------------------------------------------------ */
.flash {
    padding: 0.7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem;
    font-size: 0.9rem; border: 1px solid; display: flex; align-items: center; gap: 0.5rem;
}
.flash.ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg); }
.flash.error { background: var(--err-bg); border-color: var(--err-bd); color: var(--err-fg); }

/* ---- Badges (neutral + semantic) ----------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
    padding: 0.18rem 0.5rem; border-radius: var(--radius-pill);
    background: var(--neutral-bg); border: 1px solid var(--neutral-bd); color: var(--accent);
    white-space: nowrap;
}
.badge--success, .badge--approved, .badge--valid, .badge--succeeded, .badge--ready, .badge--active, .badge--current,
.badge--stored, .badge--granted, .badge--high {
    background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg);
}
.badge--info, .badge--submitted, .badge--pending, .badge--validating, .badge--running,
.badge--registered, .badge--medium {
    background: var(--info-bg); border-color: var(--info-bd); color: var(--info-fg);
}
.badge--warning, .badge--needs-changes, .badge--awaiting-upload {
    background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn-fg);
}
.badge--danger, .badge--invalid, .badge--failed, .badge--rejected, .badge--revoked {
    background: var(--err-bg); border-color: var(--err-bd); color: var(--err-fg);
}
.badge--muted, .badge--draft, .badge--archived, .badge--not-required, .badge--low {
    background: var(--neutral-bg); border-color: var(--neutral-bd); color: var(--muted);
}

/* ---- Tables -------------------------------------------------------------- */
table.grid {
    width: 100%; border-collapse: separate; border-spacing: 0; margin: 1rem 0 2rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
table.grid th, table.grid td {
    text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.grid thead th {
    color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
    background: var(--surface-2); position: sticky; top: 0;
}
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr { transition: background 0.12s var(--ease); }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid code { color: var(--accent); }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 0.75rem; }
tr.clickable { cursor: pointer; }

/* ---- Empty states -------------------------------------------------------- */
.empty-state {
    text-align: center; color: var(--muted); padding: 2.5rem 1rem;
}
td .empty-state { padding: 1.5rem; }

/* ---- Forms --------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 0.85rem; max-width: 580px; }
.form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.form label.inline { flex-direction: row; align-items: center; gap: 0.5rem; }
input[type=text], input[type=email], input[type=number], select, textarea,
.form input[type=text], .form input[type=email], .form input[type=number], .form select, .form textarea,
.form-row input[type=text] {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius-sm); padding: 0.55rem 0.7rem; font: inherit; font-size: 0.92rem;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { resize: vertical; min-height: 64px; }

/* ---- Modal --------------------------------------------------------------- */
.modal {
    position: fixed; inset: 0; background: rgba(2, 6, 12, 0.6); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    animation: fade-in 0.15s var(--ease);
}
.modal[hidden] { display: none; }
.modal-card {
    position: relative; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 520px; margin: 1rem;
    display: flex; flex-direction: column; gap: 0.85rem; box-shadow: var(--shadow-lg);
    animation: pop-in 0.18s var(--ease);
}
.modal-card h3 { margin: 0; }
.modal-card form { display: flex; flex-direction: column; gap: 0.7rem; }
.modal-card label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.modal-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.modal-close { position: absolute; top: 0.6rem; right: 0.9rem; color: var(--muted); text-decoration: none; font-size: 1.4rem; line-height: 1; }
.modal-close:hover { color: var(--text); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---- Import drop zone ---------------------------------------------------- */
.dropzone {
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
    padding: 2rem 1.5rem; text-align: center; transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-text { margin: 0 0 0.4rem; }
.dropzone .dz-file { margin: 0; font-size: 0.85rem; }

/* ---- Upload progress (signed-URL asset uploader) ------------------------- */
.upload-progress { display: flex; align-items: center; gap: 0.6rem; margin: 0.8rem 0; }
.upload-progress .upload-track {
    flex: 1; height: 6px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden;
}
.upload-progress .upload-bar {
    height: 100%; width: 0; background: var(--accent); transition: width 0.15s var(--ease);
}

/* ---- Chips --------------------------------------------------------------- */
.chip {
    display: inline-flex; align-items: center; gap: 0.3rem; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-pill);
    padding: 0.2rem 0.6rem; margin: 0.15rem; font-size: 0.82rem;
}
.chip button.x { color: var(--muted); }
.chip button.x:hover { color: var(--err-fg); }

/* ---- Taxonomy / providers ------------------------------------------------ */
.tax-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; }
.chips { display: flex; flex-wrap: wrap; margin-bottom: 0.75rem; }
.add-term { display: flex; gap: 0.5rem; }
.provider-card { margin-bottom: 1rem; }
.form-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.form-row label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.form-row label.inline { flex-direction: row; align-items: center; }
.provider-name { font-weight: 700; text-transform: capitalize; min-width: 80px; }

/* ---- Extraction prompts (admin) ------------------------------------------ */
.form.form--wide { max-width: none; }
.prompt-editor { display: flex; gap: 1rem; align-items: stretch; flex-wrap: wrap; }
.prompt-editor textarea { flex: 1 1 420px; }
.prompt-actions { display: flex; flex-direction: column; gap: 0.6rem; align-self: flex-start; min-width: 140px; }
.prompt-actions button { width: 100%; }

/* ---- Copyable mono value ------------------------------------------------- */
.copyable { cursor: pointer; }
.copyable:hover { color: var(--accent-strong); }

/* ---- SFT / DPO editor ---------------------------------------------------- */
.actions-bar {
    display: flex; gap: 0.6rem; align-items: center; margin: 1rem 0 1.5rem; flex-wrap: wrap;
    position: sticky; top: 58px; z-index: 20;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    padding: 0.6rem 0; backdrop-filter: blur(6px);
}
.actions-bar form { display: inline-flex; gap: 0.4rem; }
.reviewer-actions { display: inline-flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.inline-send { display: inline-flex; gap: 0.4rem; }

.editor-grid { display: grid; grid-template-columns: 1fr 360px; gap: 1.5rem; align-items: start; }
.editor-main { min-width: 0; }
.tags-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1.5rem; }
.tags-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); font-weight: 600; }

.turns { display: flex; flex-direction: column; gap: 0.75rem; }
.turn { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.turn-head { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.85rem; border-bottom: 1px solid var(--border); }
.turn-ops { display: flex; gap: 0.4rem; }
.turn-ops form { display: inline; }
.turn-body { padding: 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; }
.turn-body textarea, .turn-body input[type=text], .turn-body select {
    width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius-sm); padding: 0.55rem; font: inherit;
}
.tool-fields { display: flex; flex-direction: column; gap: 0.5rem; }
.tool-fields label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.add-turns { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.add-turns form { display: inline; }

.editor-side { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 70px; }
.preview { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem; overflow-x: auto; font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; }
.errors { margin: 0; padding-left: 1.1rem; color: var(--err-fg); font-size: 0.85rem; }
.comments { list-style: none; padding: 0; margin: 0 0 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; }
.add-comment { display: flex; gap: 0.4rem; }
.add-comment input { flex: 1; }

/* ---- DPO ----------------------------------------------------------------- */
.new-dpo { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.new-dpo form { display: inline-flex; gap: 0.4rem; }
.seed-form select { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 0.5rem; }
.prompt-form, .candidates-form, .swap-form { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; max-width: 760px; }
.prompt-form label, .candidates-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.prompt-form textarea, .candidates-form textarea {
    width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 0.55rem; font: inherit;
}
.candidates-form label.chosen textarea { border-left: 3px solid var(--ok-bd); }
.candidates-form label.rejected textarea { border-left: 3px solid var(--err-bd); }
.seeded-prompt .turn-body { padding: 0.6rem 0.75rem; }

/* ---- Landing page -------------------------------------------------------- */
.landing {
    min-height: 100vh; display: flex; flex-direction: column;
    background:
        radial-gradient(1100px 500px at 50% -10%, var(--accent-soft), transparent 70%),
        var(--bg);
}
.landing-top { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 2rem; }
.landing-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; }
.landing-hero { max-width: 560px; text-align: center; }
.landing-hero .brand-mark { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong)); box-shadow: var(--shadow-md); }
.landing-hero h1 { font-size: 2.4rem; line-height: 1.1; margin-bottom: 0.85rem; }
.landing-hero .lede { font-size: 1.1rem; color: var(--muted); margin: 0 auto 2rem; max-width: 460px; }
.landing-cta {
    display: inline-flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1.5rem;
    font-size: 1rem; font-weight: 650; border-radius: var(--radius);
    background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-md); transition: transform 0.1s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}
.landing-cta:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: var(--shadow-lg); color: var(--text); }
.landing-cta:active { transform: translateY(0) scale(0.99); }
.landing-guide { margin-top: 1.1rem; font-size: 0.9rem; color: var(--muted); }
.landing-features { display: flex; gap: 1.75rem; justify-content: center; flex-wrap: wrap; margin-top: 2.75rem; }
.landing-feature { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.landing-feature svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.landing-foot { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 1.5rem; }
/* Subject-face placeholders (VA-30): footer links + button-styled-as-link. */
.landing-foot a { color: var(--muted); }
.linklike { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit;
    padding: 0; text-decoration: underline; }

/* ---- Admin console (VA-82) ------------------------------------------------ */
/* The page's <main> is the grid: the consolenav aside takes the left column, every other child
   flows into the right column — no per-page content wrapper needed. */
.console { display: grid; grid-template-columns: 220px minmax(0, 1fr); column-gap: 2rem; align-items: start; }
.console > * { grid-column: 2; min-width: 0; }
.console > .console-nav { grid-column: 1; grid-row: 1 / span 200; }
.console-nav {
    position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto;
    display: flex; flex-direction: column; gap: 1.15rem;
    padding-right: 1.1rem; border-right: 1px solid var(--border); font-size: 0.88rem;
}
.console-nav .console-group { display: flex; flex-direction: column; gap: 0.1rem; }
.console-nav .console-group-label {
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 0.3rem;
}
.console-nav a { display: block; padding: 0.32rem 0.55rem; border-radius: var(--radius-sm); color: var(--muted); }
.console-nav a:hover { color: var(--text); background: var(--surface-2); }
.console-nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.console-nav a.sub { padding-left: 1.4rem; font-size: 0.82rem; }

/* Per-stage Configuration tab (VA-83) */
.config-form section { margin-bottom: 1.75rem; }
.config-form h3 { margin: 0 0 0.75rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }
.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.9rem 1.5rem; }
.config-field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; }
.config-field .config-label { display: flex; align-items: center; gap: 0.4rem; color: var(--text); font-weight: 600; }
.config-field .lock { font-size: 0.75rem; cursor: help; }
.config-field input[type=text], .config-field select {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius-sm); padding: 0.45rem 0.55rem; font: inherit;
}
.config-field input[disabled], .config-field select[disabled] { opacity: 0.55; cursor: not-allowed; }
.config-field .config-help { color: var(--muted); font-size: 0.76rem; line-height: 1.35; }
.config-field .config-default { color: var(--accent); }
.config-save { margin-top: 0.5rem; align-items: center; }

/* Stage picker (the /admin/extraction-prompts index) */
.stage-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.stage-card {
    display: flex; flex-direction: column; gap: 0.5rem; padding: 1.25rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); color: var(--text);
    transition: transform 0.1s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.stage-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); color: var(--text); }
.stage-card svg { width: 28px; height: 28px; color: var(--accent); }
.stage-card .stage-card-title { font-weight: 650; }
.console-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.console-card h3 { margin: 0 0 0.35rem; }
.console-card .card-stat { font-size: 1.6rem; font-weight: 750; letter-spacing: -0.02em; display: block; margin-bottom: 0.25rem; }
.console-card .card-links { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.7rem; font-size: 0.88rem; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
    .editor-grid { grid-template-columns: 1fr; }
    .editor-side { position: static; }
    .console { display: block; }
    .console-nav {
        position: static; max-height: none; flex-direction: row; flex-wrap: wrap; gap: 1.25rem;
        border-right: none; border-bottom: 1px solid var(--border);
        padding: 0 0 1rem; margin-bottom: 1.5rem;
    }
}
@media (max-width: 720px) {
    .dash-grid { grid-template-columns: 1fr; }
    .topnav { flex-wrap: wrap; gap: 0.75rem; }
    .nav-tools { margin-left: auto; }
    .landing-hero h1 { font-size: 1.9rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ── VA-37: split landing panels + guest panel + token dashboard (subject world, LLD §8.3) ── */
.landing-hero--wide { max-width: 880px; }
.landing-hero--wide .lede { margin-bottom: 1.25rem; }
.landing-panels {
    display: grid; grid-template-columns: 1fr 1px 1fr; gap: 2rem;
    margin-top: 2rem; text-align: left; align-items: stretch;
}
.landing-divider { background: var(--border); }
.landing-panel h2 { font-size: 1.15rem; margin-bottom: 0.6rem; }
.landing-panel .form { margin-top: 1rem; }
.panel-lede { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.75rem; }
.panel-links { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }
.panel-fineprint { color: var(--muted); font-size: 0.78rem; margin-top: 1.1rem; }
.code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.35em; text-transform: lowercase;
}
.tokens-panel { width: min(760px, 100%); }
.tokens-panel h1 { font-size: 1.7rem; margin-bottom: 0.5rem; }
.tokens-panel .lede { color: var(--muted); margin-bottom: 1.25rem; }
.tokens-panel .card { margin-bottom: 1.5rem; }
.tokens-panel table.grid { width: 100%; }
@media (max-width: 720px) {
    .landing-panels { grid-template-columns: 1fr; }
    /* VA-43 AC: panels stack and the divider turns horizontal at mobile width. */
    .landing-divider { width: 100%; height: 1px; }
}

/* ── VA-32: subject training surfaces (S2–S5, LLD §8) ── */
.subject-panel { width: min(760px, 100%); }
.subject-panel h1 { font-size: 1.7rem; margin-bottom: 0.5rem; }
.subject-panel h2 { font-size: 1.1rem; margin: 1.4rem 0 0.6rem; }
.subject-panel .lede { color: var(--muted); margin-bottom: 1.25rem; }
.subject-panel .card { margin-bottom: 1.2rem; }
.subject-panel .card label { display: block; font-size: 0.85rem; color: var(--muted);
    font-weight: 600; margin-bottom: 0.7rem; }
.subject-panel .card select, .subject-panel .card input[type=text] { display: block;
    width: 100%; margin-top: 0.35rem; }
.subject-panel table.grid { width: 100%; }
label.attest { display: flex; gap: 0.55rem; align-items: flex-start; font-weight: 400;
    color: var(--text); font-size: 0.85rem; line-height: 1.45; margin: 0.9rem 0; }
label.attest input { margin-top: 0.2rem; flex: none; }
.upload-progress { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.7rem; }
.upload-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--border);
    overflow: hidden; }
.upload-bar span { display: block; height: 100%; width: 0; background: var(--accent);
    transition: width 0.2s; }
.progress-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.6rem; }
.progress-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.9rem;
    border: 1px solid var(--border); border-radius: 8px; }
.progress-title { flex: 1; }
.speaker-card { margin-bottom: 0.9rem; }
.speaker-pick { display: flex; align-items: center; gap: 0.5rem; }
.speaker-quote { margin: 0.6rem 0 0; padding-left: 0.9rem; border-left: 3px solid var(--border);
    color: var(--muted); font-size: 0.9rem; max-height: 9rem; overflow-y: auto; }
.upload-list { margin: 0.4rem 0 0 1.1rem; color: var(--muted); }

/* ── VA-33: subject review wizard (S6) ── */
.review-steps { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.review-steps .step { font-size: 0.8rem; color: var(--muted); padding: 0.25rem 0.6rem;
    border: 1px solid var(--border); border-radius: 999px; }
.review-steps .step.active { color: var(--text); border-color: var(--accent); }
.review-steps .step.done { color: var(--text); }
.review-list { display: flex; flex-direction: column; gap: 0.5rem; }
.review-row { border: 1px solid var(--border); border-radius: 8px; }
.review-row summary { display: flex; align-items: center; gap: 0.6rem; cursor: pointer;
    padding: 0.65rem 0.9rem; list-style: none; }
.review-row summary::-webkit-details-marker { display: none; }
.review-row .review-text { flex: 1; }
.review-row[open] { border-color: var(--accent); }
.review-editor { padding: 0.2rem 0.9rem 0.9rem; border-top: 1px solid var(--border); }

/* The hidden attribute must beat any display rule here (the .modal[hidden] idiom) — the JS
   toggles suError / suFromWrap / suProgress via [hidden], and .flash/.card label set display. */
.subject-panel [hidden] { display: none !important; }

/* ── VA-43: advocate chat (S10, LLD §8.3) + VA-44 evidence-strength card ── */
.chat-panel { display: flex; flex-direction: column; }
.chat-ribbon {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 1px solid var(--accent); border-radius: var(--radius);
    padding: 0.55rem 0.9rem; font-size: 0.85rem; margin-bottom: 1rem;
}
.chat-disclosure { color: var(--muted); font-size: 0.8rem; margin-bottom: 1rem; }
.chat-log {
    display: flex; flex-direction: column; gap: 0.6rem;
    min-height: 260px; max-height: 55vh; overflow-y: auto;
    padding: 1rem; margin-bottom: 0.75rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.chat-msg { display: flex; }
.chat-msg--you { justify-content: flex-end; }
.chat-msg--advocate { justify-content: flex-start; }
.chat-bubble {
    max-width: 78%; padding: 0.55rem 0.85rem; border-radius: 14px;
    font-size: 0.93rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.chat-msg--you .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg--advocate .chat-bubble {
    background: color-mix(in srgb, var(--border) 40%, var(--surface));
    border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.chat-msg--pending .chat-bubble { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 0.6rem; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: none; }
.score-card .score-dial { font-size: 2rem; font-weight: 750; letter-spacing: -0.02em; margin-bottom: 0.3rem; }
.score-card .score-dial span { font-size: 1rem; font-weight: 500; color: var(--muted); }

/* ── VA-45: policy pages + cookie notice (LLD §13.3) ── */
.policy-page { max-width: 720px; text-align: left; }
.policy-page > h1, .policy-page > .lede, .policy-page > .policy-toc { text-align: center; }
.policy-toc { color: var(--muted); font-size: 0.9rem; }
.policy-text { margin-top: 2.25rem; }
.policy-text + .policy-text { border-top: 1px solid var(--border); padding-top: 1.75rem; }
.policy-text h2 { font-size: 1.35rem; margin-bottom: 0.15rem; }
.policy-text h3 { font-size: 1rem; margin: 1.25rem 0 0.35rem; }
.policy-text p, .policy-text li { color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.policy-text ul { padding-left: 1.2rem; margin: 0.4rem 0; }
.policy-text li { margin-bottom: 0.35rem; }
.policy-text strong { color: var(--text); }
.policy-meta { color: var(--muted); font-size: 0.78rem; }
.policy-accept { margin-top: 2.5rem; padding-top: 1.75rem; border-top: 1px solid var(--border); text-align: center; }
.policy-links a { color: var(--muted); }
.cookie-bar {
    position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
    display: flex; align-items: center; gap: 1rem; width: max-content; max-width: min(92vw, 640px);
    padding: 0.7rem 1rem; background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 0.85rem;
    color: var(--muted); z-index: 50;
}
/* The §8.5 lesson: explicit display rules beat the UA [hidden] default — restate it. */
.cookie-bar[hidden] { display: none; }
.cookie-bar .btn { flex: none; }

/* ── VA-71: apex landing capability strip (LLD §8.4) ── */
.landing-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-top: 2.75rem; text-align: left; }
.landing-strip h3 { font-size: 0.95rem; margin-bottom: 0.3rem; }
.landing-strip p { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
@media (max-width: 720px) {
    .landing-strip { grid-template-columns: 1fr; }
}

/* ── VA-68: Advocates panel ops counters (LLD §14.1) ── */
.ops-cards { margin: 1rem 0 1.5rem; }
.ops-cell { font-size: 0.78rem; line-height: 1.5; white-space: nowrap; }
