:root {
  --bg: #060607;
  --ink: #e8e4dc;
  --soft: #9a968f;
  --muted: #686660;
  --faint: #363533;
  --line: rgba(238, 231, 219, 0.09);
  --line-strong: rgba(238, 231, 219, 0.16);
  --panel: #0b0b0c;
  --accent: #c1c8d1;
  --accent-rgb: 193, 200, 209;
  --mono: "SFMono-Regular", "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  --sans: "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Pretendard", "Apple SD Gothic Neo", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  overflow: hidden;
  overscroll-behavior: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 1px solid rgba(var(--accent-rgb), 0.9);
  outline-offset: 4px;
}

.stage:focus-visible {
  outline: none;
}

body.keyboard-mode .stage:focus-visible {
  outline: 1px solid rgba(var(--accent-rgb), 0.38);
  outline-offset: -10px;
}

::selection {
  color: #080808;
  background: var(--accent);
}

.app {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: 78px minmax(0, 1fr) auto;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(120% 62% at 50% 8%, rgba(38, 39, 41, 0.38) 0%, transparent 62%),
    radial-gradient(80% 55% at 50% 57%, rgba(35, 36, 38, 0.2) 0%, transparent 70%),
    var(--bg);
}

.ambient {
  position: absolute;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

.ambient::before,
.ambient::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.22;
}

.ambient::before {
  top: -28vw;
  right: -18vw;
  width: 52vw;
  height: 52vw;
  background: radial-gradient(circle, rgba(140, 157, 170, 0.34), transparent 68%);
}

.ambient::after {
  bottom: -30vw;
  left: -22vw;
  width: 56vw;
  height: 56vw;
  background: radial-gradient(circle, rgba(101, 94, 81, 0.26), transparent 68%);
}

.grain {
  position: absolute;
  inset: -50%;
  z-index: 80;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
  transform: rotate(7deg);
  animation: grain-shift 1.1s steps(2) infinite;
}

@keyframes grain-shift {
  0% { transform: translate3d(0, 0, 0) rotate(7deg); }
  25% { transform: translate3d(-1.5%, 1.2%, 0) rotate(7deg); }
  50% { transform: translate3d(1%, -1.5%, 0) rotate(7deg); }
  75% { transform: translate3d(1.5%, 0.8%, 0) rotate(7deg); }
  100% { transform: translate3d(0, 0, 0) rotate(7deg); }
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(22px, 3.6vw, 54px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-glyph {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 22px;
  height: 22px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}

.brand-glyph i {
  display: block;
  width: 3px;
  border-radius: 1px 1px 0 0;
  background: linear-gradient(180deg, #f2f0ea, #8e8d89);
}

.brand-glyph i:nth-child(1) { height: 7px; }
.brand-glyph i:nth-child(2) { height: 12px; }
.brand-glyph i:nth-child(3) { height: 9px; }

.brand-word {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.3em;
}

.brand-series {
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
}

.tactile-state {
  position: absolute;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  color: #77746e;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.17em;
  white-space: nowrap;
}

.state-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #55534f;
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.is-live .state-dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.7);
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-control,
.sound-control {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #76736e;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.text-control {
  gap: 8px;
  padding: 0 12px;
}

.text-control:hover,
.sound-control:hover {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.blackout-icon {
  width: 10px;
  height: 10px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 0 50%, transparent 50%);
}

.sound-control {
  gap: 9px;
  min-width: 58px;
  padding: 0 11px;
  border-color: var(--line);
}

.sound-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 11px;
}

.sound-bars i {
  display: block;
  width: 1px;
  height: 3px;
  border-radius: 1px;
  background: #615f5b;
  transition: height 0.25s ease, background 0.25s ease;
}

.sound-bars i:nth-child(2) { height: 7px; }
.sound-bars i:nth-child(3) { height: 5px; }
.sound-bars i:nth-child(4) { height: 2px; }

.sound-control[aria-pressed="true"] .sound-bars i {
  background: var(--accent);
}

.sound-control[aria-pressed="true"] .sound-bars i:nth-child(1) { height: 4px; }
.sound-control[aria-pressed="true"] .sound-bars i:nth-child(2) { height: 9px; }
.sound-control[aria-pressed="true"] .sound-bars i:nth-child(3) { height: 6px; }
.sound-control[aria-pressed="true"] .sound-bars i:nth-child(4) { height: 3px; }

.sound-control[aria-pressed="false"] {
  color: #4b4946;
}

.stage-wrap {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
}

.stage-side {
  position: absolute;
  top: 50%;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(-50%);
  color: #393733;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.2em;
  pointer-events: none;
  animation: side-reveal 1s 0.35s both;
}

.stage-side span {
  writing-mode: vertical-rl;
}

.stage-side i {
  width: 1px;
  height: 58px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.16), transparent);
}

