/* CosmosEx web UI
   Tokens: design/tokens.css from the ce-webui-redesign package, unchanged
   except @font-face (Barlow and Barlow Condensed have no variable version;
   the static weights the spec uses are self-hosted instead). */

/* ---------------------------------------------------------------- tokens */

:root,
[data-theme] {
  --bg: #121417;
  --panel: #1A1D21;
  --panel2: #22262C;
  --line: #2A2F36;
  --line2: #3A4149;
  --fg: #E8E6E1;
  --fg2: #B8BDC4;
  --mute: #8E949C;
  --dim: #6B727A;
  --accent: #F5A623;
  --accent-fg: #121417;
  --accent-text: #FFB84D;
  --accent-soft: rgba(245, 166, 35, 0.10);
  --accent-line: rgba(245, 166, 35, 0.45);
  --ok: #4CC38A;
  --danger: #F0614F;
  --danger-line: rgba(240, 97, 79, 0.5);
  --field: #121417;
  --key: #262B31;
  --keymod: #1F2328;
  --keyedge: #0E1012;
  --screen: #050607;
  --chip: #22262C;
  --chip-fg: #C9CDD2;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #EEF0F2;
  --panel: #FFFFFF;
  --panel2: #E6E8EB;
  --line: #D6D9DE;
  --line2: #BFC4CB;
  --fg: #15181C;
  --fg2: #3B4149;
  --mute: #5E656E;
  --dim: #8A9097;
  --accent: #E59A12;
  --accent-fg: #15181C;
  --accent-text: #9A5F00;
  --accent-soft: rgba(229, 154, 18, 0.12);
  --accent-line: rgba(229, 154, 18, 0.55);
  --ok: #1E8E5A;
  --danger: #C53D2C;
  --danger-line: rgba(197, 61, 44, 0.5);
  --field: #FFFFFF;
  --key: #F7F8F9;
  --keymod: #E6E8EB;
  --keyedge: #BFC4CB;
  --screen: #0B0D0F;
  --chip: #E6E8EB;
  --chip-fg: #3B4149;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --bg: #EEF0F2;
    --panel: #FFFFFF;
    --panel2: #E6E8EB;
    --line: #D6D9DE;
    --line2: #BFC4CB;
    --fg: #15181C;
    --fg2: #3B4149;
    --mute: #5E656E;
    --dim: #8A9097;
    --accent: #E59A12;
    --accent-fg: #15181C;
    --accent-text: #9A5F00;
    --accent-soft: rgba(229, 154, 18, 0.12);
    --accent-line: rgba(229, 154, 18, 0.55);
    --ok: #1E8E5A;
    --danger: #C53D2C;
    --danger-line: rgba(197, 61, 44, 0.5);
    --field: #FFFFFF;
    --key: #F7F8F9;
    --keymod: #E6E8EB;
    --keyedge: #BFC4CB;
    --screen: #0B0D0F;
    --chip: #E6E8EB;
    --chip-fg: #3B4149;
    color-scheme: light;
  }
}

/* The sidebar (wide) and top bar (narrow) are always dark, in both themes. */
:root {
  --side-bg: #0E1012;
  --side-fg: #E8E6E1;
  --side-fg2: #B8BDC4;
  --side-mute: #8E949C;
  --side-line: #2A2F36;
  --side-line2: #3A4149;
  --side-accent: #F5A623;
  --side-accent-text: #FFB84D;
  --side-accent-soft: rgba(245, 166, 35, 0.10);
}

