/* ==================================================================
   ARMS · assets/style.css  v7.0
   Government-grade refinement · Apple SF typography throughout
   Real mobile responsiveness · Hardened cybersecurity styling
   ================================================================== */

/* ── Design tokens — light (5% darker than pure white, sober) ───── */
:root {
  /* Surfaces */
  --bg:           #f4f4f6;
  --panel:        #ebebed;
  --raised:       #dededf;
  --card:         #f9f9fb;
  --input-bg:     #dededf;
  --overlay:      rgba(0,0,0,0.45);

  /* Interactive states */
  --hover:        rgba(0,0,0,0.04);
  --hover-strong: rgba(0,0,0,0.07);
  --sel:          rgba(21,88,64,0.08);
  --pressed:      rgba(0,0,0,0.10);

  /* Separators */
  --sep:          #d0d0d3;
  --sep-soft:     #e2e2e5;

  /* Text — institutional hierarchy */
  --tx-hi:        #1d1d1f;
  --tx-md:        #6e6e73;
  --tx-lo:        #86868b;
  --tx-faint:     #aeaeb2;

  /* Accent — deep emerald (sober, institutional, distinct from blue) */
  --accent:       #155840;
  --accent-h:     #0e3e2c;
  --accent-soft:  rgba(21,88,64,0.10);

  /* Status */
  --ok:           #1d8348;
  --warn:         #a06a14;
  --err:          #b3261e;

  /* Typography — Apple SF stack (every text element uses this) */
  --f-display:    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --f-body:       -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --f-mono:       ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, "Cascadia Mono", Consolas, monospace;

  /* Layout */
  --topbar-h:     58px;
  --toolbar-h:    44px;
  --thhd-h:       30px;
  --row-h:        36px;
  --si-h:         26px;
  --sidebar-w:    220px;
  --detail-w:     330px;
  --statusbar-h:  26px;

  /* Radii */
  --r-xs:         3px;
  --r-sm:         5px;
  --r-md:         7px;
  --r-lg:         10px;
  --r-xl:         14px;
  --r-pill:       999px;

  /* Shadows */
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.06);
  --shadow-modal: 0 20px 50px rgba(0,0,0,0.18), 0 6px 18px rgba(0,0,0,0.10);

  /* Transitions */
  --t-fast:       100ms cubic-bezier(0.4,0,0.2,1);
  --t-base:       180ms cubic-bezier(0.4,0,0.2,1);

  /* Safe-area insets for modern mobile devices (iOS notch, etc.) */
  --sa-top:       env(safe-area-inset-top, 0px);
  --sa-bot:       env(safe-area-inset-bottom, 0px);
  --sa-left:      env(safe-area-inset-left, 0px);
  --sa-right:     env(safe-area-inset-right, 0px);
}

/* ── Dark theme — slightly darker, low contrast preserved ───────── */
html.dark {
  --bg:           #1a1a1c;
  --panel:        #131315;
  --raised:       #262629;
  --card:         #1a1a1c;
  --input-bg:     #262629;
  --overlay:      rgba(0,0,0,0.62);

  --hover:        rgba(255,255,255,0.04);
  --hover-strong: rgba(255,255,255,0.07);
  --sel:          rgba(95,167,138,0.12);
  --pressed:      rgba(255,255,255,0.10);

  --sep:          #2c2c2f;
  --sep-soft:     #212124;

  --tx-hi:        #ebebed;
  --tx-md:        #9a9a9e;
  --tx-lo:        #717175;
  --tx-faint:     #4a4a4d;

  --accent:       #5fa78a;
  --accent-h:     #79bea0;
  --accent-soft:  rgba(95,167,138,0.12);

  --ok:           #4caf80;
  --warn:         #d4a76a;
  --err:          #e07065;

  --shadow-md:    0 6px 18px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.35);
  --shadow-modal: 0 28px 64px rgba(0,0,0,0.65), 0 8px 22px rgba(0,0,0,0.42);
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--tx-hi);
  font-family: var(--f-body);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.003em;
  text-rendering: optimizeLegibility;
}
html, body { overflow: hidden; }

a { color: inherit; text-decoration: none; font-family: inherit; }

button, input, textarea, select {
  font-family: var(--f-body);
  font-size: inherit;
  color: inherit;
}
button { cursor: pointer; border: none; background: none; }
[hidden] { display: none !important; }

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

::-webkit-scrollbar            { width: 8px; height: 8px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: transparent; border-radius: 4px; transition: background var(--t-base); }
*:hover > ::-webkit-scrollbar-thumb,
*:hover::-webkit-scrollbar-thumb { background: var(--sep); }
::-webkit-scrollbar-thumb:hover { background: var(--tx-faint); }

.material-symbols-outlined {
  font-variation-settings: 'opsz' 24, 'wght' 400, 'FILL' 0;
  user-select: none;
  vertical-align: middle;
  -webkit-user-select: none;
}

/* Visually hidden but accessible to screen readers */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ==================================================================
   SPLASH — sober, determinate, institutional
   ================================================================== */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  opacity: 1;
  transition: opacity 480ms cubic-bezier(0.4,0,0.2,1);
  font-family: var(--f-body);
}
.splash.hide { opacity: 0; pointer-events: none; }