.stage-side-left {
  left: clamp(16px, 4vw, 62px);
}

.stage-side-right {
  right: clamp(16px, 4vw, 62px);
}

@keyframes side-reveal {
  from { opacity: 0; transform: translateY(-46%); }
  to { opacity: 1; transform: translateY(-50%); }
}

.stage-kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(880px, 100%);
  margin-bottom: 3px;
  color: #55534f;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  transition: opacity 0.5s ease;
}

.stage-kicker span:last-child {
  color: #3e3d3a;
}

.kicker-rule {
  width: 42px;
  height: 1px;
  background: var(--line);
}

.stage {
  position: relative;
  width: min(960px, 100%);
  height: clamp(330px, 48vh, 550px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  outline: none;
  transition: opacity 0.5s ease;
}

.stage.is-dragging {
  cursor: grabbing;
}

.stage.is-snapping .field-ring-a {
  box-shadow: 0 0 32px rgba(var(--accent-rgb), 0.14), inset 0 0 24px rgba(var(--accent-rgb), 0.04);
}

.stage.is-snapping .stage-hud strong {
  color: #f1eee7;
}

.stage.is-snapping .stage-beam {
  background: linear-gradient(180deg, transparent, rgba(232, 240, 248, 0.22) 28%, rgba(232, 240, 248, 0.06) 76%, transparent);
}

.stage-word {
  position: absolute;
  top: -2.5%;
  left: 50%;
  z-index: 0;
  transform: translateX(calc(-50% + var(--word-shift, 0px)));
  color: rgba(255, 255, 255, 0.006);
  font-family: var(--sans);
  font-size: clamp(150px, 17vw, 252px);
  font-weight: 500;
  line-height: 0.82;
  letter-spacing: -0.095em;
  white-space: nowrap;
  -webkit-text-stroke: 1px rgba(237, 231, 219, 0.075);
  pointer-events: none;
  user-select: none;
  opacity: calc(0.72 + var(--energy, 0) * 0.25);
  transition: opacity 0.2s linear;
}

.stage-beam {
  position: absolute;
  top: 5%;
  bottom: 27%;
  left: 50%;
  z-index: 0;
  width: 1px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, rgba(229, 236, 244, 0.11) 28%, rgba(229, 236, 244, 0.03) 76%, transparent);
  pointer-events: none;
}

.field-system {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.field-ring {
  position: absolute;
  top: 65.5%;
  left: calc(50% + var(--field-shift, 0px));
  border: 1px solid rgba(227, 236, 245, 0.06);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-7deg);
  opacity: calc(0.5 + var(--field-strength, 0) * 0.55);
  animation: field-breathe 8s ease-in-out infinite;
  pointer-events: none;
  transition: box-shadow 0.24s ease, opacity 0.12s linear;
}

.field-ring-a {
  width: min(42%, 410px);
  height: 148px;
  border-color: rgba(var(--accent-rgb), 0.12);
}

.field-ring-b {
  width: min(60%, 590px);
  height: 232px;
  border-style: dashed;
  border-color: rgba(227, 236, 245, 0.045);
  transform: translate(-50%, -50%) rotate(8deg);
  animation-delay: -2.2s;
}

