/*
 * hosted·ai files: base design system. Tokens, type and shared components, used by
 * every page (dashboard, sign-in, landing, public list, error pages). Page-specific
 * layout lives in its own sheet (dashboard.css, pages.css). See DESIGN.md.
 *
 * The pages send a strict CSP (style-src 'self'): no <style> blocks and no style=""
 * attributes anywhere. Everything visual lives in these sheets. Scripts may set
 * geometry through CSSOM (el.style.width = ...), which CSP allows.
 *
 * Brand: hosted·ai files (logo kit: ~/dev/files-logo/kit, guidelines.md). Violet
 * #503AA8 is the one accent. It is used for the logo dots, the primary button, links
 * and the selected state. Coral #FF8B53 is a mark
 * only: the logo's accent dot and the "starred" star. It is never used for text.
 * The neutrals are warm, built on #F7F6F4 / #211F1D in light mode and #141312 /
 * #F3F1EC in dark mode.
 *
 * Contrast, checked against the surface each token sits on:
 *   text 15:1, text-2 7.3:1, text-3 5.1:1 (light) / 6.6:1 (dark);
 *   accent-text 8.4:1 (light) / 6.0:1 (dark);
 *   white on accent-strong 8.1:1 (light) / 5.1:1 (dark);
 *   border-input and focus both clear 3:1.
 *
 * Dark mode is declared twice: once under prefers-color-scheme (the OS setting,
 * unless the viewer chose light) and once under [data-theme="dark"] (the toggle).
 *
 * Type: Manrope (variable, 200-800, OFL; fonts/OFL-Manrope.txt), self-hosted as
 * Google's latin + latin-ext subsets. Body text uses proportional figures. Tables
 * and figure columns set tabular-nums.
 */