.splash-content {
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  animation: splashIn 700ms cubic-bezier(0.4,0,0.2,1) both;
  padding: 0 24px;
}
@keyframes splashIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.splash-org {
  font-family: var(--f-display);
  font-size: 11px; font-weight: 500;
  color: var(--tx-md);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.splash-rule { width: 44px; height: 1px; background: var(--sep); margin: 14px auto 16px; }
.splash-system {
  font-family: var(--f-display);
  font-size: 22px; font-weight: 500;
  color: var(--tx-hi);
  letter-spacing: -0.014em;
  margin-bottom: 36px;
  max-width: 460px;
  line-height: 1.25;
}

/* Progress bar — thin, two-tone, deterministic */
.splash-bar {
  width: min(280px, 78vw);
  height: 2px;
  background: var(--sep);
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}
.splash-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  /* width is driven by JS via requestAnimationFrame */
  will-change: width;
}
/* Status row beneath the bar — institutional metadata */
.splash-meta {
  width: min(280px, 78vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--tx-md);
  letter-spacing: 0.04em;
  line-height: 1;
}
.splash-status {
  text-transform: uppercase;
  letter-spacing: 0.10em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.splash-pct {
  font-feature-settings: 'tnum' 1;
  color: var(--tx-hi);
  flex-shrink: 0;
  margin-left: 12px;
}

/* ==================================================================
   SHELL
   ================================================================== */
.app      { display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100vw; }
.body     { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.main-col { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ==================================================================
   TOPBAR
   ================================================================== */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  padding-left: max(18px, var(--sa-left));
  padding-right: max(18px, var(--sa-right));
  background: var(--panel);
  border-bottom: 1px solid var(--sep);
  font-family: var(--f-body);
}

.topbar-brand {
  display: flex; align-items: center;
  min-width: 0; gap: 10px;
}

/* Hamburger — visible only on mobile */
.menu-btn {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: var(--tx-md);
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.menu-btn:hover { background: var(--hover); color: var(--tx-hi); }
.menu-btn .material-symbols-outlined { font-size: 22px; }

.brand-text {
  display: flex; flex-direction: column;
  line-height: 1.1; min-width: 0;
}
.brand-name {
  font-family: var(--f-display);
  font-size: 13.5px; font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--tx-hi);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brand-org {
  font-family: var(--f-display);
  font-size: 10.5px; font-weight: 500;
  color: var(--tx-md);
  letter-spacing: 0.06em;
  margin-top: 3px;
  text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Search — pill-shaped */
.topbar-center { display: flex; justify-content: center; min-width: 0; }
.search-box {
  position: relative;
  width: 100%; max-width: 480px;
  height: 34px;
  display: flex; align-items: center;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 0 14px;
  transition: border-color var(--t-base), background var(--t-base);
}
.search-box:focus-within {
  border-color: var(--accent);
  background: var(--bg);
}
.search-ico { font-size: 17px; color: var(--tx-md); margin-right: 8px; flex-shrink: 0; }
.search-in {
  flex: 1; height: 100%; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--tx-hi);
  font-family: var(--f-body);
  font-size: 12.5px;
}
.search-in::placeholder { color: var(--tx-md); }
.search-in::-webkit-search-cancel-button,
.search-in::-webkit-search-decoration { display: none; -webkit-appearance: none; appearance: none; }

.search-clear {
  width: 22px; height: 22px;
  display: none; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--tx-md);
  margin-right: 2px;
}
.search-clear:hover { background: var(--hover-strong); color: var(--tx-hi); }
.search-clear .material-symbols-outlined { font-size: 14px; }
.search-box.has-value .search-clear { display: flex; }
.search-box.has-value .kbd { display: none; }

.kbd {
  font-family: var(--f-mono); font-size: 10px; font-weight: 500;
  color: var(--tx-md);
  padding: 1px 6px;
  background: var(--bg);
  border: 1px solid var(--sep);
  border-radius: var(--r-xs);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Right buttons */
.topbar-right { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }

.icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: var(--tx-md);
  font-family: var(--f-body);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--tx-hi); }
.icon-btn .material-symbols-outlined { font-size: 19px; }

.ghost-btn {
  height: 32px; padding: 0 12px;
  display: flex; align-items: center; gap: 6px;
  border-radius: var(--r-md);
  color: var(--tx-md);
  font-family: var(--f-body);
  font-size: 12px; font-weight: 500;
  letter-spacing: -0.005em;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.ghost-btn:hover { background: var(--hover); color: var(--tx-hi); }
.ghost-btn .material-symbols-outlined { font-size: 17px; }

/* ==================================================================
   SIDEBAR
   ================================================================== */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--sep);
  display: flex; flex-direction: column;
  overflow: hidden;
  font-family: var(--f-body);
}
.sidebar-body {
  flex: 1; overflow-y: auto;
  padding: 12px 8px;
  -webkit-overflow-scrolling: touch;
}
.nav-group { margin-bottom: 16px; }
.nav-group:last-child { margin-bottom: 0; }
.nav-lbl {
  font-family: var(--f-display);
  font-size: 10px; font-weight: 700;
  color: var(--tx-md);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0 10px 6px;
}

.si {
  height: var(--si-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--tx-md);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
  font-family: var(--f-body);
  font-size: 12px;
}
.si:hover { background: var(--hover); color: var(--tx-hi); }
.si.active {
  background: var(--hover-strong);
  color: var(--tx-hi);
  font-weight: 500;
}
.si .material-symbols-outlined { font-size: 16px; flex-shrink: 0; }
.si-lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-cnt {
  font-family: var(--f-mono);
  font-size: 10.5px; font-weight: 500;
  color: var(--tx-lo);
  min-width: 18px; text-align: right;
}
.si.active .si-cnt { color: var(--tx-md); }

