/* ============================================================
   DocSpace — compact design system
   Light / Dark / System theming via [data-theme] on <html>.
   Dense by default: 34px controls, 6–8px corners, borders over shadows.
   ============================================================ */

/* ---------- Vendored webfonts (self-hosted; no CDN) ---------- */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/hanken-grotesk-400.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/hanken-grotesk-500.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/hanken-grotesk-600.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/hanken-grotesk-700.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/jetbrains-mono-400.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/jetbrains-mono-500.woff2") format("woff2"); }

/* ---------- Theme tokens ---------- */
:root,
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f7fa;
    --surface: #ffffff;
    --surface-1: #f9fafc;
    --surface-2: #f0f1f5;
    --surface-3: #e5e7ee;
    --border: #dfe1e8;
    --text: #1a1c25;
    --text-dim: #5a5e70;
    --accent: #3f4bb8;
    --accent-hover: #343fa0;
    --on-accent: #ffffff;
    --accent-container: #eceefb;
    --on-accent-container: #262f8f;
    /* MCP / "connected" semantic accent (teal) — team-knowledge badges, live indicators. */
    --mcp: #0e9e8e;
    --mcp-container: #d7efec;
    --on-mcp-container: #06433b;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --danger: #ba1a1a;
    --danger-container: #ffdad6;
    --on-danger-container: #410002;
    --success: #1f7a3d;
    --success-container: #b7f0c2;
    --warning: #8a6100;
    --warning-container: #ffdf9e;
    --scrim: rgba(20, 22, 34, .45);
    /* Depth comes mostly from borders; shadow-1 is a hairline lift for cards, shadow-3 is for overlays. */
    --shadow-1: 0 1px 2px rgba(20,22,40,.05);
    --shadow-2: 0 2px 6px rgba(20,22,40,.08), 0 1px 2px rgba(20,22,40,.05);
    --shadow-3: 0 12px 32px rgba(20,22,40,.16), 0 2px 6px rgba(20,22,40,.08);
    --radius: 8px;
    --radius-sm: 6px;
    /* Shared control heights so inputs, selects and buttons line up wherever they sit together. */
    --ctrl-h: 34px;
    --ctrl-h-sm: 28px;
    /* Categorical chart series (validated for CVD separation on --surface); assigned in fixed order. */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --series-other: #9a9eac;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111217;
    --surface: #181a20;
    --surface-1: #1c1e25;
    --surface-2: #22242d;
    --surface-3: #2a2d37;
    --border: #2c2f3a;
    --text: #e4e5ec;
    --text-dim: #a0a3b4;
    --accent: #aab3ff;
    --accent-hover: #bec5ff;
    --on-accent: #1a2170;
    --accent-container: #262b52;
    --on-accent-container: #dfe2ff;
    --mcp: #2cc6b4;
    --mcp-container: #0f322e;
    --on-mcp-container: #84e3d7;
    --danger: #ffb4ab;
    --danger-container: #93000a;
    --on-danger-container: #ffdad6;
    --success: #7ce38f;
    --success-container: #0c5223;
    --warning: #f4c14b;
    --warning-container: #5a4200;
    --scrim: rgba(0, 0, 0, .6);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-other: #6c7080;
    --shadow-1: none;
    --shadow-2: 0 2px 6px rgba(0,0,0,.4);
    --shadow-3: 0 12px 32px rgba(0,0,0,.6), 0 4px 10px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: "Hanken Grotesk", "Segoe UI", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: .9375rem;
    line-height: 1.5;
    transition: background .3s ease, color .3s ease;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.01em; }

::selection { background: var(--accent-container); color: var(--on-accent-container); }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 1.05rem; padding: 4px 6px 14px;
}
/* Rocket mark on a flat accent tile (no gradient, no shadow). */
.logo {
    width: 32px; height: 32px; border-radius: var(--radius-sm); flex: none;
    background: var(--accent); color: var(--on-accent);
    display: inline-grid; place-items: center;
}
.logo svg { width: 18px; height: 18px; }
.brand small { display: block; font-size: .68rem; color: var(--text-dim); font-weight: 500; letter-spacing: .02em; }

/* Scrollable nav region so the menu never clips when the Admin group is expanded on short screens. */
.nav-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; margin: 2px -2px; padding: 0 2px; }
.nav-scroll { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.nav-scroll::-webkit-scrollbar { width: 7px; }
.nav-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.nav-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 7px 10px; border-radius: var(--radius-sm); font-size: .92rem;
    color: var(--text-dim); font-weight: 500; text-decoration: none;
    margin-bottom: 2px; position: relative; overflow: hidden; flex: none;
    transition: background .18s ease, color .18s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-container); color: var(--on-accent-container); font-weight: 600; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); padding: 10px 14px 4px; font-weight: 600; flex: none; }
/* The "Admin" heading doubles as a collapse toggle. */
.nav-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; cursor: pointer; font: inherit; text-align: left; border-radius: var(--radius-sm); }
.nav-toggle:hover { color: var(--text); }
.nav-caret { font-size: .7rem; transition: transform .18s ease; }
.nav-toggle[aria-expanded="false"] .nav-caret { transform: rotate(-90deg); }
/* Admin items sit indented under the "Admin" heading, with a subtle guide line. */
.nav-group { flex: none; margin: 0 4px 0 15px; padding-left: 9px; border-left: 1px solid var(--border); }
.nav-group .nav-link { padding-left: 11px; }
.nav-group.collapsed { display: none; }
.nav-spacer { flex: 1; }

.sidebar-user {
    border-top: 1px solid var(--border); padding-top: 14px; margin-top: 10px;
    font-size: .85rem; color: var(--text-dim);
}
.sidebar-user strong { color: var(--text); display: block; margin-bottom: 4px; }
.sidebar-user .signout-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.sidebar-user-link { display: flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--text-dim); font-size: .82rem; text-decoration: none; }
.sidebar-user-link:hover, .sidebar-user-link.active { color: var(--text); }
.sidebar-user-link .ic { width: 14px; height: 14px; }
.app-version { text-align: right; font-size: .72rem; color: var(--text-dim); margin-top: 10px; letter-spacing: .02em; }

/* Content is fluid: pages use the full window width. Forms keep a readable measure via
   .card.form-card / per-card max-widths, but lists, tables and dashboards stretch. */
.content { flex: 1; min-width: 0; padding: 20px 24px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 1.375rem; margin: 0; font-weight: 700; }

/* ---------- Cards / grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-1);
    transition: border-color .15s ease;
}
a.stat { text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--accent); }
a.stat:hover .label { color: var(--accent); }
.stat .num { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
/* When a stat's value is a label rather than a number, keep it compact so the card height matches. */
.stat .num.text { font-size: 1.2rem; line-height: 1.3; overflow-wrap: anywhere; }
.stat .label { color: var(--text-dim); font-size: .84rem; margin-top: 2px; }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow-1);
}
.card h2 { margin-top: 0; font-size: 1rem; }
/* Form card: the card spans the content column (so its edge lines up with sibling tables),
   while the form inside keeps a readable, fixed measure. Used on pages that pair a form with
   a full-width table (API keys, workspace/folder access, storage). */
.card.form-card > form { max-width: 640px; }
/* Side-by-side cards (settings sections, paired forms): columns while they fit, stacked when they don't. */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.card-grid > .card { margin-bottom: 0; }
.card-grid > form > .card:last-child { margin-bottom: 0; }
/* Inline field rows wrap instead of squeezing inputs on narrow screens. */
.form-row { flex-wrap: wrap; }
.form-row > .form-group { min-width: 180px; }
/* Full-bleed table card: no padding. Tables fit the card width (no horizontal
   scroll on desktop); only narrow screens fall back to horizontal scroll. */
.card.flush { padding: 0; }
/* Below desktop, wide tables scroll inside their card instead of the page. (Not on desktop:
   an overflow container would stop the sticky table headers following the page scroll.) */
