/*
 * DSPI Archive - design system and components.
 *
 * Design language: public-records archive. Cobalt blue accent on cool slate
 * neutrals, IBM Plex Sans for text and IBM Plex Mono for data (hashes, IDs,
 * sizes, dates). Restrained motion, high legibility, scannable records.
 *
 * Conventions locked across the site:
 *   - One accent color (cobalt) for every interactive element.
 *   - One radius system: 6px small inline, 10px controls/cards, 14px large
 *     panels, full pill for chips and badges.
 *   - One theme at a time: [data-theme] on <html> is always set by theme.js;
 *     no section ever inverts mid-page.
 *   - Numbers, hashes, IDs, byte sizes always render in --font-mono.
 */

/* ------------------------------------------------------------------ */
/* 1. Tokens                                                           */
/* ------------------------------------------------------------------ */

:root {
  /* Cobalt scale (the single accent family) */
  --blue-50: #f2f6fd;
  --blue-100: #e3edfb;
  --blue-200: #c6d9f6;
  --blue-300: #9dbef0;
  --blue-400: #6d9ce6;
  --blue-500: #3f78d8;
  --blue-600: #245dc0;
  --blue-700: #1a4a9e;
  --blue-800: #163d80;
  --blue-900: #102c5c;

  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --container: 1200px;
  --container-narrow: 860px;
  --header-h: 60px;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 140ms var(--ease);
  --t: 220ms var(--ease);
}

/* Light theme (default) */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fa;
  --bg-soft: #edf1f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f8;
  --border: #dde3ec;
  --border-strong: #c3ccda;
  --text: #101722;
  --text-2: #46536a;
  --text-3: #5d6a83;
  --accent: #1a4a9e;
  --accent-hover: #163d80;
  --accent-active: #102c5c;
  --accent-soft: #e3edfb;
  --accent-soft-2: #d3e3f8;
  --on-accent: #ffffff;
  --link: #1a4a9e;
  --focus: #245dc0;
  --danger: #a4231c;
  --danger-soft: #fbeceb;
  --success: #17683f;
  --success-soft: #e8f5ee;
  --warn: #7a5200;
  --warn-soft: #fdf3e0;
  --shadow-1: 0 1px 2px rgba(16, 23, 34, 0.05), 0 1px 1px rgba(16, 23, 34, 0.04);
  --shadow-2: 0 10px 24px -14px rgba(16, 23, 34, 0.28), 0 2px 6px -2px rgba(16, 23, 34, 0.08);
  --thumb-bg: #e8edf4;
}

/* Dark theme */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-soft: #111823;
  --surface: #151c26;
  --surface-2: #1a2330;
  --surface-3: #1f2a38;
  --border: #26303d;
  --border-strong: #3a475a;
  --text: #e7ecf3;
  --text-2: #a7b3c5;
  --text-3: #8494a8;
  --accent: #7fb0f2;
  --accent-hover: #9cc4f6;
  --accent-active: #b3d2f8;
  --accent-soft: rgba(63, 120, 216, 0.18);
  --accent-soft-2: rgba(63, 120, 216, 0.28);
  --on-accent: #0b1526;
  --link: #8ab7f4;
  --focus: #8ab7f4;
  --danger: #f2938c;
  --danger-soft: rgba(190, 60, 50, 0.16);
  --success: #7fd3a2;
  --success-soft: rgba(30, 130, 80, 0.18);
  --warn: #e8b95c;
  --warn-soft: rgba(180, 130, 30, 0.16);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 12px 28px -16px rgba(0, 0, 0, 0.7), 0 2px 8px -2px rgba(0, 0, 0, 0.4);
  --thumb-bg: #1d2734;
}

/* ------------------------------------------------------------------ */
/* 2. Base                                                             */
/* ------------------------------------------------------------------ */

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

/* The hidden attribute must win over component display rules. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "kern";
  text-rendering: optimizeLegibility;
}

img,
video {
  max-width: 100%;
  display: block;
}

a {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

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

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ------------------------------------------------------------------ */
/* 3. Layout primitives                                                */
/* ------------------------------------------------------------------ */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.container-narrow {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 64px 0;
}

.section-tight {
  padding: 40px 0;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 24px;
}

.stack > * + * {
  margin-top: 16px;
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.grid-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 24px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 48px;
  align-items: start;
}

