/* ==========================================================================
   Nova Hub console — quiet paper, HUD accents, mono numerals.
   Palette follows the device: paper #E4E6DD, ink #343832, panel light #C4C9BC.
   ========================================================================== */

@font-face {
  font-family: "JetBrains Mono";
  src: url("../../fonts/JetBrainsMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../../fonts/JetBrainsMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../../fonts/JetBrainsMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #e4e6dd;
  --paper-card: #eceee5;
  --paper-raised: #f3f4ed;
  --paper-sunken: #dcded4;
  --ink: #2b302a;
  --ink-2: #4f554a;
  --ink-3: #62685c;
  --ink-4: #6c7264;
  --line: #c3c7ba;
  --line-soft: #d4d7cb;
  --accent: #35604c;
  --accent-ink: #2c513f;
  --accent-wash: rgba(53, 96, 76, 0.09);
  --warn: #92670f;
  --warn-wash: rgba(146, 103, 15, 0.12);
  --danger: #99372a;
  --danger-wash: rgba(153, 55, 42, 0.1);
  --device-dark: #343832;
  --device-light: #c4c9bc;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --radius: 2px;
  --sidebar-w: 212px;
  --shadow: 0 1px 0 rgba(43, 48, 42, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-image: radial-gradient(rgba(43, 48, 42, 0.055) 0.6px, transparent 0.6px);
  background-size: 7px 7px;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.mono { font-family: var(--mono); font-feature-settings: "zero" 1, "ss01" 0; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ shell */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: 26px 18px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 140px);
}

.brand { display: flex; flex-direction: column; gap: 2px; padding: 0 6px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 19px; font-weight: 650; letter-spacing: 0.01em; }
.brand-sub { font-size: 10px; letter-spacing: 0.16em; color: var(--ink-3); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.nav-group-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-4);
  padding: 0 8px 8px;
  text-transform: uppercase;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 8px;
  color: var(--ink-2);
  border-radius: var(--radius);
  font-size: 13.5px;
  line-height: 1.4;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.28); color: var(--ink); text-decoration: none; }
.nav-idx { font-size: 10px; color: var(--ink-4); width: 16px; flex: none; letter-spacing: 0.04em; }
.nav-item.active { color: var(--ink); background: var(--accent-wash); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
}
.nav-item.active .nav-idx { color: var(--accent); }
.nav-group-future { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.nav-future { color: var(--ink-4); }
.nav-future:hover { color: var(--ink-3); }
.nav-stage {
  margin-left: auto;
  font-size: 9.5px;
  color: var(--ink-4);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 1px 6px;
  letter-spacing: 0.06em;
}
.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 10.5px;
  color: var(--ink-3);
}
.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink-3);
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--ink); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  padding: 12px 34px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
}
.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.page-title { font-size: 16px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.device-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  color: var(--ink-2);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.22);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); flex: none; }
.dot.online { background: var(--accent); }
.dot.offline { background: var(--danger); }
.dot.idle { background: var(--warn); }
.device-pill .dev-label { color: var(--ink-3); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.page {
  width: 100%;
  max-width: 1290px;
  padding: 30px 34px 60px;
  outline: none;
}
.page-foot {
  margin-top: auto;
  padding: 14px 34px 22px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  border-top: 1px solid var(--line-soft);
}

/* --------------------------------------------------------------- typography */
.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 34px 0 14px;
}
.section-head:first-child { margin-top: 0; }
.section-title { font-size: 13.5px; font-weight: 600; letter-spacing: 0.01em; color: var(--ink); }
.section-note { font-size: 11.5px; color: var(--ink-3); }
/* Section heading used inside cards: readable body size, mono only as ornament. */
.section-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.card-head h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.01em; color: var(--ink); }
.rule { height: 1px; background: var(--line-soft); border: 0; margin: 0; }

/* ------------------------------------------------------------------ surfaces */
.card {
  position: relative;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 20px 22px; }
