/* ==========================================================================
   2048 RL LAB — visual system
   ========================================================================== */

:root {
  --bg: #080b0c;
  --bg-raised: #0d1213;
  --panel: rgba(17, 23, 24, 0.94);
  --panel-solid: #111718;
  --panel-soft: rgba(255, 255, 255, 0.035);
  --line: rgba(231, 255, 236, 0.09);
  --line-strong: rgba(231, 255, 236, 0.16);
  --text: #edf2e9;
  --muted: #a7b4ab;
  --dim: #7f8d84;
  --lime: #c8ff62;
  --lime-strong: #d7ff8a;
  --lime-soft: rgba(200, 255, 98, 0.12);
  --amber: #ffbd5c;
  --cyan: #73e6d3;
  --red: #ff7474;
  --blue: #8cb8ff;
  --radius: 22px;
  --radius-sm: 14px;
  --gap: 10px;
  --sans: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(200, 255, 98, 0.055), transparent 55%),
    radial-gradient(900px 600px at -10% 30%, rgba(115, 230, 211, 0.045), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  z-index: -3;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 72px 72px;
  content: "";
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 85%);
  pointer-events: none;
}

::selection {
  background: var(--lime);
  color: #081008;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--lime-strong);
  font-family: var(--mono);
  font-size: 0.85em;
}

.ambient {
  position: fixed;
  z-index: -2;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.11;
  pointer-events: none;
}

.ambient-a {
  top: 8%;
  right: -100px;
  background: var(--lime);
}

.ambient-b {
  bottom: -100px;
  left: -120px;
  background: var(--cyan);
}

.noise {
  position: fixed;
  z-index: -1;
  inset: 0;
  opacity: 0.032;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px 28px;
  border-bottom: 1px solid transparent;
  background: linear-gradient(to bottom, rgba(8, 11, 12, 0.99), rgba(8, 11, 12, 0.9) 78%, rgba(8, 11, 12, 0.78));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  justify-self: start;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(3, 5px);
  gap: 3px;
  width: 27px;
  height: 27px;
  padding: 3px;
  border: 1px solid rgba(200, 255, 98, 0.35);
  border-radius: 8px;
  transform: rotate(-8deg);
  background: rgba(200, 255, 98, 0.04);
}

.brand-mark i {
  border-radius: 1px;
  background: rgba(200, 255, 98, 0.18);
}

.brand-mark i:nth-child(1),
.brand-mark i:nth-child(5),
.brand-mark i:nth-child(9) {
  background: var(--lime);
  box-shadow: 0 0 9px rgba(200, 255, 98, 0.55);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 0.92;
}

.brand-copy strong {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.08em;
}

.brand-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.24em;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 21, 22, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-btn.is-active {
  background: var(--lime);
  color: #0a1008;
  box-shadow: 0 0 24px rgba(200, 255, 98, 0.12);
}

.nav-index {
  font-family: var(--mono);
  font-size: 9px;
  opacity: 0.55;
}

.nav-btn.is-active .nav-index {
  opacity: 0.65;
}

.system-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 21, 22, 0.55);
}

.status-dot {
  position: relative;
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.025);
}

.status-dot.is-live {
  background: var(--lime);
  box-shadow: 0 0 12px rgba(200, 255, 98, 0.7);
}

.status-dot.is-live::after {
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(200, 255, 98, 0.5);
  border-radius: 50%;
  content: "";
  animation: pulse-ring 2.2s ease-out infinite;
}

.status-dot.is-warn {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(255, 189, 92, 0.5);
}

.status-dot.is-error {
  background: var(--red);
  box-shadow: 0 0 12px rgba(255, 116, 116, 0.5);
}

@keyframes pulse-ring {
  0% {
    opacity: 0.9;
    transform: scale(0.7);
  }
  80%,
  100% {
    opacity: 0;
    transform: scale(1.6);
  }
}