@media (max-width: 1100px) { .card.flush { overflow-x: auto; } }
.card-header { padding: 12px 14px; font-weight: 600; font-size: 1rem; border-bottom: 1px solid var(--border); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
/* Fixed layout lets the name column absorb remaining width and truncate long
   names with an ellipsis, so tables never overflow their card. */
.table.table-fixed { table-layout: fixed; }
.table th, .table td { text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
/* The users table carries an extra actions column (fixed-width role select + Save + ⋮); slightly
   tighter horizontal padding keeps it inside its card while everything stays column-aligned. */
.users-table th, .users-table td { padding-left: 12px; padding-right: 12px; }
.table th { color: var(--text-dim); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
/* Sticky headers keep column labels visible while scrolling long tables. */
.table thead th { background: var(--surface-1); position: sticky; top: 0; z-index: 2; }
.sort-ind { font-size: .7rem; opacity: .8; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-1); }
.table .muted { color: var(--text-dim); font-size: .86rem; }
.table th:last-child, .table td.row-actions { text-align: right; }
/* Table cell (not display:flex) so it stretches to the row height and its border aligns with
   the other columns; buttons sit inline, right-aligned, middle-aligned, with even spacing. */
.row-actions { white-space: nowrap; vertical-align: middle; }
.row-actions > * { vertical-align: middle; }
.row-actions > * + * { margin-left: 8px; }
/* Keep a visible <form> (e.g. a Delete button) inline with sibling links/buttons instead of
   dropping to its own line. Hidden menu-forms keep their inline display:none (wins by specificity). */
.row-actions form { display: inline-flex; vertical-align: middle; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--ctrl-h); padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
    background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: .875rem;
    cursor: pointer; text-decoration: none; position: relative;
    font-family: inherit; line-height: 1.2; vertical-align: middle;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.secondary, .btn.tonal { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover, .btn.tonal:hover { background: var(--surface-2); border-color: var(--surface-3); }
.btn.tonal { background: var(--accent-container); color: var(--on-accent-container); border-color: transparent; }
.btn.tonal:hover { background: var(--accent-container); border-color: var(--accent); }
.btn.outlined { background: transparent; color: var(--accent); border-color: var(--outline, var(--border)); box-shadow: none; }
.btn.text { background: transparent; color: var(--accent); box-shadow: none; padding: 0 14px; }
.btn.text:hover { background: var(--surface-2); box-shadow: none; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); box-shadow: none; }
.btn.danger:hover { background: var(--danger); color: var(--on-danger-container, #fff); }
.btn.sm { min-height: var(--ctrl-h-sm); padding: 0 10px; font-size: .8rem; }
.btn.link { background: none; border: none; color: var(--accent); min-height: 0; padding: 6px 8px; box-shadow: none; font-weight: 600; }
.btn.link:hover { box-shadow: none; text-decoration: underline; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* Icon-only button (overflow / theme toggle) */
.icon-btn {
    width: var(--ctrl-h); height: var(--ctrl-h); border-radius: var(--radius-sm); border: none; background: transparent;
    color: var(--text-dim); cursor: pointer; display: inline-grid; place-items: center;
    font-size: 1.05rem; position: relative; transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: var(--ctrl-h-sm); height: var(--ctrl-h-sm); font-size: .95rem; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }

/* ---------- Forms ---------- */
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    min-height: var(--ctrl-h); padding: 6px 10px; border-radius: var(--radius-sm); font-size: .9rem; width: 100%;
    font-family: inherit; vertical-align: middle; transition: border-color .16s ease, box-shadow .16s ease;
}
textarea { min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-container); }
select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
/* Small controls — pair with .btn.sm so inline rows/toolbars line up. */
input.sm, select.sm { min-height: var(--ctrl-h-sm); padding: 3px 8px; font-size: .84rem; }
select.sm { padding-right: 32px; background-position: calc(100% - 14px) center, calc(100% - 9px) center; }
label { display: block; margin-bottom: 5px; font-weight: 500; font-size: .875rem; }
.form-group { margin-bottom: 14px; }
.field-hint { display: block; margin-top: 6px; font-size: .8rem; color: var(--text-dim); line-height: 1.45; }
.field-hint code { font-size: .92em; padding: 1px 5px; }

/* The hidden attribute must always win, even over components that set display (.btn, etc.). */
[hidden] { display: none !important; }
.field-inline input { width: auto; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: .74rem; font-weight: 600; background: var(--surface-2); color: var(--text-dim); white-space: nowrap; }
.badge.share { background: var(--accent-container); color: var(--on-accent-container); }
.badge.admin { background: var(--warning-container); color: var(--warning); }
/* Intent-named badge variants (color reliably maps to meaning). */
.badge.ok { background: var(--success-container); color: var(--success); }
.badge.warn { background: var(--warning-container); color: var(--warning); }
.badge.danger { background: var(--danger-container); color: var(--danger); }

/* ---------- Breadcrumbs / ws tabs ---------- */
.ws-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.ws-tab { padding: 5px 12px; border-radius: var(--radius-sm); color: var(--text-dim); background: var(--surface); border: 1px solid var(--border); font-size: .88rem; font-weight: 500; transition: background .16s ease, color .16s ease; }
.ws-tab:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.ws-tab.active { background: var(--accent-container); color: var(--on-accent-container); border-color: transparent; font-weight: 600; }

.breadcrumbs { display: flex; gap: 6px; align-items: center; color: var(--text-dim); margin-bottom: 12px; font-size: .875rem; flex-wrap: wrap; }
.breadcrumbs a { color: var(--text-dim); }
.breadcrumbs .sep { opacity: .5; }
.breadcrumbs .current { color: var(--text); font-weight: 500; }

/* ---------- Alerts (inline validation) ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; font-size: .9rem; }
.alert.success { background: var(--success-container); border-color: var(--success); color: var(--success); }
.alert.error { background: var(--danger-container); border-color: var(--danger); color: var(--danger); }
.alert.info { background: var(--accent-container); border-color: var(--accent); color: var(--on-accent-container); }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.field-validation-error { color: var(--danger); font-size: .84rem; display: block; margin-top: 5px; }

/* ---------- Auth / centered ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow-2); }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }
.auth-card h1 { font-size: 1.45rem; text-align: center; margin: 6px 0 4px; }
.auth-card .sub { text-align: center; color: var(--text-dim); margin-bottom: 26px; font-size: .92rem; }
.auth-card .auth-foot { text-align: center; margin: 18px 0 0; font-size: .875rem; }
.auth-card .auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .875rem; }

/* ---------- Misc ---------- */
/* Keep this a real table cell (not display:flex) so it stretches to the row height and its
   bottom border lines up with the other columns. Content is laid out inline + middle-aligned. */
.file-name { vertical-align: middle; white-space: nowrap; }
.file-name > * { vertical-align: middle; }
.file-name .ftico { margin-right: 0; }
/* Owner/tag chips line up with the file name (icon 18px + 11px gap), not the icon. */
.file-name .prov-chips { margin-left: 29px; }
.file-name > span[aria-hidden="true"] { margin-right: 8px; }

/* File-type icons — colour-coded by category so types read at a glance. */
.ftico { flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--text-dim); }
.ftico svg { width: 18px; height: 18px; display: block; }
/* Image rows overlay a thumbnail on the icon; if the <img> errors it removes itself and the icon shows. */
.ft-thumb-wrap { position: relative; width: 22px; height: 22px; }
.ft-thumb-wrap svg { width: 20px; height: 20px; }
.ft-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 4px; background: var(--surface-2); }
.ft-folder { color: #d97706; }
.ft-image  { color: #7c3aed; }
.ft-pdf    { color: #dc2626; }
.ft-doc    { color: #2563eb; }
.ft-sheet  { color: #16a34a; }
.ft-slide  { color: #ea580c; }
.ft-archive{ color: #64748b; }
.ft-audio  { color: #db2777; }
.ft-video  { color: #4f46e5; }
.ft-code   { color: #0d9488; }
.ft-text   { color: #6b7280; }
.ft-file   { color: #94a3b8; }
/* Long file names truncate with an ellipsis (full name on hover via title=). */
.file-name > a { display: inline-block; max-width: calc(100% - 34px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--text-dim); padding: 52px 20px; }
.empty .big { font-size: 2.6rem; margin-bottom: 10px; }
.copy-box { display: flex; gap: 8px; margin-top: 6px; }
.copy-box input { font-family: ui-monospace, "Cascadia Code", monospace; font-size: .85rem; }

.dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 16px; text-align: center; color: var(--text-dim); cursor: pointer;
    transition: border-color .16s, background .16s, color .16s; background: var(--surface-1);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-container); color: var(--on-accent-container); }

/* ---------- Dialog / modal ---------- */
.dialog-backdrop {
    position: fixed; inset: 0; background: var(--scrim); z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease;
}
.dialog-backdrop.open { opacity: 1; visibility: visible; }
.dialog {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-3);
    width: 100%; max-width: 420px; padding: 20px 20px 16px; border: 1px solid var(--border);
    transform: translateY(6px); transition: transform .18s ease;
}
.dialog-backdrop.open .dialog { transform: translateY(0); }
.dialog-icon { font-size: 1.6rem; margin-bottom: 6px; }
.dialog-title { font-size: 1.1rem; font-weight: 700; margin: 0 0 6px; }
.dialog-body { color: var(--text-dim); font-size: .9rem; margin-bottom: 16px; }
.dialog-body input { margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Share dialog: people in DocSpace on top, public link below (one panel). */
.dialog.share-dialog { max-width: 520px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain; }
.share-dialog [hidden] { display: none !important; }
.share-dialog .dialog-title { margin-bottom: 12px; overflow-wrap: anywhere; }
.share-dialog .sh-error { margin-bottom: 12px; }
.sh-content { font-size: .9rem; color: var(--text); margin-bottom: 14px; }
.sh-section { min-width: 0; }
.sh-h { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 0 0 8px; }
.sh-muted { color: var(--text-dim); font-size: .85rem; margin: 0 0 10px; }
.sh-divider { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.sh-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sh-add .sh-q { flex: 1 1 200px; width: auto; min-width: 0; }
.sh-add .sh-acc { flex: 0 0 auto; width: auto; }
.sh-add .sh-share { flex: 0 0 auto; }
.sh-matches { list-style: none; margin: 6px 0 0; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-2); max-height: 216px; overflow-y: auto; }
.sh-match { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.sh-match:hover, .sh-match.active { background: var(--surface-2); }
.sh-match.active { box-shadow: inset 2px 0 0 var(--accent); }
.sh-nomatch { padding: 8px; color: var(--text-dim); font-size: .85rem; overflow-wrap: anywhere; }
.sh-list { list-style: none; margin: 10px 0 0; padding: 0; }
.sh-person { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.sh-person:first-child { border-top: 0; }
.sh-empty { color: var(--text-dim); font-size: .85rem; padding: 6px 0; }
.sh-av { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-container); color: var(--on-accent-container); font-size: .7rem; font-weight: 700; letter-spacing: .02em; }
.sh-av.group { background: var(--surface-3); color: var(--text); }
.sh-who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sh-name, .sh-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-name { color: var(--text); font-weight: 500; }
.sh-sub { color: var(--text-dim); font-size: .8rem; }
.sh-person .sh-row-acc { flex: 0 0 auto; width: 118px; }
.sh-person .sh-remove { flex: 0 0 auto; }
.sh-person .sh-remove:hover { color: var(--danger); }
.sh-link-grid { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; margin-bottom: 12px; }
.sh-link-grid .sh-field { flex: 1 1 180px; min-width: 0; }
.sh-field label { font-size: .85rem; }
.sh-check { display: flex; align-items: center; gap: 8px; margin: 0; min-height: var(--ctrl-h); font-size: .85rem; cursor: pointer; }
.sh-check input { margin: 0; width: auto; }
.sh-hint { overflow-wrap: anywhere; }
.sh-hint-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.sh-hint-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.sh-link-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
@media (max-width: 480px) {
    .share-backdrop { padding: 12px; }
    .dialog.share-dialog { padding: 16px 14px 12px; max-height: calc(100dvh - 24px); }
    .sh-add .sh-q { flex-basis: 100%; }
    .sh-add .sh-acc { flex: 1 1 auto; }
    .sh-person .sh-row-acc { width: 104px; }
}

/* ---------- Snackbar ---------- */
.snackbar-container { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 1100; display: flex; flex-direction: column; gap: 10px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.snackbar {
    background: #24262e; color: #f2f2f7; padding: 11px 16px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-3); font-size: .9rem; display: flex; align-items: center; gap: 12px;
    min-width: 260px; max-width: 460px;
    animation: snack-in .3s cubic-bezier(.2,.8,.3,1);
}
.snackbar.leaving { animation: snack-out .25s ease forwards; }
.snackbar .snack-icon { font-size: 1.15rem; }
.snackbar.success { border-left: 4px solid #62d18a; }
.snackbar.error { border-left: 4px solid #ff8a80; }
.snackbar.info { border-left: 4px solid #90caf9; }
@keyframes snack-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes snack-out { to { transform: translateY(20px); opacity: 0; } }

/* ---------- Context menu ---------- */
.context-menu {
    position: fixed; z-index: 900; min-width: 190px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-3);
    padding: 4px; display: none; animation: menu-in .12s ease;
}
.context-menu.open { display: block; }
@keyframes menu-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.menu-item {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    padding: 7px 10px; border: none; background: none; color: var(--text);
    font-size: .875rem; font-family: inherit; cursor: pointer; border-radius: var(--radius-sm); text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-container); }
.menu-item .mi-icon { font-size: 1.05rem; width: 20px; text-align: center; }
.menu-divider { height: 1px; background: var(--border); margin: 5px 8px; }

/* ---------- Loading overlay / progress ---------- */
.loading-overlay {
    position: fixed; inset: 0; z-index: 1200; background: var(--scrim);
    display: none; align-items: center; justify-content: center; flex-direction: column; gap: 18px;
    backdrop-filter: blur(2px);
}
.loading-overlay.open { display: flex; }
.loading-overlay .msg { color: #fff; font-weight: 500; font-size: .95rem; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.spinner { width: 52px; height: 52px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.linear-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1300; background: transparent; overflow: hidden; display: none; }
.linear-progress.open { display: block; }
.linear-progress::before { content: ""; position: absolute; height: 100%; width: 40%; background: var(--accent); animation: indeterminate 1.1s ease-in-out infinite; }
@keyframes indeterminate { 0% { left: -40%; } 100% { left: 100%; } }

/* ---------- Theme toggle segmented ---------- */
.theme-toggle { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.theme-toggle button { border: none; background: transparent; color: var(--text-dim); width: 32px; height: 26px; border-radius: 4px; cursor: pointer; font-size: .95rem; display: grid; place-items: center; transition: background .16s, color .16s; }
.theme-toggle button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-1); }

/* ---------- Keyboard focus visibility (a11y) ---------- */
.icon-btn:focus-visible, .nav-link:focus-visible, .menu-item:focus-visible,
.ws-tab:focus-visible, .clear-btn:focus-visible, .tag-x:focus-visible,
.theme-toggle button:focus-visible, a.stat:focus-visible, .tag-suggest-item:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- Nav badge (unread notifications) ---------- */
.nav-badge {
    margin-left: auto; background: var(--accent); color: var(--on-accent); font-size: .7rem; font-weight: 700;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-flex;
    align-items: center; justify-content: center;
}

/* ---------- Notifications list ---------- */
.notif-list { display: flex; flex-direction: column; }
.notif-item { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-1); }
.notif-item.unread { background: var(--accent-container); }
.notif-item.unread:hover { filter: brightness(.98); }
.notif-item-main { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; color: var(--text); text-decoration: none; flex: 1; min-width: 0; }
.notif-item-main:hover { text-decoration: none; }
.notif-del-form { display: flex; align-items: center; }
.notif-item .notif-del { padding: 0 16px; }
.notif-icon { font-size: 1.1rem; line-height: 1.4; }
.notif-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: .92rem; }
.notif-msg { font-size: .86rem; color: var(--text-dim); }
.notif-time { font-size: .78rem; flex-shrink: 0; white-space: nowrap; }

/* Bell button styled as a nav link */
button.nav-link { border: none; background: transparent; width: 100%; text-align: left; font: inherit; cursor: pointer; }

/* ---------- Notifications flyout (bell popup) ---------- */
.notif-flyout {
    position: fixed; z-index: 1100; width: 340px; max-height: 460px; display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-3); opacity: 0; transform: translateY(6px) scale(.98);
    transition: opacity .16s ease, transform .16s ease; overflow: hidden;
}
.notif-flyout.open { opacity: 1; transform: none; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-flyout .notif-items { overflow-y: auto; flex: 1; }
.notif-fly-item { display: flex; align-items: stretch; border-bottom: 1px solid var(--surface-2); }
.notif-fly-item:last-child { border-bottom: none; }
.notif-fly-item:hover { background: var(--surface-1); }
.notif-fly-item.unread { background: var(--accent-container); }
.notif-fly-main { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; color: var(--text); text-decoration: none; flex: 1; min-width: 0; }
.notif-fly-main:hover { text-decoration: none; }
.notif-head-actions { display: flex; gap: 2px; }
.notif-del { flex: none; border: none; background: transparent; color: var(--text-dim); cursor: pointer; padding: 0 12px; font-size: .9rem; opacity: .5; transition: opacity .12s ease, color .12s ease; }
.notif-fly-item:hover .notif-del { opacity: 1; }
.notif-del:hover { color: var(--danger); }
.notif-empty { padding: 26px 16px; text-align: center; }
.notif-footer { display: block; padding: 11px 14px; text-align: center; font-size: .86rem; font-weight: 600; border-top: 1px solid var(--border); }
.notif-footer:hover { background: var(--surface-1); text-decoration: none; }

/* ---------- Tabs (settings screens) ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 22px; border-bottom: 1px solid var(--border); }
.tabs .tab {
    padding: 10px 18px; border: none; background: transparent; color: var(--text-dim);
    font-size: .92rem; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -1px; transition: color .16s ease, border-color .16s ease;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Currently-connected storage summary */
.conn-summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 16px;
    background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.conn-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--success); flex-shrink: 0; box-shadow: 0 0 0 3px var(--success-container); }
.conn-title { font-weight: 600; font-size: .92rem; }
.conn-detail { font-size: .82rem; margin-top: 2px; }

/* ---------- Sidebar search ---------- */
.sidebar-search { position: relative; margin: 2px 4px 10px; }
.sidebar-search .ss-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: .9rem; opacity: .65; pointer-events: none; }
.sidebar-search input {
    width: 100%; padding: 6px 30px 6px 32px; font-size: .875rem; line-height: 1.2;
    background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.sidebar-search input::placeholder { color: var(--text-dim); }
.sidebar-search input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-container); }

/* ---------- Clearable inputs (search × button) ---------- */
.clearable { position: relative; display: flex; align-items: center; }
.clearable input { width: 100%; padding-right: 36px; }
/* Hide the browser's native search clear so we show only our own. */
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.clear-btn {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    border: none; background: var(--surface-2); color: var(--text-dim);
    width: 22px; height: 22px; border-radius: 999px; cursor: pointer;
    display: grid; place-items: center; font-size: 1.05rem; line-height: 1; padding: 0;
    transition: background .14s, color .14s;
}
.clear-btn:hover { background: var(--surface-3); color: var(--text); }
.sidebar-search .clear-btn { right: 9px; background: transparent; }
.sidebar-search .clear-btn:hover { background: var(--surface-3); }

/* ---------- Tag editor (metadata pills) ---------- */
.tag-box {
    position: relative;
    display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 10px; min-height: 44px;
    cursor: text; transition: border-color .16s ease, box-shadow .16s ease;
}
.tag-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-container); }
.tag-box .tag-input {
    flex: 1 1 120px; min-width: 120px; width: auto;
    border: none; background: transparent; padding: 4px 2px; border-radius: 0;
    font-size: .9rem; color: var(--text);
}
.tag-box .tag-input:focus { outline: none; box-shadow: none; border: none; }

.tag-pill, .tag-pill.static {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent-container); color: var(--on-accent-container);
    border-radius: var(--radius-sm); padding: 3px 5px 3px 9px;
    font-size: .82rem; font-weight: 600; line-height: 1;
}
.tag-pill.static { padding: 4px 9px; }
.tag-pill .tag-x {
    border: none; background: transparent; color: inherit; cursor: pointer;
    width: 18px; height: 18px; border-radius: 999px; padding: 0;
    font-size: 1rem; line-height: 1; display: grid; place-items: center; opacity: .7;
    transition: background .14s, opacity .14s;
}
.tag-pill .tag-x:hover { opacity: 1; background: rgba(0,0,0,.14); }
.tag-readonly { display: flex; flex-wrap: wrap; gap: 7px; }

.tag-suggest {
    position: absolute; left: 0; top: calc(100% + 4px); z-index: 40;
    min-width: 180px; max-width: 100%; max-height: 220px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-2); padding: 4px;
}
.tag-suggest-item {
    display: block; width: 100%; text-align: left; border: none; background: transparent;
    color: var(--text); padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: .88rem;
}
.tag-suggest-item:hover { background: var(--surface-2); }

/* ---------- File list: sorting, selection, bulk bar, pager ---------- */
.th-sort { color: var(--text-dim); font-weight: 600; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--text); text-decoration: none; }
.col-check { width: 34px; text-align: center; }
.col-check input { width: auto; cursor: pointer; }

.bulk-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--accent-container); color: var(--on-accent-container);
    border: 1px solid var(--accent); border-radius: var(--radius-sm);
    padding: 10px 14px; margin-bottom: 16px;
}
/* [hidden] must win over display:flex, or the bar shows with "0 selected". */
.bulk-bar[hidden] { display: none; }
.bulk-bar .bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bulk-count strong { font-size: 1rem; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 2px 8px; flex-wrap: wrap; }
.pager-controls { display: flex; gap: 8px; }

.folder-picker { max-height: 320px; overflow-y: auto; margin: 4px 0 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.fp-item {
    display: block; width: 100%; text-align: left; border: none; background: transparent;
    color: var(--text); padding: 10px 14px; cursor: pointer; font-size: .9rem;
    border-bottom: 1px solid var(--surface-2);
}
.fp-item:last-child { border-bottom: none; }
.fp-item:hover { background: var(--surface-2); }
.fp-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Import object picker */
.scan-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.scan-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--surface-2); font-size: .84rem; cursor: pointer; }
.scan-item:last-child { border-bottom: none; }
.scan-item:hover { background: var(--surface-2); }
.scan-item input { width: auto; flex-shrink: 0; cursor: pointer; }
.scan-key { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Details modal (compact) ---------- */
.details-modal { max-width: 600px; padding: 0; overflow: hidden; display: flex; flex-direction: column; max-height: 86vh; text-align: left; }
.details-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.details-title { font-size: 1.02rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; }
.details-title .details-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.details-body { padding: 18px; overflow-y: auto; }
.details-loading { padding: 16px 2px; }

/* Large file-type icon / image thumbnail at the top of the details modal. */
.dp-filehead { display: flex; justify-content: center; margin: 2px 0 18px; }
.dp-filehead .ftico svg { width: 46px; height: 46px; }
.dp-filehead .ft-thumb-wrap { width: 72px; height: 72px; }
.dp-filehead .ft-thumb-wrap svg { width: 60px; height: 60px; }
.dp-filehead .ft-thumb { border-radius: var(--radius-sm); box-shadow: var(--shadow-1); }

.dp-info { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin-bottom: 4px; }
/* Full-page details (not the modal): spread the facts across the width. */
.details-page .dp-filehead { justify-content: flex-start; }
.details-page .dp-info { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.dp-info > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dp-k { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); font-weight: 600; }
.dp-v { font-size: .9rem; word-break: break-word; }

.dp-group { margin-top: 18px; }
.dp-group-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 700; margin: 0 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.dp-meta { width: 100%; border-collapse: collapse; }
.dp-meta td { padding: 7px 0; vertical-align: middle; border-bottom: 1px solid var(--surface-2); }
.dp-meta tr:last-child td { border-bottom: none; }
.dp-label { width: 150px; color: var(--text-dim); font-size: .86rem; padding-right: 12px !important; }
.dp-value { font-size: .9rem; word-break: break-word; }

/* ---------- Preview lightbox (focused) ---------- */
.preview-modal { max-width: 960px; width: 92vw; height: 88vh; padding: 0; overflow: hidden; display: flex; flex-direction: column; text-align: left; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex: none; }
.preview-title { font-size: 1.02rem; font-weight: 700; margin: 0; min-width: 0; }
.preview-title .preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.preview-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.preview-body { flex: 1; min-height: 0; background: var(--surface-2); display: flex; }
.pv-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.pv-frame { width: 100%; height: 100%; border: 0; background: #fff; border-radius: var(--radius-sm); }
.pv-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-sm); box-shadow: 0 2px 12px rgba(0,0,0,.25); }
.pv-loading { padding: 20px; }
.preview-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--border); background: var(--surface-1); color: var(--text-dim); font-size: .82rem; }
.pv-info { width: 16px; height: 16px; flex: none; color: var(--accent); }