.sidebar-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--sep);
}
.copy {
  font-family: var(--f-body);
  font-size: 10.5px; line-height: 1.55;
  color: var(--tx-lo);
}
.copy a { color: var(--tx-md); transition: color var(--t-fast); }
.copy a:hover { color: var(--accent); }

/* Mobile drawer scrim */
.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base);
}
.scrim.open { opacity: 1; pointer-events: auto; }

/* ==================================================================
   TOOLBAR
   ================================================================== */
.toolbar {
  height: var(--toolbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--sep);
  gap: 10px;
}
.toolbar-left { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.breadcrumb {
  font-family: var(--f-display);
  font-size: 14px; font-weight: 600;
  color: var(--tx-hi);
  letter-spacing: -0.008em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.res-count {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--tx-md);
  flex-shrink: 0;
}
.toolbar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.chip {
  height: 26px; padding: 0 11px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid var(--sep);
  color: var(--tx-md);
  font-family: var(--f-body);
  font-size: 11.5px; font-weight: 500;
  letter-spacing: -0.003em;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.chip:hover { border-color: var(--tx-faint); color: var(--tx-hi); }
.chip.active {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.vdiv { width: 1px; height: 16px; background: var(--sep); margin: 0 6px; }

.view-btn {
  width: 28px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--tx-md);
  transition: background var(--t-fast), color var(--t-fast);
}
.view-btn:hover { background: var(--hover); color: var(--tx-hi); }
.view-btn.active { background: var(--hover-strong); color: var(--tx-hi); }
.view-btn .material-symbols-outlined { font-size: 17px; }

/* ==================================================================
   CONTENT ROW
   ================================================================== */
.content-row { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.file-section {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.thhd {
  height: var(--thhd-h); flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(220px,1.8fr) 1fr 1fr 130px 80px 100px;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--sep);
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.th {
  font-family: var(--f-display);
  font-size: 10.5px; font-weight: 700;
  color: var(--tx-md);
  text-transform: uppercase; letter-spacing: 0.06em;
  user-select: none;
  display: flex; align-items: center; gap: 4px;
}
.th.r { justify-content: flex-end; }
.th.sortable { cursor: pointer; transition: color var(--t-fast); }
.th.sortable:hover { color: var(--tx-hi); }
.th.sort-asc, .th.sort-desc { color: var(--tx-hi); }
.sort-arrow { width: 8px; height: 12px; display: inline-block; position: relative; }
.sort-arrow::before, .sort-arrow::after {
  content: ''; position: absolute; left: 50%;
  width: 0; height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}
.sort-arrow::before { top: 1px;    transform: translateX(-50%); border-bottom: 3px solid currentColor; opacity: 0.25; }
.sort-arrow::after  { bottom: 1px; transform: translateX(-50%); border-top:    3px solid currentColor; opacity: 0.25; }
.th.sort-asc  .sort-arrow::before { opacity: 1; }
.th.sort-desc .sort-arrow::after  { opacity: 1; }

.file-area {
  flex: 1; overflow-y: auto;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

/* List rows */
.list-body { display: flex; flex-direction: column; }
.frow {
  height: var(--row-h);
  display: grid;
  grid-template-columns: minmax(220px,1.8fr) 1fr 1fr 130px 80px 100px;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--sep-soft);
  cursor: pointer;
  transition: background var(--t-fast);
}
.frow:hover { background: var(--hover); }
.frow.sel {
  background: var(--sel);
  box-shadow: inset 2px 0 0 var(--accent);
}
.fcell { overflow: hidden; min-width: 0; display: flex; align-items: center; }
.fcell.r { justify-content: flex-end; }
.fname {
  font-family: var(--f-body);
  font-weight: 500; font-size: 12.5px;
  color: var(--tx-hi);
  letter-spacing: -0.003em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fsubj, .fdtype {
  font-family: var(--f-body);
  font-size: 12px; color: var(--tx-md);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flangs {
  font-family: var(--f-mono);
  font-size: 11px; font-weight: 500;
  color: var(--tx-md);
  letter-spacing: 0.05em;
  display: flex; gap: 5px;
  overflow: hidden;
}
.flangs .flang { text-transform: uppercase; }
.fsize, .fdate {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--tx-md);
}

/* Grid view */
.grid-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; padding: 14px 18px;
}
.gcard {
  background: var(--card);
  border: 1px solid var(--sep);
  border-radius: var(--r-md);
  padding: 14px;
  cursor: pointer;
  transition: border-color var(--t-base), background var(--t-fast);
  display: flex; flex-direction: column;
  position: relative;
  font-family: var(--f-body);
}
.gcard:hover { border-color: var(--tx-faint); }
.gcard.sel {
  border-color: var(--accent);
  background: var(--sel);
}
.gcard-prev {
  height: 80px;
  display: flex; align-items: center; justify-content: center;
  background: var(--raised);
  border-radius: var(--r-sm);
  margin-bottom: 11px;
}
.gcard-prev .material-symbols-outlined {
  font-size: 30px; color: var(--tx-md);
  font-variation-settings: 'opsz' 32, 'wght' 300, 'FILL' 0;
}
.gcard-name {
  font-family: var(--f-display);
  font-weight: 600; font-size: 12.5px;
  color: var(--tx-hi);
  letter-spacing: -0.005em;
  margin-bottom: 4px; line-height: 1.35;
  overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
}
.gcard-sub {
  font-family: var(--f-body);
  font-size: 11.5px; color: var(--tx-md);
  margin-bottom: 8px;
  line-height: 1.4;
}
.gcard-langs {
  font-family: var(--f-mono);
  font-size: 10.5px; font-weight: 500;
  color: var(--tx-lo);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: auto;
}

/* Empty / no-results state */
.empty-state {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px;
  color: var(--tx-md);
  text-align: center;
  font-family: var(--f-body);
}
.empty-state .material-symbols-outlined {
  font-size: 44px; color: var(--tx-faint); margin-bottom: 14px;
  font-variation-settings: 'opsz' 48, 'wght' 200, 'FILL' 0;
}
.empty-state .empty-title {
  font-family: var(--f-display);
  font-weight: 600; font-size: 16px;
  color: var(--tx-hi);
  margin-bottom: 5px;
  letter-spacing: -0.008em;
}
.empty-state .empty-sub { font-size: 12.5px; max-width: 320px; }
.empty-state em {
  color: var(--tx-hi); font-style: normal;
  font-family: var(--f-mono); font-size: 11.5px;
}

/* ==================================================================
   DETAIL PANEL — text-first
   ================================================================== */
.detail-panel {
  width: var(--detail-w); flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--sep);
  display: flex; flex-direction: column;
  overflow: hidden;
  font-family: var(--f-body);
}
.detail-hd {
  height: var(--toolbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--sep);
}
.detail-hd-lbl {
  font-family: var(--f-display);
  font-size: 10.5px; font-weight: 700;
  color: var(--tx-md);
  text-transform: uppercase; letter-spacing: 0.08em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.detail-close {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--tx-md);
  transition: background var(--t-fast), color var(--t-fast);
}
.detail-close:hover { background: var(--hover-strong); color: var(--tx-hi); }
.detail-close .material-symbols-outlined { font-size: 15px; }

.detail-body {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Empty state */
.detail-empty {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
.detail-empty .empty-title {
  font-family: var(--f-display);
  font-weight: 600; font-size: 15px;
  color: var(--tx-hi);
  margin-bottom: 6px;
  letter-spacing: -0.008em;
}
.detail-empty .empty-sub {
  font-family: var(--f-body);
  font-size: 12px;
  color: var(--tx-md);
  max-width: 240px;
  line-height: 1.55;
}

.detail-content { display: flex; flex-direction: column; }

/* Hero */
.d-hero {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--sep);
}
.d-title {
  font-family: var(--f-display);
  font-weight: 600; font-size: 17px;
  line-height: 1.25; letter-spacing: -0.012em;
  color: var(--tx-hi);
  margin-bottom: 5px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.d-subtitle {
  font-family: var(--f-body);
  font-size: 12px;
  color: var(--tx-md);
}
.d-subtitle .d-version {
  margin-left: 6px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--tx-lo);
}

/* Sections */
.d-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--sep);
}
.d-section:last-of-type { border-bottom: none; }
.d-section-lbl {
  font-family: var(--f-display);
  font-size: 10px; font-weight: 700;
  color: var(--tx-md);
  text-transform: uppercase; letter-spacing: 0.10em;
  margin-bottom: 7px;
}
.d-value {
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--tx-hi);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.003em;
  overflow-wrap: anywhere;
}
.d-abstract {
  font-family: var(--f-body);
  font-size: 12.5px; line-height: 1.6;
  color: var(--tx-md);
  overflow-wrap: anywhere;
}

/* Available languages */
.d-langs {
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--tx-hi);
  display: flex; flex-wrap: wrap; gap: 4px 14px;
}
.d-langs .d-lang { display: inline-flex; align-items: center; gap: 6px; }
.d-langs .d-lang::before {
  content: ''; width: 4px; height: 4px;
  background: var(--tx-faint);
  border-radius: 50%;
}