.system-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.system-copy strong {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.system-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

/* --------------------------------------------------------------------------
   Shell / shared
   -------------------------------------------------------------------------- */

.app-shell {
  width: min(1320px, 100%);
  min-height: calc(100vh - 180px);
  margin: 0 auto;
  padding: 46px 28px 90px;
}

.view {
  display: none;
  animation: view-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.view.is-active {
  display: block;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 60px;
  margin-bottom: 38px;
}

.page-head h1 {
  margin: 10px 0 0;
  font-size: clamp(2.9rem, 5.4vw, 5.2rem);
  font-weight: 500;
  letter-spacing: -0.065em;
  line-height: 0.99;
}

.page-head h1 em {
  color: var(--lime);
  font-style: normal;
  text-shadow: 0 0 42px rgba(200, 255, 98, 0.12);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.eyebrow span {
  color: var(--text);
}

.eyebrow i {
  color: var(--dim);
  font-style: normal;
}

.head-aside {
  width: min(430px, 42vw);
  padding-bottom: 8px;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.head-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.tag-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 7px var(--lime);
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 45%),
    var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), var(--shadow);
}

.panel::after {
  position: absolute;
  top: 0;
  right: 20px;
  left: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 255, 98, 0.18), transparent);
  content: "";
  opacity: 0.55;
  pointer-events: none;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading.compact {
  align-items: center;
}

.panel-heading h2 {
  margin: 5px 0 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.035em;
}

.panel-kicker {
  display: block;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.stat-label {
  display: block;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.mini-mark {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.065);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.btn-primary {
  border-color: var(--lime);
  background: var(--lime);
  color: #0a1008;
  box-shadow: 0 0 0 0 rgba(200, 255, 98, 0);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--lime-strong);
  background: var(--lime-strong);
  box-shadow: 0 0 32px rgba(200, 255, 98, 0.14);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  border-color: rgba(255, 116, 116, 0.3);
  background: rgba(255, 116, 116, 0.06);
}

.btn-wide {
  width: 100%;
}

.btn-small {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 10px;
}

.btn-icon {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1;
}

.text-button {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: color 160ms ease;
}

.text-button:hover {
  color: var(--lime);
}

.panel-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 18px;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  text-align: left;
  transition: color 160ms ease;
}

.panel-link:hover {
  color: var(--lime);
}

.panel-link span {
  font-family: var(--mono);
}

.progress-track {
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.progress-track i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lime), var(--cyan));
  box-shadow: 0 0 14px rgba(200, 255, 98, 0.25);
  transition: width 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.progress-track.large {
  height: 7px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
}

/* --------------------------------------------------------------------------
   Playground
   -------------------------------------------------------------------------- */

.play-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(350px, 0.92fr);
  gap: 24px;
  align-items: start;
}

.game-column {
  min-width: 0;
}

.score-strip {
  display: grid;
  grid-template-columns: 1.28fr 1.02fr 0.88fr 0.78fr 0.98fr;
  gap: 0;
  padding: 8px;
  margin-bottom: 14px;
  border-radius: 18px;
}

.score-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 66px;
  justify-content: center;
  padding: 8px 15px;
}

.score-cell + .score-cell::before {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 1px;
  background: var(--line);
  content: "";
}

.score-cell strong {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 1.1;
}

.score-main strong {
  color: var(--lime);
  font-size: 34px;
}

.score-session strong {
  color: var(--cyan);
}

.score-reset {
  position: absolute;
  top: 7px;
  right: 8px;
  padding: 2px 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 8px;
  opacity: 0.55;
  transition: color 150ms ease, opacity 150ms ease;
}

.score-session:hover .score-reset,
.score-reset:focus-visible {
  opacity: 1;
}

.score-reset:hover {
  color: var(--lime);
}

.board-frame {
  position: relative;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(200, 255, 98, 0.035), transparent 55%),
    rgba(13, 18, 19, 0.88);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.frame-topline,
.frame-bottomline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 8px 12px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.frame-bottomline {
  padding: 12px 8px 2px;
}

.board {
  --gap: 10px;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: var(--gap);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 20px;
  background: #0b1010;
  touch-action: none;
  user-select: none;
}

