/* CPONE ICCP simulator — styled with the cpone.co.nz design tokens. */
@font-face { font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(fonts/inter-latin-wght.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/jetbrains-mono-latin-500.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/jetbrains-mono-latin-700.woff2) format("woff2"); }

:root {
  --sky: #d6ebfb; --grass: #7ccf4a; --page: #f4f7fb; --card: #fff;
  --text: #1f2933; --text-2: #3e4c59; --muted: #52606d; --line: #e6ebf1;
  --accent: #4ea1ff; --on-accent: #06172b; --link: #1f6fd1;
  --good: #3fb950; --good-strong: #1a7f37; --warn: #e3a32b; --warn-text: #5c3d00; --bad: #e5534b; --bad-strong: #c93c37;
  --panel: #262b33; --panel-2: #1d2128; --edge: #353c47; --panel-text: #edf1f5; --dim: #8e98a6;
  --sim: #3fb950; --sim-tile: #e2f6e5;
  --shadow: 0 2px 8px rgba(20, 40, 60, .1); --radius: 18px;
  --sans: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --pw: 360px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; background: var(--page); color: var(--text); font: 15px/1.5 var(--sans); overflow: hidden; }
.mono { font-family: var(--mono); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ---------- header: sky band with a grass edge, like the site ---------- */
.top {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap;
  background: var(--sky); border-bottom: 10px solid var(--grass); padding: 10px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-height: 44px; }
.brand span { font-weight: 800; font-size: 21px; letter-spacing: .02em; }
.tool { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-2); padding-left: 16px; border-left: 1px solid rgba(31, 41, 51, .15); }
a.tool { text-decoration: none; }
a.tool:hover { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }
.tool .tile { width: 22px; height: 22px; border-radius: 7px; background: var(--sim-tile); box-shadow: inset 0 0 0 6px var(--sim-tile), inset 0 0 0 11px var(--sim); }
.scen { display: flex; gap: 4px; background: rgba(255, 255, 255, .55); border-radius: 999px; padding: 4px; }
.scen button {
  border: 0; background: transparent; border-radius: 999px; min-height: 36px; padding: 0 16px;
  font-weight: 700; font-size: 14px; color: var(--text-2); cursor: pointer;
}
.scen button:hover { background: rgba(255, 255, 255, .8); }
.scen button[aria-checked="true"] { background: var(--text); color: #fff; }
.scen button b { font-family: var(--mono); font-weight: 700; margin-right: 6px; opacity: .6; }
.alltools {
  margin-left: auto; display: inline-flex; align-items: center; min-height: 40px; padding: 0 18px; border-radius: 999px;
  background: var(--text); color: #fff; font-weight: 600; font-size: 14px; text-decoration: none;
}
.alltools:hover { background: #33404d; }

/* ---------- app: scene + instrument panel ---------- */
.app { flex: 1 1 auto; min-height: 0; display: flex; gap: 0; }
#stage { position: relative; flex: 1 1 auto; min-width: 0; background: linear-gradient(180deg, #e6f2fc 0%, var(--page) 70%); }
#stage canvas { display: block; }
#stage.hot { cursor: pointer; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.chart { position: absolute; top: 16px; right: 16px; width: min(520px, calc(100% - 470px)); min-width: 340px; padding: 12px 14px 10px; z-index: 2; }
.chart canvas { display: block; width: 100%; height: auto; margin-top: 4px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.legend span { display: inline-block; width: 16px; height: 3px; border-radius: 2px; background: var(--link); }
.legend .l2 { background: rgba(78, 161, 255, .5); margin-left: 10px; }

.foot { position: absolute; left: 16px; top: 16px; width: 420px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; pointer-events: none; z-index: 2; }
.foot > * { pointer-events: auto; }
.alert {
  position: absolute; z-index: 2; transform: translateX(-50%); width: max-content; max-width: 460px;
  display: none; align-items: center; gap: 12px; padding: 10px 16px 10px 12px; border-radius: 14px;
  font-size: 13px; line-height: 1.35; box-shadow: 0 4px 14px rgba(20, 40, 60, .25);
}
.alert.show { display: flex; }
.alert .ico { flex: 0 0 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; font-weight: 800; }
.alert b { display: block; font-size: 14px; }
.alert.bad { background: var(--bad-strong); color: #fff; }
.alert.bad .ico { background: rgba(255, 255, 255, .2); }
.alert.warn { background: #fdf1d8; color: var(--warn-text); }
.alert.warn .ico { background: var(--warn); color: #fff; }
.alert.good { background: var(--sim-tile); color: var(--good-strong); }
.alert.good .ico { background: var(--good); color: #fff; }
.chips { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip {
  border: 0; border-radius: 999px; min-height: 36px; padding: 0 16px; font-weight: 700; font-size: 13px; cursor: pointer;
  background: #fff; color: var(--text); box-shadow: var(--shadow);
}
.chip.on { background: var(--text); color: #fff; }
.hint { font-size: 13px; color: var(--muted); }

/* ---------- dark instrument panel (fits the window height; sketch.js zooms it) ---------- */
#panel { flex: 0 0 var(--pw); width: var(--pw); padding: 14px 14px 14px 0; overflow: hidden; }
#panelIn { background: var(--panel-2); color: var(--panel-text); border-radius: var(--radius); padding: 18px 18px 14px; }
#panel .eyebrow { color: var(--dim); margin: 14px 0 7px; }
#panel .head .eyebrow { margin: 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.sub { margin: 6px 0 0; font-size: 11.5px; color: var(--dim); }
.tiny { font-size: 11px; color: var(--dim); }
.power {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 10px; border: 0; border-radius: 999px;
  background: var(--panel); color: var(--panel-text); font-weight: 700; cursor: pointer; box-shadow: inset 0 0 0 1px var(--edge);
}
.power .sw { width: 38px; height: 22px; border-radius: 11px; background: #4a525e; position: relative; transition: background-color .2s; }
.power .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 8px; background: #fff; transition: transform .2s; }
.power[aria-checked="true"] .sw { background: var(--good); }
.power[aria-checked="true"] .sw::after { transform: translateX(16px); }

.seg { display: flex; gap: 4px; background: var(--panel); border-radius: 999px; padding: 4px; }
.seg button {
  flex: 1; min-height: 34px; border: 0; border-radius: 999px; background: transparent; color: var(--panel-text);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.seg button:hover { background: #313843; }
.seg button.on { background: var(--accent); color: var(--on-accent); font-weight: 700; }

.setpoint { display: flex; align-items: flex-end; justify-content: space-between; }
.big { font-size: 30px; font-weight: 700; line-height: 1.1; }
.pm { display: flex; gap: 6px; }
.pm button { width: 46px; height: 40px; border: 0; border-radius: 999px; background: var(--panel); color: #fff; font-size: 20px; cursor: pointer; box-shadow: inset 0 0 0 1px var(--edge); }
.pm button:hover { background: #313843; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 10px 0 2px; }

.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.meter { background: #12161b; border-radius: 14px; padding: 2px 12px 10px; box-shadow: inset 0 0 0 1px var(--edge); }
.meter .eyebrow { margin: 10px 0 2px !important; font-size: 10px; }
.mv { text-align: right; font-size: 26px; font-weight: 700; color: #3a4a3f; line-height: 1.15; }
.mv i { font-style: normal; font-size: 14px; margin-left: 4px; }
.on-state .mv { color: #7dff9b; }
.bar { height: 6px; border-radius: 3px; background: #262c34; margin-top: 4px; overflow: hidden; }
.bar b { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
.bar b.hi { background: var(--warn); }
.limit { color: var(--warn); font-weight: 700; font-size: 11.5px; min-height: 16px; margin-top: 6px; }

.status { margin-top: 12px; background: var(--panel); border-radius: 14px; padding: 2px 14px 12px; }
.prs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pr { display: flex; flex-direction: column; }
.pr span { color: var(--dim); font-size: 11.5px; }
.pr b { font-size: 21px; font-weight: 700; }
.statusbar { margin-top: 10px; border-radius: 999px; text-align: center; font-weight: 800; font-size: 13px; letter-spacing: .04em; padding: 6px; background: #4a525e; color: #fff; }

.card-d { margin-top: 12px; background: var(--panel); border-radius: 14px; padding: 12px 14px; }
.card-d h2 { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: -.01em; }
.card-d p { margin: 6px 0 0; color: #b9c2cd; font-size: 12.5px; line-height: 1.5; }
.card-d .eyebrow { margin: 0 0 2px !important; font-size: 10px; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sliderRow { display: flex; align-items: center; gap: 12px; }
.sliderRow b { font-size: 18px; min-width: 4em; text-align: right; }
#fail { accent-color: var(--bad); }
#failSeg { margin-top: 6px; }
.split { display: grid; grid-template-columns: 1fr 1fr; margin-top: 12px; }
.split b { font-size: 19px; }
.toPipe { color: var(--accent); }
.toEarth { color: #ff8a6b; }
.splitbar { height: 8px; border-radius: 4px; background: #ff7a59; margin-top: 6px; overflow: hidden; }
.splitbar b { display: block; height: 100%; width: 100%; background: var(--accent); }
.keys { color: var(--dim); font-size: 11px; line-height: 1.55; margin: 12px 0 0; }

/* ---------- narrow screens: stack, page scrolls ---------- */
@media (max-width: 860px) {
  body { overflow: auto; height: auto; }
  .app { flex-direction: column; }
  #stage { flex: 0 0 auto; height: 64vh; min-height: 360px; }
  #panel { flex: 0 0 auto; width: 100%; padding: 0 12px 12px; overflow: visible; }
  .top { padding: 8px 12px; }
  .tool, .alltools { display: none; }
  .scen { order: 3; width: 100%; }
  .scen button { flex: 1; padding: 0 8px; font-size: 12.5px; }
  .chart { width: min(calc(100% - 16px), 560px); min-width: 0; left: 50%; transform: translateX(-50%); top: 8px; right: auto; padding: 8px 12px 6px; border-radius: 14px; }
  .chart .eyebrow { font-size: 9px; }
  .legend { font-size: 9.5px; }
  .foot { left: 10px; top: auto; bottom: 10px; right: 10px; width: auto; }
  .alert { font-size: 11.5px; padding: 8px 12px 8px 10px; left: 10px; right: 10px; bottom: 58px; top: auto; transform: none; width: auto; max-width: none; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- wharf simulator additions ---------- */
.legend .l3 { background: #9b6cf0; margin-left: 10px; }
.panel-sec[hidden] { display: none; }
.anodebar { height: 10px; border-radius: 5px; background: #262c34; margin-top: 8px; overflow: hidden; }
.anodebar b { display: block; height: 100%; background: linear-gradient(90deg, #b9c3cc, #e3e8ec); }
.stat3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.stat3 .pr b { font-size: 18px; }
.pilemap { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 10px; }
.pilemap i { height: 14px; border-radius: 4px; background: #4a525e; }
