@font-face { font-family: 'Onest'; font-weight: 500; font-display: swap; src: url(fonts/onest-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Onest'; font-weight: 600; font-display: swap; src: url(fonts/onest-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Unbounded'; font-weight: 300; font-display: swap; src: url(fonts/unbounded-latin-300-normal.woff2) format('woff2'); }
@font-face { font-family: 'Unbounded'; font-weight: 500; font-display: swap; src: url(fonts/unbounded-latin-500-normal.woff2) format('woff2'); }

:root {
  --bg: #07080c;
  --ink: #f4f2ee;
  --ink-2: rgba(244, 242, 238, 0.74);
  --ink-3: rgba(244, 242, 238, 0.5);
  --ink-4: rgba(244, 242, 238, 0.3);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --accent: #cdbfff;
  --accent-ink: #15121f;
  --panel: rgba(13, 14, 20, 0.82);
  --ui: 'Onest', system-ui, -apple-system, sans-serif;
  --display: 'Unbounded', 'Onest', system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --on-glass: #f8f6f2;
  --on-glass-2: rgba(248, 246, 242, 0.72);
  --on-glass-shadow: 0 1px 12px rgba(0, 0, 0, 0.55);
  --on-glass-fill: rgba(255, 255, 255, 0.14);
  color-scheme: dark;
}

body.light {
  --on-glass: #16171c;
  --on-glass-2: rgba(22, 23, 28, 0.66);
  --on-glass-shadow: 0 1px 10px rgba(255, 255, 255, 0.6);
  --on-glass-fill: rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 2px; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#gl.grab { cursor: grab; }
body.dragging, body.dragging #gl { cursor: grabbing; }
body.dragging .content, body.dragging .panel { user-select: none; }

.brand { position: fixed; left: 28px; top: 24px; z-index: 3; pointer-events: none; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6); }
.brand h1 { margin: 0; font-family: var(--display); font-weight: 300; font-size: 22px; letter-spacing: -0.01em; }
.brand p { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-2); }
body.light .brand { color: #15161a; text-shadow: none; }
body.light .brand p { color: rgba(21, 22, 26, 0.6); }

.hint { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 3; padding: 7px 14px; border-radius: 999px; background: rgba(10, 11, 16, 0.7); border: 1px solid var(--line-2); font-size: 12px; color: var(--ink-2); pointer-events: none; transition: opacity 0.6s var(--ease); }
.hint.gone { opacity: 0; }

.credit { position: fixed; left: 28px; bottom: 20px; z-index: 3; font-size: 11px; letter-spacing: 0.02em; color: rgba(244, 242, 238, 0.26); pointer-events: none; }
body.light .credit { color: rgba(21, 22, 26, 0.32); }

.content, .drop { position: fixed; left: 0; top: 0; z-index: 2; pointer-events: none; color: var(--on-glass); text-shadow: var(--on-glass-shadow); will-change: transform; }
.content button { pointer-events: auto; touch-action: none; }
body.dragging .content button { cursor: grabbing; }
.drop { display: grid; place-items: center; }
.drop svg { width: 22px; height: 22px; filter: drop-shadow(var(--on-glass-shadow)); }
body.no-drop .drop { display: none; }

.content.circle { display: grid; place-content: center; justify-items: center; gap: 2px; }
.content.circle .k-label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-glass-2); }
.content.circle .k-value { font-family: var(--display); font-weight: 300; font-size: 44px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.content.circle .k-btns { display: flex; gap: 10px; margin-top: 4px; }
.content.circle .k-btns button { width: 30px; height: 30px; border-radius: 50%; background: var(--on-glass-fill); font-size: 17px; line-height: 1; transition: transform 0.15s var(--ease), background 0.15s; }
.content.circle .k-btns button:hover { background: rgba(255, 255, 255, 0.24); }
.content.circle .k-btns button:active { transform: scale(0.9); }

.content.rect { display: flex; flex-direction: column; justify-content: center; padding: 0 34px; }
.content.rect h2 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 22px; letter-spacing: -0.01em; }
.content.rect p { margin: 10px 0 18px; font-size: 13.5px; line-height: 1.45; color: var(--on-glass-2); }
.content.rect .row { display: flex; gap: 10px; }
.content.rect .row button { height: 36px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: 13px; text-shadow: none; transition: transform 0.15s var(--ease), background 0.15s; }
.content.rect .solid { background: var(--on-glass); color: #111217; }
body.light .content.rect .solid { color: #f8f6f2; }
.content.rect .ghost { background: var(--on-glass-fill); color: var(--on-glass); }
.content.rect .row button:active { transform: scale(0.95); }

.content.group { display: grid; place-content: center; justify-items: center; text-align: center; }
.content.group .g-title { font-family: var(--display); font-weight: 500; font-size: 17px; }
.content.group .g-sub { font-size: 10.5px; color: var(--on-glass-2); }
.content.capsule { display: flex; align-items: center; justify-content: center; padding: 0 10px; }
.content.capsule .tabs { display: flex; width: 100%; gap: 4px; }
.content.capsule .tabs button { flex: 1; height: 50px; border-radius: 999px; font-weight: 600; font-size: 13.5px; color: var(--on-glass-2); transition: background 0.2s var(--ease), color 0.2s; }
.content.capsule .tabs button:hover { color: var(--on-glass); }
.content.capsule .tabs button.on { background: var(--on-glass-fill); color: var(--on-glass); }

.panel { position: fixed; top: 16px; right: 16px; bottom: 16px; width: 340px; z-index: 4; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 22px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2); transition: transform 0.45s var(--ease), opacity 0.3s; }
body.panel-hidden .panel { transform: translateX(calc(100% + 32px)); opacity: 0; pointer-events: none; }

.panel-head { display: flex; gap: 6px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line); }
.act { height: 36px; min-width: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border-radius: 11px; color: var(--ink-2); transition: background 0.15s, color 0.15s; }
.act:hover { background: rgba(255, 255, 255, 0.07); color: var(--ink); }
.act svg { width: 18px; height: 18px; flex: none; }
.act.primary { flex: 1; justify-content: center; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px; }
.act.primary:hover { background: #ddd3ff; color: var(--accent-ink); }

.panel-scroll { flex: 1; overflow-y: auto; padding: 4px 18px 16px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
.block { padding: 14px 0 4px; }
.block h3, .group summary span { margin: 0 0 9px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.block-head h3 { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 12.5px; font-weight: 500; color: var(--ink-2); transition: background 0.15s, color 0.15s, border-color 0.15s; }
.chips button:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.28); }
.chips button.on { background: var(--ink); border-color: var(--ink); color: #101116; }

.seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); }
.seg button { flex: 1; height: 30px; border-radius: 9px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); transition: background 0.15s, color 0.15s; }
.seg button:hover { color: var(--ink-2); }
.seg button.on { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
.seg.icons button { min-width: 0; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11.5px; }
.seg.icons svg { width: 22px; height: 22px; }
.seg.tiny { padding: 2px; border-radius: 9px; }
.seg.tiny button { height: 22px; padding: 0 9px; border-radius: 7px; font-size: 11px; }

.check { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; flex: none; width: 30px; height: 18px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); transition: background 0.2s; }
.switch::after { content: ''; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); transition: transform 0.2s var(--ease); }
.check input:checked + .switch { background: var(--accent); }
.check input:checked + .switch::after { transform: translateX(12px); background: var(--accent-ink); }
.check input:focus-visible + .switch { outline: 1.5px solid var(--accent); outline-offset: 2px; }