.board:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

.board.is-shake {
  animation: board-shake 220ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes board-shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(2px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-3px);
  }
  40%,
  60% {
    transform: translateX(3px);
  }
}

.grid-bg {
  position: absolute;
  inset: var(--gap);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--gap);
}

.grid-bg i {
  border: 1px solid rgba(255, 255, 255, 0.032);
  border-radius: 11px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.03), transparent),
    rgba(255, 255, 255, 0.018);
}

.tile-layer {
  position: absolute;
  inset: var(--gap);
  pointer-events: none;
}

.tile {
  --r: 0;
  --c: 0;
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: calc((100% - 3 * var(--gap)) / 4);
  height: calc((100% - 3 * var(--gap)) / 4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: #dbe4d2;
  color: #142015;
  font-family: var(--mono);
  font-size: clamp(1.35rem, 3.2vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.08em;
  line-height: 1;
  transform: translate(
    calc(var(--c) * (100% + var(--gap))),
    calc(var(--r) * (100% + var(--gap)))
  );
  transition:
    transform 110ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 110ms ease,
    background 180ms ease,
    color 180ms ease;
  will-change: transform;
}

.tile[data-digits="3"] {
  font-size: clamp(1.05rem, 2.55vw, 1.8rem);
}

.tile[data-digits="4"] {
  font-size: clamp(0.88rem, 2.15vw, 1.48rem);
}

.tile[data-digits="5"] {
  font-size: clamp(0.72rem, 1.8vw, 1.2rem);
}

.tile[data-value="2"] {
  background: #dce5d1;
  color: #172015;
}

.tile[data-value="4"] {
  background: #cedbb4;
  color: #172015;
}

.tile[data-value="8"] {
  background: #f0d681;
  color: #20190a;
}

.tile[data-value="16"] {
  background: #f0b45c;
  color: #241508;
}

.tile[data-value="32"] {
  background: #ef8d50;
  color: #261008;
}

.tile[data-value="64"] {
  background: #ed6447;
  color: #fff8ef;
}

.tile[data-value="128"] {
  background: #d4e867;
  color: #161d08;
  box-shadow: 0 0 26px rgba(212, 232, 103, 0.15);
}

.tile[data-value="256"] {
  background: #c1ef5a;
  color: #111a07;
  box-shadow: 0 0 28px rgba(193, 239, 90, 0.18);
}

.tile[data-value="512"] {
  background: #a7e94f;
  color: #0e1705;
  box-shadow: 0 0 30px rgba(167, 233, 79, 0.2);
}

.tile[data-value="1024"] {
  background: #8ce45e;
  color: #0b1405;
  box-shadow: 0 0 34px rgba(140, 228, 94, 0.22);
}

.tile[data-value="2048"] {
  background: var(--lime);
  color: #0a1008;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.35),
    0 0 40px rgba(200, 255, 98, 0.32);
}

.tile.is-super {
  border-color: rgba(200, 255, 98, 0.38);
  background: #1c2d1e;
  color: var(--lime);
  box-shadow: 0 0 34px rgba(200, 255, 98, 0.15);
}

.tile.is-new {
  animation: tile-new 180ms cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

.tile.is-merged {
  animation: tile-merge 220ms cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

@keyframes tile-new {
  from {
    opacity: 0;
    scale: 0.55;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

@keyframes tile-merge {
  0% {
    scale: 0.78;
    filter: brightness(1.7);
  }
  60% {
    scale: 1.07;
  }
  100% {
    scale: 1;
    filter: brightness(1);
  }
}

.board-overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(7, 11, 11, 0.9);
  animation: fade-in 200ms ease both;
}

.board-overlay[hidden] {
  display: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.overlay-card {
  max-width: 320px;
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(18, 25, 25, 0.92);
  text-align: center;
  box-shadow: var(--shadow);
}

.overlay-kicker {
  color: var(--red);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.overlay-card strong {
  display: block;
  margin: 8px 0 8px;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.overlay-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 12px;
}

.overlay-card b {
  color: var(--text);
  font-family: var(--mono);
}

.key-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.game-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
}

.control-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.autoplay-cluster {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 230px;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch-label > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.switch-label strong {
  font-size: 11px;
  font-weight: 600;
}

.switch-label small {
  margin-top: 2px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  display: block;
  width: 36px;
  height: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  transition: background 180ms ease, border-color 180ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 180ms ease, background 180ms ease;
}

.switch input:checked + .switch-track {
  border-color: rgba(200, 255, 98, 0.4);
  background: rgba(200, 255, 98, 0.16);
}

.switch input:checked + .switch-track .switch-thumb {
  background: var(--lime);
  transform: translateX(16px);
  box-shadow: 0 0 10px rgba(200, 255, 98, 0.45);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

.speed-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 92px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.speed-control b {
  color: var(--muted);
  font-weight: 500;
}

input[type="range"] {
  width: 100%;
  height: 3px;
  margin: 3px 0;
  border-radius: 999px;
  accent-color: var(--lime);
  cursor: pointer;
}

/* Side column */

.side-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.agent-panel,
.pulse-panel,
.engine-panel {
  padding: 22px;
}

.source-badge {
  padding: 4px 7px;
  border: 1px solid rgba(200, 255, 98, 0.22);
  border-radius: 5px;
  background: rgba(200, 255, 98, 0.07);
  color: var(--lime);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.source-badge.is-model {
  border-color: rgba(115, 230, 211, 0.25);
  background: rgba(115, 230, 211, 0.07);
  color: var(--cyan);
}

.agent-verdict {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 20px 0 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(200, 255, 98, 0.08), transparent 58%),
    rgba(255, 255, 255, 0.018);
}

.verdict-arrow {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 1px solid rgba(200, 255, 98, 0.24);
  border-radius: 15px;
  background: rgba(200, 255, 98, 0.08);
  color: var(--lime);
  font-family: var(--mono);
  font-size: 32px;
  line-height: 1;
  box-shadow: inset 0 0 24px rgba(200, 255, 98, 0.035);
  transition: transform 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2), color 180ms ease;
}

.verdict-arrow.is-up {
  transform: rotate(0deg);
}

.verdict-arrow.is-right {
  transform: rotate(90deg);
}

.verdict-arrow.is-down {
  transform: rotate(180deg);
}

.verdict-arrow.is-left {
  transform: rotate(270deg);
}

.verdict-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.verdict-copy strong {
  margin: 4px 0 2px;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.verdict-copy small {
  overflow: hidden;
  color: var(--dim);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.q-chart {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.q-row {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  align-items: center;
  gap: 10px;
}

.q-row.is-best .q-dir,
.q-row.is-best .q-value {
  color: var(--lime);
}

.q-dir {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.q-dir b {
  margin-left: 4px;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 500;
}

.q-track {
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
}

.q-track i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(200, 255, 98, 0.5), var(--lime));
  transition: width 300ms ease, background 180ms ease;
}

.q-row.is-best .q-track i {
  box-shadow: 0 0 12px rgba(200, 255, 98, 0.25);
}

.q-value {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
}

.agent-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.mini-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.mini-field > span {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mini-field select {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  outline: none;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.mini-field select:hover,
.mini-field select:focus-visible {
  border-color: rgba(200, 255, 98, 0.28);
  color: var(--text);
}

.agent-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.agent-meta > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.meta-label {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.15em;
}

.agent-meta strong {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.live-pill span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dim);
}

.live-pill.is-live {
  border-color: rgba(200, 255, 98, 0.22);
  color: var(--lime);
}

.live-pill.is-live span {
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

.pulse-progress {
  margin: 18px 0;
}

.pulse-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pulse-stats > div {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.018);
}

.pulse-stats strong {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.engine-panel .panel-heading {
  margin-bottom: 12px;
}

.engine-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.engine-row:first-of-type {
  border-top: 0;
}

.engine-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--lime);
  font-family: var(--mono);
  font-size: 12px;
}

.engine-row > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.engine-row strong {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
}

.engine-row small {
  margin-top: 2px;
  color: var(--dim);
  font-size: 9px;
}

/* --------------------------------------------------------------------------
   Training
   -------------------------------------------------------------------------- */

.train-head {
  margin-bottom: 32px;
}

.device-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.022);
}

.device-banner > div {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.device-banner strong {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.device-banner small {
  margin-top: 2px;
  color: var(--dim);
  font-size: 9px;
}

.device-banner.is-cuda {
  border-color: rgba(200, 255, 98, 0.18);
  background: rgba(200, 255, 98, 0.04);
}

.device-banner.is-warn {
  border-color: rgba(255, 189, 92, 0.2);
  background: rgba(255, 189, 92, 0.035);
}

.device-banner.is-error {
  border-color: rgba(255, 116, 116, 0.22);
  background: rgba(255, 116, 116, 0.035);
}

.train-grid {
  display: grid;
  grid-template-columns: minmax(330px, 382px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.config-panel {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 104px);
  padding: 22px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.config-panel::-webkit-scrollbar {
  width: 5px;
}

.config-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.config-heading {
  margin-bottom: 15px;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
  padding: 9px 9px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.preset-btn strong {
  overflow: hidden;
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-btn span {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  white-space: nowrap;
}

.preset-btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.preset-btn.is-active {
  border-color: rgba(200, 255, 98, 0.28);
  background: rgba(200, 255, 98, 0.055);
  color: var(--lime);
}

.preset-btn.is-active span {
  color: rgba(200, 255, 98, 0.52);
}

.config-group {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.config-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.config-group-title span {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.two {
  grid-template-columns: 1fr 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field.span-two {
  grid-column: span 2;
}

.field > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.field > span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.field small {
  color: var(--dim);
  font-size: 9px;
  line-height: 1.45;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  transition: border-color 160ms ease, background 160ms ease;
}

.field input:hover,
.field select:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.field select:focus {
  border-color: rgba(200, 255, 98, 0.45);
  outline: 0;
  background: rgba(0, 0, 0, 0.3);
}

.field input:disabled,
.field select:disabled {
  opacity: 0.48;
}

.field select {
  cursor: pointer;
}

.config-details {
  border-top: 1px solid var(--line);
}

.config-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 0 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  list-style: none;
}

.config-details summary::-webkit-details-marker {
  display: none;
}

.config-details summary i {
  color: var(--lime);
  font-family: var(--mono);
  font-style: normal;
  font-size: 13px;
  transition: transform 160ms ease;
}

.config-details[open] summary i {
  transform: rotate(45deg);
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.toggle-row > span:first-child {
  display: flex;
  flex-direction: column;
}

.toggle-row strong {
  font-size: 10px;
  font-weight: 500;
}

.toggle-row small {
  margin-top: 2px;
  color: var(--dim);
  font-size: 8px;
}

.train-error {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 116, 116, 0.24);
  border-radius: 9px;
  background: rgba(255, 116, 116, 0.06);
  color: #ffb0b0;
  font-size: 10px;
  line-height: 1.5;
}

.config-actions {
  margin-top: 17px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 7px;
}

.secondary-actions .btn {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 10px;
}

.train-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.run-panel {
  padding: 22px;
}

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

.run-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.run-title-row h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.045em;
}

.run-subtitle {
  margin: 5px 0 0;
  color: var(--dim);
  font-size: 10px;
}

.run-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.run-state span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dim);
}

.run-state.running {
  border-color: rgba(200, 255, 98, 0.25);
  color: var(--lime);
}

.run-state.running span {
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  animation: blink 1.5s ease-in-out infinite;
}

.run-state.paused {
  border-color: rgba(255, 189, 92, 0.25);
  color: var(--amber);
}

.run-state.paused span {
  background: var(--amber);
}

.run-state.error {
  border-color: rgba(255, 116, 116, 0.25);
  color: var(--red);
}

.run-state.error span {
  background: var(--red);
}

.run-state.completed {
  border-color: rgba(115, 230, 211, 0.25);
  color: var(--cyan);
}

.run-state.completed span {
  background: var(--cyan);
}

.run-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.run-progress {
  margin: 22px 0;
}

.run-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.run-stat {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.018);
}

.run-stat strong {
  display: block;
  margin: 5px 0 2px;
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 1.1;
}

.run-stat small {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
}

.chart-panel {
  padding: 15px 15px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent),
    rgba(0, 0, 0, 0.12);
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
}

.chart-tab {
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: color 150ms ease, background 150ms ease;
}

.chart-tab:hover {
  color: var(--muted);
}

.chart-tab.is-active {
  background: rgba(200, 255, 98, 0.1);
  color: var(--lime);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
}

.chart-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dim);
}

.legend-dot.raw {
  background: rgba(200, 255, 98, 0.4);
}

.legend-dot.avg {
  background: var(--lime);
  box-shadow: 0 0 6px rgba(200, 255, 98, 0.4);
}

#chart-caption {
  margin-left: auto;
}

.chart-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--dim);
  font-size: 10px;
}

.chart-summary b {
  margin-left: 5px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
}

.chart-wrap {
  position: relative;
  height: 300px;
  margin-top: 8px;
}

#metric-chart {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
}

.chart-empty span {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
}

.chart-empty p {
  margin: 0;
  color: var(--dim);
  font-size: 10px;
  opacity: 0.72;
}

.chart-empty[hidden] {
  display: none;
}

.run-footer-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 12px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.run-footer-stats b {
  margin-left: 5px;
  color: var(--muted);
  font-weight: 500;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.log-panel,
.checkpoint-panel {
  min-height: 230px;
  padding: 19px;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 180px;
  margin-top: 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.log-empty,
.empty-note {
  color: var(--dim);
  font-size: 10px;
  line-height: 1.6;
}

.log-line {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  font-size: 9px;
  line-height: 1.5;
}

.log-line:last-child {
  border-bottom: 0;
}

.log-time {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
}

.log-message {
  color: var(--muted);
}

.log-line.success .log-message {
  color: rgba(200, 255, 98, 0.78);
}

.log-line.warn .log-message {
  color: rgba(255, 189, 92, 0.8);
}

.log-line.error .log-message {
  color: rgba(255, 116, 116, 0.9);
}

.checkpoint-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}

.checkpoint-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.018);
}

.checkpoint-item > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.checkpoint-item strong {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkpoint-item small {
  margin-top: 2px;
  color: var(--dim);
  font-size: 8px;
}

.checkpoint-item .text-button {
  flex: 0 0 auto;
  color: var(--lime);
}

.runs-panel {
  padding: 19px;
}

.table-wrap {
  width: 100%;
  margin-top: 12px;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.data-table th {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: left;
}

.data-table td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.018);
}

.data-table .table-empty {
  padding: 22px 8px;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 10px;
  text-align: center;
}

.table-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.table-status i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dim);
}

.table-status.completed i {
  background: var(--cyan);
}

.table-status.stopped i {
  background: var(--amber);
}

.table-status.error i {
  background: var(--red);
}

/* --------------------------------------------------------------------------
   Models
   -------------------------------------------------------------------------- */

.models-head {
  margin-bottom: 30px;
}

.active-model-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 17px 19px;
  margin-bottom: 30px;
}

