/* PineOps — tactical operations theme. Dark first; light = "field manual". */
:root {
  --bg: #071015; --bg-far: #0b2026; --bg-line: #1c6b63;
  --panel: rgba(9, 21, 27, .88); --panel-2: rgba(13, 30, 37, .92); --solid: #0a171d;
  --line: #1d3a40; --line-2: #2b5650;
  --text: #d5e6df; --muted: #7f9a94;
  --accent: #38e0b0; --accent-ink: #04130f; --amber: #ffb341; --red: #ff5a4f; --blue: #5cc8ff;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 3px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #e7ece6; --bg-far: #d5ded6; --bg-line: #6f9a8f;
  --panel: rgba(250, 252, 248, .92); --panel-2: rgba(241, 245, 239, .95); --solid: #f6f8f4;
  --line: #c3cfc7; --line-2: #9fb3a9;
  --text: #14241f; --muted: #56695f;
  --accent: #0a7d62; --accent-ink: #ffffff; --amber: #a45f00; --red: #c2362c; --blue: #1267a8;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

#theatre { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; cursor: crosshair; }
.scan { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0, 0, 0, .09) 3px 4px); mix-blend-mode: multiply; }
:root[data-theme="light"] .scan { opacity: .25; }
.page { position: relative; z-index: 1; pointer-events: none; transition: opacity .35s; }
.page > * { pointer-events: auto; }
.recon .page > :not(header) { opacity: 0; pointer-events: none; }
.recon-tip { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 3; display: none; align-items: center; gap: 14px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line-2); font: 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.recon .recon-tip { display: flex; }
.recon-tip b { color: var(--accent); font-weight: 600; min-width: 250px; }

/* header */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; height: 48px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 9px; font: 700 15px var(--mono); letter-spacing: .14em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { color: var(--accent); }
.brand i { font-style: normal; color: var(--accent); }
header nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
header nav a { padding: 6px 10px; font: 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; border-radius: var(--r); }
header nav a:hover, header nav a[aria-current] { color: var(--text); background: color-mix(in srgb, var(--accent) 12%, transparent); text-decoration: none; }
.top .grow { flex: 1; }
.hud { display: flex; align-items: center; gap: 8px; font: 11px var(--mono); letter-spacing: .12em; color: var(--muted); white-space: nowrap; }
.hud b { display: inline-block; min-width: 76px; font-weight: 600; color: var(--accent); }
.hud b::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.hud b[data-state="run"] { color: var(--amber); }
.hud b[data-state="run"]::before { animation: blink .7s steps(2) infinite; }
.hud b[data-state="err"] { color: var(--red); }
@keyframes blink { 50% { opacity: .15; } }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; background: transparent; border: 1px solid transparent; border-radius: var(--r); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn[aria-pressed="true"] { color: var(--accent); }
:root[data-theme="light"] .i-moon, :root:not([data-theme="light"]) .i-sun { display: none; }