.field-ring-c {
  width: min(78%, 760px);
  height: 322px;
  border-color: rgba(227, 236, 245, 0.025);
  transform: translate(-50%, -50%) rotate(-2deg);
  animation-delay: -4.5s;
}

.field-node {
  position: absolute;
  top: 65.5%;
  left: calc(50% + var(--field-shift, 0px));
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.5);
  opacity: calc(0.15 + var(--field-strength, 0) * 0.48);
  pointer-events: none;
}

.field-node-a { transform: translate(-192px, -74px); }
.field-node-b { transform: translate(208px, 62px); }

@keyframes field-breathe {
  0%, 100% { filter: brightness(0.85); }
  50% { filter: brightness(1.25); }
}

.stage-hud {
  position: absolute;
  top: 31%;
  right: 1.5%;
  left: 1.5%;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  animation: hud-reveal 0.9s 0.18s both;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-block-right {
  align-items: flex-end;
  text-align: right;
}

.hud-label {
  color: #5a5751;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.18em;
}

.hud-block strong {
  color: #cbc7bf;
  font-family: var(--mono);
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.hud-block strong em {
  margin-left: 4px;
  color: #595650;
  font-size: 0.34em;
  font-style: normal;
  letter-spacing: 0.06em;
  vertical-align: 2px;
}

@keyframes hud-reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.stage-halo {
  position: absolute;
  top: 48%;
  left: 50%;
  width: min(62%, 530px);
  height: 46%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(ellipse at 50% 52%, rgba(210, 219, 228, 0.12), transparent 58%),
    radial-gradient(ellipse at 50% 68%, rgba(133, 131, 122, 0.08), transparent 64%);
  filter: blur(28px);
  opacity: calc(0.82 + var(--energy, 0) * 0.25);
  pointer-events: none;
  transition: opacity 0.5s ease, background 0.5s ease;
}

.rail {
  position: absolute;
  top: 65.5%;
  left: 50%;
  width: min(70%, 660px);
  height: 40px;
  transform: translate(-50%, -50%);
  opacity: 0.86;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.rail-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, rgba(202, 201, 196, 0.13) 10%, rgba(202, 201, 196, 0.2) 50%, rgba(202, 201, 196, 0.13) 90%, transparent);
}

.rail-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 13px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse, rgba(var(--accent-rgb), 0.22), transparent 68%);
  filter: blur(3px);
  transition: opacity 0.3s ease;
}

.detent {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 9px;
  transform: translate(-50%, -50%);
  background: rgba(233, 230, 223, 0.17);
  transition: height 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.detent b {
  position: absolute;
  top: 19px;
  left: 50%;
  transform: translateX(-50%);
  color: #3d3b37;
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 400;
  letter-spacing: 0.1em;
  transition: color 0.2s ease, font-size 0.2s ease;
}

.detent:nth-of-type(3) { left: 13%; }
.detent:nth-of-type(4) { left: 31.5%; }
.detent:nth-of-type(5) { left: 50%; }
.detent:nth-of-type(6) { left: 68.5%; }
.detent:nth-of-type(7) { left: 87%; }

.detent.is-near {
  height: 16px;
  background: rgba(var(--accent-rgb), 0.8);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.28);
}

.detent.is-near b {
  color: var(--accent);
  font-size: 9px;
}

#objectCanvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s ease 0.05s;
}

.stage.is-ready #objectCanvas {
  opacity: 1;
}

.loading-block {
  position: absolute;
  top: 52%;
  left: 50%;
  z-index: 3;
  width: min(44%, 360px);
  aspect-ratio: 2.08 / 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 15% / 30%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(80% 120% at 24% 12%, rgba(255, 255, 255, 0.42), transparent 42%),
    linear-gradient(145deg, #c9ced4 0%, #777e86 44%, #b6bbc1 58%, #555c64 100%);
  box-shadow: 0 30px 50px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.6), inset 0 -10px 18px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transition: opacity 0.45s ease, visibility 0s linear 0.45s;
}

