:root {
  --bg: #050708;
  --panel: #0a0f11;
  --panel-2: #10171a;
  --ink: #e7f3f1;
  --muted: #93a6a5;
  --line: rgba(179, 244, 220, 0.28);
  --line-hard: rgba(216, 250, 239, 0.58);
  --green: #8df5c1;
  --cyan: #8fdfff;
  --amber: #d8a64d;
  --red: #ff5a6a;
  --paper: #f1ead8;
  --paper-ink: #14110d;
  --paper-line: rgba(20, 17, 13, 0.35);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  --mono: "IBM Plex Mono", "Noto Sans JP", monospace;
  --serif: "Libre Bodoni", "Noto Serif JP", serif;
  --sansjp: "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  line-height: 1.5;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 90;
  padding: 0.6rem 0.9rem;
  background: var(--green);
  color: #00130a;
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }
.static-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 15%, rgba(141, 245, 193, 0.09), transparent 28rem),
    radial-gradient(circle at 82% 22%, rgba(143, 223, 255, 0.08), transparent 24rem),
    linear-gradient(120deg, #030405, #071013 56%, #050708);
}
.field-grid {
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(141, 245, 193, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(141, 245, 193, 0.12) 1px, transparent 1px);
  background-size: 48px 48px;
}
.field-map {
  position: absolute;
  inset: 6% 5%;
  opacity: 0.18;
  background:
    linear-gradient(32deg, transparent 0 46%, rgba(143, 223, 255, 0.35) 46.2% 46.8%, transparent 47% 100%),
    linear-gradient(148deg, transparent 0 42%, rgba(141, 245, 193, 0.28) 42.2% 42.7%, transparent 43% 100%);
  clip-path: polygon(0 10%, 72% 0, 100% 36%, 82% 100%, 15% 88%);
}
.field-tone {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image: radial-gradient(currentColor 0.9px, transparent 0.9px);
  background-size: 8px 8px;
}
.low-gpu .field-tone { display: none; }

.frame {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11, 17, 19, 0.96), rgba(7, 10, 12, 0.96));
  box-shadow: var(--shadow);
  position: relative;
}
.frame::before,
.frame::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
}
.frame::before { left: -1px; top: -1px; border-left: 2px solid var(--line-hard); border-top: 2px solid var(--line-hard); }
.frame::after { right: -1px; bottom: -1px; border-right: 2px solid var(--line-hard); border-bottom: 2px solid var(--line-hard); }
.dense-paper {
  background-image:
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.014) 1px, transparent 1px),
    linear-gradient(180deg, rgba(12, 18, 20, 0.98), rgba(6, 10, 11, 0.98));
  background-size: 22px 22px, 22px 22px, auto;
}
.stamp-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  color: var(--green);
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.stamp-line span {
  border: 1px solid rgba(141, 245, 193, 0.28);
  padding: 0.16rem 0.35rem;
  background: rgba(141, 245, 193, 0.045);
}
.kicker {
  margin: 0 0 0.55rem;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
}
h1, h2, h3 { margin: 0; line-height: 1.02; }
h1, h2 { font-family: var(--serif); font-weight: 700; }
h1 { font-size: clamp(2.4rem, 7vw, 5.8rem); letter-spacing: -0.06em; }
h2 { font-size: clamp(1.7rem, 4vw, 4.2rem); letter-spacing: -0.05em; }
h3 { font-size: 1rem; letter-spacing: -0.02em; }
p { margin: 0; color: var(--muted); }
.lead { max-width: 68ch; font-size: clamp(0.98rem, 1.4vw, 1.15rem); color: #c9dbd9; }

.boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 5, 6, 0.94);
}
.boot.hidden { display: none; }
.boot-card {
  width: min(760px, 100%);
  padding: clamp(1.4rem, 4vw, 2.8rem);
}
.boot-sub {
  color: var(--green);
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0.4rem 0 1.2rem;
}
.boot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1.2rem 0;
}
.boot-grid span {
  border: 1px solid rgba(255,255,255,0.12);
  padding: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.72rem;
}
.boot small { display: block; color: var(--muted); margin-top: 1rem; }

.topbar {
  position: sticky;
  top: 0.6rem;
  z-index: 50;
  width: min(1500px, calc(100% - 1.2rem));
  margin: 0.6rem auto 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.6rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.7rem; min-width: 230px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); }
.brand-mark svg { width: 30px; height: 30px; fill: none; stroke: var(--green); stroke-width: 3; }
.brand-copy { display: grid; gap: 0.08rem; }
.brand-copy span { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.12em; }
.brand-copy strong { color: var(--ink); font-size: 0.95rem; }
.nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; }
.nav a, .control, .mini-action, .primary-action, .secondary-action, .filter {
  border: 1px solid rgba(141, 245, 193, 0.24);
  background: rgba(141, 245, 193, 0.045);
  color: var(--ink);
  padding: 0.58rem 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
}
.nav a:hover, .control:hover, .mini-action:hover, .secondary-action:hover, .filter:hover { border-color: var(--green); color: var(--green); }
.toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.35rem; }
.control[aria-pressed="true"], .filter.active { background: rgba(141, 245, 193, 0.16); border-color: var(--green); color: var(--green); }
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: var(--green);
  background: var(--green);
  color: #00130b;
  font-weight: 700;
}
.secondary-action { display: inline-flex; align-items: center; justify-content: center; background: rgba(143,223,255,0.06); border-color: rgba(143,223,255,0.35); }

