/* SPDX-License-Identifier: MPL-2.0 */
:root {
  color-scheme: dark;
  --bg: #0a0c0d;
  --panel: #111617;
  --panel-raised: #161c1e;
  --line: #2d383a;
  --line-bright: #465355;
  --text: #d8d1c1;
  --muted: #879293;
  --faint: #596466;
  --amber: #c28a43;
  --teal: #72aaa4;
  --rust: #9c5742;
  --bone: #b7ad91;
  --radius: 3px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 18% -10%, rgba(194, 138, 67, 0.09), transparent 32rem),
    var(--bg);
  background-size: 32px 32px, 32px 32px, auto, auto;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  color: var(--text);
  background: #0d1112;
}

button {
  min-height: 38px;
  padding: 0.62rem 0.78rem;
  color: var(--text);
  font: 700 0.72rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--amber);
  color: #f0e5ce;
  background: #181a17;
}

button:active {
  transform: translateY(1px);
}

button.danger {
  border-color: #744336;
  color: #e1a28f;
}

button.quiet {
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 0.55rem 0.62rem;
  font: 600 0.78rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(194, 138, 67, 0.35);
  outline-offset: 2px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.8rem 1rem;
  color: var(--bg);
  background: var(--text);
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  max-width: 1580px;
  margin: 0 auto;
  padding: 2.6rem 2rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.panel-heading span,
.metric-strip span,
.profile-card > span,
.geometry-grid span,
.audio-card span {
  display: block;
  margin: 0 0 0.38rem;
  color: var(--amber);
  font: 700 0.65rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.14em;
}

.site-header h1 {
  margin: 0;
  font: 850 clamp(2.6rem, 7vw, 6.4rem)/0.86 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: -0.075em;
}

.site-header h1 span {
  display: block;
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: clamp(0.78rem, 1.4vw, 1.2rem);
  letter-spacing: 0.24em;
}

.lede {
  max-width: 62rem;
  margin: 1.2rem 0 0;
  color: var(--muted);
  font: 500 0.94rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.header-receipt {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.4rem 1rem;
  min-width: 190px;
  padding: 1rem;
  border: 1px solid var(--line);
  background: rgba(17, 22, 23, 0.82);
}

.header-receipt span {
  color: var(--faint);
  font: 700 0.62rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}

.header-receipt strong {
  color: var(--bone);
  font: 700 0.7rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: right;
}

main {
  max-width: 1580px;
  margin: 0 auto;
  padding: 1.4rem 2rem 4rem;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(220px, 1.45fr);
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  background: rgba(17, 22, 23, 0.86);
}

.metric-strip > div {
  min-width: 0;
  padding: 0.9rem 1rem;
  border-right: 1px solid var(--line);
}

.metric-strip > div:last-child {
  border-right: 0;
}

.metric-strip span {
  color: var(--faint);
}

.metric-strip strong {
  display: block;
  overflow: hidden;
  color: var(--bone);
  font: 700 0.9rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lab-grid {
  display: grid;
  grid-template-columns: minmax(248px, 0.78fr) minmax(400px, 1.68fr) minmax(310px, 1fr);
  gap: 1rem;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.018), transparent 45%),
    rgba(17, 22, 23, 0.94);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.16);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: 0.82rem 1rem;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.panel-heading b,
.panel-heading > strong {
  color: var(--muted);
  font: 700 0.68rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
}

#geom-status[data-ok="true"] {
  color: var(--teal);
}

#geom-status[data-ok="false"] {
  color: var(--rust);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(114, 170, 164, 0.08);
}

.controls-panel {
  grid-row: span 2;
}