/* Details mini-table */
.d-meta { display: flex; flex-direction: column; gap: 6px; }
.d-meta-row {
  display: grid; grid-template-columns: 90px 1fr; align-items: baseline;
  font-size: 12.5px;
}
.d-meta-row > span:first-child {
  font-family: var(--f-display);
  color: var(--tx-md);
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 500;
}
.d-meta-row > span:last-child {
  color: var(--tx-hi);
  font-family: var(--f-mono);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

/* Footer */
.detail-foot {
  flex-shrink: 0;
  display: flex; gap: 8px;
  padding: 12px 14px;
  padding-bottom: max(12px, var(--sa-bot));
  background: var(--panel);
  border-top: 1px solid var(--sep);
}
.d-btn {
  flex: 1; height: 34px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r-md);
  font-family: var(--f-body);
  font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.005em;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.d-btn .material-symbols-outlined { font-size: 16px; }
.d-btn-primary { background: var(--accent); color: white; }
.d-btn-primary:hover { background: var(--accent-h); }
.d-btn-ghost {
  background: var(--raised);
  color: var(--tx-hi);
  border: 1px solid var(--sep);
}
.d-btn-ghost:hover { background: var(--hover-strong); }

/* ==================================================================
   STATUSBAR
   ================================================================== */
.statusbar {
  height: var(--statusbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
  padding: 0 14px;
  padding-bottom: var(--sa-bot);
  background: var(--panel);
  border-top: 1px solid var(--sep);
  font-family: var(--f-body);
  font-size: 10.5px; color: var(--tx-md);
  overflow: hidden; white-space: nowrap;
}
.sb { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.sb-sep { color: var(--tx-lo); margin: 0 4px; flex-shrink: 0; }
.sb-kbd {
  font-family: var(--f-mono);
  font-size: 9.5px;
  padding: 1px 4px;
  background: var(--bg);
  border: 1px solid var(--sep);
  border-radius: 2px;
  color: var(--tx-md);
}

/* ==================================================================
   MODAL
   ================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 20px;
  padding-top: max(20px, var(--sa-top));
  padding-bottom: max(20px, var(--sa-bot));
  animation: bdIn 180ms cubic-bezier(0.4,0,0.2,1);
}
@keyframes bdIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  background: var(--card);
  border: 1px solid var(--sep);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: modalIn 220ms cubic-bezier(0.34,1.2,0.64,1);
  font-family: var(--f-body);
}
.modal-narrow { max-width: 440px; }
.modal-wide   { max-width: 880px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--tx-md);
  transition: background var(--t-fast), color var(--t-fast);
  z-index: 2;
}
.modal-close:hover { background: var(--hover-strong); color: var(--tx-hi); }
.modal-close .material-symbols-outlined { font-size: 18px; }

.modal-hd {
  padding: 24px 26px 14px;
  border-bottom: 1px solid var(--sep);
}
.modal-wide .modal-hd { padding: 26px 36px 16px; }
.modal-title {
  font-family: var(--f-display);
  font-weight: 600; font-size: 18px;
  letter-spacing: -0.012em;
  color: var(--tx-hi);
  margin-bottom: 5px;
}
.modal-sub {
  font-family: var(--f-body);
  font-size: 12.5px; line-height: 1.5;
  color: var(--tx-md);
  max-width: 460px;
}

.modal-foot {
  padding: 14px 26px;
  display: flex; justify-content: flex-end;
  border-top: 1px solid var(--sep);
}

/* Language picker options */
.lang-options {
  padding: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.lang-option {
  display: grid; grid-template-columns: 32px 1fr auto;
  align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--tx-hi);
  text-align: left;
  transition: background var(--t-fast), border-color var(--t-fast);
  cursor: pointer;
  font-family: var(--f-body);
  width: 100%;
}
.lang-option:hover {
  background: var(--hover);
  border-color: var(--sep);
}
.lang-option .lo-code {
  font-family: var(--f-mono);
  font-size: 11px; font-weight: 600;
  color: var(--tx-md);
  letter-spacing: 0.04em;
}
.lang-option .lo-name {
  font-family: var(--f-body);
  font-size: 13.5px; font-weight: 500;
  color: var(--tx-hi);
  letter-spacing: -0.005em;
}
.lang-option .lo-meta {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--tx-md);
  overflow: hidden; text-overflow: ellipsis;
  max-width: 220px; white-space: nowrap;
}

/* ==================================================================
   CONTRIBUTE MODAL — tutorial + form
   ================================================================== */

/* Tutorial section */
.ctb-tutorial { padding: 28px 36px 12px; }
.ctb-eyebrow {
  font-family: var(--f-display);
  font-size: 10.5px; font-weight: 700;
  color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.10em;
  margin-bottom: 12px;
}
.ctb-headline {
  font-family: var(--f-display);
  font-weight: 600; font-size: 26px;
  letter-spacing: -0.018em;
  color: var(--tx-hi);
  margin-bottom: 12px;
  line-height: 1.22;
}
.ctb-lede {
  font-family: var(--f-body);
  font-size: 13.5px; line-height: 1.65;
  color: var(--tx-md);
  margin-bottom: 24px;
  max-width: 680px;
}

/* Cards explaining the philosophy */
.ctb-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.ctb-card {
  display: flex; flex-direction: column;
  padding: 18px 20px;
  background: transparent;
  border: 1px solid var(--sep);
  border-radius: var(--r-md);
}
.ctb-card-ico {
  font-size: 22px;
  color: var(--accent);
  margin-bottom: 10px;
  font-variation-settings: 'opsz' 24, 'wght' 400, 'FILL' 0;
}
.ctb-card-title {
  font-family: var(--f-display);
  font-weight: 600; font-size: 14px;
  color: var(--tx-hi);
  letter-spacing: -0.008em;
  margin-bottom: 6px;
}
.ctb-card-body {
  font-family: var(--f-body);
  font-size: 12.5px; line-height: 1.55;
  color: var(--tx-md);
}

/* Skip-tutorial button */
.ctb-skip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 16px;
  background: transparent;
  border: 1px solid var(--sep);
  border-radius: var(--r-pill);
  color: var(--tx-md);
  font-family: var(--f-body);
  font-size: 12px; font-weight: 500;
  margin-bottom: 4px;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.ctb-skip:hover { border-color: var(--accent); color: var(--accent); }
.ctb-skip .material-symbols-outlined { font-size: 14px; }

/* Divider between tutorial and form */
.ctb-divider {
  border: none;
  height: 1px;
  background: var(--sep);
  margin: 24px 0 0;
}

/* Form */
.ctb-form { padding: 26px 36px 6px; }
.ctb-form-title {
  font-family: var(--f-display);
  font-weight: 600; font-size: 17px;
  color: var(--tx-hi);
  letter-spacing: -0.012em;
  margin-bottom: 18px;
  scroll-margin-top: 18px;
}

.ctb-section {
  font-family: var(--f-display);
  font-size: 11px; font-weight: 700;
  color: var(--tx-md);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 22px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--sep);
}
.ctb-section:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.ctb-field { margin-bottom: 14px; }

.ctb-label-strong {
  display: block;
  font-family: var(--f-body);
  font-size: 13px; font-weight: 600;
  color: var(--tx-hi);
  margin-bottom: 12px;
  letter-spacing: -0.005em;
}

/* Type selector — radio cards */
.ctb-types { display: grid; grid-template-columns: 1fr; gap: 8px; }
.ctb-type { position: relative; display: block; cursor: pointer; }
.ctb-type input { position: absolute; opacity: 0; pointer-events: none; }
.ctb-type-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center; gap: 14px;
  padding: 14px 16px;
  background: transparent;
  border: 1px solid var(--sep);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.ctb-type:hover .ctb-type-card { border-color: var(--tx-faint); }
.ctb-type input:checked + .ctb-type-card {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.ctb-type input:focus-visible + .ctb-type-card {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ctb-type-ico {
  font-size: 24px;
  color: var(--tx-md);
  font-variation-settings: 'opsz' 24, 'wght' 400, 'FILL' 0;
  transition: color var(--t-fast);
}
.ctb-type input:checked + .ctb-type-card .ctb-type-ico { color: var(--accent); }
.ctb-type-text { display: flex; flex-direction: column; min-width: 0; }
.ctb-type-name {
  font-family: var(--f-display);
  font-size: 13.5px; font-weight: 600;
  color: var(--tx-hi);
  letter-spacing: -0.005em;
  margin-bottom: 2px;
}
.ctb-type-desc {
  font-family: var(--f-body);
  font-size: 12px; line-height: 1.45;
  color: var(--tx-md);
}

/* Conditional field groups */
.ctb-conditional { animation: ctbFade 220ms cubic-bezier(0.4,0,0.2,1); }
@keyframes ctbFade {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Verification notice — important info banner */
.ctb-notice {
  display: flex; gap: 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--input-bg);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm);
  font-family: var(--f-body);
  font-size: 12px; line-height: 1.6;
  color: var(--tx-md);
}
.ctb-notice strong { font-weight: 600; color: var(--tx-hi); }
.ctb-notice-ico {
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
  font-variation-settings: 'opsz' 20, 'wght' 400, 'FILL' 0;
}

/* Hint at bottom */
.ctb-hint {
  display: flex; gap: 12px;
  margin-top: 22px;
  padding: 14px 16px;
  background: var(--input-bg);
  border-radius: var(--r-md);
  font-family: var(--f-body);
  font-size: 12px; line-height: 1.55;
  color: var(--tx-md);
}
.ctb-hint-ico {
  font-size: 17px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
  font-variation-settings: 'opsz' 20, 'wght' 400, 'FILL' 0;
}
.ctb-email {
  font-family: var(--f-mono);
  color: var(--tx-hi);
  overflow-wrap: anywhere;
}

/* Modal footer for contribute */
.ctb-foot {
  padding: 16px 36px;
  padding-bottom: max(16px, var(--sa-bot));
  margin-top: 6px;
  display: flex; gap: 12px; justify-content: flex-end;
}

/* ==================================================================
   FORM CONTROLS — shared input/button styles
   ================================================================== */
.fb-form { padding: 20px 26px 22px; }
.fb-field { margin-bottom: 16px; }
.fb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.fb-row > .fb-field { margin-bottom: 0; }

.fb-label {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--f-display);
  font-size: 11px; font-weight: 700;
  color: var(--tx-hi);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 6px;
}
.fb-opt {
  font-family: var(--f-body);
  font-weight: 400; text-transform: none;
  letter-spacing: 0; font-size: 11px;
  color: var(--tx-md); font-style: italic;
}

/* Required marker — discreet red asterisk, no text */
.fb-req {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  color: var(--err);
  text-transform: none;
  letter-spacing: 0;
  margin-left: -2px;
  position: relative;
  top: 1px;
}

.fb-input {
  width: 100%;
  padding: 9px 11px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--tx-hi);
  font-family: var(--f-body);
  font-size: 12.5px;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast);
  -webkit-appearance: none; appearance: none;
}
.fb-input::placeholder { color: var(--tx-md); }
.fb-input:focus {
  border-color: var(--accent);
  background: var(--bg);
}
.fb-input.invalid { border-color: var(--err); }
.fb-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.55;
  font-family: var(--f-body);
}