@font-face {
  font-family: "Manrope";
  src: url("../../fonts/manrope-latin.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  src: url("../../fonts/manrope-latin-ext.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --bg: #f7f6f4;
  --surface: #fdfcfa;
  --surface-2: #f1efeb;
  --surface-3: #e7e4de;
  --border: rgba(33, 31, 29, 0.10);
  --border-strong: rgba(33, 31, 29, 0.18);
  --border-input: rgba(33, 31, 29, 0.50);
  --text: #211f1d;
  --text-2: #57534d;
  --text-3: #6f6a62;
  --accent: #503aa8;
  --accent-strong: #503aa8;
  --accent-strong-hover: #43308f;
  --accent-ink: #ffffff;
  --accent-text: #4a34a0;
  --accent-wash: rgba(80, 58, 168, 0.09);
  --accent-wash-strong: rgba(80, 58, 168, 0.17);
  --coral: #ff8b53;
  --coral-mark: #e0662f;
  --focus: #6e54c8;
  --good: #2f7434;
  --good-mark: #37a643;
  --warning-text: #8a5a00;
  --warning-mark: #e8a20c;
  --warning-wash: rgba(232, 162, 12, 0.10);
  --warning-border: rgba(232, 162, 12, 0.38);
  --critical: #b3261e;
  --critical-hover: #9c1f18;
  --critical-mark: #c9362e;
  --critical-wash: rgba(201, 54, 46, 0.07);
  --critical-border: rgba(201, 54, 46, 0.32);
  --lk-dot: #503aa8;
  --lk-accent: #ff8b53;
  --lk-word: #211f1d;
  /* File-type hues (icons only, never text). Each clears 3:1 on --surface. */
  --ft-pdf: #c63d33;
  --ft-doc: #3b6bd6;
  --ft-sheet: #22855a;
  --ft-slides: #cf5f16;
  --ft-archive: #946300;
  --ft-image: #0f8a84;
  --ft-video: #b03a8a;
  --ft-audio: #1782ab;
  --ft-code: #5a4bc4;
  --ft-disk: #56677a;
  --ft-exec: #8a5540;
  --ft-data: #687a0e;
  --ft-other: #7a746b;
  --scrim: rgba(33, 31, 29, 0.38);
  --shadow-pop: 0 1px 2px rgba(33, 31, 29, 0.06), 0 8px 24px rgba(33, 31, 29, 0.12);
  --shadow-seg: 0 1px 2px rgba(33, 31, 29, 0.08), 0 0 0 1px rgba(33, 31, 29, 0.07);
  --shadow-card: 0 1px 2px rgba(33, 31, 29, 0.04), 0 12px 40px rgba(33, 31, 29, 0.07);
  --shadow-dialog: 0 2px 6px rgba(33, 31, 29, 0.08), 0 24px 64px rgba(33, 31, 29, 0.20);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-xs: 5px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --page-max: 1320px;
  --gutter: 28px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141312;
    --surface: #1c1b19;
    --surface-2: #262422;
    --surface-3: #312f2c;
    --border: rgba(243, 241, 236, 0.09);
    --border-strong: rgba(243, 241, 236, 0.17);
    --border-input: rgba(243, 241, 236, 0.38);
    --text: #f3f1ec;
    --text-2: #d2cec6;
    --text-3: #a6a198;
    --accent: #8b72e0;
    --accent-strong: #7359d1;
    --accent-strong-hover: #8068da;
    --accent-ink: #ffffff;
    --accent-text: #a38dee;
    --accent-wash: rgba(139, 114, 224, 0.15);
    --accent-wash-strong: rgba(139, 114, 224, 0.26);
    --coral-mark: #ff8b53;
    --focus: #a38dee;
    --good: #6cc672;
    --good-mark: #7ad98a;
    --warning-text: #e9b452;
    --warning-mark: #efa810;
    --warning-wash: rgba(239, 168, 16, 0.10);
    --warning-border: rgba(239, 168, 16, 0.34);
    --critical: #f2837a;
    --critical-hover: #f59a92;
    --critical-mark: #e0564c;
    --critical-wash: rgba(242, 131, 122, 0.10);
    --critical-border: rgba(242, 131, 122, 0.34);
    --lk-dot: #8b72e0;
    --lk-accent: #ff8b53;
    --lk-word: #f3f1ec;
    --ft-pdf: #f0736a;
    --ft-doc: #6f9cf0;
    --ft-sheet: #57c28b;
    --ft-slides: #f0924f;
    --ft-archive: #d6a344;
    --ft-image: #3cc4bc;
    --ft-video: #e07ac0;
    --ft-audio: #5bbfe6;
    --ft-code: #9a90f0;
    --ft-disk: #9aabbd;
    --ft-exec: #c99478;
    --ft-data: #b3c24f;
    --ft-other: #a8a298;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.45);
    --shadow-seg: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(243, 241, 236, 0.07);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.35);
    --shadow-dialog: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 64px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141312;
  --surface: #1c1b19;
  --surface-2: #262422;
  --surface-3: #312f2c;
  --border: rgba(243, 241, 236, 0.09);
  --border-strong: rgba(243, 241, 236, 0.17);
  --border-input: rgba(243, 241, 236, 0.38);
  --text: #f3f1ec;
  --text-2: #d2cec6;
  --text-3: #a6a198;
  --accent: #8b72e0;
  --accent-strong: #7359d1;
  --accent-strong-hover: #8068da;
  --accent-ink: #ffffff;
  --accent-text: #a38dee;
  --accent-wash: rgba(139, 114, 224, 0.15);
  --accent-wash-strong: rgba(139, 114, 224, 0.26);
  --coral-mark: #ff8b53;
  --focus: #a38dee;
  --good: #6cc672;
  --good-mark: #7ad98a;
  --warning-text: #e9b452;
  --warning-mark: #efa810;
  --warning-wash: rgba(239, 168, 16, 0.10);
  --warning-border: rgba(239, 168, 16, 0.34);
  --critical: #f2837a;
  --critical-hover: #f59a92;
  --critical-mark: #e0564c;
  --critical-wash: rgba(242, 131, 122, 0.10);
  --critical-border: rgba(242, 131, 122, 0.34);
  --lk-dot: #8b72e0;
  --lk-accent: #ff8b53;
  --lk-word: #f3f1ec;
  --ft-pdf: #f0736a;
  --ft-doc: #6f9cf0;
  --ft-sheet: #57c28b;
  --ft-slides: #f0924f;
  --ft-archive: #d6a344;
  --ft-image: #3cc4bc;
  --ft-video: #e07ac0;
  --ft-audio: #5bbfe6;
  --ft-code: #9a90f0;
  --ft-disk: #9aabbd;
  --ft-exec: #c99478;
  --ft-data: #b3c24f;
  --ft-other: #a8a298;
  --scrim: rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-seg: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(243, 241, 236, 0.07);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-dialog: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 64px rgba(0, 0, 0, 0.55);
}

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

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: proportional-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.92em; }
img, svg { display: block; }
::selection { background: var(--accent-wash-strong); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-radius: var(--radius-sm); border-color: transparent; }