.shell {
  width: min(1500px, calc(100% - 1.2rem));
  margin: 0 auto 0.7rem;
}
.access-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 0.7rem;
  padding-top: 0.7rem;
}
.status-rail { padding: 0.75rem; display: grid; gap: 0.55rem; align-content: start; }
.status-rail div { display: grid; grid-template-columns: 1fr auto; gap: 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.45rem; }
.status-rail span { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.14em; }
.status-rail strong { color: var(--green); }
.status-rail p { font-size: 0.68rem; word-break: break-word; }
.command-slab { padding: clamp(1rem, 2vw, 1.6rem); min-height: 280px; display: grid; align-content: center; }
.slab-grid { display: grid; grid-template-columns: 1fr minmax(220px, 320px); gap: 1rem; align-items: end; margin-top: 1rem; }
.slab-grid h2 { margin-bottom: 1rem; max-width: 900px; }
.instant-actions { padding: 0.75rem; display: grid; gap: 0.45rem; align-self: stretch; }
.command-button { text-align: left; }

.compact-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
}
.compact-head h2 { font-size: clamp(1.4rem, 3vw, 3rem); }
.bank-console { padding: 0.7rem; display: grid; grid-template-columns: minmax(240px, 1fr) auto; gap: 0.7rem; align-items: center; margin-bottom: 0.7rem; }
.search-box { display: grid; gap: 0.3rem; }
.search-box span { color: var(--amber); font-size: 0.68rem; letter-spacing: 0.16em; }
.search-box input {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.28);
  color: var(--ink);
  padding: 0.72rem;
  outline: none;
}
.search-box input:focus { border-color: var(--green); }
.filter-row { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: flex-end; }
.main-grid { display: grid; grid-template-columns: 1fr 330px; gap: 0.7rem; align-items: start; }
.record-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem; }
.record-card { padding: 0.75rem; min-height: 240px; display: grid; align-content: start; gap: 0.7rem; }
.record-card.is-sealed { filter: saturate(0.74); }
.record-card.is-ghost { border-color: rgba(255,90,106,0.45); }
.record-top { display: flex; justify-content: space-between; gap: 0.5rem; color: var(--muted); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.12em; }
.record-card h3 { font-size: 1.05rem; color: var(--ink); }
.record-card p { font-size: 0.86rem; }
.damage-meter { height: 8px; border: 1px solid rgba(255,255,255,0.15); background: rgba(0,0,0,0.35); }
.damage-meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); }
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tags span { border: 1px solid rgba(255,255,255,0.12); padding: 0.14rem 0.3rem; color: var(--muted); font-size: 0.62rem; text-transform: uppercase; }
.card-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: auto; }
.card-actions button { flex: 1 1 auto; }
.card-actions button:disabled { opacity: 0.35; cursor: not-allowed; }
.right-stack { display: grid; gap: 0.7rem; }
.queue, .marginalia, .node-map { padding: 0.75rem; }
.queue-list, .trace-log { display: grid; gap: 0.45rem; margin-top: 0.7rem; }
.queue-item, .log-line { border: 1px solid rgba(255,255,255,0.1); padding: 0.55rem; color: var(--muted); font-size: 0.76rem; }
.node-map svg { width: 100%; height: auto; margin-top: 0.6rem; }
.node-map path, .node-map circle { fill: none; stroke: var(--green); stroke-width: 2; }
.node-map .thin { stroke: var(--cyan); opacity: 0.55; }
.node-map text { fill: var(--muted); font-size: 14px; font-family: var(--mono); }