.active-model-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(200, 255, 98, 0.22);
  border-radius: 13px;
  background: rgba(200, 255, 98, 0.06);
  color: var(--lime);
  font-family: var(--mono);
  font-size: 24px;
  box-shadow: inset 0 0 24px rgba(200, 255, 98, 0.04);
}

.active-model-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.active-model-copy strong {
  overflow: hidden;
  margin: 3px 0 2px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-model-copy small {
  color: var(--dim);
  font-size: 10px;
}

.models-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
}

.models-toolbar h2 {
  margin: 5px 0 0;
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}

.model-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 19px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background:
    radial-gradient(100% 90% at 100% 0%, rgba(200, 255, 98, 0.04), transparent 55%),
    var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 18px 50px rgba(0, 0, 0, 0.22);
  transition: border-color 180ms ease, transform 180ms ease;
}

.model-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.model-card.is-active {
  border-color: rgba(200, 255, 98, 0.26);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 0 50px rgba(200, 255, 98, 0.045);
}

.model-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.model-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.model-name strong {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-name small {
  margin-top: 3px;
  color: var(--dim);
  font-size: 8px;
}

.model-badge {
  flex: 0 0 auto;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.model-card.is-active .model-badge {
  border-color: rgba(200, 255, 98, 0.25);
  color: var(--lime);
}

.model-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 17px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}

.model-metrics > div {
  padding: 9px;
  background: rgba(11, 16, 16, 0.7);
}

.model-metrics span {
  display: block;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.model-metrics strong {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.model-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 18px;
}

.model-tag {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
}

.model-eval {
  margin-bottom: 13px;
  padding: 10px;
  border: 1px solid rgba(115, 230, 211, 0.16);
  border-radius: 10px;
  background: rgba(115, 230, 211, 0.035);
}

.model-eval-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.model-eval-head span:last-child {
  color: var(--dim);
}

.model-eval-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line);
}

