:root {
  --bg: #0b0d12; --panel: #141821; --panel2: #1b2030; --line: #262c3d; --text: #e7eaf2;
  --muted: #8b93a7; --accent: #aa66cc; --accent2: #c394db; --on-accent: #0b0d12; --good: #22c55e; --warn: #f59e0b; --bad: #ef4444;
  --radius: 14px;
  /* --accent is Prong's logo purple ($prong-color in slab-webconfig). White on it is 3.8:1, so text on it
     is --on-accent (5.1:1); --accent2 is a lighter step of the same hue for text and outlines (7.3:1 on panels). */
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent2); }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; background: linear-gradient(90deg, #0e1118 220px, var(--bg) 220px); }
.side { border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; background: #0e1118; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 0 8px 14px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--muted);
  text-decoration: none; font-weight: 500; }
.nav a.on { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav a .ic { width: 20px; text-align: center; }
.side .foot { margin-top: auto; color: var(--muted); font-size: 12px; padding: 8px; }

main { padding: 18px 26px 0; display: flex; flex-direction: column; min-height: 100vh; max-width: 1280px; width: 100%; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.device { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px 6px 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.device b { font-weight: 600; } .device span { color: var(--muted); }
.pill { border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; background: var(--panel2);
  border: 1px solid var(--line); white-space: nowrap; }
.pill.good { color: #86efac; border-color: #14532d; background: #0c2116; }
.pill.warn { color: #fcd34d; border-color: #78350f; background: #241a08; }
.pill.acc { color: #c4b5fd; border-color: #4c1d95; background: #1a1233; }
.pill.new { color: #67e8f9; border-color: #155e75; background: #082029; }
.update { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }

h1 { font-size: 22px; margin: 4px 0 2px; } h2 { font-size: 15px; margin: 0 0 10px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1.6fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.flat { padding: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sp { flex: 1; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { background: none; border: 0; padding: 6px 11px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--on-accent); }

/* The slab picture */
.boardwrap { position: relative; }
.board { position: relative; width: 100%; aspect-ratio: 70100 / 34000; border-radius: 22px;
  background: radial-gradient(120% 140% at 50% 0%, #1d2333 0%, #10131b 60%); border: 1px solid #2b3245;
  box-shadow: inset 0 1px 0 #ffffff10, 0 20px 50px #0008; overflow: hidden; }
.board svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.key { position: absolute; width: 5.9%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #2a3044, #161a25 70%); border: 1px solid #39405a;
  display: grid; place-items: center; text-align: center; font-weight: 700; font-size: clamp(7px, 1.05vw, 13px);
  user-select: none; cursor: pointer; touch-action: none; transition: transform .06s, background .06s; }
.key .sub { position: absolute; bottom: 12%; font-size: .62em; font-weight: 600; color: var(--muted); }
.key.down { transform: translate(-50%, -50%) scale(.92); background: radial-gradient(circle at 50% 35%, #fff, #c7d2fe 70%); color: #111; }
.key.sel { outline: 2px solid var(--accent2); outline-offset: 2px; }
.key.changed::after { content: ''; position: absolute; top: 6%; right: 8%; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.key.drop { outline: 2px dashed var(--accent2); outline-offset: 3px; }
.key.menu { width: 4.2%; border-radius: 30%; font-size: clamp(6px, .8vw, 11px); }
.key.slotnum { font-size: clamp(8px, 1.1vw, 14px); }
.key.slotnum.has { border-color: var(--accent); }
.key.slotnum.act { background: var(--accent); color: var(--on-accent); }

.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 12px; }

/* Live outputs */
.gates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gate { background: var(--panel2); border-radius: 12px; padding: 10px; text-align: center; }
.gate svg { width: 100%; max-width: 160px; aspect-ratio: 1; }
.gate .val { font: 600 12px ui-monospace, monospace; color: var(--muted); }
.bar { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; }
.kv .k { color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; }
.chip.on { background: #1d3a5f; border-color: #2563eb; color: #bfdbfe; }

/* Lighting */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; text-align: center; font-size: 12px; font-weight: 600; }
.tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tile canvas { width: 100%; height: 38px; border-radius: 8px; display: block; margin-bottom: 6px; background: #0b0d12; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.sw { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.sw .c { width: 44px; height: 44px; border-radius: 12px; border: 2px solid #ffffff22; }
.sw.add .c { display: grid; place-items: center; border-style: dashed; color: var(--muted); font-size: 22px; }
.slider { display: grid; grid-template-columns: 120px 1fr 56px; align-items: center; gap: 10px; margin: 8px 0; }
.slider input { width: 100%; accent-color: var(--accent); }
.slider output { font: 600 12px ui-monospace, monospace; text-align: right; color: var(--muted); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.toggle:first-child { border-top: 0; }
.sw-t { width: 40px; height: 22px; border-radius: 99px; background: #374151; position: relative; flex: none; }
.sw-t::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: .15s; }
.sw-t.on { background: var(--accent); } .sw-t.on::after { left: 21px; }
.meter { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

/* Mapping */
.palette { display: flex; flex-direction: column; gap: 10px; }
.palette .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.act { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; margin: 0 4px 4px 0; border-radius: 9px; background: var(--panel2);
  border: 1px solid var(--line); cursor: grab; font-weight: 600; font-size: 12px; user-select: none; touch-action: none; }
.act .tint { width: 8px; height: 8px; border-radius: 50%; }
.act.dragging { opacity: .4; }
.dragghost { position: fixed; pointer-events: none; z-index: 50; transform: translate(-50%, -50%); }
.inspector { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.warnbox { background: #241a08; border: 1px solid #78350f; color: #fcd34d; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.halves { display: none; }

/* Profiles */
.plist { display: flex; flex-direction: column; gap: 8px; }
.prow { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.prow.act { border-color: var(--accent); }
.prow .n { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: #0b0d12; }
.prow .nm { font-weight: 600; } .prow .meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.prow.empty { opacity: .55; border-style: dashed; }
.grad { width: 44px; height: 10px; border-radius: 99px; display: inline-block; }

/* Share */
.code { font: 600 13px ui-monospace, monospace; background: #0b0d12; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; word-break: break-all; }
.qr { width: 132px; height: 132px; background: white; border-radius: 10px; padding: 8px; flex: none; }
.diff { width: 100%; border-collapse: collapse; font-size: 13px; }
.diff td, .diff th { padding: 6px 8px; border-top: 1px solid var(--line); text-align: left; }
.diff th { color: var(--muted); font-weight: 600; font-size: 12px; }
.diff .from { color: #fca5a5; } .diff .to { color: #86efac; }
.hubgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hubcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.hubcard .art { height: 70px; }
.hubcard .body { padding: 10px 12px; }
.concept { border: 1px dashed #4c1d95; }

/* Advanced */
.search { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.adv { width: 100%; border-collapse: collapse; }
.adv td { padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.adv td:first-child { width: 42%; }
.adv .scope { font-size: 11px; color: var(--muted); }
.adv select, .adv input[type=number] { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; width: 100%; max-width: 220px; }
.coords { border-collapse: collapse; font: 12px ui-monospace, monospace; width: 100%; }
.coords td, .coords th { border: 1px solid var(--line); padding: 4px 6px; text-align: center; }
.coords th { color: var(--muted); font-weight: 600; }
.coords input { width: 62px; background: transparent; border: 0; text-align: center; }

/* Save bar */
.savebar { position: sticky; bottom: 0; margin: 24px -26px 0; top: auto; background: #0e1118ee; backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 10px 26px; display: flex; align-items: center; gap: 12px; z-index: 20; }
.savebar .live { display: flex; align-items: center; gap: 8px; color: #86efac; font-weight: 600; font-size: 13px; }
.savebar .live i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.mocknote { font-size: 11px; color: #6b7280; }
main > .savebar { margin-top: auto; }
main > .grid, main > .card, main > .hubgrid { margin-bottom: 24px; }

/* Phone */
@media (max-width: 860px) {
  .app { display: flex; flex-direction: column; background: var(--bg); }
  .side { order: 2; position: sticky; top: auto; bottom: 0; height: auto; flex-direction: row; padding: 6px; z-index: 30;
    border-right: 0; border-top: 1px solid var(--line); justify-content: space-around; }
  .brand, .side .foot { display: none; }
  .nav { display: contents; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 4px; }
  .nav a .ic { font-size: 17px; }
  .nav a.on { box-shadow: inset 0 3px 0 var(--accent); }
  main { padding: 12px 12px 0; min-height: 0; }
  .g2, .g3, .hubgrid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .update { margin-left: 0; }
  .savebar { bottom: 0; margin: 20px -12px 0; padding: 8px 12px; }
  .savebar .mocknote { display: none; }
  .key { font-size: 8px; } .key .sub { display: none; }
  .scrollboard { overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 22px; }
  .scrollboard .board { width: 200%; }
  .scrollboard .snap { position: absolute; top: 0; width: 50%; height: 1px; scroll-snap-align: start; }
  .halves { display: flex; justify-content: center; margin-top: 8px; }
  .slider { grid-template-columns: 96px 1fr 48px; }
  h1 { font-size: 19px; }
  .device span.hide-sm { display: none; }
}

/* Full-page pictures: bars in the flow instead of pinned to the first screen. */
body.shot .savebar, body.shot .side { position: static; }