.loading-block::after {
  content: "";
  position: absolute;
  inset: -30% -60%;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.18) 49%, transparent 58%);
  animation: loading-sheen 2.2s ease-in-out infinite;
}

.stage.is-ready .loading-block {
  visibility: hidden;
  opacity: 0;
}

@keyframes loading-sheen {
  0%, 18% { transform: translateX(-40%); }
  72%, 100% { transform: translateX(40%); }
}

.fallback-block {
  position: absolute;
  top: 52%;
  left: 50%;
  z-index: 3;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 26px;
  background:
    radial-gradient(80% 120% at 24% 12%, rgba(255, 255, 255, 0.52), transparent 42%),
    linear-gradient(145deg, #d5d9de 0%, #8f959c 46%, #d8dbde 58%, #6d737a 100%);
  box-shadow: 0 26px 46px rgba(0, 0, 0, 0.72), inset 0 1px 1px rgba(255, 255, 255, 0.65), inset 0 -10px 18px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: background 0.4s ease;
}

.snap-flare {
  position: absolute;
  top: 65.5%;
  left: 50%;
  z-index: 4;
  width: 190px;
  height: 70px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  background: radial-gradient(ellipse, rgba(var(--accent-rgb), 0.18), transparent 64%);
  opacity: 0;
  pointer-events: none;
}

.snap-flare.is-active {
  animation: snap-flare 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes snap-flare {
  0% { opacity: 0.8; transform: translate(-50%, -50%) scale(0.55); }
  40% { opacity: 0.5; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.7); }
}

.drag-caption {
  position: absolute;
  bottom: 34px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  color: #716e68;
  font-size: 13px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: opacity 0.5s ease, color 0.3s ease;
}

.has-touched .drag-caption {
  color: #55534f;
}

.detent-readout {
  position: absolute;
  bottom: 7px;
  left: 50%;
  z-index: 4;
  display: flex;
  align-items: baseline;
  gap: 3px;
  transform: translateX(-50%);
  color: #575550;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  transition: opacity 0.5s ease;
}

.detent-readout #detentNumber {
  color: #9a9790;
  font-size: 15px;
  letter-spacing: -0.04em;
}

.readout-slash {
  color: #393835;
}

.readout-label {
  margin-left: 11px;
  padding-left: 11px;
  border-left: 1px solid var(--line);
  color: #454440;
  font-size: 8px;
  letter-spacing: 0.18em;
}

.trace-deck {
  position: relative;
  z-index: 5;
  width: min(960px, 100%);
  margin: -1px auto 0;
  padding: 11px 0 0;
  border-top: 1px solid var(--line);
  animation: hud-reveal 0.9s 0.3s both;
}

.trace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #56534d;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
}

.trace-head span:last-child {
  color: #77736b;
}

.trace-body {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 76px 24px;
  align-items: center;
  gap: 12px;
  height: 38px;
}

.trace-index {
  color: #34322f;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.trace-index-right {
  text-align: right;
}

.trace-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 38px;
  overflow: hidden;
}

.wave-bar {
  display: block;
  width: 100%;
  min-height: 1px;
  border-radius: 1px;
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.8), rgba(var(--accent-rgb), 0.16));
  opacity: 0.56;
  transition: height 0.09s linear, opacity 0.15s ease;
}

.wave-bar:nth-child(3n) {
  opacity: 0.34;
}

.wave-bar:nth-child(4n) {
  opacity: 0.72;
}

.trace-value {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  color: #4e4b46;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.1em;
}

.trace-value strong {
  color: #c7c2b8;
  font-size: 21px;
  font-weight: 300;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.spark {
  position: absolute;
  top: 65.5%;
  left: calc(50% + var(--spark-origin, 0px));
  z-index: 5;
  width: 2px;
  height: 7px;
  border-radius: 99px;
  background: rgba(var(--accent-rgb), 0.9);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.45);
  pointer-events: none;
  animation: spark-fly 0.56s cubic-bezier(0.18, 0.74, 0.3, 1) forwards;
}