.fb-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 18px;
}
.fb-btn {
  height: 36px; padding: 0 16px;
  display: flex; align-items: center; gap: 6px;
  border-radius: var(--r-md);
  font-family: var(--f-body);
  font-size: 12.5px; font-weight: 600;
  letter-spacing: -0.003em;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.fb-btn .material-symbols-outlined { font-size: 16px; }
.fb-btn-ghost {
  background: transparent;
  color: var(--tx-md);
  border: 1px solid var(--sep);
}
.fb-btn-ghost:hover { color: var(--tx-hi); border-color: var(--tx-faint); }
.fb-btn-primary { background: var(--accent); color: white; }
.fb-btn-primary:hover { background: var(--accent-h); }
.fb-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==================================================================
   TOAST
   ================================================================== */
.toast {
  position: fixed; bottom: max(50px, calc(var(--sa-bot) + 24px)); left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 200;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  background: var(--card);
  border: 1px solid var(--sep);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-md);
  font-family: var(--f-body);
  font-size: 12px; font-weight: 500;
  color: var(--tx-hi);
  letter-spacing: -0.003em;
  opacity: 0;
  transition: opacity 220ms cubic-bezier(0.34,1.3,0.64,1), transform 220ms cubic-bezier(0.34,1.3,0.64,1);
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast .material-symbols-outlined { font-size: 16px; color: var(--ok); flex-shrink: 0; }
.toast.err .material-symbols-outlined { color: var(--err); }
.toast > span:last-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 70vw;
}