#section canvas { display: block; width: 100%; height: 170px; border-radius: 12px; background: rgba(0, 0, 0, 0.28); }
.caption { margin: 8px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-4); }

.group { border-top: 1px solid var(--line); margin-top: 12px; }
.group summary { display: flex; align-items: baseline; gap: 8px; padding: 14px 0 6px; cursor: pointer; list-style: none; }
.group summary::-webkit-details-marker { display: none; }
.group summary span { margin: 0; }
.group summary em { font-style: normal; font-size: 11.5px; color: var(--accent); opacity: 0.8; }
.group summary::after { content: ''; margin-left: auto; width: 7px; height: 7px; border-right: 1.5px solid var(--ink-4); border-bottom: 1.5px solid var(--ink-4); transform: rotate(45deg) translateY(-2px); transition: transform 0.2s var(--ease); }
.group:not([open]) summary::after { transform: rotate(-45deg); }
.group-body { padding-bottom: 4px; }
.group-body .check { margin: 6px 0 10px; }

.sl { display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: 2px; padding: 7px 0; cursor: default; }
.sl-label { font-size: 12.5px; color: var(--ink-2); }
.sl output { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sl small { grid-column: 1 / 3; font-size: 11px; line-height: 1.35; color: var(--ink-4); }
.sl input { grid-column: 1 / 3; width: 100%; height: 20px; margin: 2px 0 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; }
.sl input::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); }
.sl input::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); }
.sl input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--ink); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); transition: transform 0.15s var(--ease); }
.sl input::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--ink); }
.sl input:active::-webkit-slider-thumb { transform: scale(1.15); background: var(--accent); }
.sl:hover .sl-label { color: var(--ink); }