@keyframes spark-fly {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--spark-rot, 0deg)) scaleY(0.4); }
  18% { opacity: 0.8; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--spark-dx, 0px)), calc(-50% + var(--spark-dy, 0px))) rotate(var(--spark-rot, 0deg)) scaleY(0.2); }
}

.console {
  position: relative;
  z-index: 10;
  width: min(960px, calc(100% - 36px));
  margin: 0 auto;
  padding: 17px 0 max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.metric-row {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
}

.metric {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 3px;
  min-width: 0;
  padding: 0 18px;
}

.metric:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 1px;
  background: var(--line);
}

.metric:first-child {
  padding-left: 0;
}

.metric-label {
  margin-bottom: 1px;
  color: #595753;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.18em;
}

.metric strong {
  color: #dedad2;
  font-family: var(--mono);
  font-size: clamp(27px, 2.8vw, 38px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.metric-today strong {
  color: #f1eee7;
  font-size: clamp(36px, 3.7vw, 52px);
}

.metric strong em {
  margin-left: 2px;
  color: #77736c;
  font-size: 0.48em;
  font-style: normal;
  letter-spacing: 0;
}

.metric-unit {
  overflow: hidden;
  color: #4b4945;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-code {
  font-size: clamp(28px, 2.9vw, 38px) !important;
  letter-spacing: -0.08em !important;
}

.console-actions {
  display: flex;
  gap: 7px;
  margin-top: 14px;
}

.action-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  height: 40px;
  flex: 1;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.012);
  color: #8a8781;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.action-link:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}

.action-link:active {
  background: rgba(255, 255, 255, 0.05);
}

.action-arrow {
  color: #55524d;
  font-family: var(--mono);
  font-size: 11px;
}

.action-material {
  justify-content: flex-start;
  gap: 9px;
}

.material-dot {
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-radius: 50%;
  background: linear-gradient(135deg, #eef0f3, #777d84);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  transition: background 0.4s ease;
}

.console-note {
  margin: 9px 0 0;
  color: #3b3a37;
  font-size: 9px;
  letter-spacing: 0.02em;
  text-align: center;
}

.blackout-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transform: translate(-50%, -50%);
  color: #46443f;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.2em;
  opacity: 0;
  pointer-events: none;
}

.blackout-hint span:last-child {
  color: #31302d;
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.02em;
}

body.blackout {
  background: #000;
}

body.blackout .app {
  background: #000;
  grid-template-rows: 0 minmax(0, 1fr) 0;
}

body.blackout .topbar,
body.blackout .console,
body.blackout .stage-kicker,
body.blackout .drag-caption,
body.blackout .detent-readout,
body.blackout .console-note,
body.blackout .stage-side,
body.blackout .stage-word,
body.blackout .stage-hud {
  opacity: 0;
  pointer-events: none;
}

body.blackout .trace-deck {
  display: none;
}

body.blackout .stage-hud,
body.blackout .stage-side {
  visibility: hidden;
}

body.blackout .detent b {
  opacity: 0;
}

body.blackout .stage-halo {
  opacity: 0.46;
}

body.blackout .rail {
  opacity: 0.28;
}

body.blackout .blackout-hint {
  animation: blackout-hint 2.6s ease forwards;
}

@keyframes blackout-hint {
  0% { opacity: 0; }
  12% { opacity: 1; }
  64% { opacity: 1; }
  100% { opacity: 0; }
}

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0s linear 0.34s;
}

.sheet-layer.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.sheet-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  cursor: default;
}

.sheet {
  position: relative;
  width: min(680px, 100%);
  max-height: min(88svh, 760px);
  overflow: auto;
  padding: 22px clamp(22px, 4vw, 36px) max(26px, calc(env(safe-area-inset-bottom) + 18px));
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background:
    radial-gradient(100% 60% at 50% 0%, rgba(62, 62, 61, 0.17), transparent 62%),
    linear-gradient(180deg, #101011 0%, #0a0a0b 58%, #080809 100%);
  box-shadow: 0 -30px 100px rgba(0, 0, 0, 0.55);
  transform: translateY(36px);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  scrollbar-width: thin;
  scrollbar-color: #353432 transparent;
}

.sheet:focus,
.sheet:focus-visible {
  outline: none;
}

.sheet-layer.is-open .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 34px;
  height: 3px;
  margin: -8px auto 18px;
  border-radius: 99px;
  background: #343330;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.sheet-kicker {
  display: block;
  margin-bottom: 7px;
  color: #5a5853;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.2em;
}

