:root {
  --ink: #e8f4f8;
  --ink-dim: #93a8b3;
  --ink-faint: #5f7280;
  --rail: rgba(6, 12, 18, 0.92);
  --line: rgba(232, 244, 248, 0.1);
  --accent: #a5f8d3;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; user-select: none; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

canvas#canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ── top bar ────────────────────────────────────────────────────────── */
#top {
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; pointer-events: none; z-index: 6;
}
#top .brand { display: flex; align-items: baseline; gap: 8px; pointer-events: auto; }
#top .name { font-size: 15px; font-weight: 500; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
#top .sub { font-size: 12px; color: var(--ink-dim); text-shadow: 0 1px 3px rgba(0,0,0,.8); }
#top .bar { display: flex; gap: 6px; }

#top .bar button {
  pointer-events: auto; height: 32px; padding: 0 12px;
  border-radius: 6px; border: 1px solid var(--line);
  background: rgba(6, 12, 18, 0.7); color: var(--ink);
  font-size: 12.5px; cursor: pointer; backdrop-filter: blur(6px);
}
#top .bar button:hover { border-color: rgba(232, 244, 248, 0.3); }

#credit {
  position: fixed; top: 56px; left: 14px; z-index: 6;
  font-size: 10px; line-height: 1.25; color: rgba(147, 168, 179, 0.8);
  pointer-events: none; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
#credit a {
  color: rgba(232, 244, 248, 0.7); text-decoration: none; pointer-events: auto;
  border-bottom: 1px solid rgba(232, 244, 248, 0.2);
}
#credit a:hover { color: #fff; }

#boot {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: #000; color: #6f8896;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em;
  transition: opacity .4s ease; pointer-events: none;
}
#boot.gone { opacity: 0; }

/* ── panel ──────────────────────────────────────────────────────────── */
#panel {
  position: fixed; top: 52px; right: 0; bottom: 0;
  width: 320px; max-width: 88vw;
  background: var(--rail); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .22s ease;
  display: flex; flex-direction: column; z-index: 7; backdrop-filter: blur(8px);
}
body.panel-open #panel { transform: translateX(0); }

#panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--ink-dim);
}
#panel-close { border: 0; background: none; color: var(--ink-dim); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
#panel-close:hover { color: var(--ink); }

#panel-body { padding: 4px 14px 24px; overflow-y: auto; flex: 1; }
#panel-body h3 {
  margin: 16px 0 6px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint);
}
#panel-body h3.toggle { cursor: pointer; }
#panel-body h3.toggle::before {
  content: "\25B8"; display: inline-block; margin-right: 7px; transition: transform .15s ease;
}
#panel-body h3.toggle.open::before { transform: rotate(90deg); }
#panel-body .section.collapsed { display: none; }

#panel-foot { border-top: 1px solid var(--line); padding: 10px 14px 14px; }
#reset {
  width: 100%; height: 34px; border-radius: 6px;
  border: 1px solid var(--line); background: #0d1a24; color: var(--ink);
  font-size: 12.5px; cursor: pointer;
}
#reset:hover { border-color: rgba(232, 244, 248, 0.3); }
#panel-foot .keys {
  display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 10px 0 0;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
}
#panel-foot .keys b { color: var(--ink-dim); font-weight: 500; }
#panel-foot .share { margin: 8px 0 0; font-size: 10.5px; color: var(--ink-faint); }

.row { display: flex; align-items: center; gap: 10px; padding: 5px 0; min-height: 30px; }
.row .label { flex: 1; font-size: 12.5px; color: var(--ink-dim); line-height: 1.3; }
.row input[type="range"] { flex: 0 0 104px; accent-color: var(--accent); height: 18px; }
.row .val { flex: 0 0 40px; text-align: right; font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }

.row input[type="checkbox"] {
  appearance: none; width: 34px; height: 20px; border-radius: 999px;
  border: 1px solid var(--line); background: #152230; position: relative;
  cursor: pointer; flex: 0 0 auto; transition: background .15s ease, border-color .15s ease;
}
.row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #8a8a8a; transition: transform .15s ease, background .15s ease;
}
.row input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.row input[type="checkbox"]:checked::after { transform: translateX(14px); background: #04241c; }

.row input[type="color"] {
  width: 42px; height: 28px; padding: 0; border: 1px solid var(--line);
  border-radius: 6px; background: #0d1a24; cursor: pointer;
}

.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button {
  height: 28px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--line); background: #0d1a24; color: var(--ink-dim);
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; cursor: pointer;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: #04241c; }

@media (max-width: 640px) {
  #top .sub { display: none; }
  #top .bar button { padding: 0 9px; font-size: 12px; }
  #panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; max-width: none; height: 68vh;
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0; transform: translateY(100%);
  }
  body.panel-open #panel { transform: translateY(0); }
  #credit { top: 54px; left: 12px; }
}