/* The hidden attribute wins over any display a class sets. */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--accent-text);
  padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* The icon sprite itself takes no space. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1 1 auto; }
.clip { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- icons */

.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.i-sm { width: 14px; height: 14px; }
.i-lg { width: 18px; height: 18px; }

/* File-type glyph: a page tinted with its category hue. */
.ft { width: 18px; height: 18px; flex: none; color: var(--ft-other); fill: currentColor; fill-opacity: 0.14; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.ft-pdf { color: var(--ft-pdf); }
.ft-doc { color: var(--ft-doc); }
.ft-sheet { color: var(--ft-sheet); }
.ft-slides { color: var(--ft-slides); }
.ft-archive { color: var(--ft-archive); }
.ft-image { color: var(--ft-image); }
.ft-video { color: var(--ft-video); }
.ft-audio { color: var(--ft-audio); }
.ft-code { color: var(--ft-code); }
.ft-disk { color: var(--ft-disk); }
.ft-exec { color: var(--ft-exec); }
.ft-data { color: var(--ft-data); }

/* ---------------------------------------------------------------- brand */

/*
 * The logo is always one of the kit's own files (assets/img/logo/, from
 * ~/dev/files-logo/kit), printed by ui_logo(): the light master and the -dark master
 * side by side, with CSS showing the one that matches the theme. The kit's rule is to
 * use the dark file on dark backgrounds, since its dots are slightly thinner, and never
 * to recolour. The lockup files carry 0.5X of built-in clear space (the artwork is about
 * 87% of the image height). Size by height only.
 */
.logo { display: inline-flex; align-items: center; flex: none; line-height: 0; }
.logo img { display: block; height: 100%; width: auto; max-width: none; }
.logo .logo-dark { display: none; }
:root[data-theme="dark"] .logo .logo-light { display: none; }
:root[data-theme="dark"] .logo .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo .logo-dark { display: block; }
}
.logo-horizontal, .logo-endorsed { height: var(--lockup-h, 30px); }
.logo-stacked { height: var(--stacked-h, 96px); }
.logo-symbol { height: var(--symbol-h, 32px); }
.logo-symbol-small { height: var(--symbol-h, 16px); }

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter);
  height: var(--topbar-h); display: flex; align-items: center; gap: 28px;
}
.brand {
  --lockup-h: 41px;
  display: flex; align-items: center; flex: none; color: var(--text);
  border-radius: 6px; text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand:focus-visible { outline-offset: 6px; }

.nav { display: flex; align-items: stretch; gap: 2px; height: var(--topbar-h); min-width: 0; }
.nav a {
  display: flex; align-items: center; gap: 7px; padding: 0 10px;
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 13.5px; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.nav a:focus-visible { outline-offset: -6px; }
.nav-count {
  min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-3); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1;
}
.nav a[aria-current="page"] .nav-count { color: var(--accent-text); background: var(--accent-wash); border-color: transparent; }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
.viewer { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; padding: 0 6px 0 2px; white-space: nowrap; min-width: 0; }
.viewer-name { overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: var(--accent-wash); color: var(--accent-text);
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
}
.topbar-sep { width: 1px; height: 20px; background: var(--border-strong); flex: none; margin: 0 4px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500; line-height: 1; cursor: pointer;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { background: var(--surface-3); }
.btn .i { width: 15px; height: 15px; }
.btn-primary { background: var(--accent-strong); color: var(--accent-ink); border-color: var(--accent-strong); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong-hover); border-color: var(--accent-strong-hover); }
.btn-primary:active { background: var(--accent-strong-hover); }
.btn-danger { background: var(--critical); color: #fff; border-color: var(--critical); font-weight: 600; }
.btn-danger:hover { background: var(--critical-hover); border-color: var(--critical-hover); }
:root[data-theme="dark"] .btn-danger { color: #1c1b19; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { color: #1c1b19; } }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-quiet:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn-sm .i { width: 14px; height: 14px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; pointer-events: none; }
.btn .spinner { width: 14px; height: 14px; }

.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; flex: none;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer; padding: 0;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.icon-btn.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn.icon-btn-xs { width: 24px; height: 24px; border-radius: var(--radius-xs); }
.icon-btn[disabled] { opacity: 0.4; cursor: default; pointer-events: none; }

/* ---------------------------------------------------------------- form controls */

.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--text-3); }
.field-error { font-size: 12.5px; color: var(--critical); }
.field-error:empty { display: none; }

.input {
  height: 32px; width: 100%; min-width: 0; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text);
  font-size: 13px;
}
.input::placeholder { color: var(--text-3); opacity: 1; }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.input[aria-invalid="true"] { border-color: var(--critical); }
.input[aria-invalid="true"]:focus-visible { outline-color: var(--critical); border-color: transparent; }
.field:has(.field-error:not(:empty)) .field-hint { display: none; }
.input-lg { height: 40px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.input.mono { font-size: 12.5px; }

.search { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.search > .i { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.search .input { width: 260px; max-width: 100%; padding-left: 30px; padding-right: 30px; }
.search .input { -webkit-appearance: none; appearance: none; }
.search .input::-webkit-search-cancel-button, .search .input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search kbd {
  position: absolute; right: 7px; height: 18px; min-width: 18px; padding: 0 4px;
  display: inline-grid; place-items: center; border-radius: 4px;
  border: 1px solid var(--border-strong); color: var(--text-3); background: var(--surface-2);
  font-size: 11px; line-height: 1; pointer-events: none;
}
.search .input:focus + kbd, .search .input:not(:placeholder-shown) + kbd { display: none; }

.select { position: relative; display: inline-flex; align-items: center; flex: none; }
.select select {
  appearance: none; -webkit-appearance: none;
  height: 32px; padding: 0 28px 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-input); background-color: var(--surface);
  color: var(--text); font-size: 13px; cursor: pointer; max-width: 100%;
}
.select.select-sm select { height: 28px; font-size: 12.5px; }
.select::after {
  content: ""; position: absolute; right: 11px; top: 50%;
  width: 6px; height: 6px; margin-top: -5px;
  border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg); pointer-events: none;
}

/* iOS Safari zooms the page when a field under 16px takes focus. */
@supports (-webkit-touch-callout: none) {
  input.input:not(#totp), .select select, textarea { font-size: 16px !important; }
}

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
/* Drawn checkboxes and radios: native dark-mode controls render as grey blocks off the warm palette. */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; margin: 0; flex: none; cursor: pointer;
  display: inline-grid; place-content: center;
  border: 1px solid var(--border-input); border-radius: 4px; background: var(--surface);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before, input[type="radio"]::before { content: ""; transform: scale(0); transition: transform 0.12s ease; background: var(--accent-ink); }
input[type="checkbox"]::before { width: 9px; height: 9px; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
input[type="radio"]::before { width: 7px; height: 7px; border-radius: 50%; }
input[type="checkbox"]:checked, input[type="checkbox"]:indeterminate, input[type="radio"]:checked { background: var(--accent-strong); border-color: var(--accent-strong); }
input[type="checkbox"]:checked::before, input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:indeterminate::before { clip-path: inset(38% 8% round 1px); transform: scale(1); }
input[type="checkbox"]:hover:not(:checked):not(:indeterminate), input[type="radio"]:hover:not(:checked) { border-color: var(--text-3); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.5; cursor: default; }

/* Segmented control: the pressed button is a raised chip with violet text. */
.seg {
  display: inline-flex; padding: 2px; gap: 2px; flex: none; max-width: 100%;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
}
.seg button {
  height: 26px; padding: 0 11px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-seg), inset 0 0 0 1px var(--accent); font-weight: 600; }
.seg button:focus-visible { outline-offset: 0; }
.seg .seg-count { font-size: 11.5px; color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] .seg-count { color: var(--accent-text); }

kbd.kbd {
  display: inline-grid; place-items: center; height: 18px; min-width: 18px; padding: 0 5px;
  border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text-2); font-size: 11px; line-height: 1;
}

/* ---------------------------------------------------------------- page layout */

.page { max-width: var(--page-max); margin: 0 auto; padding: 18px var(--gutter) 40px; }
.page:focus { outline: none; }
.page-head { display: flex; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin: 0 0 14px; }
.page-head .titles { min-width: 0; flex: 1 1 auto; }
.page-head h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; }
.page-head .sub { color: var(--text-3); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 0; display: flex; flex-direction: column;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 0; }
.card-head .titles { min-width: 0; flex: 1 1 auto; }
.card-title { font-size: 14.5px; font-weight: 700; }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 14px 20px 18px; min-width: 0; }
.card-foot {
  border-top: 1px solid var(--border); padding: 8px 12px 8px 20px; font-size: 12.5px; color: var(--text-3);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* ---------------------------------------------------------------- notices */

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 13px; line-height: 1.45;
}
.notice > .i { margin-top: 1px; color: var(--text-3); }
.notice strong { color: var(--text); font-weight: 700; }
.notice .notice-body { min-width: 0; flex: 1 1 auto; }
.notice .notice-body p + p { margin-top: 4px; }
.notice-warning { background: var(--warning-wash); border-color: var(--warning-border); }
.notice-warning > .i { color: var(--warning-text); }
.notice-critical { background: var(--critical-wash); border-color: var(--critical-border); }
.notice-critical > .i { color: var(--critical); }
.notice-accent { background: var(--accent-wash); border-color: transparent; }
.notice-accent > .i { color: var(--accent-text); }
.notice details { margin-top: 6px; }
.notice summary { cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 12.5px; }
.notice dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin-top: 6px; font-size: 12.5px; }
.notice dt { color: var(--text-3); }
.notice dd { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; line-height: 1;
}
.badge .i { width: 12px; height: 12px; }
.badge-accent { color: var(--accent-text); background: var(--accent-wash); border-color: transparent; }
.badge-good { color: var(--good); }
.badge-warning { color: var(--warning-text); background: var(--warning-wash); border-color: var(--warning-border); }