/* ---------- Dashboard: your-workspaces grid ---------- */
.ws-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.ws-section-title { font-weight: 600; font-size: 1rem; }
.ws-filter { width: 240px; max-width: 50%; }
.ws-section .tabs { margin: 12px 18px 0; }
.ws-scroll { max-height: 344px; overflow-y: auto; }
.ws-card.filtered-out { display: none; }
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 16px 18px; }
.ws-card { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-decoration: none; transition: background .15s ease, box-shadow .15s ease, border-color .15s ease; }
.ws-card:hover { background: var(--surface-1); box-shadow: var(--shadow-1); border-color: var(--accent); text-decoration: none; }
.ws-card-ic { font-size: 1.5rem; flex: none; }
.ws-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ws-card-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-card-meta { font-size: .8rem; }

/* ---------- Dashboard charts: shared chrome ---------- */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.chart-title { font-weight: 600; }
.chart-sub { font-weight: 400; font-size: .82rem; margin-left: 4px; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--radius-sm); background: var(--surface-2); }
.seg button { height: calc(var(--ctrl-h-sm) - 4px); padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--text-dim); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart-legend { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .82rem; }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.chart-legend li.is-zero { opacity: .55; }
.lg-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.lg-num { color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Activity by workspace (stacked columns, rendered by dashboard-charts.js) */
.act-card { margin-bottom: 16px; }
.act-body { padding: 10px 14px 10px; }
.act-plot { position: relative; min-height: 190px; }
.act-plot[hidden] { display: none; }
.act-svg { display: block; overflow: visible; }
.act-grid { stroke: var(--surface-3); stroke-width: 1; shape-rendering: crispEdges; }
.act-base { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.act-axis { fill: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.act-hit { fill: transparent; }
.act-col { outline: none; cursor: default; }
.act-col:focus-visible .act-hit { fill: var(--surface-2); }
.act-seg { transition: opacity .12s ease; }
.act-svg.is-hovering .act-col:not(.active) .act-seg { opacity: .4; }
.act-empty { padding: 28px 16px; }
.act-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin-top: 4px; }
.act-note { font-size: .78rem; }
.chart-tip { position: absolute; left: 0; top: 0; z-index: 5; min-width: 150px; max-width: 240px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-2); font-size: .8rem; pointer-events: none; }
.chart-tip[hidden] { display: none; }
.tip-head { font-weight: 600; margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 1px 0; }
.tip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--surface-3); color: var(--text-dim); }
.chart-table summary { cursor: pointer; font-size: .82rem; color: var(--accent); font-weight: 600; }
.chart-table[open] { flex-basis: 100%; }
.chart-table-scroll { max-height: 260px; overflow: auto; margin-top: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.chart-table table { margin: 0; font-size: .82rem; }
.chart-table th, .chart-table td { padding: 5px 10px; white-space: nowrap; }
.chart-table thead th { position: sticky; top: 0; background: var(--surface-1); }
.chart-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-table .strong { font-weight: 600; }

/* Files by type (horizontal bars, single series in the accent colour) */
.hbars { list-style: none; margin: 0; padding: 6px 14px 10px; }
.hbars[hidden] { display: none; }
.hbar { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(40px, 1fr) minmax(5.5ch, auto); align-items: center; column-gap: 10px; padding: 5px 0; font-size: .86rem; border-radius: 4px; outline: none; }
.hbar:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.hbar-label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label .muted { font-weight: 400; font-size: .8rem; }
.hbar-track { height: 12px; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar:hover .hbar-fill, .hbar:focus-visible .hbar-fill { background: var(--accent-hover); }
.hbar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* ---------- Dashboard: storage-by-type chart ---------- */
.storage-chart { display: flex; gap: 30px; align-items: center; padding: 22px 20px; flex-wrap: wrap; }
.donut-wrap { position: relative; width: 132px; height: 132px; flex: none; }
.donut { width: 100%; height: 100%; }
.donut circle[stroke-dasharray] { transition: stroke-dasharray .5s ease; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-total { font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; }
.donut-sub { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.storage-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 260px; }
.storage-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto auto; align-items: center; column-gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--surface-2); font-size: .9rem; }
.storage-legend li:last-child { border-bottom: none; }
.lg-dot { width: 11px; height: 11px; border-radius: 3px; }
.lg-label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-count { font-size: .8rem; }
.lg-size { font-variant-numeric: tabular-nums; font-weight: 600; }
.lg-pct { font-size: .8rem; min-width: 44px; text-align: right; }

/* ---------- Mobile drawer ---------- */
.mobile-bar { display: none; }
.drawer-toggle { display: none; }
.drawer-overlay { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
    .details-modal { max-height: 92vh; }
    .dp-info { grid-template-columns: 1fr; }
    /* On phones, wide non-fixed tables may still exceed the viewport — allow scroll there only. */
    .card.flush { overflow-x: auto; }

    /* Sidebar becomes an off-canvas drawer toggled by the hamburger in the mobile top bar. */
    .shell { flex-direction: column; }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100%; width: 280px; max-width: 86vw; z-index: 900;
        transform: translateX(-100%); transition: transform .24s cubic-bezier(.2,.8,.3,1);
        box-shadow: var(--shadow-3);
    }
    .shell.drawer-open .sidebar { transform: translateX(0); }

    .drawer-overlay {
        position: fixed; inset: 0; background: var(--scrim); z-index: 850;
        opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease;
    }
    .shell.drawer-open .drawer-overlay { opacity: 1; visibility: visible; }

    .mobile-bar {
        display: flex; align-items: center; gap: 6px; position: sticky; top: 0; z-index: 800;
        height: 52px; padding: 0 8px; background: var(--surface); border-bottom: 1px solid var(--border);
    }
    .mobile-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 1rem; }
    .mobile-brand:hover { text-decoration: none; }
    .mobile-brand .logo { width: 28px; height: 28px; }
    .mobile-brand .logo svg { width: 16px; height: 16px; }
    .drawer-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 44px; height: 44px; border-radius: var(--radius-sm); border: 0;
        background: transparent; color: var(--text); font-size: 1.2rem; cursor: pointer;
    }
    .drawer-toggle:hover { background: var(--surface-2); }
    .drawer-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    /* Touch-sized nav rows inside the drawer. */
    .sidebar .nav-link { min-height: 44px; padding-top: 0; padding-bottom: 0; }
    .sidebar-search input { min-height: 44px; font-size: 1rem; }

    .content { padding: 14px 14px 22px; }
    .topbar { margin-bottom: 14px; }
    .topbar h1 { font-size: 1.25rem; }
    .bulk-bar { flex-direction: column; align-items: flex-start; }
}