.panel-foot { display: flex; justify-content: space-between; gap: 10px; margin: 18px 0 0; font-size: 11px; color: var(--ink-4); }
#fps { font-variant-numeric: tabular-nums; }

.expand { position: fixed; top: 20px; right: 20px; z-index: 4; display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line-2); font-size: 13px; font-weight: 600; color: var(--ink); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); opacity: 0; pointer-events: none; transform: translateY(-6px); transition: opacity 0.3s, transform 0.3s var(--ease); }
.expand svg { width: 18px; height: 18px; }
body.panel-hidden .expand { opacity: 1; pointer-events: auto; transform: none; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 6; transform: translate(-50%, 12px); padding: 9px 16px; border-radius: 999px; background: var(--ink); color: #101116; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.3s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.fallback { display: none; }
body.no-webgl .fallback { display: grid; place-items: center; position: fixed; inset: 0; margin: 0; padding: 24px; text-align: center; color: var(--ink-2); }
body.no-webgl .panel, body.no-webgl .content, body.no-webgl .drop, body.no-webgl .hint { display: none; }

@media (max-width: 760px) {
  .brand { left: 16px; top: 16px; }
  .brand h1 { font-size: 18px; }
  .brand p { display: none; }
  .panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: min(50vh, 460px); border-radius: 20px; }
  body.panel-hidden .panel { transform: translateY(calc(100% + 24px)); }
  .panel-scroll { padding: 2px 16px 14px; }
  .panel-foot span:last-child { display: none; }
  .credit { left: auto; right: 16px; top: 20px; bottom: auto; }
  .hint { bottom: calc(min(50vh, 460px) + 22px); }
  .expand { top: auto; bottom: 20px; right: 50%; transform: translate(50%, 6px); }
  body.panel-hidden .expand { transform: translate(50%, 0); }
  .toast { bottom: calc(min(50vh, 460px) + 22px); }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .expand, .toast, .switch::after { transition: none; }
}

.content.capsule { container-type: inline-size; }
@container (max-width: 320px) {
  .content.capsule .tabs button:nth-child(4) { display: none; }
}
@media (max-width: 760px) {
  #collapse svg { transform: rotate(90deg); }
}

body[data-backdrop='page'] .brand { padding: 10px 14px; margin: -10px -14px; border-radius: 16px; background: rgba(250, 248, 244, 0.82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
body[data-backdrop='page'] .credit { padding: 3px 8px; margin: -3px -8px; border-radius: 8px; background: rgba(250, 248, 244, 0.7); }