.card.flush { overflow: hidden; }
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em; }
.card-body { padding: 18px 20px; }
.card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line-soft);
}
.card-grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* corners: quiet HUD marks, only on preview frames and key cards */
.marked { position: relative; }
.marked::before, .marked::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
  border-color: var(--ink-4);
  border-style: solid;
  opacity: 0.75;
}
.marked::before { top: 4px; left: 4px; border-width: 1px 0 0 1px; }
.marked::after { right: 4px; bottom: 4px; border-width: 0 1px 1px 0; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 80ms linear, border-color 80ms linear, color 80ms linear;
  white-space: nowrap;
}
.btn:hover { background: #f7f8f2; border-color: var(--ink-4); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 500;
}
.btn-primary:hover { background: #3a4038; border-color: #3a4038; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #f2f4ee; font-weight: 500; }
.btn-accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn-danger:hover { background: var(--danger-wash); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); padding: 5px 8px; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.4); border-color: var(--line-soft); }
.btn-sm { font-size: 12px; padding: 4px 10px; min-height: 27px; }
.btn-icon { padding: 6px 8px; min-height: 30px; }
.btn .ico { font-size: 14px; line-height: 1; }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 11px; letter-spacing: 0.06em; color: var(--ink-3); }
.field-hint { font-size: 11.5px; color: var(--ink-3); }
.field-error { font-size: 11.5px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%;
  padding: 7px 10px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 80ms linear, box-shadow 80ms linear;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-wash);
}
.input.mono, .textarea.mono { font-size: 12.5px; letter-spacing: 0.01em; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-narrow { width: 84px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 49%, var(--ink-3) 50%, var(--ink-3) 60%, transparent 61%), linear-gradient(-45deg, transparent 49%, var(--ink-3) 50%, var(--ink-3) 60%, transparent 61%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.textarea { min-height: 80px; resize: vertical; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: var(--ink); border: 2px solid var(--paper-card); box-shadow: 0 0 0 1px var(--ink); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent-wash), 0 0 0 1px var(--accent); }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { appearance: none; width: 15px; height: 15px; border: 1px solid var(--line); border-radius: 2px; background: var(--paper-raised); margin: 0; position: relative; cursor: pointer; }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { content: ""; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px; border: 2px solid var(--paper); border-top: 0; border-left: 0; transform: rotate(42deg); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.switch input { appearance: none; width: 34px; height: 19px; border-radius: 20px; border: 1px solid var(--line); background: var(--paper-sunken); position: relative; cursor: pointer; margin: 0; transition: background 100ms linear; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--paper-raised); border: 1px solid var(--line); transition: transform 100ms linear; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(15px); background: #f1f3ec; border-color: transparent; }

.form-grid { display: grid; gap: 18px 22px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.pair { display: flex; align-items: center; gap: 8px; }
.pair .input { flex: 1 1 0; min-width: 0; }
.pair span { color: var(--ink-3); font-size: 12px; }

details.advanced { margin-top: 22px; border-top: 1px solid var(--line-soft); padding-top: 16px; }
details.advanced > summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 8px;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: "+"; font-size: 12px; }
details.advanced[open] > summary::before { content: "−"; }
details.advanced .advanced-body { margin-top: 16px; }

/* ------------------------------------------------------------------ tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.24);
  white-space: nowrap;
}
.tag-current { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-wash); }
.tag-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-wash); }
.tag-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: var(--danger-wash); }
.tag-muted { color: var(--ink-4); }
.tag-stage { color: var(--ink-4); border-style: dashed; }

/* ------------------------------------------------------------------ alerts */
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 26px; }
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-left-width: 2px;
  border-radius: var(--radius);
  background: var(--paper-card);
  font-size: 13px;
}
.alert a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.alert-warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-wash) 55%, var(--paper-card)); }
.alert-error { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger-wash) 55%, var(--paper-card)); }
.alert-info { border-left-color: var(--ink-4); }
.alert-quiet { border: 0; background: transparent; padding: 0 2px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; color: var(--ink-3); }
.alert-quiet::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; margin-right: 8px; }