/* ---------- Inline SVG icons (replace emoji across the chrome) ---------- */
.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.nav-link .ic { width: 19px; height: 19px; }
.ss-icon .ic { width: 16px; height: 16px; }
.theme-toggle button .ic { width: 16px; height: 16px; }
.signout-btn .ic { width: 15px; height: 15px; }
.drawer-toggle .ic { width: 20px; height: 20px; }
code, .mono, kbd { font-family: var(--font-mono); }

/* ---------- MCP / team-knowledge accent helpers ---------- */
.badge-mcp { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--mcp-container); color: var(--on-mcp-container); font-size: .72rem; font-weight: 700; letter-spacing: .02em; }
.badge-mcp .ic { width: 13px; height: 13px; }
.mcp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mcp); box-shadow: 0 0 0 3px var(--mcp-container); display: inline-block; }

/* ---------- Collapsible sidebar (desktop rail for more content room) ---------- */
.nav-collapse-btn { margin-left: auto; width: 30px; height: 30px; border: 0; background: none; color: var(--text-dim); border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.nav-collapse-btn:hover { background: var(--surface-2); color: var(--text); }
:root[data-nav="collapsed"] .nav-collapse-btn .ic { transform: rotate(180deg); }
@media (max-width: 1100px) { .nav-collapse-btn { display: none; } }
/* Icon rail: chosen by the user on desktop (data-nav="collapsed"), automatic on tablets (821–1100px).
   The two rule sets are identical; CSS can't share one selector list across a media query. */
@media (min-width: 1101px) {
    :root[data-nav="collapsed"] .sidebar { width: 60px; padding-left: 8px; padding-right: 8px; }
    :root[data-nav="collapsed"] .brand { justify-content: center; padding-left: 0; padding-right: 0; }
    :root[data-nav="collapsed"] .brand-name,
    :root[data-nav="collapsed"] .sidebar-search,
    :root[data-nav="collapsed"] .nav-toggle,
    :root[data-nav="collapsed"] .theme-toggle,
    :root[data-nav="collapsed"] .sidebar-user strong,
    :root[data-nav="collapsed"] .sidebar-user .meta,
    :root[data-nav="collapsed"] .sidebar-user form,
    :root[data-nav="collapsed"] .sidebar-user-link,
    :root[data-nav="collapsed"] .app-version { display: none; }
    :root[data-nav="collapsed"] .nav-collapse-btn { margin: 0; }
    :root[data-nav="collapsed"] .nav-link { justify-content: center; gap: 0; padding: 0; min-height: 40px; }
    :root[data-nav="collapsed"] .nav-link > span:not(.nav-badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    :root[data-nav="collapsed"] .nav-badge { position: absolute; top: 5px; right: 6px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; }
    :root[data-nav="collapsed"] .nav-group { margin-left: 0; padding-left: 0; border-left: 0; }
}
@media (min-width: 821px) and (max-width: 1100px) {
    .sidebar { width: 60px; padding-left: 8px; padding-right: 8px; }
    .brand { justify-content: center; padding-left: 0; padding-right: 0; }
    .brand-name,
    .sidebar-search,
    .nav-toggle,
    .theme-toggle,
    .sidebar-user strong,
    .sidebar-user .meta,
    .sidebar-user form,
    .sidebar-user-link,
    .app-version { display: none; }
    .nav-link { justify-content: center; gap: 0; padding: 0; min-height: 44px; }
    .nav-link > span:not(.nav-badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .nav-badge { position: absolute; top: 7px; right: 8px; min-width: 8px; width: 8px; height: 8px; padding: 0; font-size: 0; }
    .nav-group { margin-left: 0; padding-left: 0; border-left: 0; }
}

/* icon alignment in reskinned views */
.ws-tab { display: inline-flex; align-items: center; gap: 7px; }
.big .ic { width: 46px; height: 46px; }
.hero-ic .ic { width: 48px; height: 48px; }
.menu-item .mi-icon .ic { width: 16px; height: 16px; }
.tabs .tab { display: inline-flex; align-items: center; gap: 6px; }
.ws-card-ic .ic { width: 24px; height: 24px; }
.badge .ic { width: 13px; height: 13px; }
.file-name .ic { width: 19px; height: 19px; }
h1 > .ic, h2 > .ic, h3 > .ic { vertical-align: -0.12em; margin-right: 6px; }
.notif-icon .ic { width: 20px; height: 20px; }
.notif-del .ic { width: 15px; height: 15px; }

/* team-knowledge banner + provenance (author/tag) chips */
.tk-banner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; box-shadow: var(--shadow-1); }
.tk-banner strong { font-size: 1rem; }
.prov-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.prov-chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: .72rem; color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.prov-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }
.prov-av { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: .56rem; font-weight: 700; }
.prov-av.mcp { background: var(--mcp); color: #fff; }
.audit-actor { display: inline-flex; align-items: center; gap: 7px; }
.audit-actor .prov-av { width: 20px; height: 20px; font-size: .64rem; flex: 0 0 auto; }

/* Files browser: list + docked preview rail (board layout) */
.files-layout { display: flex; gap: 20px; align-items: flex-start; }
.files-main { flex: 1 1 auto; min-width: 0; }
.file-rail { flex: 0 0 336px; position: sticky; top: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); max-height: calc(100vh - 40px); overflow: auto; }
.file-rail .rail-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.file-rail .rail-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-rail .rail-body { padding: 14px 16px; }
.rail-empty { text-align: center; padding: 34px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rail-empty .ic { width: 30px; height: 30px; opacity: .55; }
@media (max-width: 1100px) { .file-rail { display: none; } }

/* ---------- Dashboard: inbox-review card + recent-activity feed ---------- */
.stat.warn .num, .stat.warn .label { color: var(--warning); }
.card-header.warn { display: flex; align-items: center; gap: 10px; background: var(--warning-container); color: var(--warning); border-bottom-color: transparent; }
.card-header.warn .ic { width: 18px; height: 18px; }

/* ---------- Governance tab (team-knowledge inbox curation) ---------- */
.gov-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.gov-head h1 { margin: 0; }
.gov-row { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.gov-row:last-child { border-bottom: 0; }
.gov-row-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.gov-main { flex: 1 1 300px; min-width: 0; }
.gov-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.gov-title b { font-weight: 600; }
.gov-prov { margin-top: 6px; font-size: .84rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gov-prov code { font-size: .78rem; }
.gov-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mcp); display: inline-block; flex: none; }
.gov-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gov-actions form { margin: 0; }
.gov-validate { display: flex; align-items: center; gap: 8px; }
.gov-validate select { min-height: 38px; max-width: 220px; }
.gov-rc { margin-top: 10px; }
.gov-rc > summary { cursor: pointer; width: fit-content; color: var(--accent); font-weight: 600; font-size: .86rem; list-style: none; padding: 2px 0; }
.gov-rc > summary::-webkit-details-marker { display: none; }
.gov-rc > summary::before { content: "✎ "; }
.gov-rc[open] > summary { margin-bottom: 9px; }
.gov-rc-form { display: flex; flex-direction: column; gap: 9px; max-width: 640px; }
.gov-rc-form textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 74px; font: inherit; }
.gov-rc-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gov-empty { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gov-empty h2 { margin: 0; font-size: 1.15rem; }
.gov-empty p { max-width: 48ch; margin: 0; }
.gov-empty-mark { width: 64px; height: 64px; border-radius: 12px; background: var(--mcp-container); color: var(--on-mcp-container); display: grid; place-items: center; }
.gov-empty-mark .ic { width: 30px; height: 30px; }
.code-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; font-family: var(--font-mono); font-size: .8rem; line-height: 1.55; overflow-x: auto; margin: 0; white-space: pre; }

/* Shared table pager (Audit, Users) */
.pager { display: flex; align-items: center; gap: 7px; margin: 14px 2px; font-size: .88rem; }
.pager .pg { min-width: 30px; height: 30px; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 600; }
.pager a.pg:hover { border-color: var(--accent); }
.pager .pg.cur { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pager .pg.off { opacity: .4; }

/* Storage: the add/edit-connection form hides behind a disclosure until needed. */
.conn-details > .conn-summary { cursor: pointer; list-style: none; background: none; border: 0; padding: 0; margin: 0; }
/* Collapsed: just the "+ Add connection" button, no card frame around it. */
.conn-details:not([open]) { background: none; border: 0; box-shadow: none; padding: 0; }
.conn-details[open] > .conn-summary { margin-bottom: 14px; }
.conn-details > .conn-summary::-webkit-details-marker { display: none; }
.conn-details[open] > .conn-summary .btn { background: var(--surface-2); color: var(--text-dim); }

/* Authentication settings: form + reference rail side by side, one screen instead of two. */
/* Full width: settings form 2/3, info rail 1/3; one column on narrower screens. */
.auth-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .auth-cols { grid-template-columns: 1fr; } }
.auth-main { min-width: 0; margin: 0; }
.auth-rail { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
/* Callback URLs read as label-over-value so long addresses don't break mid-word in a narrow cell. */
.auth-rail .dp-meta tr { display: flex; flex-direction: column; gap: 3px; padding: 6px 0; }
.auth-rail .dp-meta td { padding: 0; border: 0; }
.auth-rail .dp-meta code { word-break: break-all; font-size: .76rem; }
.auth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
@media (max-width: 760px) { .auth-grid { grid-template-columns: 1fr; } }

/* Administration hub + admin sub-rail */
.adm-sec { margin-bottom: 22px; }
.adm-sec-head { display: flex; align-items: center; gap: 9px; font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px; }
.adm-role { padding: 1px 7px; border-radius: 4px; background: var(--surface-2); font-size: .66rem; font-weight: 700; letter-spacing: 0; text-transform: none; }
/* Fixed column count so every section spans the full width with aligned cards. */
.adm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .adm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .adm-grid { grid-template-columns: 1fr; } }
.adm-card { display: flex; gap: 11px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; color: var(--text); text-decoration: none; transition: border-color .14s, box-shadow .14s; }
.adm-card:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.adm-ic { width: 34px; height: 34px; border-radius: var(--radius); background: var(--accent-container); color: var(--on-accent-container); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.adm-ic .ic { width: 17px; height: 17px; }
.adm-body { min-width: 0; }
.adm-body b { font-size: .92rem; font-weight: 700; }
.adm-sub { display: block; font-size: .8rem; color: var(--text-dim); margin-top: 2px; }
.adm-chip { display: inline-block; margin-top: 7px; padding: 1px 7px; border-radius: 4px; background: var(--surface-2); color: var(--text-dim); font-size: .7rem; font-weight: 700; }
.adm-chip.mcp { background: var(--mcp-container); color: var(--on-mcp-container); }
.admin-rail { width: 200px; flex: none; background: var(--surface-1); border-right: 1px solid var(--border); padding: 22px 12px; box-sizing: border-box; font-size: .88rem; font-weight: 600; color: var(--text-dim); }
.admin-rail a { display: block; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-dim); text-decoration: none; }
.admin-rail a:hover { color: var(--text); background: var(--surface-2); }
.admin-rail a.active { background: var(--accent-container); color: var(--on-accent-container); }
.admin-rail .admin-rail-back { display: flex; align-items: center; gap: 7px; font-size: .8rem; margin-bottom: 14px; padding: 4px 8px; }
.admin-rail-sec { font-size: .64rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-dim); padding: 12px 10px 5px; }
/* Tablet: narrower sub-rail beside the icon rail. Phone: the sub-rail becomes a wrapping bar
   under the top bar (the shell is a column there, so 100% width stacks cleanly). */
