:root {
  color-scheme: dark;
  --paper: #0c1014;
  --ink: #e7eef4;
  --dim: #8b9aab;
  --hover: #182028;
  --rule: 1.5px solid #9eb0c2;
  --gutter: clamp(12px, 3vw, 28px);
  --pill: 40px;
  --wall: #343c46;
  --g-ink: #d7f3ff;
  --g-dim: #7eb4d6;
  --g-lit: #7ad7ff;
  --g-glass: #070b10;
  --g-rule: rgba(122, 190, 230, 0.45);
  --alarm: #ff6b62;
  font-family: "Liberation Mono", ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
}

:root[data-mode="light"] {
  color-scheme: light;
  --paper: #eef2f6;
  --ink: #0c1218;
  --dim: #4d5d6e;
  --hover: #e2e8ef;
  --rule: 1.5px solid #0c1218;
}

:root[data-phosphor="green"] {
  --g-ink: #c6f5c4;
  --g-dim: #7dcc78;
  --g-lit: #5dff6a;
  --g-glass: #061208;
  --g-rule: rgba(125, 204, 120, 0.4);
}

:root[data-phosphor="amber"] {
  --g-ink: #ffe0b0;
  --g-dim: #e0a15a;
  --g-lit: #ffb020;
  --g-glass: #110c07;
  --g-rule: rgba(224, 161, 90, 0.42);
}

:root[data-phosphor="ice"] {
  --g-ink: #d7f3ff;
  --g-dim: #7eb4d6;
  --g-lit: #7ad7ff;
  --g-glass: #070b10;
  --g-rule: rgba(122, 190, 230, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 12px;
  letter-spacing: 0.04em;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; letter-spacing: inherit; color: inherit; }

.nav {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--gutter) 10px;
}

.nav-sites, .nav-tools { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand, .pill, .icon {
  border: var(--rule);
  background: var(--paper);
  color: var(--ink);
  height: var(--pill);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 10px;
  text-decoration: none;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.brand img.mark {
  width: 26px;
  height: 26px;
  display: block;
  flex: none;
}

.brand-lock {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.brand-kicker {
  color: #3ec6f0;
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 700;
}

:root[data-mode="light"] .brand-kicker { color: #0b6f92; }

.brand:hover, .pill button:hover, .icon:hover { background: var(--hover); }

.pill { display: flex; padding: 0; }

.pill button {
  background: transparent;
  border: 0;
  padding: 0 12px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pill button + button { border-left: var(--rule); }

.icon {
  width: var(--pill);
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sound-off { display: none; }
body[data-sound="off"] .sound-waves { display: none; }
body[data-sound="off"] .sound-off { display: block; }

.phosphor .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--g-lit);
  box-shadow: 0 0 8px var(--g-lit);
}

.room {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.wall {
  position: relative;
  flex: 1;
  min-height: 180px;
  margin: 0 var(--gutter);
  background: var(--wall);
  overflow: hidden;
}

#modules {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.terminal {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 22px 12px;
  background: var(--g-glass);
  color: var(--g-ink);
  container-type: size;
  box-shadow:
    inset 0 0 80px color-mix(in srgb, var(--g-lit) 16%, transparent),
    inset 0 0 12px color-mix(in srgb, var(--g-lit) 10%, transparent);
  overflow: hidden;
}

.terminal::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.42) 100%);
}

.terminal::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0.13;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.55) 0 1px,
    transparent 1px 3px
  );
  animation: bay-scan 0.7s linear infinite;
}

.kicker-row, .rule, .mast, .log, .prompt { position: relative; z-index: 2; }

#status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--g-lit);
  box-shadow: 0 0 8px var(--g-lit);
  vertical-align: 0;
  animation: bay-blink 1.1s steps(1) infinite;
}

.kicker-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--g-dim);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
}

.kicker-row span:last-child { white-space: nowrap; text-align: right; }

.rule {
  height: 1px;
  margin: 10px 0;
  border: 0;
  background: var(--g-rule);
  flex: none;
}

.mast { flex: none; }

.mast h1 {
  margin: 2px 0 0;
  font-weight: 500;
  font-size: clamp(32px, 18cqh, 64px);
  letter-spacing: 0.06em;
  line-height: 0.9;
  color: var(--g-lit);
  text-shadow: 0 0 14px color-mix(in srgb, var(--g-lit) 70%, transparent);
}

.lede, .sub { margin: 0; line-height: 1.45; }

.lede { margin-top: 10px; color: var(--g-ink); font-size: clamp(13px, 3.5cqh, 16px); }

.sub { color: var(--g-dim); font-size: clamp(12px, 3.2cqh, 15px); }

@container (max-height: 340px) {
  .mast h1 { font-size: clamp(28px, 14cqh, 44px); }
  .rule { margin: 6px 0; }
  .lede { margin-top: 6px; }
}

@container (max-height: 220px) {
  .mast h1 { font-size: 26px; }
  .lede, .sub { display: none; }
}

.log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--g-dim) transparent;
  font-size: 13px;
  line-height: 1.45;
  padding-right: 4px;
}

.line { white-space: pre-wrap; word-break: break-word; }
.line.cmd { color: var(--g-lit); }
.line.dim { color: var(--g-dim); }
.line.ok { color: var(--g-ink); }
.line.bad { color: var(--alarm); }

.prompt {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--g-rule);
  padding-top: 8px;
}

.gt { color: var(--g-lit); }

.prompt input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  padding: 0;
  color: var(--g-ink);
  caret-color: var(--g-lit);
  caret-shape: block;
}

.tip {
  position: absolute;
  z-index: 5;
  min-width: 120px;
  max-width: 230px;
  padding: 7px 9px;
  background: var(--g-glass);
  color: var(--g-ink);
  border: 2px solid #141414;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
}

.tip b { font-weight: 700; }
.tip .muted { color: var(--g-dim); letter-spacing: 0.12em; text-transform: uppercase; }
.tip .job { margin-top: 3px; }

.flip { position: absolute; inset: 0; z-index: 8; }

.flip-shade {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.62);
  cursor: zoom-out;
}

.flip-card { position: absolute; }

.spin {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.spin.on { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.back { transform: rotateY(180deg); }

.flip-meta {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 10px);
  margin: 0;
  text-align: center;
  color: #fff;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
}

.desk {
  position: relative;
  flex: none;
  height: 200px;
  background: #12161c;
  overflow: hidden;
}

#desk-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hit {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.hit:focus-visible { outline: 1px solid #fff; outline-offset: -2px; }

body.heard .terminal {
  box-shadow: inset 0 0 120px color-mix(in srgb, var(--g-lit) 42%, transparent);
}

@keyframes bay-scan {
  from { background-position: 0 0; }
  to { background-position: 0 8px; }
}

@keyframes bay-blink {
  50% { opacity: 0.25; }
}

@media (max-width: 720px) {
  :root { --pill: 34px; --gutter: 10px; }
  .nav { padding: 8px 8px 6px; gap: 6px; }
  .nav-sites, .nav-tools { gap: 6px; }
  .brand { padding: 0 8px; letter-spacing: 0.1em; }
  .brand img.mark { width: 22px; height: 22px; }
  .pill button { padding: 0 7px; letter-spacing: 0.04em; }
  .terminal { padding: 12px 12px 8px; }
  .wall { margin: 0 8px; }
}

@media (max-width: 480px) {
  .brand-kicker { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .spin { transition: none; }
  .terminal::after { opacity: 0.06; animation: none; }
  #status::before, .mast h1 { animation: none; }
}