.reader { min-height: 420px; padding: clamp(0.8rem, 2vw, 1.2rem); }
.reader-empty { min-height: 360px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.reader-empty span { color: var(--green); letter-spacing: 0.16em; }
.reader-head { display: grid; grid-template-columns: 1fr auto; gap: 1rem; border-bottom: 1px solid rgba(255,255,255,0.12); padding-bottom: 0.8rem; margin-bottom: 0.8rem; }
.reader-title h3 { font-family: var(--serif); font-size: clamp(1.6rem, 3vw, 3rem); letter-spacing: -0.04em; }
.reader-code { color: var(--green); font-size: 0.72rem; letter-spacing: 0.13em; text-transform: uppercase; }
.reader-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0.7rem; }
.file-plate { display: grid; gap: 0.65rem; }
.file-block { border: 1px solid rgba(255,255,255,0.1); padding: 0.7rem; }
.file-block h4 { margin: 0 0 0.4rem; color: var(--amber); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; }
.file-block p { color: #cbd9d8; }
.corrupt-text { color: var(--red); word-break: break-word; }
.scan-result { color: var(--green); }
.repaired-text { color: var(--ink); }
.side-file { display: grid; gap: 0.7rem; }
.side-file dl { margin: 0; display: grid; gap: 0.35rem; }
.side-file div { display: grid; grid-template-columns: 95px 1fr; gap: 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.09); padding-bottom: 0.35rem; }
.side-file dt { color: var(--muted); text-transform: uppercase; font-size: 0.68rem; }
.side-file dd { margin: 0; color: var(--green); font-size: 0.76rem; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.trace-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.trace-log, .raw-output { min-height: 260px; padding: 0.75rem; }
.raw-output pre {
  margin: 0.7rem 0 0;
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 0.78rem;
}
.hearing-room { padding: 0.9rem; }
.transcript { display: grid; gap: 0.55rem; margin-top: 0.8rem; }
.transcript p { border-left: 2px solid var(--line-hard); padding-left: 0.65rem; color: #cddbd9; }
.transcript strong { color: var(--amber); text-transform: uppercase; font-size: 0.75rem; }
.hearing-room .secondary-action { margin-top: 0.9rem; }
.ghost-card, .signal-panel { padding: clamp(1rem, 2vw, 1.5rem); }
.ghost-card h2 { margin: 0.65rem 0; }
.ghost-questions { display: grid; gap: 0.5rem; margin: 1rem 0; }
.ghost-questions button { text-align: left; }
.signal-shell { padding-bottom: 2rem; }

.terminal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  background: rgba(0,0,0,0.45);
}
.terminal.open { display: flex; }
.terminal-panel { width: min(980px, 100%); max-height: min(620px, 86vh); display: grid; grid-template-rows: auto 1fr auto; background: #020505; }
.terminal-head { display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem; border-bottom: 1px solid rgba(255,255,255,0.12); color: var(--green); letter-spacing: 0.12em; font-size: 0.75rem; }
.terminal-head button { background: transparent; border: 0; color: var(--muted); }
.terminal-output { padding: 0.75rem; overflow: auto; display: grid; gap: 0.35rem; min-height: 260px; }
.terminal-line { color: var(--muted); font-size: 0.82rem; }
.terminal-line.good { color: var(--green); }
.terminal-line.warn { color: var(--amber); }
.terminal-line.bad { color: var(--red); }
.terminal-form { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem; align-items: center; padding: 0.65rem; border-top: 1px solid rgba(255,255,255,0.12); }
.terminal-form label { color: var(--green); }
.terminal-form input { border: 0; background: transparent; color: var(--ink); outline: none; }

.maskable.is-camouflaged { color: transparent; text-shadow: 0 0 0 rgba(141,245,193,0.55); position: relative; }
.maskable.is-camouflaged::after { content: attr(data-mask); color: rgba(141,245,193,0.74); position: absolute; inset: 0; overflow: hidden; }
.maskable.is-camouflaged:hover,
.maskable.is-camouflaged:focus { color: var(--ink); text-shadow: none; }
.maskable.is-camouflaged:hover::after,
.maskable.is-camouflaged:focus::after { display: none; }

body.ink-mode {
  --bg: #eee6d3;
  --panel: #f4ecdc;
  --panel-2: #e8dcc6;
  --ink: #14110d;
  --muted: #5a5146;
  --line: rgba(20, 17, 13, 0.38);
  --line-hard: rgba(20, 17, 13, 0.78);
  --green: #116f4a;
  --cyan: #135e80;
  --amber: #8d5515;
  --red: #9d1b2d;
  background: var(--bg);
}
body.ink-mode .static-field { background: #eee6d3; }
body.ink-mode .frame, body.ink-mode .dense-paper {
  background: linear-gradient(180deg, rgba(245,238,221,0.96), rgba(234,224,204,0.96));
  box-shadow: 0 12px 0 rgba(20,17,13,0.16);
}
body.ink-mode .field-grid { opacity: 0.12; background-image: linear-gradient(rgba(20,17,13,0.16) 1px, transparent 1px), linear-gradient(90deg, rgba(20,17,13,0.16) 1px, transparent 1px); }
body.ink-mode .field-tone { display: block; opacity: 0.18; color: #111; }
body.density-compact .record-card { min-height: 260px; }
body:not(.density-compact) .right-stack, body:not(.density-compact) .status-rail { display: none; }
body:not(.density-compact) .access-shell, body:not(.density-compact) .main-grid { grid-template-columns: 1fr; }
body:not(.density-compact) .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.001ms !important; }
}
@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr; }
  .nav, .toolbar { justify-content: flex-start; }
  .access-shell, .main-grid, .reader-body, .trace-layout { grid-template-columns: 1fr; }
  .status-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .shell, .topbar { width: calc(100% - 0.7rem); }
  .boot-grid, .slab-grid, .record-grid { grid-template-columns: 1fr; }
  .status-rail { grid-template-columns: 1fr; }
  .bank-console { grid-template-columns: 1fr; }
  .reader-head { grid-template-columns: 1fr; }
  .brand { min-width: 0; }
  h1 { font-size: 2.55rem; }
  h2 { font-size: 2rem; }
}