@media (min-width: 821px) and (max-width: 1100px) {
    .admin-rail { width: 172px; padding: 18px 8px; }
}
@media (max-width: 820px) {
    /* One swipeable row of section links; group labels drop out to keep it a single line. */
    .admin-rail { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: nowrap; gap: 4px; align-items: center; padding: 6px 10px; overflow-x: auto; scrollbar-width: none; }
    .admin-rail::-webkit-scrollbar { display: none; }
    .admin-rail a { flex: none; white-space: nowrap; min-height: 40px; display: inline-flex; align-items: center; }
    .admin-rail .admin-rail-back { margin: 0 6px 0 0; padding: 4px 8px; }
    .admin-rail-sec { display: none; }
}
.gov-seed { text-align: left; width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 10px; margin: 6px 0 2px; }
.gov-seed textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: .9rem; resize: vertical; }
.gov-seed-opt { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: flex-start; font-size: .88rem; cursor: pointer; }
.gov-seed-opt .muted { flex-basis: 100%; margin-left: 24px; font-size: .8rem; }
.gov-seed-opt input { margin-top: 3px; accent-color: var(--accent); }
.gov-seed .btn { align-self: flex-start; }
.gov-cols { display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap; }
.gov-col-main { flex: 1 1 560px; min-width: 0; }
.gov-rail { flex: 1 1 300px; max-width: 360px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 920px) { .gov-rail { max-width: none; } }