/* ==================================================================
   RESPONSIVE — tablet and mobile breakpoints
   The platform is fully usable on small screens.
   ================================================================== */

/* Narrow desktop / large tablet */
@media (max-width: 1180px) {
  :root {
    --sidebar-w: 200px;
    --detail-w: 300px;
  }
  .thhd, .frow {
    grid-template-columns: minmax(180px,1.7fr) 0.9fr 0.9fr 110px 70px 90px;
  }
}

/* Tablet — hide detail panel inline; selecting opens it as overlay */
@media (max-width: 980px) {
  .detail-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(380px, 100vw);
    z-index: 80;
    box-shadow: var(--shadow-modal);
    transform: translateX(100%);
    transition: transform var(--t-base);
  }
  .detail-panel.open { transform: translateX(0); }
  .ctb-cards { grid-template-columns: 1fr 1fr; }
  .topbar { grid-template-columns: 1fr 1.4fr auto; }
  .ghost-btn-lbl { display: none; }
}

/* Mobile — full responsive mode */
@media (max-width: 720px) {
  :root {
    --topbar-h:   54px;
    --toolbar-h:  42px;
    --row-h:      auto;
    --thhd-h:     0px;
  }

  body { font-size: 14px; }

  /* Splash — slightly compact on mobile, still legible */
  .splash-org      { font-size: 10.5px; letter-spacing: 0.20em; }
  .splash-rule     { width: 40px; margin: 13px auto 15px; }
  .splash-system   { font-size: 19px; margin-bottom: 30px; max-width: 340px; line-height: 1.22; }
  .splash-bar, .splash-meta { width: min(240px, 72vw); }
  .splash-meta     { font-size: 10px; margin-top: 12px; }

  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 0 12px;
    padding-left: max(12px, var(--sa-left));
    padding-right: max(12px, var(--sa-right));
  }
  .menu-btn       { display: flex; width: 38px; height: 38px; }
  .menu-btn .material-symbols-outlined { font-size: 22px; }
  .topbar-brand   { gap: 8px; }
  .topbar-brand .brand-text { display: none; }
  .topbar-center  { justify-content: stretch; }
  .search-box     { max-width: 100%; height: 36px; padding: 0 14px; }
  .search-in      { font-size: 14px; }
  .kbd            { display: none; }
  .ghost-btn      { padding: 0; width: 34px; height: 34px; justify-content: center; }
  .ghost-btn .ghost-btn-lbl { display: none; }
  .ghost-btn .material-symbols-outlined { font-size: 19px; }
  .icon-btn       { width: 34px; height: 34px; }
  .icon-btn .material-symbols-outlined { font-size: 19px; }

  /* Sidebar drawer */
  .sidebar {
    position: fixed;
    top: var(--topbar-h); bottom: 0;
    left: 0;
    width: 280px;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    box-shadow: var(--shadow-modal);
  }
  .sidebar.open { transform: translateX(0); }

  /* Toolbar — comfortable, chips wrap if needed */
  .toolbar {
    flex-wrap: wrap;
    height: auto; min-height: var(--toolbar-h);
    padding: 7px 12px;
    gap: 8px;
  }
  .toolbar-left   { gap: 10px; }
  .toolbar-right  { flex-wrap: wrap; gap: 5px; }
  .breadcrumb     { font-size: 14px; }
  .res-count      { font-size: 11px; }
  .chip           { height: 26px; padding: 0 11px; font-size: 11.5px; }
  .vdiv           { display: none; }
  #btn-list, #btn-grid { display: none; }

  .thhd { display: none; }
  .file-area { padding: 8px 10px 14px; -webkit-overflow-scrolling: touch; }

  /* List rows — readable cards. Density via spacing, not by shrinking type. */
  .list-body { gap: 6px; display: flex; flex-direction: column; }
  .frow {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "title   size"
      "subject date"
      "langs   langs";
    height: auto; min-height: 60px;
    padding: 11px 13px;
    background: var(--card);
    border: 1px solid var(--sep);
    border-radius: var(--r-md);
    gap: 3px 12px;
  }
  .frow.sel { box-shadow: inset 0 0 0 2px var(--accent); }
  .fcell { white-space: normal; }
  .fcell.r { justify-content: flex-end; }
  .fcell:nth-child(1) { grid-area: title; }
  .fcell:nth-child(2) { grid-area: subject; }
  .fcell:nth-child(3) { display: none; }      /* type — hidden on small screens */
  .fcell:nth-child(4) { grid-area: langs; margin-top: 2px; }
  .fcell:nth-child(5) { grid-area: size; }
  .fcell:nth-child(6) { grid-area: date; }
  .fname  { font-size: 14px; line-height: 1.35; font-weight: 500; white-space: normal; }
  .fsubj  { font-size: 12px; }
  .flangs { gap: 6px; font-size: 10.5px; }
  .fsize, .fdate { font-size: 11px; }

  /* Grid view */
  .grid-body {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px; padding: 10px;
  }
  .gcard         { padding: 12px; }
  .gcard-prev    { height: 70px; margin-bottom: 9px; }
  .gcard-prev .material-symbols-outlined { font-size: 26px; }
  .gcard-name    { font-size: 13px; line-height: 1.3; }
  .gcard-sub     { font-size: 11.5px; margin-bottom: 7px; }
  .gcard-langs   { font-size: 10px; }

  /* Detail panel — bottom sheet */
  .detail-panel {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%;
    height: 78vh; height: 78dvh;
    border-left: none;
    border-top: 1px solid var(--sep);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
  }
  .detail-panel.open { transform: translateY(0); }
  .d-hero        { padding: 16px 20px 14px; }
  .d-title       { font-size: 17px; }
  .d-subtitle    { font-size: 12px; }
  .d-section     { padding: 13px 20px; }
  .d-section-lbl { margin-bottom: 6px; }
  .d-value       { font-size: 13px; }
  .d-abstract    { font-size: 12.5px; line-height: 1.6; }
  .detail-foot   { padding: 11px 12px; padding-bottom: max(11px, var(--sa-bot)); }
  .d-btn         { height: 38px; font-size: 12.5px; }

  .statusbar { display: none; }

  /* Modals — full-screen, comfortable for thumbs */
  .modal-backdrop { padding: 0; }
  .modal {
    max-width: 100%;
    max-height: 100vh; max-height: 100dvh;
    height: 100vh; height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .modal-narrow, .modal-wide { max-width: 100%; }
  .modal-close   { top: 10px; right: 10px; }
  .modal-hd, .modal-wide .modal-hd { padding: 22px 22px 14px; }
  .modal-foot, .ctb-foot { padding-left: 22px; padding-right: 22px; }
  .modal-title   { font-size: 17px; }
  .modal-sub     { font-size: 12.5px; }

  /* Contribute modal — relaxed mobile rhythm */
  .ctb-tutorial   { padding: 20px 22px 10px; }
  .ctb-form       { padding: 22px 22px 6px; }
  .ctb-eyebrow    { font-size: 10.5px; margin-bottom: 10px; letter-spacing: 0.10em; }
  .ctb-headline   { font-size: 21px; margin-bottom: 10px; line-height: 1.22; }
  .ctb-lede       { font-size: 13px; line-height: 1.6; margin-bottom: 20px; }
  .ctb-cards      { grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
  .ctb-card       { padding: 15px 17px; }
  .ctb-card-ico   { font-size: 21px; margin-bottom: 8px; }
  .ctb-card-title { font-size: 13.5px; margin-bottom: 5px; }
  .ctb-card-body  { font-size: 12px; line-height: 1.5; }
  .ctb-skip       { height: 32px; font-size: 12px; padding: 0 16px; }
  .ctb-divider    { margin-top: 22px; }
  .ctb-form-title { font-size: 16px; margin-bottom: 16px; }
  .ctb-section    { font-size: 11px; margin: 20px 0 12px; padding-top: 16px; }
  .ctb-types      { gap: 7px; }
  .ctb-type-card  { padding: 13px 15px; gap: 12px; grid-template-columns: 32px 1fr; }
  .ctb-type-ico   { font-size: 22px; }
  .ctb-type-name  { font-size: 13px; margin-bottom: 2px; }
  .ctb-type-desc  { font-size: 12px; line-height: 1.45; }
  .ctb-notice     { padding: 12px 14px; font-size: 12px; line-height: 1.6; gap: 11px; }
  .ctb-notice-ico { font-size: 18px; }
  .ctb-hint       { padding: 12px 14px; font-size: 12px; margin-top: 20px; gap: 11px; }
  .ctb-hint-ico   { font-size: 17px; }

  .fb-row         { grid-template-columns: 1fr; gap: 0; margin-bottom: 0; }
  .fb-row > .fb-field { margin-bottom: 14px; }
  .fb-field       { margin-bottom: 14px; }
  .fb-label       { font-size: 11px; margin-bottom: 6px; letter-spacing: 0.06em; }
  .fb-input       { font-size: 16px; padding: 11px 12px; }   /* 16px prevents iOS zoom */
  .fb-textarea    { min-height: 100px; }
  .fb-btn         { height: 40px; padding: 0 18px; font-size: 13px; }
  .ctb-foot {
    padding: 13px 22px;
    padding-bottom: max(13px, var(--sa-bot));
    background: var(--card);
    position: sticky; bottom: 0;
    border-top: 1px solid var(--sep);
    margin-top: 0;
    gap: 10px;
  }
  .ctb-foot .fb-btn { flex: 1; justify-content: center; }

  /* Toast — readable */
  .toast { max-width: calc(100vw - 24px); padding: 10px 18px; font-size: 13px; }
  .toast > span:last-child { max-width: calc(100vw - 90px); white-space: normal; }
}

/* Very small phones */
@media (max-width: 380px) {
  .topbar       { gap: 6px; padding: 0 10px; }
  .toolbar      { padding: 6px 10px; }
  .chip         { padding: 0 10px; font-size: 11px; height: 24px; }
  .breadcrumb   { font-size: 13px; }
  .res-count    { font-size: 10.5px; }
  .frow         { padding: 10px 12px; min-height: 56px; }
  .fname        { font-size: 13.5px; }
  .ctb-headline { font-size: 19px; }
  .ctb-lede     { font-size: 12.5px; }
  .modal-hd, .modal-wide .modal-hd { padding: 18px 18px 12px; }
  .ctb-tutorial { padding: 16px 18px 6px; }
  .ctb-form     { padding: 18px 18px 4px; }
  .ctb-foot     { padding: 12px 18px; padding-bottom: max(12px, var(--sa-bot)); }
}

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

/* High-contrast mode tweaks (Windows / forced colors) */
@media (forced-colors: active) {
  .frow.sel, .gcard.sel { outline: 2px solid CanvasText; }
  .chip.active, .ctb-type input:checked + .ctb-type-card { outline: 2px solid Highlight; }
}

/* Print styles — hide UI chrome, show pure content */
@media print {
  .topbar, .sidebar, .toolbar, .detail-panel, .statusbar, .splash, .scrim,
  .modal-backdrop, .toast { display: none !important; }
  .file-area { overflow: visible; }
}