/* ---------------------------------------------------------------- tables */

.table-tools { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); min-height: 53px; }
.table-count { color: var(--text-3); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 0 10px; height: 36px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th:first-child, table.data td:first-child { padding-left: 16px; }
table.data th:last-child, table.data td:last-child { padding-right: 12px; }
table.data thead th {
  height: 34px; font-size: 12px; font-weight: 500; color: var(--text-3);
  background: var(--surface); position: sticky; top: 0; z-index: 1;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.n, table.data th.n { text-align: right; }
table.data td.muted { color: var(--text-3); }

.th-sort {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent;
  padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; white-space: nowrap;
}
.th-sort:hover { color: var(--text); }
.th-sort .i { width: 12px; height: 12px; opacity: 0; }
.th-sort:hover .i { opacity: 0.45; }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--text); font-weight: 600; }
th[aria-sort="ascending"] .th-sort .i, th[aria-sort="descending"] .th-sort .i { opacity: 1; color: var(--accent-text); }
th.n .th-sort { flex-direction: row-reverse; }

/* ---------------------------------------------------------------- menus */

.menu {
  position: fixed; z-index: 45; min-width: 184px; max-width: min(320px, calc(100vw - 16px));
  padding: 4px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 9px; box-shadow: var(--shadow-pop);
}
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 9px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text);
  font-size: 13px; font-weight: 500; text-align: left; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.menu-item .i { width: 15px; height: 15px; color: var(--text-3); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); text-decoration: none; outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.menu-item.is-danger { color: var(--critical); }