/* Self-hosted fonts (Fontsource 5.2.8, Latin subset, OFL; see fonts/LICENSE-*) */
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("../fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("../fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("../fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 3px;
  --radius-panel: 4px;
  --tap: 44px;

  --page-max: 1240px;
  --sidebar-w: 232px;
  --bottom-nav-h: 60px;
}

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

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font-body); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: var(--accent-text); }
a:hover { color: var(--accent-text); text-decoration: underline; }
input::placeholder { color: var(--dim); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 10;
  padding: 10px 14px; background: var(--accent); color: var(--accent-fg);
  font-family: var(--font-display); font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
.skip:focus { top: 8px; }

.mono { font-family: var(--font-mono); }

.dot { display: inline-block; flex: none; width: 6px; height: 6px; }
.dot-ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot-bad { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.dot-off { background: var(--mute); }
.cf-warn, .hint.cf-warn { color: var(--danger); }
.dot-dim { background: var(--dim); }

/* ----------------------------------------------------------------- shell */

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Sidebar: wide screens only */
.sidebar {
  display: none;
  width: var(--sidebar-w); flex: none;
  background: var(--side-bg); color: var(--side-fg);
  border-right: 1px solid var(--side-line);
  flex-direction: column; gap: 24px; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { color: var(--side-accent); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .04em; text-transform: uppercase; }
.brand-host { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--side-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap); padding: 0 12px;
  border-left: 2px solid transparent; border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--side-fg2); text-decoration: none;
  font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.nav-item:hover { color: var(--side-fg); text-decoration: none; background: rgba(255, 255, 255, .03); }
.nav-item[aria-current="page"] { border-left-color: var(--side-accent); background: var(--side-accent-soft); color: var(--side-accent-text); }
.nav-sep { margin-top: 8px; border-top: 1px solid var(--side-line); padding-top: 8px; }
.nav-ext { color: var(--side-mute); padding-left: 14px; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }

.theme-switch {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--side-line2); border-radius: var(--radius); overflow: hidden;
}
.theme-switch button {
  min-height: 36px; border: 0; border-right: 1px solid var(--side-line2);
  background: transparent; color: var(--side-fg2);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; cursor: pointer;
}
.theme-switch button:last-child { border-right: 0; }
.theme-switch button[aria-pressed="true"] { background: var(--side-accent); color: #121417; }

.side-status {
  margin: 0; border-top: 1px solid var(--side-line); padding: 14px 6px 0;
  display: flex; flex-direction: column; gap: 6px;
  font-family: var(--font-mono); font-size: 12px; color: var(--side-mute);
}
.side-status > div { display: flex; justify-content: space-between; gap: 8px; }
.side-status dt { margin: 0; }
.side-status dd { margin: 0; display: inline-flex; align-items: center; gap: 6px; color: var(--side-fg); min-width: 0; }
.side-status .side-floppy { color: var(--side-accent-text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-version { padding: 0 6px; font-family: var(--font-mono); font-size: 12px; color: #6B727A; }

/* Top bar and drawer: narrow screens only */
.topbar { background: var(--side-bg); color: var(--side-fg); border-bottom: 1px solid var(--side-line); }
.topbar-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; min-height: 60px; }
.menu-btn {
  width: var(--tap); height: var(--tap); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--side-line2); border-radius: var(--radius);
  background: transparent; color: var(--side-fg); cursor: pointer;
}
.menu-btn .icon-close { display: none; }
.menu-btn[aria-expanded="true"] { background: var(--side-accent); border-color: var(--side-accent); color: #121417; }
.menu-btn[aria-expanded="true"] .icon-open { display: none; }
.menu-btn[aria-expanded="true"] .icon-close { display: block; }
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.topbar-page { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .04em; text-transform: uppercase; }
.topbar-sub, .conn { font-family: var(--font-mono); font-size: 11px; color: var(--side-mute); }
.conn { display: inline-flex; align-items: center; gap: 6px; }

.drawer { padding: 8px 12px 16px; border-top: 1px solid var(--side-line); }
.drawer .nav-item { min-height: 52px; gap: 14px; padding: 0 14px; font-size: 20px; }
.drawer .nav-label { flex: 1; }
.drawer .nav-hint { font-family: var(--font-body); font-size: 13px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--side-mute); }
.drawer .nav-sep { margin-top: 6px; padding-top: 6px; }
.drawer-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px 0; }
.drawer-foot .theme-switch { width: 210px; }
.drawer-foot .theme-switch button { min-height: 40px; }
.drawer-status { display: flex; gap: 14px; font-family: var(--font-mono); font-size: 12px; color: var(--side-mute); }
.drawer-status > span { display: inline-flex; align-items: center; gap: 6px; }

/* Connection lost bar */
.conn-bar {
  position: sticky; top: 0; z-index: 3;
  padding: 8px 16px; background: var(--accent); color: var(--accent-fg);
  font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; text-align: center;
}

/* Page area */
/* overflow-x: clip, not hidden: clips the page slide animation the same way
   without making .page a scroll container, so position: sticky inside it
   (the Config navigation) sticks to the window. hidden is the fallback for
   browsers without clip (Safari < 16), where sticky then doesn't stick. */
.page { flex: 1 1 0; min-width: 0; padding: 20px 16px; outline: none; touch-action: pan-y; overflow-x: hidden; overflow-x: clip; }
.page-inner { max-width: var(--page-max); margin: 0 auto; }
.page-inner[data-anim="next"] { animation: ce-in-next 200ms ease-out; }
.page-inner[data-anim="prev"] { animation: ce-in-prev 200ms ease-out; }
@keyframes ce-in-next { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ce-in-prev { from { transform: translateX(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .page-inner[data-anim] { animation: none; } }

/* Page switcher: narrow screens only */
.pager {
  position: sticky; bottom: 0; z-index: 2;
  height: var(--bottom-nav-h); background: var(--panel); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 6px;
}
.pager button {
  min-width: 100px; min-height: var(--tap); padding: 0 10px; border: 0; background: transparent;
  color: var(--accent-text); cursor: pointer;
  font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.pager-prev { text-align: left; }
.pager-next { text-align: right; }
.pager button[disabled] { visibility: hidden; }
.pager-dots { display: flex; align-items: center; }
.pager-dots a { width: 28px; height: var(--tap); display: inline-flex; align-items: center; justify-content: center; }
.pager-dots span { display: block; width: 6px; height: 6px; background: var(--line2); transition: width 150ms ease-out; }
.pager-dots a[aria-current="page"] span { width: 22px; background: var(--accent); }

/* Wide layout */
@media (min-width: 760px) {
  .app { flex-direction: row; }
  .sidebar { display: flex; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .topbar, .pager { display: none; }
  .page { padding: 36px 32px; }
  .conn-bar { position: fixed; left: var(--sidebar-w); right: 0; }
}

/* ------------------------------------------------------------ components */

/* Page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 6px; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); }
h1 { margin: 0; font-family: var(--font-display); font-size: 44px; font-weight: 700; line-height: 1; text-transform: uppercase; letter-spacing: .02em; }
.page-hint { margin: 10px 0 0; color: var(--mute); font-size: 14px; max-width: 60ch; }
h2 { margin: 0 0 14px; font-family: var(--font-display); font-size: 21px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--fg2); }
h3 { margin: 0 0 10px; font-family: var(--font-display); font-size: 17px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Panel */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 20px 22px; }
.panel-accent { border-top: 3px solid var(--accent); }
.hint { color: var(--mute); font-size: 13px; }

/* Stat grid */
.stat-grid { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-grid > * { background: var(--panel); padding: 14px 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius); cursor: pointer; text-decoration: none;
  font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border: 0; }
.btn-primary:hover { color: var(--accent-fg); filter: brightness(1.06); }
.btn-secondary { background: transparent; color: var(--fg); border: 1px solid var(--line2); }
.btn-secondary:hover { color: var(--fg); border-color: var(--mute); }
.btn-secondary[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger-line); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Segmented control */
.segmented { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--radius); overflow: hidden; }
.segmented > button {
  min-height: 40px; padding: 0 14px; border: 0; border-right: 1px solid var(--line2);
  background: transparent; color: var(--fg2); cursor: pointer;
  font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.segmented > button:last-child { border-right: 0; }
.segmented > button[aria-pressed="true"], .segmented > button[aria-checked="true"] { background: var(--accent); color: var(--accent-fg); }

/* Chips and tags */
.chip { display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 2px; background: var(--chip); color: var(--chip-fg); }
.chip-hit { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.tag { display: inline-block; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; border: 1px solid var(--line2); padding: 3px 8px; color: var(--fg2); }
.tag-accent { border-color: var(--accent-line); color: var(--accent-text); }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; color: var(--fg2); }
.input, .select {
  min-height: var(--tap); padding: 0 10px; background: var(--field); color: var(--fg);
  border: 1px solid var(--line2); border-radius: var(--radius);
}
.input.mono { font-family: var(--font-mono); }
textarea.input { height: auto; min-height: 76px; padding-top: 8px; padding-bottom: 8px; resize: vertical; line-height: 1.5; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* Row list */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.rows > li:last-child { border-bottom: 0; }

/* Section heading row: h2 left, caption or action right */
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
h2.tight { margin-bottom: 2px; }
.link-action {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 4px;
  color: var(--accent-text); text-decoration: none;
  font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
a.link-action:hover { text-decoration: underline; }

/* Stat cells (chips & interfaces) */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 11px; color: var(--mute); letter-spacing: .06em; text-transform: uppercase; }
.stat-state { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.stat-state .dot { width: 8px; height: 8px; }
.stat-detail { font-size: 12px; color: var(--mute); }

/* Overview layout */
.ov-section { margin-bottom: 28px; }
.ov-columns { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.ov-main { flex: 999 1 560px; min-width: 0; }
.ov-side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.ov-sub { margin: 24px 0 8px; color: var(--fg2); }
.ov-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--mute); }

/* ACSI/SCSI ID tiles */
.id-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.id-tile { display: flex; flex-direction: column; gap: 1px; min-height: 72px; padding: 10px 12px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent-line); min-width: 0; }
.id-tile.off { background: transparent; border: 1px dashed var(--line2); }
.id-num { font-size: 11px; color: var(--mute); }
.id-mode { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-text); }
.id-tile.off .id-mode { color: var(--mute); }
.id-detail { font-size: 11px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Drives on the ST */
.drive-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.drive-list > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.drive-letter { width: 32px; color: var(--accent-text); }
.drive-source { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.drive-free { margin-left: auto; font-size: 13px; }
.drive-acts { display: inline-flex; gap: 14px; flex: 0 0 auto; }
.hd-newdrive { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin: 14px 0 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.hd-newdrive .field { flex: 0 0 auto; min-width: 190px; }
.hd-newdrive .hint { flex: 1 1 100%; margin: 0; }

/* Floppy slots */
.slot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.slot { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); }
.slot.active { background: var(--accent-soft); border-color: var(--accent-line); }
.slot-num { flex: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; background: var(--line); color: var(--fg2); }
.slot.active .slot-num { background: var(--accent); color: var(--accent-fg); }
.slot-text { flex: 1; min-width: 0; }
.slot-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.empty .slot-name { color: var(--mute); }
.slot-meta { font-size: 12px; color: var(--mute); }

/* Definition list (inputs & network) */
.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv dd.mono { font-size: 13px; }
.kv dd.none { color: var(--mute); }

/* Download rows (ST tools) */
.download-list { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.download-list a { display: flex; justify-content: space-between; align-items: center; min-height: var(--tap); border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; }
.download-list .mono { font-size: 13px; }
.download-list .link-action { min-height: 0; font-size: 15px; }
.download-list a:hover .link-action, .download-list a:focus-visible .link-action { text-decoration: underline; }

/* Placeholder content (until each page is wired up) */
.placeholder { display: grid; gap: 16px; }
.placeholder .panel { min-height: 160px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 6px; }
.placeholder .panel.dashed { background: transparent; border-style: dashed; }

/* ------------------------------------------------------------------ Floppy */
.fl-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.fl-slot {
  background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--line);
  border-radius: var(--radius-panel); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; min-height: 240px;
}
.fl-slot.active { border-color: var(--accent-line); border-top-color: var(--accent); }
.fl-slot.drag { border-color: var(--accent); background: var(--accent-soft); }
.fl-slot-head { display: flex; justify-content: space-between; align-items: center; }
.fl-slot-n { font-size: 12px; color: var(--mute); letter-spacing: .08em; }
.fl-badge {
  font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-fg); background: var(--accent); padding: 2px 8px;
}
.fl-slot-body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fl-slot-name { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.05; letter-spacing: .02em; overflow-wrap: anywhere; }
.fl-slot-meta { font-size: 12px; color: var(--mute); overflow-wrap: anywhere; }
.fl-ondisk { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.fl-ondisk-h { font-size: 11px; color: var(--mute); letter-spacing: .08em; margin-bottom: 4px; }
.fl-ondisk ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.fl-ondisk li { display: flex; gap: 8px; align-items: baseline; }
.fl-ondisk li::before { content: ""; width: 5px; height: 5px; background: var(--accent); flex: none; transform: translateY(-3px); }
.fl-ondisk li.more { color: var(--mute); }
.fl-ondisk li.more::before { background: transparent; }
.fl-slot-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.fl-slot-btns .fl-select { flex: 1; }
.fl-drop {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1px dashed var(--line2); border-radius: var(--radius); color: var(--mute); text-align: center; padding: 16px; cursor: pointer;
}
.fl-drop:hover, .fl-drop:focus-within { border-color: var(--accent-line); color: var(--fg2); }
.fl-drop-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--fg); }
.fl-drop-hint { font-size: 13px; }
.fl-own { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 10px 0 0; font-size: 13px; }
.fl-own .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.fl-message { min-height: 1.5em; margin: 10px 0 0; color: var(--fg2); font-size: 14px; }

.fl-lib { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.fl-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.fl-search {
  flex: 1 1 320px; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 12px;
  border: 1px solid var(--line2); border-radius: var(--radius); background: var(--field); color: var(--mute);
}
.fl-search:focus-within { border-color: var(--accent); }
.fl-search input { flex: 1; border: 0; outline: none; font: inherit; color: var(--fg); background: transparent; min-width: 0; }
.fl-tools .segmented { flex-wrap: wrap; }
.fl-tools .segmented > button { min-height: 44px; }
.fl-rows { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.fl-thumb { flex: 0 0 auto; width: 64px; height: 40px; background: var(--chip); border-radius: 3px; overflow: hidden; align-self: center; }
.fl-thumb { position: relative; }
.fl-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: pixelated; opacity: 0; transition: opacity .7s ease; }
.fl-thumb img.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .fl-thumb img { transition: none; } }
.fl-thumb[data-act] { cursor: zoom-in; }
.fl-thumb[data-act]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* lightbox: an entry's pictures, large */
.fl-lb { border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--panel); color: var(--fg);
  padding: 14px 16px 12px; width: min(92vw, 1000px); max-height: 92vh; }
.fl-lb::backdrop { background: rgba(0, 0, 0, .72); }
.fl-lb-top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.fl-lb-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: .04em; flex: 1 1 auto; min-width: 0; }
.fl-lb-close { background: none; border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); width: 36px; height: 36px; cursor: pointer; font-size: 16px; }
.fl-lb-stage { display: flex; align-items: center; gap: 10px; }
.fl-lb-stage img { flex: 1 1 auto; min-width: 0; width: 100%; max-height: 72vh; object-fit: contain; image-rendering: pixelated; background: #000; border-radius: var(--radius); }
.fl-lb-nav { flex: 0 0 auto; width: 44px; height: 64px; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); font-size: 28px; cursor: pointer; }
.fl-lb-nav[hidden] { display: none; }
.fl-lb-nav:hover, .fl-lb-close:hover { border-color: var(--accent); color: var(--accent-text); }
.fl-lb-cap { margin: 8px 0 0; min-height: 1.2em; font-size: 14px; color: var(--mute); text-align: center; }
.fl-thumb-none { visibility: hidden; width: 0; }
.fl-row-gone .fl-row-main, .fl-row-gone .fl-row-insert { opacity: .45; }
.fl-clock { margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--accent-line); border-radius: var(--radius); color: var(--accent-text); font-size: 14px; }
.fl-clock[hidden] { display: none; }
.fl-dl { min-height: 36px; padding: 0 12px; font-size: 14px; margin-right: 6px; }
.fl-warn { color: var(--accent-text); }
.fl-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.fl-row-main { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fl-row-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.fl-row-title .hint { font-size: 12px; overflow-wrap: anywhere; }
.fl-row-name { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: .02em; overflow-wrap: anywhere; }
.fl-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.fl-row-tags { flex: 0 1 200px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 4px; }
.fl-row-tags .tag { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.fl-row-insert { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.fl-row-insert .hint { font-size: 11px; margin-right: 6px; letter-spacing: .06em; }
.fl-target, .fl-pg {
  width: 44px; height: 44px; border-radius: var(--radius); border: 1px solid var(--line2); background: transparent;
  font-family: var(--font-mono); font-size: 14px; cursor: pointer; color: var(--fg);
}
.fl-target:hover:not([disabled]), .fl-pg:hover:not([disabled]) { border-color: var(--accent); color: var(--accent-text); }
.fl-target.in { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.fl-target[disabled], .fl-pg[disabled] { opacity: .4; cursor: not-allowed; }
.fl-empty { padding: 32px 0; text-align: center; color: var(--mute); }
.fl-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; color: var(--mute); }
.fl-pager { display: flex; gap: 6px; align-items: center; }
.fl-pg { font-size: 16px; }
.fl-manage { margin: 0; font-size: 13px; }

/* ------------------------------------------------------------------ Config */
.cf { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.cf-nav { flex: 1 1 200px; max-width: 240px; min-width: 0; display: flex; flex-direction: column; }
.cf-nav h1 { margin: 2px 0 16px; }
.cf-nav-links { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.cf-nav-links a {
  padding: 9px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--fg2); text-decoration: none;
  font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.cf-nav-group { margin: 14px 0 4px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.cf-nav-group:first-of-type { margin-top: 0; }
.cf-group { margin: 12px 0 -8px; }
.cf-group:first-child { margin-top: 0; }
.cf-nav-links a:hover { color: var(--fg); }
.cf-nav-links a[aria-current] { border-left-color: var(--accent); color: var(--accent-text); }
.cf-classic { margin-top: 16px; font-size: 13px; }
/* Navigation beside the settings (wide screens): stays in view while the
   settings scroll; scrolls itself if the window is too low for it */
@media (min-width: 1100px) {
  .cf-nav { position: sticky; top: 20px; max-height: calc(100vh - 40px - 64px); overflow-y: auto; }
}
.cf-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; padding-bottom: 24px; }
.cf-sec { scroll-margin-top: 16px; }
.cf-sec.has-error { border-color: var(--danger-line); }
.cf-hint { margin: -8px 0 14px; font-size: 14px; }
.cf-problem:empty { display: none; }
.cf-problem { margin: 0 0 14px; padding: 8px 12px; border-radius: var(--radius); font-size: 14px; }
.cf-problem.error { border: 1px solid var(--danger-line); color: var(--danger); }
.cf-problem.warning { border: 1px solid var(--accent-line); color: var(--accent-text); }
.cf-status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--mute); }
.cf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 10px; }
.cf-grid.cf-wifi-grid { grid-template-columns: 1fr; }
.cf-wifi { position: relative; }
.cf-wifi-row { display: flex; gap: 8px; }
.cf-wifi-row .input { flex: 1; min-width: 0; }
.cf-wifi-row .btn { flex: none; min-width: 6.5em; }
.cf-wifi-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(19px + 6px + var(--tap) + 2px); margin: 0; padding: 4px 0; list-style: none;
  max-height: 280px; overflow-y: auto; background: var(--field); border: 1px solid var(--accent); border-radius: var(--radius);
}
.cf-wifi-list[hidden] { display: none; }
.cf-wifi-list li { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 10px; cursor: pointer; }
.cf-wifi-list li:hover, .cf-wifi-list li.cur { background: var(--accent-soft); }
.cf-wifi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-wifi-meta { font-size: 11px; color: var(--mute); white-space: nowrap; }
.cf-wifi-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.cf-wifi-bars i { width: 3px; background: var(--line2); }
.cf-wifi-bars i:nth-child(1) { height: 4px; } .cf-wifi-bars i:nth-child(2) { height: 7px; }
.cf-wifi-bars i:nth-child(3) { height: 10px; } .cf-wifi-bars i:nth-child(4) { height: 14px; }
.cf-wifi-bars i.on { background: var(--accent); }
.cf-wifi .hint { font-size: 12px; min-height: 1.3em; }
.cf-grid .field > span, .cf-src .field > span { font-size: 13px; color: var(--fg2); }
.cf-radios, .cf-checks { display: flex; flex-wrap: wrap; gap: 10px 40px; margin-top: 16px; }
.cf-radio { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.cf-radio legend { font-size: 13px; color: var(--fg2); margin-bottom: 6px; padding: 0; }
.cf-check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.cf-check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.cf-ids { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.cf-id { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cf-id-n { width: 52px; color: var(--accent-text); }
.cf-id .segmented > button { min-width: 56px; }
.cf-id .hint { font-size: 13px; }
.cf-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.cf-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; min-width: 0; }
.cf-box legend { padding: 0 6px; font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--fg2); }
.cf-hdd-new { margin-top: 16px; }
.cf-hdd-new-go { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; }
.cf-hdd-new-go .hint { margin: 0; }
.cf-sys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.cf-sys-grid .cf-box { display: flex; flex-direction: column; gap: 10px; }
.cf-sys-grid .cf-box .hint { margin: 0; }
.cf-sys-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.cf-sys-run { border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; }
.cf-sys-run p { margin: 0 0 8px; }
.cf-sys-run .hint { margin: 8px 0 0; }
.cf-sys-list { display: block; margin: 12px 0; }
.cf-sys-list > .hint { display: block; margin-bottom: 4px; }
.cf-sys-list-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.cf-sys-list-row .input { flex: 1 1 260px; min-width: 0; font-size: 13px; }
.cf-sys-run progress { width: 100%; height: 10px; accent-color: var(--accent); }
.cf-sys-trial .cf-sys-btns { margin-top: 10px; }
.cf-sys-run + .cf-box { margin-top: 14px; }
.cf-flash { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.cf-flash .hint { margin: 0; }
.cf-sys-grid .cf-check .hint { white-space: nowrap; }
.cf-sys-slots { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.cf-sys-slots td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.25)); vertical-align: baseline; }
.cf-sys-slots th { font: 500 11px/1.2 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); text-align: center; padding: 0 8px 4px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.25)); }
.cf-sys-slots td:nth-child(3), .cf-sys-slots td:nth-child(4) { text-align: center; width: 90px; vertical-align: middle; }
.cf-sys-radio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.cf-sys-radio input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; cursor: pointer; }
.cf-sys-radio input:disabled { cursor: default; }
.cf-sys-rl { display: none; }
@media (max-width: 520px) { .cf-sys-slots thead { display: none; } .cf-sys-rl { display: inline; } .cf-sys-slots td { display: block; border: 0; padding: 2px 0; text-align: left !important; width: auto !important; } .cf-sys-slots td:nth-child(3), .cf-sys-slots td:nth-child(4) { display: inline-block; margin-right: 18px; } .cf-sys-slots tr { display: block; padding: 6px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.25)); } }
.cf-bk-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.cf-bk-warn { border: 1px solid var(--danger-line); border-radius: var(--radius); padding: 10px 12px; }
.cf-bk-warn p { margin: 0 0 8px; font-size: 14px; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); text-decoration: underline; cursor: pointer; }
.cf-static[hidden] { display: none; }
.cf-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; margin-top: 8px; }
.cf-sources { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.cf-src { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cf-src-n { width: 18px; padding-top: 30px; color: var(--accent-text); font-size: 13px; }
.cf-src-body { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cf-src-top { display: grid; grid-template-columns: minmax(150px, 190px) repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.cf-src-body > .hint { font-size: 12px; }
.cf-src-ctl { display: flex; align-items: center; gap: 4px; padding-top: 22px; margin-left: auto; }
.cf-src-ctl .cf-check { margin-right: 8px; font-size: 14px; }
.cf-mini {
  width: 40px; height: 40px; border-radius: var(--radius); border: 1px solid var(--line2); background: transparent;
  color: var(--fg); cursor: pointer; font-size: 15px;
}
.cf-mini:hover:not([disabled]) { border-color: var(--accent); color: var(--accent-text); }
.cf-mini[disabled] { opacity: .35; cursor: not-allowed; }
.cf-src-add { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.cf-src-add .hint { font-size: 13px; }
.cf-usb { margin-top: 18px; }
.kv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
/* fixed: always at the bottom of the window, whatever the page's height */
.cf-bar {
  position: fixed; left: 0; right: 0; bottom: var(--bottom-nav-h); z-index: 3;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line);
}
.cf-bar-text { font-size: 12px; letter-spacing: .08em; color: var(--mute); }
.cf-bar-btns { display: flex; gap: 8px; }
.cf-bar.dirty { background: var(--accent); border-top-color: var(--accent); }
.cf-bar.dirty .cf-bar-text { color: var(--accent-fg); font-weight: 500; }
.cf-bar.dirty .btn-secondary { border-color: var(--accent-fg); color: var(--accent-fg); }
.cf-bar.dirty .btn-primary { background: var(--accent-fg); color: var(--accent); }
.cf-main { padding-bottom: 80px; }
@media (min-width: 760px) {
  .cf-bar { left: var(--sidebar-w); bottom: 0; padding: 12px 32px; }
}

/* ------------------------------------------------------------------ Remote */
.rm { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.rm-screen-col { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.rm-side { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.rm-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.rm-toolbar .rm-cad { margin-left: auto; }
.rm-screen {
  position: relative; aspect-ratio: 16 / 10; background: var(--screen); border: 1px solid var(--line);
  border-radius: var(--radius-panel); overflow: hidden; display: flex; align-items: center; justify-content: center;
  cursor: crosshair; outline: none;
}
.rm-screen:focus-visible, .rm-screen:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.rm-screen canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.rm-idle { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #8E949C; text-align: center; padding: 16px; }
.rm-idle[hidden] { display: none; }
.rm-idle-t { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #B8BDC4; }
.rm-idle-h { font-size: 13px; max-width: 40ch; }
.rm-tags { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.rm-live { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; color: #fff; background: #C53D2C; padding: 2px 8px; }
.rm-res { font-size: 11px; color: #E8E6E1; background: rgba(0,0,0,.6); padding: 2px 8px; }
.rm-under { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin: 0; font-size: 12px; color: var(--mute); }
.rm-msg { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--fg2); }
.rm-side h2 { margin-bottom: 10px; }
.rm-joyhint { margin: 10px 0 0; font-size: 13px; }
.rm-kbd-panel { margin-top: 20px; }
.rm-kbd-scroll { overflow-x: auto; padding-bottom: 6px; }
.rm-kbd { display: flex; gap: 22px; min-width: 900px; --u: 44px; }
.rm-kbd-main, .rm-kbd-side { display: flex; flex-direction: column; gap: 4px; }
.rm-kbd-side { justify-content: flex-start; }
.rm-kbd-side .rm-row:first-child { margin-bottom: calc(var(--u) + 4px); }
.rm-row { display: flex; gap: 4px; }
.rm-key {
  width: calc(var(--u) * var(--w) + 4px * (var(--w) - 1)); height: 44px; flex: none;
  border: 1px solid var(--keyedge); border-bottom-width: 3px; border-radius: var(--radius);
  background: var(--key); color: var(--fg); cursor: pointer; padding: 0 4px;
  font-family: var(--font-body); font-size: 13px; line-height: 1.1; user-select: none; touch-action: manipulation;
}
.rm-key.mod { background: var(--keymod); }
.rm-key:hover { border-color: var(--accent-line); }
.rm-key.pressed, .rm-key:active { transform: translateY(2px); border-bottom-width: 1px; }
.rm-key.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* ---------------------------------------------------------- Hard disk page */
.hd-message.error { color: var(--danger); }
.hd-panel + .hd-panel { margin-top: 20px; }
.hd-id-top { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.hd-ids { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.hd-id { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hd-id.off .hd-id-detail { color: var(--mute); }
.hd-id .segmented { width: 100%; }
.hd-id .segmented button { flex: 1; padding-left: 4px; padding-right: 4px; }
.hd-id-detail { flex: 1; min-width: 0; text-align: right; font-size: 12px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-attached { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 12px 14px; border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: var(--radius); }
.hd-attached > div:first-child { flex: 1 1 240px; min-width: 0; }
.hd-attached .eyebrow, .hd-attached p { margin: 0; }
.hd-att-name { font-size: 18px; overflow-wrap: anywhere; }
.hd-warn { margin: 10px 0 0; }
.hd-rows { margin-top: 14px; border-top: 1px solid var(--line); }
.hd-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto; gap: 8px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hd-row.on .hd-name { color: var(--accent-text); }
.hd-row-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.hd-name { overflow-wrap: anywhere; }
.hd-notes { min-height: 38px; resize: vertical; font-size: 14px; }
.hd-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.hd-acts .btn { min-height: 34px; padding: 4px 12px; font-size: 13px; }
.hd-badge { font-size: 11px; letter-spacing: .08em; color: var(--accent-text); border: 1px solid var(--accent-line); border-radius: 3px; padding: 1px 6px; }
.hd-empty { padding: 12px 0; margin: 0; }
.hd-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 18px; align-items: start; }
.hd-tools .cf-hdd-new { margin-top: 0; }
.hd-other summary { cursor: pointer; font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--fg2); }
.hd-other[open] summary { margin-bottom: 10px; }
.hd-tr { margin-top: 16px; }
@media (max-width: 759px) {
  .hd-row { grid-template-columns: minmax(0, 1fr); }
  .hd-acts { justify-content: flex-start; }
  .hd-ids { gap: 8px; }
  .hd-id { padding: 8px 10px; gap: 6px; }
}
.hd-id-img { display: flex; flex-direction: column; gap: 6px; }
.hd-id-img .select { min-height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.hd-id-warn { margin: 0; font-size: 12px; }
.hd-att-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hd-att-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.hd-att-list .hd-att-name { font-size: 16px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ files (two panes) */
.fm-switch { display: none; margin-bottom: 10px; }
.fm { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fm-pane { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 10px; }
.fm-pane.active { border-color: var(--accent-line); box-shadow: inset 0 3px 0 var(--accent); }
.fm-head { display: flex; gap: 8px; }
.fm-head .select { flex: 1 1 auto; min-width: 0; min-height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.fm-path { margin: 8px 2px 6px; font-size: 13px; color: var(--accent-text); overflow-wrap: anywhere; min-height: 1.2em; }
.fm-list { height: min(60vh, 560px); overflow-y: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); outline: none; font-size: 14px; }
.fm-list:focus-visible { box-shadow: 0 0 0 2px var(--accent-line); }
.fm-row { display: grid; grid-template-columns: minmax(0, 1fr) 82px 128px; gap: 8px; padding: 3px 6px; cursor: default; user-select: none; white-space: nowrap; }
.fm-row:hover { background: var(--panel2); }
.fm-name { overflow: hidden; text-overflow: ellipsis; }
.fm-size, .fm-date { color: var(--mute); font-size: 12px; text-align: right; }
.fm-folder .fm-name, .fm-up .fm-name, .fm-part .fm-name { font-weight: 600; }
.fm-link .fm-name, .fm-other .fm-name { color: var(--mute); }
.fm-row.sel { color: var(--accent-text); }
.fm-row.sel .fm-name::before { content: "▸ "; }
.fm-pane.active .fm-row.cur { background: var(--accent); color: var(--accent-fg); }
.fm-pane.active .fm-row.cur .fm-size, .fm-pane.active .fm-row.cur .fm-date { color: var(--accent-fg); }
.fm-pane:not(.active) .fm-row.cur { outline: 1px dashed var(--line2); outline-offset: -1px; }
.fm-foot { margin: 6px 2px 0; font-size: 12px; color: var(--mute); }
.fm-error { margin: 10px 6px; color: var(--danger); font-size: 13px; }
.fm-drop { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); border: 2px dashed var(--accent); border-radius: var(--radius-panel); pointer-events: none; font-weight: 600; color: var(--accent-text); }
.fm-msg { min-height: 1.3em; margin: 10px 2px; font-size: 14px; color: var(--fg2); }
.fm-msg.error { color: var(--danger); }
.fm-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel); }
.fm-progress-text { flex: 1 1 100%; font-size: 13px; overflow-wrap: anywhere; }
.fm-bar { flex: 1 1 200px; height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.fm-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.fm-bar.wait span { width: 30%; animation: fm-wait 1.2s linear infinite; }
@keyframes fm-wait { from { transform: translateX(-100%); } to { transform: translateX(334%); } }
@media (prefers-reduced-motion: reduce) { .fm-bar.wait span { animation: none; width: 100%; opacity: .4; } }
.fm-view-read { padding: 14px 12px; max-width: 520px; }
.fm-view-read p { margin: 0 0 8px; font-size: 13px; color: var(--fg2); }
.fm-view-read .fm-bar { flex: none; }
.fm-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.fm-keys .btn { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.fm-keys .btn b { font-family: var(--font-mono); color: var(--accent-text); margin-right: 4px; }
.fm-dlg { width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--fg); padding: 16px 18px; }
.fm-dlg::backdrop { background: rgba(0, 0, 0, .55); }
.fm-dlg h2 { margin: 0 0 8px; font-size: 18px; overflow-wrap: anywhere; }
.fm-dlg h2 { text-transform: none; letter-spacing: 0; }
.fm-dlg p { overflow-wrap: anywhere; }
.fm-dlg .input { width: 100%; box-sizing: border-box; }
.fm-dlg-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.fm-view { width: min(1100px, calc(100vw - 32px)); height: min(860px, calc(100vh - 48px)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--fg); padding: 14px 16px; }
.fm-view[open] { display: flex; flex-direction: column; }
.fm-view::backdrop { background: rgba(0, 0, 0, .65); }
.fm-view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 10px; }
.fm-view-head h2 { margin: 0; font-size: 16px; overflow-wrap: anywhere; text-transform: none; letter-spacing: 0; }
.fm-view-head .hint { flex: 1 1 auto; }
.fm-view-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fm-view-tools .btn, .fm-view-tools .segmented > button { min-height: 32px; padding: 3px 10px; font-size: 13px; }
.fm-view-body { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.fm-view-text { margin: 0; padding: 10px 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 8; }
.fm-view-msg { margin: 0 0 8px; min-height: 1.2em; font-size: 13px; color: var(--fg2); }
.fm-view-msg.error { color: var(--danger); }
.fm-view-edit { display: block; width: 100%; height: 100%; min-height: 300px; box-sizing: border-box; margin: 0; padding: 10px 12px; border: 0; resize: none; background: var(--field); color: var(--fg); font-size: 13px; line-height: 1.45; tab-size: 8; white-space: pre; overflow: auto; }
.fm-view-edit:focus { outline: 2px solid var(--accent-line); outline-offset: -2px; }
.fm-view-edit.hex { letter-spacing: .02em; }
.fm-view-pic { display: block; margin: 12px auto; max-width: calc(100% - 24px); height: auto; image-rendering: pixelated; background: #000; }
@media (max-width: 759px) {
  .fm-switch { display: inline-flex; }
  .fm { grid-template-columns: 1fr; }
  .fm-pane:not(.shown) { display: none; }
  .fm-row { grid-template-columns: minmax(0, 1fr) 70px; }
  .fm-date { display: none; }
  .fm-list { height: 55vh; }
}

/* ------------------------------------------------------------------ restart (menu) */
.nav-btn { width: 100%; background: none; border: 0; border-left: 2px solid transparent; text-align: left; cursor: pointer; }
.restart-dlg { width: min(440px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--fg); padding: 18px 20px; }
.restart-dlg::backdrop { background: rgba(0, 0, 0, .6); }
.restart-dlg h2 { margin: 0 0 10px; font-size: 20px; }
.restart-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.restart-reset { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 600; cursor: pointer; }
.restart-reset + .hint { margin-top: 4px; }
