/* =========================================================================
   MET-AL · Novel Plotting Gallery — dark chrome-on-near-black "heavy metal"
   ========================================================================= */
:root {
  --bg: #0b0e14;
  --bg-2: #0e131d;
  --panel: #12161f;
  --panel-2: #161b27;
  --ink: #e8eef9;
  --muted: #97a6c4;
  --faint: #5b6880;
  --line: #26324a;
  --line-2: #313f5c;
  --accent: #6fe3c4;
  --accent-2: #4aa8ff;
  --warn: #ffcf6b;
  --bad: #ff7a7a;
  --steel: #aab8d6;
  --radius: 12px;
  --chrome: linear-gradient(180deg, #f6f9ff 0%, #c4d0ea 42%, #6b7a99 52%, #aab8d6 60%, #eef3ff 100%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 15px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 640px at 82% -12%, #16233f 0%, rgba(11,14,20,0) 55%),
    radial-gradient(900px 500px at 10% 0%, #14121f 0%, rgba(11,14,20,0) 50%),
    linear-gradient(180deg, #0c0f16 0%, var(--bg) 40%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* brushed-metal sheen overlay (very subtle, non-interactive) */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    repeating-linear-gradient(95deg, rgba(255,255,255,0.014) 0 2px, rgba(0,0,0,0) 2px 5px);
  mix-blend-mode: overlay; opacity: 0.5;
}
.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 22px 80px; }

/* ---------- header ---------- */
header.app {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 26px 22px 18px; max-width: 1180px; margin: 0 auto;
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 1;
}
.brand-logo {
  height: 74px; width: auto; display: block;
  filter: drop-shadow(0 6px 26px rgba(0,0,0,.7));
}
.title-block { flex: 1; min-width: 260px; }
.title-block h1 {
  margin: 0 0 2px; font-size: 23px; letter-spacing: .6px; font-weight: 800;
  text-transform: uppercase;
  background: var(--chrome);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 1px 0 rgba(0,0,0,.3);
}
.title-block h1 .spark { color: var(--accent); -webkit-text-fill-color: var(--accent); }
.title-block .kicker {
  margin: 0; font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--accent-2); font-weight: 700;
}
.title-block p.tag { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; max-width: 640px; }

.syn-banner {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 4px; padding: 5px 12px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: #0b0e14;
  background: linear-gradient(180deg, #ffe9a8, var(--warn));
  border: 1px solid #d8a93a;
  box-shadow: 0 2px 12px rgba(255,207,107,.18);
}
.syn-banner .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #7a5a12;
  box-shadow: 0 0 0 0 rgba(122,90,18,.6); animation: pulse 2.4s infinite;
}
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(122,90,18,.5)} 70%{box-shadow:0 0 0 7px rgba(122,90,18,0)} 100%{box-shadow:0 0 0 0 rgba(122,90,18,0)} }

.data-status {
  font: 600 11.5px ui-monospace, Menlo, monospace; letter-spacing: .3px;
  padding: 4px 10px; border-radius: 7px; border: 1px solid var(--line);
  color: var(--muted); background: rgba(255,255,255,.02); margin-left: auto; align-self: flex-start;
}
.data-status.ok { color: var(--accent); border-color: rgba(111,227,196,.4); }
.data-status.warn { color: var(--warn); border-color: rgba(255,207,107,.4); }

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 22px 0 6px;
}
.tab {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 9px 15px; border-radius: 10px;
  background: linear-gradient(180deg, var(--panel) 0%, #0f1420 100%);
  border: 1px solid var(--line); color: var(--muted);
  font-size: 13.5px; font-weight: 600; transition: all .15s ease;
}
.tab:hover { border-color: var(--line-2); color: var(--ink); transform: translateY(-1px); }
.tab.on {
  color: #06120f; border-color: rgba(111,227,196,.6);
  background: linear-gradient(180deg, #bff3e4 0%, var(--accent) 60%, #45c4a4 100%);
  box-shadow: 0 4px 18px rgba(111,227,196,.22), inset 0 1px 0 rgba(255,255,255,.6);
}
.tab .tab-short {
  font: 700 10px ui-monospace, Menlo, monospace; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(0,0,0,.22); color: inherit; opacity: .85;
}
.tab.on .tab-short { background: rgba(0,0,0,.18); }

/* ---------- visual frame ---------- */
.visual-meta {
  display: flex; flex-direction: column; gap: 6px;
  margin: 14px 0 12px; padding: 12px 16px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px;
}
#visual-blurb { margin: 0; color: var(--ink); opacity: .94; font-size: 13.8px; }
#visual-formula {
  margin: 0; font: 12px ui-monospace, Menlo, monospace; color: var(--accent-2);
  opacity: .92; word-spacing: 2px;
}

.visual-host {
  background: linear-gradient(180deg, #0f131c 0%, #0c1019 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; position: relative; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 18px 40px rgba(0,0,0,.4);
}
.visual-host::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(111,227,196,.5), rgba(74,168,255,.4), transparent);
}

/* ---------- controls ---------- */
.controls {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 12px;
}
.ctrl {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .2px;
}
.ctrl select {
  background: #0c1019; color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
  background-image: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.12));
}
.ctrl select:hover { border-color: var(--accent-2); }

.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.segmented button {
  background: #0c1019; color: var(--muted); border: none; padding: 6px 13px; cursor: pointer;
  font: 600 12.5px ui-monospace, Menlo, monospace; border-right: 1px solid var(--line);
}
.segmented button:last-child { border-right: none; }
.segmented button.on { background: linear-gradient(180deg, #bff3e4, var(--accent)); color: #06120f; }
.segmented button:hover:not(.on) { color: var(--ink); }

.legend-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.legend-chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.03); border: 1px solid var(--line); color: var(--ink);
  transition: all .12s ease;
}
.legend-chip:hover { border-color: var(--line-2); }
.legend-chip.off { opacity: .38; filter: grayscale(.7); }
.legend-chip .swatch { width: 11px; height: 11px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }

.play-btn {
  cursor: pointer; padding: 7px 16px; border-radius: 8px; font: 600 13px ui-sans-serif;
  color: var(--ink); border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #1a2233 0%, #11151f 100%);
}
.play-btn:hover { border-color: var(--accent); }
.play-btn.on { color: #06120f; background: linear-gradient(180deg, #bff3e4, var(--accent)); border-color: rgba(111,227,196,.6); }

/* ---------- canvas stage ---------- */
.canvas-stage { width: 100%; position: relative; }
.plot-canvas { display: block; width: 100%; }

/* ---------- slider ---------- */
.slider-wrap { display: flex; align-items: center; gap: 14px; margin: 6px 0 4px; }
.slabel { font-size: 12px; color: var(--muted); font-weight: 600; min-width: 130px; }
.slider-label {
  font: 700 13px ui-monospace, Menlo, monospace; color: var(--accent);
  min-width: 86px; text-align: right;
}
input[type=range].thr-slider { flex: 1; }
input[type=range] {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, #1a2233, #2a3b5c); outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--chrome); border: 1px solid #6b7a99; cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #cfd9ef; border: 1px solid #6b7a99; cursor: grab;
}
.mini-slider { width: 120px; }
.mini-val { font: 700 12px ui-monospace, Menlo, monospace; color: var(--accent); min-width: 36px; }

/* ---------- readouts / stat tiles ---------- */
.readout, .obj-summary, .cont-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; min-width: 78px;
  padding: 8px 12px; border-radius: 9px;
  background: linear-gradient(180deg, var(--panel) 0%, #0e131d 100%);
  border: 1px solid var(--line);
}
.stat .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); }
.stat .v { font: 700 15px ui-monospace, Menlo, monospace; color: var(--ink); }
.stat.good-lower { border-color: rgba(111,227,196,.35); }
.stat.good-higher { border-color: rgba(74,168,255,.35); }
.stat.verdict .v { font-size: 13px; color: var(--warn); }

/* ---------- scrubber mini contingency panel ---------- */
.cont-panel { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 16px; align-items: flex-start; }
.cont-grid-wrap { flex: 0 0 auto; }
.cont-title { font: 700 13px ui-monospace, Menlo, monospace; margin-bottom: 8px; }
.cont-grid {
  display: grid; grid-template-columns: auto auto auto; gap: 3px;
}
.cont-grid .cc {
  min-width: 64px; text-align: center; padding: 8px 10px; border-radius: 6px;
  font: 700 15px ui-monospace, Menlo, monospace;
  background: #0e131d; border: 1px solid var(--line);
}
.cont-grid .cc.head {
  font: 600 11px ui-sans-serif; color: var(--muted); background: transparent; border-color: transparent;
  display: flex; align-items: center; justify-content: center;
}
.cont-grid .cc.a { color: var(--accent); border-color: rgba(111,227,196,.4); }
.cont-grid .cc.b { color: var(--bad); border-color: rgba(255,122,122,.4); }
.cont-grid .cc.c { color: var(--warn); border-color: rgba(255,207,107,.4); }
.cont-grid .cc.d { color: var(--steel); }
.cont-legend { margin-top: 8px; font-size: 11px; color: var(--faint); }
.cont-stats { flex: 1; min-width: 240px; margin-top: 0; align-content: flex-start; }

/* ---------- object panel ---------- */
.obj-panel { margin-top: 16px; }
.obj-table {
  width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px;
}
.obj-table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.obj-table td { padding: 6px 10px; border-bottom: 1px solid rgba(38,50,74,.5); font-family: ui-monospace, Menlo, monospace; }
.obj-table tr.focus td { background: rgba(74,168,255,.1); color: var(--ink); }
.obj-table tbody tr:hover td { background: rgba(255,255,255,.03); cursor: pointer; }
.obj-note { margin-top: 10px; font-size: 11.5px; color: var(--faint); font-style: italic; }

/* ---------- tooltip ---------- */
.metal-tooltip {
  position: fixed; z-index: 50; display: none; pointer-events: none;
  min-width: 150px; padding: 10px 12px; border-radius: 10px;
  background: linear-gradient(180deg, #161d2c 0%, #0c1019 100%);
  border: 1px solid var(--line-2); color: var(--ink);
  box-shadow: 0 12px 34px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06);
  font-size: 12px;
}
.metal-tooltip .tip-title {
  display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12.5px;
  margin-bottom: 7px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.metal-tooltip .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.tip-tab { border-collapse: collapse; width: 100%; }
.tip-tab td { padding: 1.5px 0; font-family: ui-monospace, Menlo, monospace; }
.tip-tab td:first-child { color: var(--muted); padding-right: 14px; }
.tip-tab td:last-child { text-align: right; color: var(--ink); font-weight: 600; }
.tip-tab .dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* ---------- misc ---------- */
.error { color: var(--bad); padding: 20px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
#loading { color: var(--muted); padding: 40px; text-align: center; font-size: 14px; }

footer.app {
  margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--faint); font-size: 12px; line-height: 1.7;
}
footer.app code { color: var(--muted); background: rgba(255,255,255,.04); padding: 1px 6px; border-radius: 5px; }
footer.app a { color: var(--accent-2); }

@media (max-width: 640px) {
  .brand-logo { height: 54px; }
  .title-block h1 { font-size: 19px; }
  .data-status { margin-left: 0; }
  .tab .tab-label { display: none; }
}