/* Governance board (kanban) view */
.gov-view { margin-left: auto; align-self: center; display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); margin-bottom: 6px; }
.gov-view a { padding: 6px 14px; font-size: .86rem; font-weight: 600; color: var(--text-dim); text-decoration: none; }
.gov-view a.active { color: var(--accent); background: var(--accent-container); }
.gb-board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 10px; }
.gb-col { flex: 0 0 260px; display: flex; flex-direction: column; gap: 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 11px; }
.gb-col.inbox { background: var(--warning-container); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.gb-col.rej { background: var(--surface-1); }
.gb-col-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .88rem; padding: 0 3px; }
.gb-col.inbox .gb-col-head { color: var(--warning); }
.gb-col-head .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.gb-col-head .dot.warn { background: var(--warning); }
.gb-col-head .dot.ok { background: var(--success); }
.gb-col-head .dot.danger { background: var(--danger); }
.gb-count { margin-left: auto; font-size: .82rem; color: var(--text-dim); font-weight: 700; }
.gb-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.gb-card[draggable="true"] { cursor: grab; }
.gb-card.dragging { opacity: .45; }
.gb-card-title { display: flex; align-items: center; gap: 7px; font-size: .9rem; flex-wrap: wrap; overflow-wrap: anywhere; }
.gb-card-sub { font-size: .78rem; margin-top: 4px; }
.gb-card-link { font-size: .8rem; font-weight: 600; color: var(--accent); display: inline-block; margin-top: 7px; }
button.gb-card-link { background: none; border: 0; padding: 0; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.gb-card.rej .gb-card-title b { text-decoration: line-through; color: var(--text-dim); font-weight: 600; }
.gb-drop-hint { display: none; border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 11px; text-align: center; color: var(--text-dim); font-size: .8rem; font-weight: 600; }
.gb-col.droppable { outline: 1.5px dashed var(--accent); outline-offset: -1.5px; }
.gb-col.droppable .gb-drop-hint { display: block; }
.gb-col.over { background: var(--accent-container); }
.gb-col.over .gb-drop-hint { border-color: var(--accent); color: var(--accent); }

/* Governance review drawer */
.gov-drawer-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 60; }
.gov-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); background: var(--surface); box-shadow: var(--shadow-3); z-index: 61; display: flex; flex-direction: column; }
.gov-drawer-head { display: flex; align-items: center; gap: 9px; padding: 13px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.gov-drawer-title { flex: 1; }
.gov-drawer-pos { font-weight: 400; font-size: .84rem; }
.gov-drawer-head .icon-btn:disabled { opacity: .4; cursor: default; }
.gov-drawer-body { flex: 1; overflow: auto; padding: 16px 18px; }
.gov-drawer-file { display: flex; align-items: center; gap: 9px; font-size: 1.02rem; margin-bottom: 12px; overflow-wrap: anywhere; }
.gov-drawer-prov { display: flex; gap: 10px; align-items: flex-start; background: var(--mcp-container); color: var(--on-mcp-container); border-radius: var(--radius); padding: 11px 13px; margin-bottom: 14px; font-size: .86rem; }
.gov-drawer-prov .fav { width: 28px; height: 28px; font-size: .64rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; background: var(--accent); color: var(--on-accent); }
.gov-drawer-prov .fav.mcp { background: var(--mcp); color: #fff; }
.gov-drawer-prov .gd-prov-sub { font-size: .8rem; color: inherit; opacity: .8; }
.gov-drawer .gd-content { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.gov-drawer-foot { border-top: 1px solid var(--border); padding: 12px 18px; background: var(--surface-1); display: flex; flex-direction: column; gap: 10px; }
.gov-drawer-foot .gd-validate { display: flex; align-items: center; gap: 9px; }
.gov-drawer-foot .gd-validate select { flex: 1; min-width: 0; }
.gov-drawer-foot-row { display: flex; align-items: center; gap: 10px; }
body.gov-drawer-open { overflow: hidden; }

/* Governance queue toolbar (filter / sort / bulk-select) */
.gq-filter { width: auto; font: inherit; font-size: .82rem; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.gq-bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: var(--accent-container); color: var(--on-accent-container); border-bottom: 1px solid var(--border); font-size: .88rem; }
.gq-bulkbar .gq-dest { width: auto; max-width: 220px; font: inherit; font-size: .84rem; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.gq-rc-row { flex-basis: 100%; display: flex; gap: 9px; align-items: flex-start; }
.gq-rc-row textarea { flex: 1; font: inherit; font-size: .86rem; resize: vertical; }
.gov-row-top .gq-sel { width: 16px; height: 16px; margin: 4px 2px 0 0; flex: none; accent-color: var(--accent); }
/* Phone width: stats as a 2x2 grid (not one long column), per the mobile artboard. */
@media (max-width: 520px) { .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.card-header.warn .hdr-action { margin-left: auto; }
.inbox-list { padding: 4px 18px 10px; }
.inbox-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-top: 1px solid var(--border); }
.inbox-row:first-child { border-top: none; }
.inbox-row .ib-ic { display: inline-flex; flex: 0 0 auto; color: var(--text-dim); }
.inbox-row .ib-ic .ic { width: 16px; height: 16px; }
.inbox-row .ib-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-row .ib-ws { font-size: .72rem; color: var(--text-dim); font-weight: 400; }
/* Phone: name gets its own line; provenance chip and action sit underneath. */
@media (max-width: 560px) {
    .inbox-row { flex-wrap: wrap; row-gap: 6px; }
    .inbox-row .ib-name { flex-basis: calc(100% - 30px); }
    .inbox-row .prov-chip { margin-left: 27px; }
    .inbox-row .btn { margin-left: auto; }
}
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 11px; padding: 11px 0; border-top: 1px solid var(--border); align-items: flex-start; font-size: .88rem; }
.feed li:first-child { border-top: none; }
.feed .fav { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .58rem; font-weight: 700; background: var(--accent); color: var(--on-accent); margin-top: 1px; }
.feed .fav.mcp { background: var(--mcp); color: #fff; }
.feed .fav .ic { width: 13px; height: 13px; }
.feed .fw { font-weight: 600; }
.feed .when { color: var(--text-dim); }
/* Dashboard two-column region: feed-style content left, spaces/storage right. */
.dash-cols { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 16px; }
.dash-main { flex: 3 1 440px; min-width: 0; }
.dash-side { flex: 1 1 320px; min-width: 0; max-width: 520px; }
@media (max-width: 1000px) { .dash-side { max-width: none; } }
.dash-side > * { margin-bottom: 16px; }
.dash-side > *:last-child { margin-bottom: 0; }

/* ---------- Search results (card list) ---------- */
.search-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 6px 2px 14px; }
.search-head h2 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.search-results { padding: 0; }
.res { display: block; padding: 11px 16px; border-top: 1px solid var(--border); text-decoration: none; color: inherit; }
.res:first-child { border-top: none; }
.res:hover { background: var(--surface-1); }
.res-name { display: flex; align-items: center; gap: 9px; }
.res-name .res-ic { display: inline-flex; color: var(--accent); flex: 0 0 auto; }
.res-name .res-ic .ic { width: 17px; height: 17px; }
.res-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 4px 0 0 26px; }
.res-path { font-size: .8rem; color: var(--text-dim); }
.res-snippet { margin: 6px 0 0 26px; font-size: .86rem; color: var(--text-dim); line-height: 1.5; }
.res-snippet mark { background: var(--accent-container); color: var(--on-accent-container); padding: 0 2px; border-radius: 3px; }
.res .prov-chips { margin: 9px 0 0 26px; }

/* ---------- Rendered Markdown (editor preview + preview lightbox) ---------- */
.md-preview :first-child { margin-top: 0; }
.md-preview pre { background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-sm); overflow: auto; }
.md-preview code { font-family: var(--font-mono); font-size: .88em; }
.md-preview table { border-collapse: collapse; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 5px 10px; }
.md-preview img { max-width: 100%; }
.pv-md { height: 100%; overflow: auto; padding: 22px 26px; max-width: 880px; margin: 0 auto; }
.pv-src { height: 100%; overflow: auto; margin: 0; padding: 22px 26px; white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: .84rem; line-height: 1.55; color: var(--text); background: var(--surface); }
.pv-md .pv-loading { padding: 24px; }
.pv-toggle { display: inline-flex; }
.pv-toggle .btn { border-radius: 0; }
.pv-toggle .btn:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.pv-toggle .btn:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

/* ---------- MCP hero banner (API keys) ---------- */
.mcp-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--mcp-container); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; }
.mcp-banner-ic { display: inline-flex; flex: 0 0 auto; color: var(--mcp); }
.mcp-banner-ic .ic { width: 22px; height: 22px; }
.mcp-banner-text { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; color: var(--on-mcp-container); }
.mcp-banner-text strong { font-size: .98rem; }
.mcp-banner-text span { font-size: .84rem; }
.mcp-banner-text code { background: var(--surface); border: 1px solid var(--border); color: inherit; padding: 1px 6px; border-radius: 5px; font-size: .82rem; }

/* ---------- Feature card + toggle switch (Features settings) ---------- */
.feature-head { display: flex; align-items: flex-start; gap: 16px; }
.feature-ic { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius); background: var(--mcp-container); color: var(--mcp); flex: 0 0 auto; }
.feature-ic .ic { width: 20px; height: 20px; }
.feature-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.feature-title h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.feature-sep { height: 1px; background: var(--border); margin: 18px 0; }
.feature-adds { margin: 0; padding-left: 20px; font-size: .86rem; line-height: 1.7; columns: 2; column-gap: 40px; }
@media (max-width: 620px) { .feature-adds { columns: 1; } }
.feature-warn { display: flex; align-items: flex-start; gap: 7px; margin: 14px 0 18px; font-size: .8rem; color: var(--warning); }
.feature-warn .ic { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; }
.feature-warn code { background: var(--surface-2); padding: 0 4px; border-radius: 4px; }

/* Toggle switch — visually-hidden checkbox drives a pill track. */
.switch { position: relative; display: inline-flex; flex: 0 0 auto; width: 44px; height: 24px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { width: 44px; height: 24px; border-radius: 999px; background: var(--surface-3); transition: background .15s ease; position: relative; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform .15s ease; }
.switch input:checked + .track { background: var(--mcp); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A label-left / switch-right toggle row. */
.toggle-row { display: flex; align-items: center; gap: 14px; }
.toggle-row .tr-text { flex: 1; min-width: 0; }
.toggle-row .tr-text b { font-weight: 600; font-size: .92rem; display: block; }
.toggle-row .tr-text .field-hint { display: block; margin-top: 2px; }

/* Generic coloured avatar (groups, members) — background set inline per name. */
.av { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex: 0 0 auto; width: 28px; height: 28px; font-size: .72rem; letter-spacing: .01em; }
.av.lg { width: 34px; height: 34px; font-size: .8rem; }
.member-name { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Signing ---------- (theme tokens only, so light + dark both follow the palette) */
.link-tabs a.tab { text-decoration: none; }
.link-tabs a.tab .badge { margin-left: 4px; padding: 1px 8px; }
.sign-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .sign-grid { grid-template-columns: 1fr; } }
.sign-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.sign-col > .card, .sign-grid > .card { margin: 0; }
.sign-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sign-head h2, .sd-h2 { margin: 0; font-size: 1.05rem; }
.sd-h2 { margin-bottom: 12px; }
.sign-hash { font-size: .76rem; word-break: break-all; color: var(--text-dim); }
.sign-next { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); background: var(--accent-container); color: var(--on-accent-container); font-size: .88rem; }
.sign-next .ic { flex: 0 0 auto; margin-top: 2px; }

.sd-top { align-items: flex-start; }
.sd-title h1 { display: flex; align-items: center; gap: 10px; word-break: break-word; }
.sd-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; font-size: .86rem; }
.sd-small { font-size: .84rem; }
.sd-empty { margin: 0; }
.sd-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.sd-banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; margin-bottom: 20px; border-radius: var(--radius); background: var(--accent-container); color: var(--on-accent-container); font-size: .9rem; }
.sd-banner > div { flex: 1; }
.sd-banner .ic { margin-top: 2px; flex: 0 0 auto; }
.sd-banner-error { margin-top: 6px; color: var(--danger); }
.sd-banner form { margin: 0; }
.sd-result { display: flex; gap: 16px; align-items: flex-start; border-left: 4px solid var(--success); }
.sd-result-ic { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--success-container); color: var(--success); flex: 0 0 auto; }
.sd-result-main { min-width: 0; }
.sd-result-main h2 { margin: 0 0 6px; font-size: 1.05rem; }
.sd-result-main p { margin: 0; font-size: .9rem; }
.sd-result .sd-actions { margin-top: 14px; }
.btn.danger-text { color: var(--danger); }