.menu-item.is-danger .i { color: var(--critical); }
.menu-item[aria-disabled="true"] { color: var(--text-3); cursor: default; }
.menu-item[aria-disabled="true"]:hover { background: transparent; }
.menu-item.is-danger[aria-disabled="true"], .menu-item.is-danger[aria-disabled="true"] .i { color: var(--text-3); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--border); }
.menu-note { padding: 4px 9px 6px; font-size: 11.5px; color: var(--text-3); white-space: normal; }

/* ---------------------------------------------------------------- dialogs */

dialog.dialog {
  width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-dialog);
  overflow: hidden;
}
dialog.dialog[open] { display: flex; flex-direction: column; }
dialog.dialog-wide { width: min(620px, calc(100vw - 24px)); }
dialog.dialog::backdrop { background: var(--scrim); }
.dialog-form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; margin: 0; }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 0 20px; }
.dialog-head .titles { flex: 1 1 auto; min-width: 0; }
.dialog-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.dialog-sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; overflow-wrap: anywhere; }
.dialog-body { padding: 14px 20px 18px; overflow-y: auto; display: grid; gap: 14px; min-height: 0; font-size: 13.5px; color: var(--text-2); }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px 14px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.dialog-foot .dialog-foot-note { margin-right: auto; font-size: 12px; color: var(--text-3); }
@media (prefers-reduced-motion: no-preference) {
  dialog.dialog[open] { animation: dialog-in 0.16s ease-out; }
  dialog.dialog[open]::backdrop { animation: fade-in 0.16s ease-out; }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed; left: 50%; bottom: 20px; z-index: 70; transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center; width: max-content; max-width: calc(100vw - 24px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; min-height: 40px; max-width: 560px; padding: 8px 8px 8px 14px;
  background: #211f1d; color: #f3f1ec; border-radius: 9px; box-shadow: var(--shadow-pop);
  font-size: 13px; font-weight: 500; pointer-events: auto;
}
:root[data-theme="dark"] .toast { background: #f3f1ec; color: #211f1d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #f3f1ec; color: #211f1d; } }
.toast > .i { color: var(--good-mark); }
.toast.is-error > .i { color: #f2837a; }
:root[data-theme="dark"] .toast.is-error > .i { color: #b3261e; }
:root[data-theme="dark"] .toast:not(.is-error) > .i { color: #2f7434; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast.is-error > .i { color: #b3261e; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast:not(.is-error) > .i { color: #2f7434; } }
.toast-text { min-width: 0; overflow-wrap: anywhere; padding-right: 6px; }
.toast-action {
  height: 26px; padding: 0 9px; border-radius: 6px; border: 0; cursor: pointer;
  background: rgba(243, 241, 236, 0.14); color: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.toast-action:hover { background: rgba(243, 241, 236, 0.24); }
.toast-action:focus-visible { outline-color: currentColor; }
:root[data-theme="dark"] .toast-action { background: rgba(33, 31, 29, 0.10); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast-action { background: rgba(33, 31, 29, 0.10); } }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 0.18s ease-out; }
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- status, progress, spinner */

.status-line { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12.5px; white-space: nowrap; min-width: 0; }
.status-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-line.is-good .dot { background: var(--good-mark); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good-mark) 18%, transparent); }
.status-line.is-warning .dot { background: var(--warning-mark); }
.status-line.is-warning { color: var(--warning-text); }
.status-line.is-busy .dot { background: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .status-line.is-busy .dot { animation: pulse 1.4s ease-in-out infinite; }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.progress { height: 4px; border-radius: 2px; background: var(--accent-wash-strong); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width 0.2s ease; }
.progress.is-done > i { background: var(--good-mark); }
.progress.is-failed > i { background: var(--critical-mark); }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-wash-strong); border-top-color: var(--accent); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .spinner { animation: spin 0.8s linear infinite; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- empty state */

.empty { display: grid; justify-items: center; gap: 6px; padding: 48px 20px 52px; text-align: center; }
.empty-mark { --symbol-h: 34px; margin-bottom: 6px; opacity: 0.9; }
.empty-title { font-size: 14.5px; font-weight: 700; color: var(--text); }
.empty-text { font-size: 13px; color: var(--text-3); max-width: 46ch; }
.empty .btn { margin-top: 8px; }

/* ---------------------------------------------------------------- footer */

.site-foot { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter) 28px; color: var(--text-3); font-size: 12px; }
.site-foot-inner { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 860px) {
  :root { --gutter: 16px; }
  .topbar-inner { gap: 14px; }
  .viewer-name { display: none; }
}
@media (max-width: 560px) {
  .page-head h1 { font-size: 18px; }
  .search .input { width: 100%; }
  .search { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