.sheet h2 {
  margin: 0;
  color: #eae6de;
  font-size: clamp(29px, 3.8vw, 38px);
  font-weight: 400;
  letter-spacing: -0.045em;
}

.sheet-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: #77736d;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.sheet-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  transform: rotate(5deg);
}

.sheet-close svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.2;
}

.sheet-intro {
  max-width: 480px;
  margin: 12px 0 18px;
  color: #77736c;
  font-size: 12.5px;
  line-height: 1.65;
}

.material-list {
  border-top: 1px solid var(--line);
}

.material-row {
  position: relative;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 62px;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 16px 8px 16px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.25s ease, padding 0.25s ease;
}

.material-row:hover,
.material-row.is-active {
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.055), transparent 78%);
}

.material-row:hover {
  padding-left: 8px;
}

.material-row:disabled {
  cursor: default;
  opacity: 0.5;
}

.material-swatch {
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -8px 16px rgba(0, 0, 0, 0.34), 0 8px 18px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.material-swatch::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

.material-swatch i {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 12%, rgba(255, 255, 255, 0.44) 35%, transparent 50%, rgba(255, 255, 255, 0.08) 72%, transparent 82%);
  transform: translateX(-35%);
  transition: transform 0.45s ease;
}

.material-row:hover .material-swatch i {
  transform: translateX(35%);
}

.swatch-titanium {
  background: linear-gradient(145deg, #d9dde1 0%, #8f959d 43%, #e1e3e4 58%, #6f747a 100%);
}

.swatch-brass {
  background: linear-gradient(145deg, #d7b26f 0%, #956b30 43%, #e0bf84 58%, #60451f 100%);
}

.swatch-carbon {
  background:
    linear-gradient(45deg, transparent 46%, rgba(255, 255, 255, 0.055) 47% 53%, transparent 54%) 0 0 / 8px 8px,
    linear-gradient(-45deg, transparent 46%, rgba(255, 255, 255, 0.04) 47% 53%, transparent 54%) 0 0 / 8px 8px,
    linear-gradient(145deg, #2f3032, #121314 46%, #353638 54%, #0c0c0d);
}

.material-copy {
  display: block;
  min-width: 0;
}

.material-title-line {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 4px;
}

.material-title-line strong {
  color: #dedad3;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.material-code-small {
  color: #4d4b47;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.14em;
}

.material-desc {
  display: block;
  overflow: hidden;
  color: #76736d;
  font-size: 11.5px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.material-spec {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  color: #4e4c47;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.13em;
}

.material-spec i {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #3e3c38;
}

.material-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.material-price strong {
  color: #97938b;
  font-size: 10.5px;
  font-weight: 400;
}

.material-row.is-active .material-price strong {
  color: var(--accent);
}

.material-price small {
  color: #514f4a;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
}

.sheet-footnote {
  margin: 18px 0 0;
  color: #44423e;
  font-size: 9.5px;
  line-height: 1.6;
}

.stats-hero {
  position: relative;
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--line);
}

.stats-hero-label {
  display: block;
  margin-bottom: 6px;
  color: #56534e;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.18em;
}

.stats-hero strong {
  color: #f1eee6;
  font-family: var(--mono);
  font-size: clamp(52px, 8vw, 76px);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.08em;
  font-variant-numeric: tabular-nums;
}

.stats-hero p {
  margin: 10px 0 0;
  color: #89857d;
  font-size: 12.5px;
  line-height: 1.6;
}

.wear-card {
  margin-top: 16px;
  padding: 14px 0 2px;
}

.wear-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 9px;
  color: #66625c;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.11em;
}

.wear-card-head span:last-child {
  color: #57544f;
}

.wear-card-head span:last-child strong {
  color: var(--accent);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.05em;
}

.wear-track {
  position: relative;
  height: 3px;
  overflow: hidden;
  background: #191919;
}

.wear-track i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #6c7178, var(--accent));
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.wear-grain {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 5px, rgba(0, 0, 0, 0.18) 5px 6px);
}

.wear-card p {
  margin: 8px 0 0;
  color: #4d4a45;
  font-size: 9.5px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 17px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stats-grid > div {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 0;
}

.stats-grid > div:not(:first-child) {
  padding-left: 17px;
}

.stats-grid > div:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 1px;
  background: var(--line);
}

.stats-grid span {
  color: #4b4843;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.13em;
}

.stats-grid strong {
  color: #cbc7bf;
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 400;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.stats-grid small {
  color: #4d4a45;
  font-size: 9px;
}

.week-card {
  padding-top: 15px;
}

.week-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #56534e;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.13em;
}

.week-head span:last-child {
  color: #7d7972;
}

.week-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 10px;
  height: 98px;
  padding: 0 2px 1px;
  border-bottom: 1px solid var(--line);
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
}