.sign-people { list-style: none; margin: 0; padding: 0; }
.sign-people li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.sign-people li:first-child { border-top: none; padding-top: 2px; }
.sign-people .sp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sign-people .sp-main span { font-size: .8rem; }
.sign-people .sp-main span:empty { display: none; }
.sign-people .sp-order { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--text-dim); font-size: .76rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sign-people .sp-reason { font-style: italic; color: var(--text); }

.sd-activity { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.sd-activity .sign-timeline { overflow-y: auto; padding-right: 4px; }
@media (max-width: 900px) { .sd-activity { position: static; max-height: none; } }
/* Timeline: dot + connector drawn inside each item, so a scrolling container never clips them. */
.sign-timeline { list-style: none; margin: 0; padding: 0 0 0 2px; }
.sign-timeline li { position: relative; padding: 0 0 14px 24px; }
.sign-timeline li:last-child { padding-bottom: 2px; }
.sign-timeline li::before { content: ""; position: absolute; left: 0; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--text-dim); }
.sign-timeline li::after { content: ""; position: absolute; left: 4px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.sign-timeline li:last-child::after { display: none; }
.sign-timeline li.good::before { background: var(--success); }
.sign-timeline li.warn::before { background: var(--warning); }
.sign-timeline li.broken::before { background: var(--danger); }
.sign-timeline .st-row { display: flex; justify-content: space-between; gap: 8px; font-size: .88rem; }
.sign-timeline .st-row span { white-space: nowrap; font-size: .8rem; }
.sign-timeline .st-meta { font-size: .78rem; margin-top: 2px; word-break: break-word; }
/* Signing field editor: wide page column on the left, a sticky step panel on the right. Field
   colours come from --fc (per signer); everything else uses theme tokens so light + dark both work. */
.sed-topbar { align-items: flex-start; margin-bottom: 18px; }
.sed-topbar h1 { display: flex; align-items: center; gap: 10px; }
.sed-sub { margin: 6px 0 0; font-size: .9rem; }
.sed { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.sed-pages { display: flex; flex-direction: column; align-items: center; gap: 20px; min-width: 0; padding: 20px; border-radius: var(--radius); background: var(--surface-1); border: 1px solid var(--border); }
.sed-pages > .sed-page { max-width: 880px; }
.sed-loading { padding: 80px 0; text-align: center; }
.sed-page { position: relative; width: 100%; background: #fff; border-radius: 4px; box-shadow: var(--shadow-2); overflow: hidden; }
.sed-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sed-overlay { position: absolute; inset: 0; }
.sed-pages.placing .sed-overlay { cursor: crosshair; }
.sed-page-no { position: absolute; right: 8px; bottom: 6px; font-size: .7rem; color: #565a6e; background: rgba(255,255,255,.9); padding: 1px 6px; border-radius: 4px; pointer-events: none; }
.sed-field { position: absolute; box-sizing: border-box; border: 2px solid var(--fc); background: color-mix(in srgb, var(--fc) 14%, transparent); border-radius: 4px; cursor: move; display: flex; flex-direction: column; justify-content: center; padding: 0 6px; overflow: hidden; touch-action: none; user-select: none; color: #1b1d2a; }
.sed-field.t-checkbox { padding: 0; border-radius: 3px; }
.sed-field:focus-visible, .sed-field.selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc) 35%, transparent); outline: none; }
.sed-field-label { font-size: .72rem; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sed-field-who { font-size: .64rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .8; }
.sed-field-resize { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--fc) 50%); }

/* Sized to fit below the page header on load, so Save/Send are always visible. */
.sed-side { position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 124px); padding: 0; overflow: hidden; }
.sed-scroll { overflow-y: auto; padding: 20px 20px 8px; display: flex; flex-direction: column; gap: 22px; }
.sed-sec { display: flex; flex-direction: column; gap: 10px; }
.sed-sec + .sed-sec { padding-top: 20px; border-top: 1px solid var(--border); }
.sed-step { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1rem; }
.sed-step > span:first-child { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-container); color: var(--on-accent-container); font-size: .74rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sed-optional { font-weight: 500; font-size: .8rem; }
.sed-label { display: block; font-weight: 600; font-size: .82rem; line-height: 1.3; margin: 2px 0 -3px; }
.sed-hint { font-size: .8rem; margin: 0; }
.sed-sec select, .sed-sec textarea, .sed-sec input:not([type=checkbox]) { width: 100%; font: inherit; font-size: .9rem; }

.sed-people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sed-people:empty { display: none; }
.sed-person { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px 10px; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--fc); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); }
.sed-person.active { background: color-mix(in srgb, var(--fc) 9%, var(--surface)); border-color: var(--fc); }
.sed-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--fc); color: #fff; font-size: .74rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; margin-top: 6px; }
.sed-person-inputs { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sed-person-inputs input { width: 100%; font-size: .88rem; padding: 7px 10px; }
.sed-person-meta { grid-column: 2; display: flex; align-items: center; gap: 4px; min-height: 28px; }
.sed-count { margin-right: auto; font-size: .76rem; color: var(--warning); }
.sed-count.ok { color: var(--text-dim); }
.sed-add { width: 100%; padding: 10px; border: 1.5px dashed var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--accent); font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; }
.sed-add:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.sed-seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; gap: 3px; border-radius: var(--radius); background: var(--surface-2); }
.sed-seg button { padding: 7px 8px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-dim); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.sed-seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.sed-for { margin: -2px 0 0; font-size: .86rem; color: var(--text-dim); }
.sed-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); }
.sed-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--fc, var(--text-dim)); }
.sed-palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sed-tool { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; font-size: .86rem; font-weight: 500; cursor: pointer; text-align: left; }
.sed-tool:hover:not(:disabled) { border-color: var(--accent); }
.sed-tool:disabled { opacity: .5; cursor: not-allowed; }
.sed-tool.active { background: var(--accent-container); color: var(--on-accent-container); border-color: var(--accent); }
.sed-ini { font-size: .64rem; font-weight: 800; border: 1.5px solid currentColor; border-radius: 3px; padding: 0 2px; line-height: 1.3; }
.sed-box { width: 13px; height: 13px; border: 1.5px solid currentColor; border-radius: 3px; flex: 0 0 auto; }

.sed-inspect { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); border-left: 4px solid var(--fc, var(--accent)); background: var(--surface-1); }
.sed-inspect-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sed-inspect-head b { font-size: .88rem; }
.sed-required { margin: 0; gap: 10px; font-size: .86rem; }

