:root {
  --bg: #14161a;
  --panel: #1b1e24;
  --line: #2c313a;
  --text: #e8e6e1;
  --muted: #9aa0aa;
  --accent: #ff7a3d;
  --ok: #5ccf8a;
  --warn: #ffbf47;
  --bad: #ff5d5d;
  --w: 360px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }

#views { position: fixed; top: 12px; left: 12px; right: calc(var(--w) + 12px); display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; z-index: 2; }
.seg { display: flex; background: rgba(20,22,26,.82); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 10px; padding: 3px; pointer-events: auto; }
.seg button { background: none; border: 0; padding: 6px 10px; border-radius: 7px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: #2d323b; color: var(--text); }
.seg button:hover { color: var(--text); }

#hud { position: fixed; left: 12px; bottom: 12px; z-index: 2; background: rgba(20,22,26,.82); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-variant-numeric: tabular-nums; pointer-events: none; max-width: calc(100vw - var(--w) - 36px); }
#hud b { color: var(--accent); font-size: 18px; }
#hud span { color: var(--muted); }

#panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--w); background: var(--panel); border-left: 1px solid var(--line); z-index: 3; display: flex; flex-direction: column; }
#panel .scroll { overflow-y: auto; padding: 16px 16px 40px; overscroll-behavior: contain; }
#grip { display: none; }
h1 { font-size: 18px; margin: 0 0 4px; }
.sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

#models { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.model { text-align: left; background: #20242b; border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.model .brand { font-size: 11px; color: var(--muted); }
.model .nm { font-weight: 650; }
.model .pr { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }
.model.on { border-color: var(--accent); background: #2a2420; }

#readout { background: #20242b; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
#readout .big { display: flex; align-items: baseline; gap: 8px; }
#readout .big b { font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
#readout .big span { color: var(--muted); }
#readout dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 10px 0 0; font-size: 13px; }
#readout dt { color: var(--muted); }
#readout dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
#readout .feats { margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
#readout .feats b { color: var(--text); font-weight: 600; }

#warnings { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#warnings li { padding: 6px 10px; border-radius: 8px; font-size: 13px; background: rgba(255,191,71,.1); color: var(--warn); border: 1px solid rgba(255,191,71,.25); }
#warnings li.bad { background: rgba(255,93,93,.1); color: var(--bad); border-color: rgba(255,93,93,.3); }
#warnings li.ok { background: rgba(92,207,138,.1); color: var(--ok); border-color: rgba(92,207,138,.25); }

details { border-top: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
summary::after { content: "+"; color: var(--muted); }
details[open] summary::after { content: "–"; }
.ctl { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.row label { font-size: 13px; color: var(--muted); }
.row output { font-variant-numeric: tabular-nums; font-size: 13px; }
.row input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 0; height: 22px; }
.row .hint { grid-column: 1 / -1; font-size: 11.5px; color: #757b85; }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.pick { display: flex; gap: 4px; }
.pick button { flex: 1; background: #20242b; border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 13px; color: var(--muted); }
.pick button.on { border-color: var(--accent); color: var(--text); }

#compare table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; font-variant-numeric: tabular-nums; }
#compare th, #compare td { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
#compare th:first-child, #compare td:first-child { text-align: left; color: var(--muted); font-weight: 400; }
#compare th { font-weight: 600; }
#compare th.on { color: var(--accent); }

footer { border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; color: var(--muted); }
footer a { color: var(--muted); }
#reset { background: #20242b; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }

@media (max-width: 760px) {
  :root { --w: 0px; --peek: 118px; }
  #views { right: 0; left: 0; top: max(8px, env(safe-area-inset-top)); padding: 0 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; pointer-events: auto; }
  #views::-webkit-scrollbar { display: none; }
  .seg { flex: none; }
  .seg button { padding: 6px 9px; font-size: 13px; }
  #panel { top: auto; left: 0; width: auto; height: var(--peek); border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.35); transition: height .32s cubic-bezier(.2,.8,.2,1); will-change: height; }
  #panel.dragging { transition: none; }
  #grip { display: flex; justify-content: center; align-items: center; background: none; border: 0; height: 26px; flex: none; touch-action: none; cursor: grab; }
  #grip span { width: 44px; height: 5px; border-radius: 3px; background: #4a505b; }
  #panel header { display: none; }
  #panel .scroll { padding: 0 12px max(40px, env(safe-area-inset-bottom)); }
  #panel.peek .scroll { overflow: hidden; }
  #models { margin-bottom: 10px; }
  .model { padding: 6px 8px; }
  #hud { bottom: calc(var(--peek) + 10px); max-width: calc(100vw - 24px); font-size: 13px; }
  #models { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