.week-bar-wrap {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 68px;
}

.week-bar {
  display: block;
  width: 100%;
  min-height: 2px;
  background: #2c2c2d;
  transition: height 0.4s ease, background 0.3s ease;
}

.week-day.is-today .week-bar {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.75), rgba(var(--accent-rgb), 0.18));
}

.week-day-label {
  color: #4a4844;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.week-day.is-today .week-day-label {
  color: #928e87;
}

.toast {
  position: fixed;
  top: max(84px, calc(env(safe-area-inset-top) + 64px));
  left: 50%;
  z-index: 140;
  max-width: min(440px, calc(100vw - 40px));
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 3px;
  background: rgba(17, 17, 18, 0.94);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  color: #bbb7af;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 780px) {
  .sheet {
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 20px;
  }

  .sheet-handle {
    display: none;
  }

  .sheet-head {
    padding-top: 2px;
  }
}

@media (max-width: 720px) {
  .app {
    grid-template-rows: calc(64px + env(safe-area-inset-top, 0px)) minmax(0, 1fr) auto;
  }

  .topbar {
    padding: env(safe-area-inset-top, 0px) 18px 0;
    gap: 10px;
  }

  .brand {
    gap: 9px;
  }

  .brand-series {
    display: none;
  }

  .tactile-state {
    right: 142px;
    left: auto;
    transform: none;
    font-size: 8px;
  }

  .text-control {
    width: 32px;
    padding: 0;
  }

  .text-control > span:last-child {
    display: none;
  }

  .sound-control {
    min-width: 53px;
  }

  .stage-wrap {
    padding: 0 9px;
  }

  .stage-kicker {
    width: calc(100% - 22px);
    gap: 9px;
    font-size: 8px;
  }

  .stage {
    height: clamp(300px, 45vh, 455px);
  }

  .stage-word {
    top: 1.5%;
    font-size: clamp(88px, 26vw, 122px);
    -webkit-text-stroke-color: rgba(237, 231, 219, 0.065);
  }

  .stage-beam {
    top: 10%;
    bottom: 29%;
  }

  .stage-hud {
    top: 28%;
    right: 3.5%;
    left: 3.5%;
  }

  .hud-label {
    font-size: 6.5px;
    letter-spacing: 0.13em;
  }

  .hud-block strong {
    font-size: 18px;
  }

  .field-node {
    display: none;
  }

  .stage-halo {
    width: 84%;
    height: 40%;
    filter: blur(22px);
  }

  .rail {
    width: min(78%, 520px);
  }

  .drag-caption {
    bottom: 31px;
    font-size: 12px;
  }

  .detent-readout {
    font-size: 9px;
  }

  .detent-readout #detentNumber {
    font-size: 13px;
  }

  .detent b {
    top: 17px;
    font-size: 6.5px;
  }

  .detent.is-near b {
    font-size: 8px;
  }

  .trace-deck {
    width: calc(100% - 18px);
    padding-top: 9px;
  }

  .trace-head {
    margin-bottom: 4px;
    font-size: 7px;
  }

  .trace-body {
    grid-template-columns: 18px minmax(0, 1fr) 58px 18px;
    gap: 7px;
    height: 33px;
  }

  .trace-wave {
    height: 33px;
    gap: 1.5px;
  }

  .trace-value strong {
    font-size: 18px;
  }

  .trace-index {
    font-size: 6px;
  }

  .console {
    width: calc(100% - 32px);
    padding-top: 14px;
  }

  .metric {
    padding: 0 11px;
    column-gap: 5px;
  }

  .metric:first-child {
    padding-left: 0;
  }

  .metric strong {
    font-size: clamp(20px, 6.4vw, 25px);
  }

  .metric-today strong {
    font-size: clamp(26px, 8vw, 34px);
  }

  .metric-unit {
    font-size: 6.5px;
    letter-spacing: 0.06em;
  }

  .metric-label {
    font-size: 7.5px;
  }

  .material-code {
    font-size: clamp(21px, 6.7vw, 26px) !important;
  }

  .console-actions {
    margin-top: 11px;
  }

  .action-link {
    height: 36px;
    font-size: 10.5px;
  }

  .console-note {
    margin-top: 7px;
    font-size: 8px;
  }

  .sheet {
    max-height: 90svh;
    padding-right: 20px;
    padding-left: 20px;
  }

  .sheet-intro {
    margin-bottom: 13px;
  }

  .material-row {
    grid-template-columns: 42px minmax(0, 1fr) 50px;
    gap: 11px;
    padding: 13px 4px 13px 0;
  }

  .material-swatch {
    width: 38px;
    height: 38px;
  }

  .material-desc {
    font-size: 10.5px;
  }

  .material-spec {
    margin-top: 5px;
  }

  .material-row:hover {
    padding-left: 4px;
  }

  .stats-hero strong {
    font-size: 54px;
  }

  .week-chart {
    gap: 7px;
    height: 92px;
  }

  .week-bar-wrap {
    height: 62px;
  }
}