.transport {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.field-stack {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
}

.field-stack label > span {
  display: block;
  margin-bottom: 0.42rem;
  color: var(--muted);
  font: 700 0.66rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.profile-card {
  margin: 0 1rem 1rem;
  padding: 0.85rem;
  border-left: 3px solid var(--amber);
  background: #0d1112;
}

.profile-card strong {
  display: block;
  color: var(--bone);
  font: 700 0.72rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.profile-card p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.status-message {
  margin: 0 1rem 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  color: var(--muted);
  font: 700 0.68rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.status-message[data-kind="pass"] {
  border-color: rgba(114, 170, 164, 0.42);
  color: var(--teal);
}

.status-message[data-kind="active"] {
  border-color: rgba(194, 138, 67, 0.45);
  color: var(--amber);
}

.status-message[data-kind="fail"] {
  border-color: rgba(156, 87, 66, 0.55);
  color: #d88870;
}

.sphere-panel {
  grid-row: span 2;
}

canvas {
  display: block;
  width: 100%;
  background: #0d1011;
}

.sphere-panel canvas {
  height: 590px;
  cursor: grab;
  touch-action: none;
}

.sphere-panel canvas:active {
  cursor: grabbing;
}

.lut-panel canvas {
  height: 494px;
}

.canvas-note {
  margin: 0;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.canvas-note strong {
  color: var(--bone);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
  color: var(--muted);
  font: 600 0.64rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin: 0;
  color: var(--muted);
  letter-spacing: 0;
}

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend .target { background: var(--amber); }
.legend .actual { background: var(--teal); }
.legend .forecast { background: var(--bone); }

.wide {
  grid-column: 1 / -1;
}

.state-panel canvas {
  height: 250px;
}

.surface-panel {
  grid-column: 1 / span 2;
}

.surface-panel canvas,
.contour-panel canvas {
  height: 360px;
}

.geometry-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
}

.geometry-grid > div {
  min-width: 0;
  padding: 1rem;
  border-right: 1px solid var(--line);
}

.geometry-grid > div:last-child {
  border-right: 0;
}

.geometry-grid span {
  color: var(--faint);
}

.geometry-grid strong {
  display: block;
  overflow: hidden;
  color: var(--bone);
  font: 700 0.78rem/1.25 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.digest-line {
  margin: 0;
  padding: 0.72rem 1rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.72rem;
}

.digest-line code {
  color: var(--muted);
}

.inspector {
  margin: 0;
}

.inspector > div {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 0.8rem;
  padding: 0.72rem 1rem;
  border-bottom: 1px solid var(--line);
}

.inspector > div:last-child {
  border-bottom: 0;
}

.inspector dt {
  color: var(--faint);
  font: 700 0.66rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.inspector dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--bone);
  font: 600 0.72rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-panel {
  grid-column: span 2;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  padding: 1rem;
}

.audio-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.8rem;
  align-items: center;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.audio-card p {
  margin: 0;
  color: var(--muted);
  font: 600 0.72rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.audio-card > div:nth-child(2) {
  display: flex;
  gap: 0.55rem;
}

.audio-card audio {
  grid-column: 1 / -1;
  width: 100%;
  height: 34px;
  filter: grayscale(1) sepia(0.15);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font: 600 0.72rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
}

th,
td {
  padding: 0.67rem 1rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  color: var(--faint);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
}

td {
  color: var(--muted);
}

tbody tr:hover td {
  color: var(--text);
  background: rgba(194, 138, 67, 0.035);
}

.boundary {
  margin-top: 1rem;
  padding: 2rem;
  border: 1px solid var(--line);
  background: #0e1213;
}

.boundary h2 {
  max-width: 50rem;
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.6rem);
  letter-spacing: -0.035em;
}

.boundary > p:last-child {
  max-width: 76rem;
  margin: 1rem 0 0;
  color: var(--muted);
  line-height: 1.65;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  max-width: 1580px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font: 600 0.68rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

footer p {
  margin: 0;
}

@media (max-width: 1120px) {
  .lab-grid {
    grid-template-columns: minmax(240px, 0.72fr) minmax(430px, 1.35fr);
  }

  .lut-panel,
  .contour-panel {
    grid-column: 1 / -1;
  }

  .controls-panel,
  .sphere-panel {
    grid-row: auto;
  }

  .surface-panel,
  .export-panel {
    grid-column: 1 / -1;
  }

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

  .metric-strip > div:nth-child(3) {
    border-right: 0;
  }

  .metric-strip > div:nth-child(n+4) {
    border-top: 1px solid var(--line);
  }

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

  .geometry-grid > div:nth-child(3) {
    border-right: 0;
  }

  .geometry-grid > div:nth-child(n+4) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .site-header {
    align-items: stretch;
    flex-direction: column;
    padding: 1.7rem 1rem 1rem;
  }

  main {
    padding: 1rem 1rem 3rem;
  }

  .lab-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .wide,
  .surface-panel,
  .export-panel,
  .lut-panel,
  .contour-panel {
    grid-column: 1;
  }

  .metric-strip {
    grid-template-columns: 1fr 1fr;
  }

  .metric-strip > div {
    border-top: 1px solid var(--line);
  }

  .metric-strip > div:nth-child(odd) {
    border-right: 1px solid var(--line);
  }

  .metric-strip > div:nth-child(even) {
    border-right: 0;
  }

  .hash-metric {
    grid-column: 1 / -1;
  }

  .sphere-panel canvas {
    height: 470px;
  }

  .lut-panel canvas {
    height: 430px;
  }

  .geometry-grid {
    grid-template-columns: 1fr 1fr;
  }

  .geometry-grid > div,
  .geometry-grid > div:nth-child(3) {
    border-top: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  .geometry-grid > div:nth-child(even) {
    border-right: 0;
  }

  .button-grid {
    grid-template-columns: 1fr 1fr;
  }

  .audio-card {
    grid-template-columns: 1fr;
  }

  .audio-card > div:nth-child(2) {
    flex-wrap: wrap;
  }

  footer {
    flex-direction: column;
    padding: 1.5rem 1rem 2.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
