:root {
  color-scheme: dark;
  --ink: #f4f0e6;
  --muted: #aaa9a1;
  --panel: rgba(17, 20, 20, .9);
  --line: rgba(255, 255, 255, .12);
  --accent: #f2bb52;
  --good: #5dde9a;
  --bad: #ff786f;
  --tile-size: 72px;
  --surface: #153d33;
  --surface-pattern: rgba(255, 255, 255, .025);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: #090b0b; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(52, 118, 91, .15), transparent 30rem),
    #090b0b;
}

body[data-surface="light"] { --surface: #e5e1d8; --surface-pattern: rgba(0, 0, 0, .035); }
body[data-surface="felt"] { --surface: #17483b; --surface-pattern: rgba(255, 255, 255, .025); }
body[data-surface="dark"] { --surface: #17191d; --surface-pattern: rgba(255, 255, 255, .035); }

button, select, input { font: inherit; }
button, select { color: inherit; }

.topbar, main, footer { width: min(1440px, calc(100% - 40px)); margin-inline: auto; }

.topbar {
  min-height: 116px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 3vw, 2.35rem); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 1.1rem; letter-spacing: -.01em; }
.eyebrow { color: var(--accent); font: 700 .66rem/1.4 ui-monospace, monospace; letter-spacing: .16em; margin-bottom: 7px; }
.topbar__status { color: var(--muted); display: flex; align-items: center; gap: 9px; font-size: .8rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px currentColor; }
.status-dot.is-good { background: var(--good); }
.status-dot.is-bad { background: var(--bad); }

main { padding-block: 24px 60px; display: grid; gap: 18px; }
.control-panel, .overview, .workbench-panel { border: 1px solid var(--line); background: var(--panel); }
.control-panel { padding: 14px; display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.control { display: grid; gap: 7px; min-width: 170px; }
.control--wide { flex: 1; min-width: 240px; }
.control > span, .control legend { color: var(--muted); font-size: .69rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
select, .button, .segmented button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #171a1a;
  padding: 0 12px;
}
select:focus-visible, button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"] { accent-color: var(--accent); min-height: 40px; }
.segmented { border: 0; padding: 0; margin: 0; grid-template-columns: repeat(3, 1fr); }
.segmented legend { grid-column: 1 / -1; margin-bottom: 7px; }
.segmented button { min-width: 64px; padding: 0 8px; cursor: pointer; border-radius: 0; }
.segmented button:first-of-type { border-radius: 4px 0 0 4px; }
.segmented button:last-of-type { border-radius: 0 4px 4px 0; }
.segmented button + button { margin-left: -1px; }
.segmented button.is-active { background: var(--accent); color: #17130c; border-color: var(--accent); }
.button { cursor: pointer; font-weight: 700; }
.button:hover { border-color: var(--accent); }

.overview { padding: 14px; display: grid; grid-template-columns: repeat(4, minmax(90px, 140px)) 1fr; gap: 10px; align-items: center; }
.metric { display: grid; border-right: 1px solid var(--line); }
.metric strong { font: 700 1.25rem/1.1 ui-monospace, monospace; }
.metric span { color: var(--muted); font-size: .66rem; text-transform: uppercase; }
.progress-wrap { padding-left: 12px; }
.progress-label { display: flex; justify-content: space-between; color: var(--muted); font-size: .7rem; margin-bottom: 7px; }
.progress-track { height: 5px; overflow: hidden; background: rgba(255,255,255,.09); border-radius: 9px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s; }

.workbench-panel { padding: clamp(16px, 2.5vw, 28px); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin-bottom: 22px; }
.section-heading > p { margin-bottom: 0; max-width: 620px; color: var(--muted); font-size: .78rem; line-height: 1.6; }
.section-heading--compact { align-items: start; }
.section-heading--compact > div:last-child > p { margin: 0 0 10px; max-width: 520px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.scene-angle-control { display: inline-grid; min-width: 200px; }

.tile-grid {
  min-height: 180px;
  padding: clamp(14px, 3vw, 34px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-size), 1fr));
  justify-items: center;
  align-items: start;
  gap: max(8px, calc(var(--tile-size) * .16));
  border: 1px solid rgba(255,255,255,.08);
  background-color: var(--surface);
  background-image: linear-gradient(45deg, var(--surface-pattern) 25%, transparent 25%, transparent 75%, var(--surface-pattern) 75%), linear-gradient(45deg, var(--surface-pattern) 25%, transparent 25%, transparent 75%, var(--surface-pattern) 75%);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  transition: background-color .2s;
}

.tile-card { width: var(--tile-size); display: grid; gap: 6px; }
.tile-button { width: var(--tile-size); aspect-ratio: 5 / 7; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: calc(var(--tile-size) * .08); }
.tile-button img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 calc(var(--tile-size) * .07) calc(var(--tile-size) * .06) rgba(0,0,0,.38)); transition: transform .15s; }
.tile-button:hover img, .tile-button:focus-visible img { transform: translateY(-4%); }
.tile-button.is-selected { outline: 2px solid var(--accent); outline-offset: 4px; }
.tile-button.is-error { background: repeating-linear-gradient(135deg, rgba(255,120,111,.18) 0 5px, transparent 5px 10px); border: 1px dashed var(--bad); }
.tile-label { overflow: hidden; color: color-mix(in srgb, var(--ink) 70%, transparent); font: 600 max(7px, calc(var(--tile-size) * .12))/1.2 ui-monospace, monospace; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.split-layout { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(480px, 1.28fr); gap: 18px; }
.inspect-panel { min-height: 440px; }
.empty-state { min-height: 300px; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); }
.inspector { display: grid; grid-template-columns: minmax(110px, 180px) 1fr; gap: 20px; }
.inspector__preview { padding: 18px; background: var(--surface); display: grid; place-items: center; min-height: 230px; }
.inspector__preview img { width: 100%; max-height: 230px; object-fit: contain; filter: drop-shadow(0 12px 12px rgba(0,0,0,.4)); }
.inspector__data { margin: 0; min-width: 0; }
.inspector__data div { display: grid; grid-template-columns: 100px 1fr; padding: 9px 0; border-bottom: 1px solid var(--line); gap: 8px; }
.inspector__data dt { color: var(--muted); font-size: .67rem; text-transform: uppercase; }
.inspector__data dd { min-width: 0; margin: 0; font: 600 .72rem/1.4 ui-monospace, monospace; overflow-wrap: anywhere; }
.button--link { grid-column: 1 / -1; display: inline-grid; place-items: center; color: inherit; text-decoration: none; }

.scene { --scene-angle: 45deg; position: relative; min-height: 350px; overflow: hidden; perspective: 850px; background: linear-gradient(155deg, color-mix(in srgb, var(--surface) 80%, white 7%), var(--surface)); border: 1px solid rgba(255,255,255,.08); }
.scene__table { position: absolute; inset: 47% -15% -35%; transform: rotateX(63deg); transform-origin: center top; border-top: 1px solid rgba(255,255,255,.2); background: radial-gradient(ellipse at center top, rgba(255,255,255,.12), transparent 60%); }
.stack { position: absolute; left: 22%; top: 51%; transform-style: preserve-3d; transform: rotateX(var(--scene-angle)) rotateZ(-13deg); transition: transform .2s; }
.fan { position: absolute; right: 29%; top: 55%; transform-style: preserve-3d; transform: rotateX(var(--scene-angle)) rotateZ(11deg); transition: transform .2s; }
.tile-3d { position: absolute; width: 62px; aspect-ratio: 5 / 7; transform-style: preserve-3d; border-radius: 5px; background: #d7cba8; box-shadow: 0 12px 16px rgba(0,0,0,.25); }
.tile-3d::before { content: ""; position: absolute; left: 4px; right: -7px; bottom: -8px; top: 7px; z-index: -1; border-radius: 5px; background: linear-gradient(90deg, #b8a980, #e4d8b5); transform: translateZ(-7px); }
.tile-3d img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: inherit; }
.scene__label { position: absolute; color: rgba(255,255,255,.55); font: 700 .61rem/1 ui-monospace, monospace; letter-spacing: .15em; }
.scene__label--stack { left: 8%; bottom: 12%; }
.scene__label--fan { right: 8%; bottom: 12%; }

.criteria-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.criterion { min-height: 104px; padding: 15px; border: 1px solid var(--line); display: grid; grid-template-columns: 10px 1fr; align-content: start; gap: 4px 12px; }
.criterion__dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--muted); }
.criterion.is-pass .criterion__dot { background: var(--good); box-shadow: 0 0 10px rgba(93,222,154,.45); }
.criterion.is-fail .criterion__dot { background: var(--bad); }
.criterion strong { font-size: .8rem; }
.criterion p { grid-column: 2; color: var(--muted); font-size: .7rem; line-height: 1.5; margin-bottom: 0; }
.criterion__value { grid-column: 2; color: var(--accent); font: 600 .65rem/1.4 ui-monospace, monospace; }

footer { display: flex; justify-content: space-between; gap: 20px; padding-block: 22px 35px; border-top: 1px solid var(--line); color: var(--muted); font-size: .68rem; }
code { font-family: ui-monospace, monospace; color: var(--accent); }

@media (max-width: 900px) {
  .overview { grid-template-columns: repeat(4, 1fr); }
  .progress-wrap { grid-column: 1 / -1; padding: 8px 0 0; }
  .split-layout { grid-template-columns: 1fr; }
  .criteria-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .topbar, main, footer { width: min(100% - 22px, 1440px); }
  .topbar { min-height: 94px; align-items: start; padding-block: 22px; flex-direction: column; }
  .overview { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-of-type(2) { border-right: 0; }
  .section-heading { align-items: start; flex-direction: column; gap: 10px; }
  .criteria-grid { grid-template-columns: 1fr; }
  .inspector { grid-template-columns: 1fr; }
  .scene { min-height: 300px; }
  .tile-3d { width: 50px; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