@media (max-width: 390px) {
  .tactile-state {
    right: 134px;
  }

  .metric {
    padding: 0 9px;
  }

}

@media (max-height: 700px) and (max-width: 720px) {
  .app {
    grid-template-rows: 56px minmax(0, 1fr) auto;
  }

  .stage {
    height: 280px;
  }

  .stage-kicker {
    display: none;
  }

  .console-note {
    display: none;
  }

  .trace-head {
    font-size: 6.5px;
  }
}

@media (max-width: 1150px) {
  .stage-side {
    display: none;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .app {
    grid-template-rows: calc(46px + env(safe-area-inset-top, 0px)) minmax(0, 1fr) auto;
  }

  .topbar {
    padding: env(safe-area-inset-top, 0px) 20px 0;
  }

  .brand-series,
  .stage-kicker,
  .detent-readout,
  .console-note,
  .trace-deck {
    display: none;
  }

  .stage-wrap {
    padding: 0 12px;
  }

  .stage {
    height: min(300px, calc(100svh - 165px));
    min-height: 180px;
  }

  .stage-halo {
    width: 54%;
    height: 54%;
  }

  .stage-word {
    top: -4%;
    font-size: min(140px, 32vh);
  }

  .stage-hud {
    top: 19%;
  }

  .drag-caption {
    bottom: 7px;
    font-size: 9px;
  }

  .console {
    width: calc(100% - 40px);
    padding: 7px 0 max(7px, env(safe-area-inset-bottom));
  }

  .metric-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-label {
    margin-bottom: 2px;
  }

  .metric strong,
  .metric-today strong {
    font-size: 19px;
  }

  .console-actions {
    margin-top: 6px;
  }

  .action-link {
    height: 27px;
  }

  .sheet {
    max-height: 96svh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .grain {
    animation: none;
  }
}