.model-eval-grid > div {
  padding: 6px;
  background: rgba(11, 16, 16, 0.72);
}

.model-eval-grid span {
  display: block;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.model-eval-grid strong {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.model-eval-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}

.eval-tile {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 8px;
}

.eval-tile i {
  color: var(--dim);
  font-style: normal;
}

.model-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.model-actions .btn {
  flex: 1;
  min-height: 36px;
  padding: 7px 8px;
  font-size: 10px;
}

.model-actions .evaluate-model {
  flex: 0 0 auto;
  padding-right: 11px;
  padding-left: 11px;
}

.model-actions .btn-icon-only {
  flex: 0 0 34px;
  padding: 0;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: 40px;
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.012);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--lime);
  font-family: var(--mono);
  font-size: 22px;
}

.empty-state strong {
  font-size: 16px;
  font-weight: 500;
}

.empty-state p {
  margin: 5px 0 18px;
  color: var(--dim);
  font-size: 11px;
}

.model-runs {
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   Footer / toast
   -------------------------------------------------------------------------- */

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 20px 28px 30px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.site-footer i {
  margin: 0 5px;
  color: var(--line-strong);
  font-style: normal;
}

.site-footer b {
  color: var(--muted);
  font-weight: 500;
}

.help-tip {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: help;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.help-tip:hover,
.help-tip:focus-visible {
  border-color: rgba(200, 255, 98, 0.45);
  background: rgba(200, 255, 98, 0.08);
  color: var(--lime);
}

.help-popover {
  position: fixed;
  z-index: 120;
  max-width: 300px;
  padding: 10px 12px;
  border: 1px solid rgba(200, 255, 98, 0.26);
  border-radius: 9px;
  background: #0c1313;
  color: var(--text);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
  font-size: 12px;
  line-height: 1.65;
  pointer-events: none;
  white-space: normal;
}

.help-popover[hidden] {
  display: none;
}

.toast-stack {
  position: fixed;
  z-index: 60;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(330px, calc(100vw - 44px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(20, 27, 27, 0.96);
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
  animation: toast-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
  pointer-events: auto;
}

.toast::before {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--lime);
  content: "";
}

.toast.is-error {
  border-color: rgba(255, 116, 116, 0.25);
}

.toast.is-error::before {
  background: var(--red);
}

.toast.is-warn::before {
  background: var(--amber);
}

.toast.is-leaving {
  animation: toast-out 180ms ease both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .play-grid,
  .train-grid {
    grid-template-columns: 1fr;
  }

  .config-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .side-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

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

  .engine-panel {
    align-self: stretch;
  }

  .head-aside {
    width: min(390px, 45vw);
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 14px 18px;
  }

  .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: center;
  }

  .nav-btn {
    flex: 1;
    justify-content: center;
  }

  .system-chip {
    grid-column: 2;
    grid-row: 1;
  }

  .app-shell {
    padding: 30px 18px 70px;
  }

  .page-head {
    display: block;
    margin-bottom: 28px;
  }

  .page-head h1 {
    font-size: clamp(2.55rem, 9vw, 4.2rem);
  }

  .head-aside {
    width: auto;
    margin-top: 22px;
    padding-bottom: 0;
  }

  .lede {
    max-width: 560px;
  }

  .model-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .run-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .system-copy small {
    display: none;
  }

  .system-chip {
    padding: 7px 9px;
  }

  .play-head h1 br,
  .train-head h1 br,
  .models-head h1 br {
    display: none;
  }

  .play-head h1,
  .train-head h1,
  .models-head h1 {
    max-width: 600px;
  }

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

  .score-cell {
    min-height: 58px;
  }

  .score-cell:nth-child(3)::before,
  .score-cell:nth-child(5)::before {
    display: none;
  }

  .score-cell:nth-child(3),
  .score-cell:nth-child(4),
  .score-cell:nth-child(5) {
    border-top: 1px solid var(--line);
  }

  .score-cell:nth-child(5) {
    grid-column: span 2;
  }

  .score-main strong {
    font-size: 26px;
  }

  .game-controls {
    display: block;
    padding: 12px;
  }

  .autoplay-cluster {
    justify-content: space-between;
    margin-top: 13px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
  }

  .side-column {
    display: flex;
    align-items: stretch;
  }

  .agent-panel {
    grid-row: auto;
  }

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

  .run-head {
    display: block;
  }

  .run-meta {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-top: 12px;
    gap: 5px 14px;
  }

  .chart-head {
    align-items: flex-start;
  }

  .chart-legend {
    width: 100%;
    justify-content: flex-start;
  }

  #chart-caption {
    margin-left: 0;
  }

  .chart-wrap {
    height: 240px;
  }

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

  .active-model-banner {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .active-model-copy {
    flex-basis: calc(100% - 70px);
  }

  .active-model-banner > .btn {
    width: 100%;
  }

  .site-footer {
    display: block;
    padding: 18px;
    line-height: 1.8;
  }

  .site-footer span {
    display: block;
  }
}

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

  .nav-btn {
    padding: 8px 10px;
    font-size: 11px;
  }

  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar {
    padding-right: 12px;
    padding-left: 12px;
  }

  .page-head h1 {
    font-size: clamp(2rem, 9vw, 2.6rem);
  }

  .panel,
  .run-panel,
  .agent-panel,
  .pulse-panel,
  .engine-panel {
    border-radius: 16px;
  }

  .agent-panel,
  .pulse-panel,
  .engine-panel,
  .run-panel,
  .config-panel {
    padding: 16px;
  }

  .board-frame {
    padding: 8px;
    border-radius: 21px;
  }

  .board {
    --gap: 7px;
    border-radius: 15px;
  }

  .tile {
    border-radius: 9px;
  }

  .grid-bg i {
    border-radius: 8px;
  }

  .frame-topline,
  .frame-bottomline {
    padding-right: 5px;
    padding-left: 5px;
    font-size: 7px;
  }

  .control-cluster {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .control-cluster .btn-primary {
    grid-column: 1 / -1;
  }

  .autoplay-cluster {
    gap: 12px;
  }

  .speed-control {
    min-width: 80px;
  }

  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .field.span-two {
    grid-column: auto;
  }

  .preset-row {
    grid-template-columns: 1fr;
  }

  .preset-btn {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .preset-btn span {
    white-space: normal;
    text-align: right;
  }

  .run-stats {
    grid-template-columns: 1fr 1fr;
  }

  .run-title-row h2 {
    font-size: 21px;
  }

  .chart-tabs {
    width: 100%;
  }

  .chart-tab {
    flex: 1;
  }

  .model-metrics strong {
    font-size: 12px;
  }

  .agent-controls {
    grid-template-columns: 1fr;
  }

  .model-eval-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@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;
  }
}