/* shell */
.shell { display: grid; grid-template-columns: 196px minmax(0, 1fr); gap: 12px; max-width: 1760px; margin: 0 auto; padding: 12px 16px 0; }
.shell.has-rail { grid-template-columns: 196px minmax(0, 1fr) 172px; }
.solid { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(6px); }
.bracket { position: relative; }
.bracket::before, .bracket::after { content: ""; position: absolute; width: 10px; height: 10px; border: 1px solid var(--accent); pointer-events: none; }
.bracket::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.bracket::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.side { align-self: start; position: sticky; top: 60px; padding: 10px 8px; max-height: calc(100vh - 72px); overflow: auto; }
.side h2 { margin: 10px 8px 4px; font: 10px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.side h2:first-child { margin-top: 2px; }
.side a { display: flex; align-items: center; gap: 8px; padding: 5px 8px; font-size: 13.5px; color: var(--text); border-left: 2px solid transparent; }
.side a:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); text-decoration: none; }
.side a[aria-current] { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.side a small { margin-left: auto; font: 10px var(--mono); color: var(--muted); }

.brief { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; padding: 2px 2px 10px; }
.brief h1 { margin: 0; font: 600 19px/1.25 var(--sans); letter-spacing: -.01em; }
.brief p { margin: 0; color: var(--muted); font-size: 13.5px; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; background: transparent; border: 1px solid var(--line-2); border-radius: var(--r); font: 12px var(--mono); letter-spacing: .04em; color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn svg { flex: none; }
.btn.run { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 0 16px; min-width: 96px; justify-content: center; }
.btn.run:hover { filter: brightness(1.1); color: var(--accent-ink); }
.btn.run.busy { background: var(--amber); border-color: var(--amber); }
.btn.run .spin { display: none; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.run.busy .spin { display: block; }
.btn.run.busy .play { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip { height: 24px; padding: 0 8px; display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 12px; font: 11px var(--mono); color: var(--amber); }
.chip[data-v="6"] { color: var(--accent); }
select.btn { appearance: none; padding-right: 22px; background: no-repeat right 7px center / 8px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 5'%3E%3Cpath d='M0 0h8L4 5z' fill='%237f9a94'/%3E%3C/svg%3E"); }
select.btn option { background: var(--solid); color: var(--text); }
.toolbar .grow { flex: 1; }
.file-btn input { display: none; }

.panes { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); height: clamp(420px, calc(100vh - 215px), 860px); }
.editor-col { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); }
.editor-host { position: relative; flex: 1; min-height: 0; }
#code, #monaco { position: absolute; inset: 0; width: 100%; height: 100%; }
#code { resize: none; border: 0; outline: 0; padding: 12px 14px; background: transparent; color: var(--text); font: 13.5px/1.5 var(--mono); tab-size: 4; white-space: pre; overflow: auto; }
.stdin { border-top: 1px solid var(--line); }
.stdin summary { padding: 6px 12px; font: 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.stdin textarea { display: block; width: 100%; height: 84px; resize: vertical; border: 0; border-top: 1px solid var(--line); padding: 8px 12px; background: transparent; font: 13px/1.45 var(--mono); outline: 0; }

.out-col { display: flex; flex-direction: column; min-width: 0; background: color-mix(in srgb, var(--bg) 55%, transparent); }
.tabs { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.tabs button { height: 34px; padding: 0 14px; background: transparent; border: 0; border-bottom: 2px solid transparent; font: 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { margin-left: 6px; padding: 1px 6px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; }
.tabs .grow { flex: 1; }
.tabs .mini { white-space: nowrap; height: 24px; margin-right: 6px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: var(--r); letter-spacing: .04em; text-transform: none; }
.pane { flex: 1; min-height: 0; overflow: auto; }
#console { padding: 10px 12px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
#console:empty::before { content: "> awaiting orders — press Run (Ctrl/Cmd + Enter)"; color: var(--muted); }
.ln.out { color: var(--text); } .ln.ok { color: var(--accent); } .ln.err { color: var(--red); } .ln.warn { color: var(--amber); } .ln.sys { color: var(--muted); }
.chart-pane { display: flex; flex-direction: column; overflow: hidden; }
#chart-legend { padding: 6px 10px; font: 11px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line); }
#chart { flex: 1; min-height: 0; width: 100%; display: block; cursor: crosshair; }
.data-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line); font: 11px var(--mono); color: var(--muted); }
#preview { width: 100%; height: 100%; border: 0; background: #fff; }
#problems { padding: 8px; }
#problems .empty { margin: 8px; color: var(--muted); font: 12.5px var(--mono); }
.problem { display: block; width: 100%; margin-bottom: 4px; padding: 7px 9px; text-align: left; background: transparent; border: 0; border-left: 2px solid var(--muted); font: 12.5px/1.45 var(--mono); color: var(--text); cursor: pointer; }
.problem:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.problem.error { border-left-color: var(--red); } .problem.warning { border-left-color: var(--amber); }

/* ads: reserved boxes so layout never shifts; never overlap the editor */
.ad { display: grid; place-items: center; overflow: hidden; }
.ad-rail { align-self: start; position: sticky; top: 60px; width: 172px; min-height: 612px; padding: 5px; }
.ad-wide { max-width: 760px; min-height: 102px; margin: 14px auto 0; padding: 5px; }
.ad .ph { font: 10px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); text-align: center; line-height: 1.8; }

/* below the fold */
.below { max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }
.doc { margin-top: 14px; padding: 22px 26px; }
.doc h2 { margin: 26px 0 8px; font: 600 18px var(--sans); }
.doc h2:first-child { margin-top: 0; }
.doc h3 { margin: 18px 0 4px; font: 600 15px var(--sans); }
.doc p, .doc li { color: color-mix(in srgb, var(--text) 86%, var(--muted)); max-width: 76ch; }
.doc pre { margin: 10px 0; padding: 12px 14px; overflow: auto; background: color-mix(in srgb, var(--bg) 70%, transparent); border: 1px solid var(--line); border-radius: var(--r); font: 12.5px/1.5 var(--mono); }
.doc code { font: .92em var(--mono); color: var(--amber); }
.doc pre code { color: var(--text); }
.doc table { border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.doc th, .doc td { padding: 6px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.doc th { font: 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.faq details { border-top: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.grid a { display: block; height: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); color: var(--text); }
.grid a:hover { border-color: var(--accent); text-decoration: none; }
.grid b { display: block; font: 600 14px var(--sans); color: var(--accent); }
.grid span { font-size: 13px; color: var(--muted); }
footer.foot { position: relative; z-index: 1; margin-top: 10px; padding: 18px 16px 26px; border-top: 1px solid var(--line); background: var(--panel); font-size: 13px; color: var(--muted); }
footer .in { max-width: 1100px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 22px; }
footer .in p { flex-basis: 100%; margin: 6px 0 0; max-width: 90ch; }

@media (max-width: 1500px) { .shell.has-rail { grid-template-columns: 196px minmax(0, 1fr); } .ad-rail { display: none; } }
@media (max-width: 980px) {
  .shell, .shell.has-rail { grid-template-columns: minmax(0, 1fr); padding: 10px 10px 0; }
  .side { position: static; display: flex; gap: 4px; overflow-x: auto; max-height: none; padding: 6px; }
  .side h2 { display: none; }
  .side a { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; }
  .side a[aria-current] { border-bottom-color: var(--accent); }
  .side a small { display: none; }
  .panes { grid-template-columns: minmax(0, 1fr); height: auto; }
  .editor-col { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor-host { flex: none; height: 300px; }
  .out-col { height: 380px; }
  .hud span, header nav { display: none; }
  .below { padding: 0 10px 30px; }
  .doc { padding: 16px; }
  #theatre { cursor: default; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