@media (max-width: 900px) {
  .split {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .grid-facts {
    grid-template-columns: 1fr;
  }
  .section {
    padding: 48px 0;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  transition: top var(--t-fast);
}

.skip-link:focus {
  top: 12px;
}

/* ------------------------------------------------------------------ */
/* 4. Typography                                                       */
/* ------------------------------------------------------------------ */

.h-display {
  font-size: clamp(2rem, 1.3rem + 2.6vw, 3.05rem);
  letter-spacing: -0.025em;
  line-height: 1.08;
}

.h-section {
  font-size: clamp(1.4rem, 1.15rem + 0.9vw, 1.75rem);
}

.lede {
  font-size: 1.0625rem;
  color: var(--text-2);
  max-width: 62ch;
}

.prose {
  color: var(--text-2);
  max-width: 68ch;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose p + p {
  margin-top: 0.9em;
}

.muted {
  color: var(--text-3);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
  font-variant-ligatures: none;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  color: var(--text-3);
  font-size: 0.875rem;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.meta-item .mono {
  color: var(--text-2);
}

/* ------------------------------------------------------------------ */
/* 5. Icons                                                            */
/* ------------------------------------------------------------------ */

/* The hidden icon sprite. Sized via attributes + this class (not an inline
   style attribute) so the strict CSP never blocks it. */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ic {
  width: 18px;
  height: 18px;
  flex: none;
  fill: currentColor;
}

.ic-sm {
  width: 15px;
  height: 15px;
}

.ic-lg {
  width: 22px;
  height: 22px;
}

.ic-xl {
  width: 30px;
  height: 30px;
}

/* ------------------------------------------------------------------ */
/* 6. Header                                                           */
/* ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

@supports not (backdrop-filter: blur(4px)) {
  .site-header {
    background: var(--bg);
  }
}

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  flex: none;
}

.brand-name {
  font-size: 0.9688rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.site-nav a {
  color: var(--text-2);
  padding: 7px 11px;
  border-radius: var(--r-sm);
  font-size: 0.9063rem;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}

.site-nav a:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mobile: nav moves to a second row; the rest of the header stays one line. */
@media (max-width: 719px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 0 0;
    row-gap: 0;
  }
  .site-nav {
    order: 3;
    width: 100%;
    margin: 0;
    padding: 4px 0 8px;
    gap: 2px;
  }
}

/* ------------------------------------------------------------------ */
/* 7. Buttons                                                          */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-1);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  background: var(--accent-active);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  color: var(--text-2);
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn-sm {
  padding: 7px 13px;
  font-size: 0.875rem;
  border-radius: var(--r-sm);
}

.btn-lg {
  padding: 13px 24px;
  font-size: 1rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* Compact language switch: shows the language it switches to. */
.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.lang-btn:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* 8. Chips, tags, badges                                              */
/* ------------------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.7813rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.chip .chip-count {
  opacity: 0.72;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

:root[data-theme="dark"] .tag {
  color: var(--accent-hover);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ------------------------------------------------------------------ */
/* 9. Panels and cards                                                 */
/* ------------------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
}

.panel-tight {
  padding: 18px 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.panel-head .ic {
  color: var(--accent);
}

/* Tagged with a left accent bar when a panel needs emphasis. */
.panel-accent {
  border-left: 3px solid var(--accent);
}

/* ------------------------------------------------------------------ */
/* 10. Record cards                                                    */
/* ------------------------------------------------------------------ */

.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.record-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  color: var(--text);
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
}

.record-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
}

/* Cards never embed the submitted files themselves: the index shows a
   compact neutral type panel; previews live on the record page. */
.record-thumb {
  position: relative;
  height: 118px;
  background: var(--thumb-bg);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.record-thumb .thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
}

.thumb-fallback .ic {
  width: 30px;
  height: 30px;
}

.thumb-fallback .thumb-kind {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.record-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 18px;
  flex: 1;
}

.record-title {
  font-size: 1.0313rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.record-snippet {
  color: var(--text-2);
  font-size: 0.9063rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Generated stand-in when a record has no description of its own. */
.record-snippet.is-generated {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-3);
}

.record-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  color: var(--text-3);
  font-size: 0.8125rem;
}

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

mark {
  background: var(--accent-soft-2);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

/* ------------------------------------------------------------------ */
/* 11. Toolbar (search, sort, filters)                                 */
/* ------------------------------------------------------------------ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.search-box {
  position: relative;
  flex: 1 1 260px;
}

.search-box .ic {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 36px 9px 38px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--bg);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

.search-clear:hover {
  background: var(--surface-3);
  color: var(--text);
}

.search-box.has-value .search-clear {
  display: inline-flex;
}

.sort-box {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 0.875rem;
}

.sort-box select {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.sort-box select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 2px 4px;
}

.filter-row:empty {
  display: none;
}

.result-line {
  padding: 16px 2px 0;
  color: var(--text-3);
  font-size: 0.875rem;
}

.result-line strong {
  color: var(--text-2);
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* 12. States: skeleton, empty, alerts                                 */
/* ------------------------------------------------------------------ */

.skeleton {
  border-radius: var(--r-lg);
  background: linear-gradient(100deg, var(--surface-3) 40%, var(--surface) 50%, var(--surface-3) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-card {
  height: 292px;
}

.skeleton-block {
  height: 220px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.state-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 40px 28px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--text-2);
}

.state-block .ic-xl {
  color: var(--text-3);
}

.state-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
}

.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.9375rem;
}

.alert .ic {
  margin-top: 2px;
  flex: none;
}

.alert-title {
  font-weight: 600;
  color: var(--text);
  display: block;
}

.alert-error {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.alert-error .ic {
  color: var(--danger);
}

.alert-success {
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.alert-success .ic {
  color: var(--success);
}

.alert-warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

.alert-warn .ic {
  color: var(--warn);
}

.alert-info .ic {
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* 13. Forms                                                           */
/* ------------------------------------------------------------------ */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 20px;
}

.field-label {
  font-size: 0.9063rem;
  font-weight: 600;
}

.field-label .optional {
  font-weight: 400;
  color: var(--text-3);
}

.field-hint {
  font-size: 0.8125rem;
  color: var(--text-3);
}

.field-error {
  font-size: 0.8125rem;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-error:empty {
  display: none;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
  opacity: 0.9;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.field-counter {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-3);
}

.check {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}

.check input {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex: none;
}

.check-label {
  font-size: 0.9063rem;
  color: var(--text-2);
  line-height: 1.55;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 34px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text-2);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.drop-zone:hover,
.drop-zone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone .ic-xl {
  color: var(--accent);
}

.drop-zone strong {
  color: var(--text);
  font-weight: 600;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  margin-top: 12px;
}

.file-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--thumb-bg);
  flex: none;
}

.file-thumb-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.file-info-body {
  min-width: 0;
  flex: 1;
}

.file-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* 14. Hero (index)                                                    */
/* ------------------------------------------------------------------ */

.hero {
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr);
  gap: 48px;
  align-items: center;
}

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .hero {
    padding: 40px 0 32px;
  }
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: flex-start;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

/* Live record preview: a real record from the manifest, not a mockup. */
.hero-preview {
  position: relative;
}

.hero-preview-caption {
  font-size: 0.8125rem;
  color: var(--text-3);
  margin-bottom: 8px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.hero-preview .record-card {
  box-shadow: var(--shadow-1);
}

.hero-preview-note {
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--text-3);
}

/* ------------------------------------------------------------------ */
/* 15. Facts (about band)                                              */
/* ------------------------------------------------------------------ */

.fact {
  border-left: 2px solid var(--accent-soft-2);
  padding-left: 16px;
}

.fact h3 {
  font-size: 0.9688rem;
  margin-bottom: 4px;
}

.fact p {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.55;
}

/* ------------------------------------------------------------------ */
/* 16. Item page                                                       */
/* ------------------------------------------------------------------ */

.h-record {
  font-size: clamp(1.5rem, 1.2rem + 1.3vw, 2.05rem);
}

.record-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.file-kind {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.preview-note {
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.item-grid {
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
  gap: 40px;
  align-items: start;
}

@media (max-width: 980px) {
  .item-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

.item-side {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 980px) {
  .item-side {
    position: static;
  }
}

.def-list {
  display: flex;
  flex-direction: column;
}

.def-list > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
}

.def-list > div + div {
  border-top: 1px solid var(--border);
}

.def-list dt {
  color: var(--text-3);
  font-size: 0.8438rem;
  flex: none;
}

.def-list dd {
  margin: 0;
  font-size: 0.8438rem;
  color: var(--text-2);
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}

.file-card + .file-card {
  margin-top: 20px;
}

.file-preview {
  background: var(--thumb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  max-height: 560px;
  overflow: hidden;
}

.file-preview img,
.file-preview video {
  max-height: 560px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  background: var(--thumb-bg);
}

.file-preview .preview-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 24px;
  color: var(--text-3);
}

.file-preview pre {
  width: 100%;
  margin: 0;
  padding: 18px 20px;
  max-height: 420px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.file-meta {
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-meta-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.file-name-lg {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.hash-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.hash-row .hash-label {
  font-size: 0.75rem;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: none;
  padding-top: 2px;
}

.hash-value {
  font-family: var(--font-mono);
  font-size: 0.7813rem;
  color: var(--text-2);
  overflow-wrap: anywhere;
  min-width: 0;
  flex: 1;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.copy-btn {
  flex: none;
}

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pager a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9063rem;
  min-width: 0;
}

.pager .pager-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
}

.pager-next {
  margin-left: auto;
  text-align: right;
}

/* ------------------------------------------------------------------ */
/* 17. Upload page                                                     */
/* ------------------------------------------------------------------ */

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 44px;
  align-items: start;
}

@media (max-width: 980px) {
  .upload-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rules-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.rules-list .ic {
  color: var(--accent);
  margin-top: 3px;
}

.rules-list h3 {
  font-size: 0.9375rem;
  margin-bottom: 3px;
}

.rules-list p {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.55;
}

.steps {
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.steps li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--r-pill);
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transform: translateY(2px);
}

.submission-result {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.submission-id-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.submission-id {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
  flex: 1;
}

/* ------------------------------------------------------------------ */
/* 18. Status page                                                     */
/* ------------------------------------------------------------------ */

.status-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-form .input {
  flex: 1 1 320px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.status-result:empty {
  display: none;
}

/* ------------------------------------------------------------------ */
/* 19. Footer                                                          */
/* ------------------------------------------------------------------ */

.site-footer {
  margin-top: 72px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 3fr) minmax(0, 4fr);
  gap: 32px;
  padding: 44px 0 28px;
}

@media (max-width: 860px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 32px 0 20px;
  }
}

.footer-note {
  margin-top: 12px;
  color: var(--text-3);
  font-size: 0.8438rem;
  max-width: 46ch;
  line-height: 1.6;
}

.footer-h {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
  margin-bottom: 10px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.875rem;
}

.footer-links a {
  color: var(--text-2);
  width: fit-content;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 16px 0 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  color: var(--text-3);
  font-size: 0.8125rem;
}

/* ------------------------------------------------------------------ */
/* 20. Motion                                                          */
/* ------------------------------------------------------------------ */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 500ms var(--ease), transform 500ms var(--ease);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
  .skeleton {
    animation: none;
  }
}

/* ------------------------------------------------------------------ */
/* 21. Chinese (Simplified) typography                                 */
/* ------------------------------------------------------------------ */

/* CJK text needs looser leading and no negative tracking (Latin display
   tricks read as cramped in Chinese). */
html[lang^="zh"] body {
  line-height: 1.8;
}

html[lang^="zh"] h1,
html[lang^="zh"] h2,
html[lang^="zh"] h3,
html[lang^="zh"] h4 {
  letter-spacing: 0;
  line-height: 1.45;
}

html[lang^="zh"] .h-display {
  letter-spacing: 0;
  line-height: 1.3;
}

html[lang^="zh"] .h-record {
  line-height: 1.45;
}

html[lang^="zh"] .lede,
html[lang^="zh"] .prose,
html[lang^="zh"] .fact p,
html[lang^="zh"] .rules-list p,
html[lang^="zh"] .footer-note {
  line-height: 1.85;
}

html[lang^="zh"] .chip,
html[lang^="zh"] .tag,
html[lang^="zh"] .badge,
html[lang^="zh"] .field-hint,
html[lang^="zh"] .meta-line {
  letter-spacing: 0;
}

/* ------------------------------------------------------------------ */
/* 22. Print                                                           */
/* ------------------------------------------------------------------ */

@media print {
  .site-header,
  .site-footer,
  .toolbar,
  .pager,
  .hero-ctas,
  .skip-link {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .panel,
  .file-card,
  .record-card {
    border-color: #999;
    box-shadow: none;
  }
  .item-side {
    position: static;
  }
}
