/* Ternary Prime Lab – styles. Platform palette: #111317 / #181b20 / #e7eaef / accent #FF5707. */
:root {
  --bg: #111317;
  --panel: #181b20;
  --panel2: #1e2228;
  --line: #2a3038;
  --line2: #353c46;
  --text: #e7eaef;
  --muted: #9aa3af;
  --faint: #6b7480;
  --accent: #ff5707;
  --accent2: #ff7a3d;
  --t0: #4a5260;
  --t1: #39c4d2;
  --t2: #ff5707;
  --tT: #a08cff;
  --good: #52c27a;
  --warn: #f2b84b;
  --bad: #ff5f56;
  --violet: #a08cff;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); }
a { color: var(--accent2); }
a:hover { color: #ff9a68; }
button, input, select { font: inherit; color: inherit; }
::selection { background: rgba(255, 87, 7, .35); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- header */
#top { position: sticky; top: 0; z-index: 20; background: rgba(17, 19, 23, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
#top .bar { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 20px; }
.exit { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line2); border-radius: 6px; background: var(--panel); color: var(--text); text-decoration: none; font-size: 14px; white-space: nowrap; }
.exit:hover { border-color: var(--accent); color: var(--text); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .glyph { display: grid; grid-template-columns: repeat(3, 7px); gap: 3px; }
.brand .glyph i { width: 7px; height: 18px; border-radius: 2px; background: var(--t0); }
.brand .glyph i:nth-child(2) { background: var(--t1); height: 18px; }
.brand .glyph i:nth-child(3) { background: var(--t2); }
.brand b { font-size: 17px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.brand span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#jobs { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); min-width: 0; }
#jobs .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
#jobs.busy .dot { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
#tabs { max-width: 1280px; margin: 0 auto; display: flex; gap: 2px; padding: 0 14px; overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button { flex: none; padding: 10px 14px 11px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); cursor: pointer; font-size: 14px; white-space: nowrap; }
#tabs button:hover { color: var(--text); }
#tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
#tabs button small { color: var(--faint); margin-left: 4px; }

/* ---------------------------------------------------------------- layout */
main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 40px; }
section.tab { display: none; }
section.tab.on { display: block; animation: fade .25s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1000px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .span2 { grid-column: auto; } main { padding: 16px 12px 30px; } #top .bar { padding: 8px 12px; gap: 10px; } .brand span { display: none; } #jobtext { display: none; } }
@media (max-width: 460px) { .brand b { font-size: 14px; letter-spacing: .03em; } .brand .glyph { display: none; } .exit { padding: 6px 9px; font-size: 13px; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; min-width: 0; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.card h2 { margin: 0 0 6px; font-size: 19px; line-height: 1.3; }
.card h3 { margin: 18px 0 6px; font-size: 15px; }
.card h3:first-child { margin-top: 0; }
.card p { margin: 8px 0; }
.card p:first-child { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.kicker { display: block; margin-bottom: 6px; color: var(--accent2); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.lead { font-size: 16px; color: #cfd5dd; max-width: 920px; }
.note { font-size: 13px; color: var(--muted); }
.sep { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
ul.clean { margin: 8px 0; padding-left: 20px; }
ul.clean li { margin: 4px 0; }
.math { font-family: var(--mono); font-size: 14px; color: #d8dde5; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; overflow-x: auto; white-space: nowrap; }
.formula { font-family: var(--mono); color: #d8dde5; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details summary:hover { color: var(--text); }
details[open] summary { margin-bottom: 8px; }

/* ---------------------------------------------------------------- hero */
.hero { position: relative; overflow: hidden; padding: 28px 30px; border-radius: 12px; border: 1px solid var(--line); background: radial-gradient(1200px 400px at 85% -20%, rgba(255, 87, 7, .16), transparent 60%), radial-gradient(800px 300px at 0% 120%, rgba(57, 196, 210, .10), transparent 60%), var(--panel); }
.hero h1 { margin: 0 0 8px; font-size: 32px; line-height: 1.15; letter-spacing: -.01em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead { margin: 0; }
.hero canvas { position: absolute; right: 0; top: 0; height: 100%; width: 46%; opacity: .55; pointer-events: none; }
.hero .inner { position: relative; max-width: 760px; }
@media (max-width: 720px) { .hero { padding: 20px; } .hero h1 { font-size: 25px; } .hero canvas { width: 100%; opacity: .18; } }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- badges & verdicts */
.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; vertical-align: 2px; border: 1px solid; white-space: nowrap; }
.b-theorem { color: var(--good); border-color: rgba(82, 194, 122, .45); background: rgba(82, 194, 122, .08); }
.b-measured { color: var(--t1); border-color: rgba(57, 196, 210, .45); background: rgba(57, 196, 210, .08); }
.b-conjecture { color: var(--warn); border-color: rgba(242, 184, 75, .45); background: rgba(242, 184, 75, .08); }
.b-heuristic { color: var(--violet); border-color: rgba(160, 140, 255, .45); background: rgba(160, 140, 255, .08); }
.b-literature { color: #c9cfd8; border-color: var(--line2); background: rgba(255, 255, 255, .03); }
.verdict { display: inline-flex; align-items: center; gap: 8px; padding: 4px 11px; border-radius: 999px; font-weight: 700; font-size: 13px; letter-spacing: .04em; border: 1px solid; }
.v-no { color: #ff8a80; border-color: rgba(255, 95, 86, .5); background: rgba(255, 95, 86, .1); }
.v-yes { color: #7fe0a2; border-color: rgba(82, 194, 122, .5); background: rgba(82, 194, 122, .1); }
.v-part { color: #ffd27a; border-color: rgba(242, 184, 75, .5); background: rgba(242, 184, 75, .1); }
.v-wait { color: var(--muted); border-color: var(--line2); }
.hyp { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; }
.hyp .num { font-family: var(--mono); font-size: 26px; font-weight: 700; color: var(--faint); line-height: 1; padding-top: 2px; }
.hyp h2 { margin-bottom: 8px; }
.hyp .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 10px; }
@media (max-width: 720px) { .hyp { grid-template-columns: minmax(0, 1fr); gap: 4px; } .hyp .num { font-size: 18px; } }
.evidence { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; margin-top: 10px; align-items: start; }
@media (max-width: 900px) { .evidence { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- stats tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.tile .k { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tile .v { font-family: var(--mono); font-size: 20px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .s { font-size: 12px; color: var(--faint); margin-top: 2px; }
.tile.accent .v { color: var(--accent); }
.tile.cyan .v { color: var(--t1); }
.tile.good .v { color: var(--good); }

/* ---------------------------------------------------------------- controls */
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 4px 0 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select { height: 36px; padding: 0 10px; border: 1px solid var(--line2); border-radius: 6px; background: var(--panel2); outline: none; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input[type="range"] { padding: 0; accent-color: var(--accent); }
.field input.wide { width: min(560px, 80vw); font-family: var(--mono); }
.btn { height: 36px; padding: 0 16px; border: 1px solid var(--line2); border-radius: 6px; background: var(--panel2); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #ff6a24; }
.btn:disabled { opacity: .45; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 9px; border: 1px solid var(--line2); border-radius: 999px; background: none; cursor: pointer; font-size: 12px; font-family: var(--mono); color: var(--muted); }
.chip:hover, .chip.on { color: var(--text); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 7px; overflow: hidden; }
.seg button { padding: 7px 13px; border: 0; background: var(--panel2); color: var(--muted); cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button.on { background: rgba(255, 87, 7, .16); color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; height: 36px; }
.check input { accent-color: var(--accent); }
.progress { position: relative; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin: 8px 0; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); transition: width .15s; }
.runrow { display: flex; align-items: center; gap: 10px; min-height: 22px; font-size: 13px; color: var(--muted); }
.runrow .progress { flex: 1; margin: 0; max-width: 320px; }
.err { color: #ff8a80; }

/* ---------------------------------------------------------------- tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th { position: sticky; top: 0; background: var(--panel2); color: var(--muted); font-weight: 600; font-size: 12px; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td.l, table.data th.l { text-align: left; }
table.data td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data td.sans { font-family: var(--sans); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.hl td { background: rgba(255, 87, 7, .08); }
table.data tr.hl2 td { background: rgba(57, 196, 210, .07); }
.scroll { max-height: 420px; overflow: auto; }
.pv-sig { color: #ff8a80; font-weight: 700; }
.pv-ok { color: var(--good); }

/* ---------------------------------------------------------------- numbers & trits */
.trits { font-family: var(--mono); word-break: break-all; line-height: 1.5; font-size: 15px; }
.trits.big { font-size: 22px; letter-spacing: .02em; }
.t0 { color: var(--t0); }
.t1 { color: var(--t1); }
.t2 { color: var(--t2); }
.tT { color: var(--tT); }
.trits .gap { display: inline-block; width: .35em; }
.repr { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 14px; align-items: baseline; }
.repr > span:nth-child(odd) { color: var(--muted); font-size: 13px; }
.repr > div { font-family: var(--mono); word-break: break-all; min-width: 0; }
@media (max-width: 720px) { .repr { grid-template-columns: minmax(0, 1fr); gap: 2px; } .repr > span:nth-child(odd) { margin-top: 8px; } }
.bigverdict { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.bigverdict .word { font-size: 28px; font-weight: 800; letter-spacing: .08em; }
.bigverdict .word.prime { color: var(--good); }
.bigverdict .word.comp { color: var(--accent); }
.factor { display: inline-block; margin: 3px 8px 3px 0; padding: 3px 8px; border: 1px solid var(--line2); border-radius: 6px; font-family: var(--mono); font-size: 13px; }

/* ---------------------------------------------------------------- charts */
.chart { position: relative; width: 100%; }
.chart canvas { display: block; width: 100%; }
.chart .tip { position: absolute; z-index: 5; pointer-events: none; padding: 7px 10px; border: 1px solid var(--line2); border-radius: 6px; background: rgba(24, 27, 32, .96); font-size: 12px; font-family: var(--mono); white-space: nowrap; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); }
.chart .tip b { font-family: var(--sans); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 8px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; height: 2px; }
.viz { position: relative; width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #0d0f12; overflow: hidden; }
.viz canvas { display: block; width: 100%; touch-action: none; }
.viz .tip { position: absolute; pointer-events: none; padding: 7px 10px; border: 1px solid var(--line2); border-radius: 6px; background: rgba(24, 27, 32, .96); font-size: 12px; font-family: var(--mono); white-space: nowrap; z-index: 4; }

/* ---------------------------------------------------------------- footer */
footer { border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; }
footer .bar { max-width: 1280px; margin: 0 auto; padding: 14px 20px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
footer a { color: var(--muted); }
footer .grow { flex: 1; }
.refs { margin: 0; padding-left: 20px; font-size: 13px; color: #c3c9d2; }
.refs li { margin: 5px 0; }
.refs i { color: var(--muted); }