/* -------------------------------------------------------------- screen frames */
.screens { display: flex; gap: 20px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.screen { flex: 1 1 0; min-width: 240px; max-width: 400px; }
.screen-img {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--device-light);
  border: 1px solid var(--device-dark);
  box-shadow: 0 2px 0 rgba(52, 56, 50, 0.12);
  overflow: hidden;
}
.screen-img img { width: 100%; height: 100%; image-rendering: pixelated; }
.screen-img .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--device-dark);
  opacity: 0.55;
}
.screen-cap { display: flex; flex-direction: column; gap: 3px; padding: 10px 2px 0; min-width: 0; }
.screen-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.screen-name > :first-child { flex: none; }
.screen-name .tag { min-width: 0; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.screen-meta { font-family: var(--mono); font-size: 10px; letter-spacing: 0.03em; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.screen-meta .sep::before { content: "/"; margin-right: 8px; color: var(--ink-4); }

/* ------------------------------------------------------------------ stats */
.stat-row { display: flex; align-items: flex-end; gap: 30px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.15; color: var(--ink); }
.stat-value small { font-size: 11px; color: var(--ink-3); font-weight: 400; margin-left: 3px; }
.stat-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; color: var(--ink-3); text-transform: uppercase; }
.stat-alert .stat-value { color: var(--danger); }
.stat-warn .stat-value { color: var(--warn); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; font-size: 13px; }
.kv dt { color: var(--ink-3); white-space: nowrap; }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.kv dd.mono { font-size: 12px; }

/* ------------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255, 255, 255, 0.22); }
.table .mono { font-size: 11.5px; }
.table .num { text-align: right; }
.status-code { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; }
.status-2 { color: var(--accent-ink); }
.status-3 { color: var(--ink-3); }
.status-4 { color: var(--warn); }
.status-5 { color: var(--danger); }

/* ------------------------------------------------------------------ empty / skeleton */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 24px;
  text-align: center;
  color: var(--ink-3);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.14);
}
.empty-title { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.empty p { max-width: 460px; font-size: 12.5px; line-height: 1.7; }
.empty .mono { font-size: 10px; letter-spacing: 0.1em; color: var(--ink-4); }
.skeleton {
  background: linear-gradient(90deg, var(--paper-sunken) 25%, #e7e9e0 37%, var(--paper-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 2px;
}
.skeleton.img { width: 400px; height: 300px; background: var(--paper-sunken); animation: none; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; left: 24px; bottom: 22px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  font-size: 12.5px;
  box-shadow: 0 8px 30px rgba(43, 48, 42, 0.22);
  max-width: 460px;
  animation: toast-in 120ms ease-out;
}
.toast .toast-detail { color: rgba(228, 230, 221, 0.66); font-size: 11.5px; }
.toast-error { background: var(--danger); }
.toast-warn { background: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ modal / drawer */
.modal-root { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(43, 48, 42, 0.32); }
.modal {
  position: relative;
  width: min(480px, calc(100vw - 40px));
  background: var(--paper-raised);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(43, 48, 42, 0.28);
  border-radius: var(--radius);
  padding: 24px;
  animation: modal-in 120ms ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.modal p { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.drawer-root { position: fixed; inset: 0; z-index: 70; display: flex; justify-content: flex-end; }
.drawer {
  position: relative;
  width: min(520px, calc(100vw - 24px));
  height: 100%;
  overflow-y: auto;
  background: var(--paper-raised);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(43, 48, 42, 0.18);
  padding: 22px 24px 40px;
}
.drawer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.drawer h2 { font-size: 15px; font-weight: 600; }

/* ------------------------------------------------------------------ login */
.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
}
.login-mark { font-size: 10px; letter-spacing: 0.2em; color: var(--ink-3); margin-bottom: 18px; }
.login-title { font-size: 26px; font-weight: 620; letter-spacing: 0.01em; }
.login-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.login-form {
  width: min(380px, 100%);
  margin-top: 26px;
  padding: 24px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-btn { width: 100%; }
.login-error { font-size: 12px; color: var(--danger); margin: 0; }
.login-foot { margin-top: 22px; font-size: 10px; letter-spacing: 0.04em; color: var(--ink-4); }

/* ------------------------------------------------------------------ skin cards */
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.skin-card { display: flex; flex-direction: column; background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.skin-thumb { position: relative; aspect-ratio: 400 / 300; background: var(--device-light); border-bottom: 1px solid var(--line-soft); }
.skin-thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--device-light); image-rendering: pixelated; }
.skin-thumb .tag { position: absolute; top: 8px; left: 8px; background: var(--paper-raised); }
.skin-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.skin-name { font-size: 13px; font-weight: 600; }
.skin-meta { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.skin-actions { display: flex; gap: 8px; padding: 0 14px 14px; margin-top: auto; }

/* ------------------------------------------------------------------ upload / wizard */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 34px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
  text-align: center;
  cursor: pointer;
  transition: border-color 100ms linear, background 100ms linear;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-wash); }
.dropzone .dz-title { font-size: 13px; color: var(--ink-2); }
.dropzone .mono { font-size: 10px; color: var(--ink-4); letter-spacing: 0.08em; }
.dropzone.dz-slim {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 14px 18px;
  text-align: left;
  margin-bottom: 16px;
}
.dropzone.dz-slim .dz-title { font-size: 12.5px; }
.dropzone.dz-slim .mono { font-size: 9.5px; }
.upload-tabs { display: flex; gap: 2px; margin-bottom: 14px; }
.upload-tab { font-size: 12.5px; padding: 5px 12px; border: 1px solid transparent; border-bottom: 0; color: var(--ink-3); cursor: pointer; background: none; border-radius: 2px 2px 0 0; }
.upload-tab.active { color: var(--ink); border-color: var(--line); background: var(--paper-card); }

.slots { display: flex; flex-direction: column; }
.slot-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.slot-row:last-child { border-bottom: 0; }
.slot-name { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.slot-name .mono { font-size: 10.5px; color: var(--ink-3); }
.slot-name .req { font-size: 9px; color: var(--ink-4); letter-spacing: 0.08em; }
.slot-name .req.required { color: var(--accent); }
.slot-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.slot {
  position: relative;
  width: 88px;
  height: 66px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slot img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; background: var(--device-light); }
.slot .slot-add { font-family: var(--mono); font-size: 16px; color: var(--ink-4); }
.slot .slot-label { position: absolute; left: 3px; bottom: 2px; font-family: var(--mono); font-size: 8px; letter-spacing: 0.04em; color: var(--ink-2); background: color-mix(in srgb, var(--paper-raised) 82%, transparent); padding: 0 3px; }
.slot.selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.slot:hover { border-color: var(--ink-4); }
.slot-empty { border-style: dashed; background: rgba(255, 255, 255, 0.16); }

.process-panel { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.process-preview { position: relative; background: var(--device-light); border: 1px solid var(--device-dark); }
.process-preview img { width: 100%; image-rendering: pixelated; }
.face-zone { position: absolute; left: 0; right: 0; top: 17.27%; height: 33.8%; background: rgba(53, 96, 76, 0.16); border-top: 1px dashed var(--accent); border-bottom: 1px dashed var(--accent); pointer-events: none; }
.face-zone span { position: absolute; right: 4px; top: 2px; font-family: var(--mono); font-size: 8.5px; color: var(--accent-ink); letter-spacing: 0.06em; }
.thumb-sm { width: 54px; height: 41px; border: 1px solid var(--line); background: var(--device-light); image-rendering: pixelated; }

.checks { display: flex; flex-direction: column; }
.check-row { display: flex; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line-soft); font-size: 13px; align-items: flex-start; }
.check-row:last-child { border-bottom: 0; }
.check-mark { width: 16px; flex: none; font-family: var(--mono); font-size: 12px; line-height: 1.55; text-align: center; }
.check-pass .check-mark { color: var(--accent); }
.check-warn .check-mark { color: var(--warn); }
.check-error .check-mark { color: var(--danger); }
.check-info .check-mark { color: var(--ink-4); }
.check-msg { color: var(--ink-2); }
.check-item { font-family: var(--mono); font-size: 10px; color: var(--ink-4); margin-left: 5px; }

.anim-strip { display: flex; flex-wrap: wrap; gap: 20px; }
.anim-item { display: flex; flex-direction: column; gap: 8px; }
.anim-stage { width: 200px; height: 139px; border: 1px solid var(--line); background: var(--device-light); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.anim-stage img { image-rendering: pixelated; }

/* Wallpaper page styles live in wallpaper.css (see index.html). */

.access-scroll { max-height: 560px; overflow: auto; }
.access-scroll .table th { position: sticky; top: 0; background: var(--paper-card); z-index: 1; }
.sim-dialog {
  position: absolute;
  left: 4px;
  top: 206px;
  width: 391px;
  height: 90px;
  background: var(--device-dark);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  padding: 1px;
  display: none;
}
.sim-dialog-inner {
  position: relative;
  height: 100%;
  background: #f4f5ef;
  clip-path: polygon(8px 1px, calc(100% - 8px) 1px, calc(100% - 1px) 8px, calc(100% - 1px) calc(100% - 8px), calc(100% - 8px) calc(100% - 1px), 8px calc(100% - 1px), 1px calc(100% - 8px), 1px 8px);
  box-shadow: inset 0 0 0 1px var(--device-dark);
}
.sim-dialog-inner::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid var(--device-dark);
  clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px);
  pointer-events: none;
}
.sim-name {
  position: absolute;
  left: 20px;
  top: 191px;
  z-index: 2;
  display: none;
  background: var(--device-dark);
  color: var(--device-light);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 1px 8px;
}
.sim-pill {
  position: absolute;
  left: 16px;
  top: 24px;
  background: var(--device-dark);
  color: var(--device-light);
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 10px;
}
.sim-text {
  position: absolute;
  left: 86px;
  top: 26px;
  width: 280px;
  font-size: 13px;
  line-height: 20px;
  color: var(--device-dark);
}
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare figure { display: flex; flex-direction: column; gap: 6px; }
.compare .frame { border: 1px solid var(--line); background: var(--device-light); overflow: hidden; position: relative; }
.compare .frame img { width: 100%; image-rendering: pixelated; }
.compare figcaption { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; color: var(--ink-3); }
.bar-note { position: absolute; inset: 0 0 auto 0; height: 22px; background: rgba(52, 56, 50, 0.72); }

/* ------------------------------------------------------------------ chart */
.chart-wrap { position: relative; width: 100%; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-label { font-family: var(--mono); font-size: 8px; fill: var(--ink-4); letter-spacing: 0.04em; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.chart .ideal { fill: none; stroke: var(--ink-4); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .area { fill: var(--accent-wash); }
.chart .now-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .point { fill: var(--accent); }

/* ------------------------------------------------------------------ utilities */
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.gap-6 { gap: 6px; }
.gap-10 { gap: 10px; }
.gap-14 { gap: 14px; }
.gap-16 { gap: 16px; }
.grow { flex: 1 1 auto; min-width: 0; }
.flex-none { flex: none; }
.w-full { width: 100%; }
.max-w-340 { max-width: 340px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--ink-3); }
.text-center { text-align: center; }
.align-end { align-items: flex-end; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-md { display: flex; flex-direction: column; gap: 14px; }
.inline-note { font-size: 12px; color: var(--ink-3); line-height: 1.65; }
.pl-16 { padding-left: 16px; }
.mono-10 { font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; }

/* ------------------------------------------------------------------ health strip */
.health {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  padding: 10px 2px 0;
  margin-bottom: 18px;
}
.health-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}
.health-item .dot { width: 5px; height: 5px; }
.health-item strong { font-weight: 500; color: var(--ink-2); }
.health-item.warn { color: var(--warn); }
.health-item.warn strong { color: var(--warn); }
.health-item.danger { color: var(--danger); }
.health-item.danger strong { color: var(--danger); }
.health-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------------ save bar */
.card .save-bar {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.save-bar {
  position: static;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  padding: 11px 16px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 -6px 24px rgba(43, 48, 42, 0.07);
}

/* ------------------------------------------------------------------ misc */
.code-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper-sunken);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11.5px;
  overflow-x: auto;
  white-space: pre;
}
.code-line .copy { margin-left: auto; flex: none; }
.token-reveal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  background: var(--accent-wash);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}
.note { font-size: 12px; color: var(--ink-3); line-height: 1.7; }
.split { display: flex; gap: 18px; align-items: flex-start; }
.split > .card:first-child { flex: 1.35; }
.split > .card:last-child { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-tight { gap: 6px; }
.actions-end { display: flex; justify-content: flex-end; gap: 10px; }
.dirty-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  padding: 12px 18px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 -6px 24px rgba(43, 48, 42, 0.06);
}
.dirty-note { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; color: var(--ink-3); }

.stage-page { max-width: 560px; padding: 60px 0; display: flex; flex-direction: column; gap: 14px; }
.stage-num { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--ink-4); }
.stage-title { font-size: 22px; font-weight: 600; }
.stage-page p { font-size: 13.5px; color: var(--ink-2); line-height: 1.8; }
.stage-list { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.stage-list li { padding-left: 18px; position: relative; font-size: 13px; color: var(--ink-2); }
.stage-list li::before { content: "—"; position: absolute; left: 0; color: var(--ink-4); font-family: var(--mono); }

.toast-enter { animation: toast-in 120ms ease-out; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .split { flex-direction: column; }
  .split > .card { width: 100%; }
  .process-panel { grid-template-columns: 1fr; }
  .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand { flex-direction: row; align-items: baseline; gap: 8px; padding: 0; }
  .brand-name { font-size: 16px; }
  .brand-sub { display: none; }
  .nav { flex-direction: row; align-items: center; gap: 2px; }
  .nav-group { flex-direction: row; margin: 0; gap: 2px; }
  .nav-group-label, .nav-idx, .sidebar-foot, .nav-stage { display: none; }
  .nav-item { padding: 6px 9px; font-size: 12.5px; white-space: nowrap; }
  .nav-group-future { border-top: 0; padding-top: 0; margin-top: 0; }
  .topbar { padding: 10px 16px; min-height: 54px; flex-wrap: wrap; }
  .page { padding: 20px 16px 50px; }
  .page-foot { padding: 12px 16px; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .screens { gap: 12px; }
  .screen { flex: none; width: min(400px, 86vw); }
  .compare { grid-template-columns: 1fr; }
  .slot-row { grid-template-columns: 1fr; gap: 8px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .modal { padding: 20px; }
}

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

/* ------------------------------------------------------------------ page bits */
.time-input { max-width: 104px; }
.skin-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.list-row:last-child { border-bottom: 0; }
.py-4 { padding-top: 4px; padding-bottom: 4px; }
.nowrap { flex-wrap: nowrap; }

/* ------------------------------------------------------------------ spaced utilities */
.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.mb-18 { margin-bottom: 18px; }
.m-16 { margin: 16px; }
.pb-0 { padding-bottom: 0 !important; }
.text-lg { font-size: 16px; }
.page-subtitle { font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.item-strong { font-weight: 600; color: var(--ink); }
.kv-row { display: contents; }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------------ inline notices */
.inline-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left-width: 2px;
  border-radius: var(--radius);
  font-size: 12.5px;
}
.inline-alert strong { font-weight: 600; }
.inline-alert .inline-note { flex-basis: 100%; margin: 2px 0 0; }
.inline-alert-warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-wash) 45%, var(--paper-card)); }

/* ------------------------------------------------------------------ quota page */
.quota-top {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.preview-body {
  background: var(--paper-sunken);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.preview-screen { width: 400px; height: 300px; max-width: 100%; margin: 0; }
.preview-caption {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--ink-3);
}
.stat-value-sm { font-size: 20px; }
.chart-empty { padding: 30px; }
.source-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-3);
}
.source-name { font-weight: 600; color: var(--ink-2); }
.source-line .spacer { flex: 1; }

/* ------------------------------------------------------------------ system page */
.token-kind-field { flex: 0 1 240px; min-width: 0; }
.token-reveal-label { font-size: 10px; letter-spacing: 0.08em; color: var(--ink-3); }
.token-reveal-value { margin-top: 4px; word-break: break-all; }
.token-form .select, .token-form .input { width: 100%; }
.tech-info { border-top: 1px solid var(--line-soft); }
.tech-info .kv { max-width: 720px; }

/* ------------------------------------------------------------------ skin editor sim */
.sim-stage {
  position: relative;
  width: 400px;
  height: 300px;
  background: var(--device-light);
  border: 1px solid var(--device-dark);
  overflow: hidden;
}
.sim-base {
  position: absolute;
  left: 0;
  top: 22px;
  width: 400px;
  height: 278px;
  image-rendering: pixelated;
}
.sim-statusbar {
  position: absolute;
  left: 0;
  top: 0;
  width: 400px;
  height: 22px;
  background: var(--device-dark);
  color: var(--device-light);
  font-size: 12px;
  display: flex;
  align-items: center;
  padding: 0 8px;
}
.sim-statusbar-date { margin-left: 10px; font-size: 11px; }
.sim-panel { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.sim-side { display: flex; flex-direction: column; gap: 14px; max-width: 280px; }
.sim-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.anim-canvas { width: 200px; height: 139px; image-rendering: pixelated; }

@media (max-width: 1100px) {
  .quota-top { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .quota-top { grid-template-columns: 1fr; }
  .save-bar { position: static; }
  .health { gap: 4px 14px; }
  .sim-stage { width: min(400px, 86vw); height: auto; aspect-ratio: 4 / 3; }
  .sim-base, .sim-statusbar { width: 100%; }
  .sim-base { height: 92.6%; }
  .sim-statusbar { height: 7.3%; }
  .token-kind-field { flex: 1 1 100%; }
}
.mt-6 { margin-top: 6px; }
.mt-10 { margin-top: 10px; }
.self-start { align-self: flex-start; }
.truncate { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