.sed-foot { border-top: 1px solid var(--border); padding: 12px 20px 16px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.sed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sed-status { font-size: .8rem; }
.sed-foot .sed-actions .btn { white-space: nowrap; }
.sed-foot .sed-actions .btn:first-of-type { margin-left: auto; }
.sed-errors { margin: 0; padding: 10px 12px 10px 28px; border-radius: var(--radius-sm); background: var(--danger-container); color: var(--danger); font-size: .84rem; }

@media (max-width: 1100px) {
    .sed { grid-template-columns: 1fr; }
    .sed-side { position: static; max-height: none; order: -1; }
    .sed-pages { padding: 10px; }
}

/* Public signer page (/sign/{token}). Reuses the editor's page column (.sed-pages/.sed-page). */
.sgn-body { background: var(--bg); min-height: 100vh; margin: 0; }
.sgn-top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.sgn-top .logo { width: 28px; height: 28px; }
.sgn-top .logo svg { width: 16px; height: 16px; }
.sgn-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sgn-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgn-title span { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgn { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; padding: 24px; max-width: 1400px; margin: 0 auto; }
.sgn-side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 18px; padding: 20px; max-height: calc(100vh - 100px); overflow-y: auto; }
.sgn-note { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-1); border: 1px solid var(--border); font-size: .86rem; }
.sgn-note span { font-size: .76rem; }
.sgn-note p { margin: 0; white-space: pre-line; }
.sgn-progress { display: flex; flex-direction: column; gap: 10px; }
.sgn-progress-head { font-size: .95rem; }
.sgn-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.sgn-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .25s ease; }
.sgn-adopts { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.sgn-adopt { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sgn-adopt-main { min-width: 0; }
.sgn-adopt-main b { font-size: .88rem; }
.sgn-preview { margin-top: 4px; min-height: 30px; display: flex; align-items: center; font-size: .8rem; }
.sgn-preview img { max-height: 38px; max-width: 200px; background: #fff; border-radius: 4px; padding: 2px 6px; border: 1px solid var(--border); }
.sgn-consent { display: flex; gap: 10px; align-items: flex-start; padding-top: 16px; border-top: 1px solid var(--border); font-size: .84rem; line-height: 1.45; cursor: pointer; }
.sgn-consent input { margin-top: 3px; flex: 0 0 auto; width: 16px; height: 16px; }
.sgn-finish { width: 100%; justify-content: center; }
.sgn-decline summary { cursor: pointer; font-size: .82rem; color: var(--text-dim); }
.sgn-decline form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; align-items: flex-start; }
.sgn-decline textarea { width: 100%; font: inherit; font-size: .88rem; }
.sgn-decline .sed-label { margin: 0; }

.sgn-field { position: absolute; box-sizing: border-box; border: 2px dashed var(--accent); border-radius: 4px; background: color-mix(in srgb, var(--accent) 10%, rgba(255,255,255,.6)); color: #1b2a6b; font: 600 .78rem/1.1 inherit; display: flex; align-items: center; justify-content: center; padding: 0 4px; cursor: pointer; overflow: hidden; }
.sgn-field.sig:not(.done), .sgn-field.required:not(.done) { animation: sgn-pulse 1.8s ease-in-out infinite; }
.sgn-field.done { border-style: solid; border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: transparent; animation: none; }
.sgn-field.date { cursor: default; color: #1b1d2a; font-weight: 500; justify-content: flex-start; padding-left: 6px; }
.sgn-field.text { padding: 0; cursor: text; }
.sgn-field.text input { width: 100%; height: 100%; border: none; background: transparent; padding: 0 6px; color: #1b1d2a; font-family: inherit; outline: none; }
.sgn-field.text input::placeholder { color: #6a6f8a; }
.sgn-field.text:focus-within { border-style: solid; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.sgn-field.check { padding: 0; }
.sgn-field.check.done::after { content: ""; width: 45%; height: 70%; border: solid #1b2a6b; border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-8%, -8%); }
.sgn-field img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sgn-field.pulse { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 40%, transparent); }
@keyframes sgn-pulse { 50% { background: color-mix(in srgb, var(--accent) 24%, rgba(255,255,255,.6)); } }
@media (prefers-reduced-motion: reduce) { .sgn-field { animation: none !important; } }

.sgn-modal { position: fixed; inset: 0; background: rgba(10, 12, 24, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.sgn-modal[hidden] { display: none; }
.sgn-modal-card { width: min(640px, 100%); display: flex; flex-direction: column; gap: 14px; }
.sgn-modal-card h2 { margin: 0; font-size: 1.15rem; }
.sgn-tabs { display: inline-grid; grid-auto-flow: column; padding: 3px; gap: 3px; border-radius: var(--radius); background: var(--surface-2); justify-self: start; width: max-content; }
.sgn-tabs button { padding: 6px 18px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-dim); font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; }
.sgn-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
#sgn-typed { width: 100%; font-size: .95rem; }
#sgn-pad { width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); touch-action: none; cursor: crosshair; display: block; }

.sign-alert { padding: 8px 12px; border-radius: var(--radius-sm); font-size: .86rem; margin: 0; }
.sign-alert.error { background: var(--danger-container); color: var(--danger); }
.sign-alert.ok { background: var(--success-container); color: var(--success); }
.sign-code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }

.sgn-mobilebar { display: none; }
@media (max-width: 960px) {
    .sgn { grid-template-columns: 1fr; padding: 12px 12px 88px; gap: 12px; }
    .sgn-side { position: static; max-height: none; }
    .sgn-top { padding: 10px 14px; }
    .sgn-pages { padding: 8px; }
    .sgn-mobilebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,.12); font-weight: 600; font-size: .9rem; }
    .sgn-mobilebar .btn { min-width: 140px; justify-content: center; }
}
.sealed-note { margin: 0 0 14px; } .badge .ic { width: 12px; height: 12px; vertical-align: -2px; }

/* Signing settings: certificate replacement blocks. */
.ss-replace { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.ss-replace > summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--accent); }
.ss-block { margin-top: 18px; display: flex; flex-direction: column; }
.ss-block + .ss-block { padding-top: 18px; border-top: 1px solid var(--border); }
.ss-h3 { margin: 0 0 4px; font-size: .98rem; }
.ss-help { margin: 0 0 10px; font-size: .84rem; }
.ss-grid { display: grid; gap: 12px; align-items: start; margin-top: 8px; }
.ss-grid-3 { grid-template-columns: 1fr 1fr 130px; }
.ss-grid-2 { grid-template-columns: 1fr 1fr; }
.ss-grid .form-group { margin-bottom: 12px; }
@media (max-width: 640px) { .ss-grid-3, .ss-grid-2 { grid-template-columns: 1fr; } }
.ss-file { width: 100%; height: 40px; box-sizing: border-box; font: inherit; font-size: .86rem; color: var(--text-dim); padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.ss-grid input:not([type=file]) { height: 40px; box-sizing: border-box; }
.ss-file::file-selector-button { margin-right: 10px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }

/* Signer page: a checkbox's statement shown beside the box. */
.sgn-check-label { position: absolute; transform: translateY(-50%); margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(255, 255, 255, .9); color: #1b1d2a; font-weight: 500; line-height: 1.3; white-space: nowrap; cursor: pointer; }

/* Signer state pages (/sign/{token} when there's nothing to sign). */
.sgn-state-ic { width: 56px; height: 56px; margin: 14px auto 6px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.sgn-state-ic .ic { width: 26px; height: 26px; }
.sgn-state-ic.tone-ok { background: var(--success-container); color: var(--success); }
.sgn-state-ic.tone-warn { background: var(--warning-container); color: var(--warning); }
.sgn-state-ic.tone-info { background: var(--accent-container); color: var(--on-accent-container); }
.sgn-state-title { margin-top: 8px; }

/* Verify a signed PDF (/sign/verify). */
.vf { max-width: 720px; margin: 0 auto; padding: 32px 20px 48px; display: flex; flex-direction: column; gap: 20px; }
.vf-form { display: flex; flex-direction: column; gap: 14px; }
.vf-h1 { margin: 0; font-size: 1.4rem; }
.vf-lead { margin: 0; font-size: .92rem; line-height: 1.5; }
.vf-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-1); cursor: pointer; text-align: center; }
.vf-drop:hover, .vf-drop:focus-within { border-color: var(--accent); }
.vf-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.vf-drop-main { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; }
.vf-drop-name { font-size: .82rem; }
.vf-submit { align-self: flex-start; }
.vf-result { display: flex; flex-direction: column; gap: 16px; border-left: 4px solid var(--border); }
.vf-result.tone-ok { border-left-color: var(--success); }
.vf-result.tone-bad { border-left-color: var(--danger); }
.vf-result.tone-info { border-left-color: var(--accent); }
.vf-verdict { display: flex; gap: 16px; align-items: flex-start; }
.vf-verdict .sgn-state-ic { margin: 0; flex: 0 0 auto; }
.vf-verdict h2 { margin: 4px 0 6px; font-size: 1.15rem; }
.vf-verdict p { margin: 0 0 10px; font-size: .92rem; line-height: 1.5; }
.vf-facts { margin: 0; }
.vf-sig { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-1); }
.vf-sig-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.vf-dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: .86rem; }
.vf-dl dt { color: var(--text-dim); }
.vf-dl dd { margin: 0; word-break: break-word; }
.vf-note { margin: 0; font-size: .8rem; line-height: 1.5; }
@media (max-width: 560px) { .vf-dl { grid-template-columns: 1fr; } .vf-dl dt { margin-top: 4px; } }

/* Editor: templates. */
.sed-tpl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.sed-tpl select { width: 100%; font: inherit; font-size: .88rem; }
.sed-tpl-save { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.sed-tpl-save[hidden], .sed-tpl[hidden] { display: none; }
.sed-tpl-save input { width: 100%; font: inherit; font-size: .88rem; padding: 7px 10px; }
.sed-status-wrap { flex: 1 1 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.sed-status-wrap:has(.sed-status:empty) { justify-content: flex-end; }
.sed-status-wrap .sed-status { margin: 0; }
.sed-link { align-self: flex-start; padding: 0; border: none; background: none; color: var(--accent); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.sed-link:hover { text-decoration: underline; }

/* Files table on phones: size + modified fold into a meta line under the name; actions = the ⋮ menu
   (Download stays inside it), so nothing overflows or overlaps. */
.fn-meta { display: none; }
@media (max-width: 640px) {
    .table .col-size, .table .col-mod { display: none; }
    .table th.col-act { width: 48px !important; }
    /* 14px cell padding each side + the sibling margin left only ~16px for the 28px ⋮ button: it spilled past the card. */
    .table-fixed th.col-act, .table-fixed td.row-actions { padding-left: 6px; padding-right: 6px; }
    .table-fixed td.row-actions > * + * { margin-left: 0; }
    .row-actions .row-download { display: none; }
    .fn-meta { display: block; margin: 3px 0 0 29px; font-size: .78rem; color: var(--text-dim); }
    .file-name .badge { font-size: .68rem; padding: 1px 6px; }
    /* Icon | name on one line (name ellipsised); badges drop under the name, not under the icon. */
    .file-name > span { display: grid !important; grid-template-columns: 18px minmax(0, 1fr); column-gap: 11px; row-gap: 4px; width: 100%; }
    .file-name > span > a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
    .file-name > span > .badge { grid-column: 2; justify-self: start; }
}
/* A notebook's uploaded icon (custom:<nodeId>), wherever an icon box shows it: fills the box, never stretched. */
.nbk-ic-img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* A shared notebook page's own icon (emoji or uploaded image) in the notebook symbol's 18px place. */
.share-table .sh-page-ic { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; vertical-align: -3px; font-size: 15px; font-style: normal; line-height: 1; }
/* Shared page on phones: each row stacks - name line, muted meta line (From/With · Access · Since/Opens),
   then the actions - so nothing hides behind a sideways scroll. */
@media (max-width: 640px) {
    .share-table, .share-table tbody { display: block; width: 100%; }
    .share-table thead { display: none; }
    .share-table tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; padding: 10px 14px; border-bottom: 1px solid var(--border); }
    .share-table tbody tr:last-child { border-bottom: none; }
    .share-table tbody td { display: block; padding: 0; border: none; background: none; }
    .share-table tbody tr:hover td { background: none; }
    .share-table .sh-cell-name { flex: 1 1 100%; min-width: 0; display: flex; align-items: center; gap: 11px; }
    .share-table .sh-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
    .share-table td.sh-from, .share-table td.sh-access, .share-table td.sh-since, .share-table td.sh-opens, .share-table td.sh-with { margin-left: 0; font-size: .8rem; }
    .share-table td.sh-from { margin-left: 29px; }
    .share-table td.sh-with { flex: 1 1 100%; margin: 2px 0 2px 29px; max-width: calc(100% - 29px); }
    .share-table td.sh-from ~ td:not(.sh-actions)::before,
    .share-table td.sh-with ~ td:not(.sh-actions)::before { content: "·"; margin: 0 6px; color: var(--text-dim); }
    .share-table td.sh-with:has(.copy-box) + td.sh-access { margin-left: 29px; }
    .share-table td.sh-with:has(.copy-box) + td.sh-access::before { content: none; }
    .share-table td.sh-with:not(:has(.copy-box)) { flex: 0 1 auto; max-width: none; }
    .share-table td.sh-with:not(:has(.copy-box)) + td.sh-access::before { margin: 0 6px; }
    .share-table .copy-box { width: 100%; }
    .share-table .copy-box input { min-width: 0 !important; flex: 1 1 auto; width: 100%; }
    .share-table td.sh-actions { flex: 1 1 100%; text-align: left; margin: 6px 0 0 29px; }
    .share-table td.sh-actions::before { content: none !important; }
}
/* Chip text ellipsises instead of pushing the Files table wider than a phone (long names / e-mail fallbacks). */
.prov-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.prov-chip { max-width: 100%; }
@media (max-width: 640px) {
    .table-fixed td.file-name { overflow: hidden; }
    .file-name .prov-chips { min-width: 0; max-width: calc(100% - 29px); }
}
.ss-grid-n { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
@media (max-width: 640px) { .ss-grid-n { grid-template-columns: 1fr; } }

/* API keys: create-key fields in one row. */
.key-grid { display: grid; grid-template-columns: minmax(0, 1fr) 150px minmax(0, 2fr); gap: 12px; align-items: end; }
.key-grid .form-group { margin-bottom: 0; }
.key-grid input, .key-grid select { width: 100%; }
.key-hint { font-size: .82rem; margin: 6px 0 16px; }
@media (max-width: 760px) { .key-grid { grid-template-columns: 1fr; } }
