:root {
  color-scheme: dark;
  --bg: #000;
  --fill: rgba(28, 28, 30, 0.72);
  --fill-2: rgba(44, 44, 46, 0.72);
  --sep: rgba(84, 84, 88, 0.36);
  --label: #fff;
  --label-2: rgba(235, 235, 245, 0.62);
  --label-3: rgba(235, 235, 245, 0.32);
  --blue: #0a84ff;
  --blue-tint: rgba(10, 132, 255, 0.18);
  --green: #30d158;
  --red: #ff453a;
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--label); font: 17px/1.35 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- library ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 60px max(20px, env(safe-area-inset-left)); }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.nav .actions { display: flex; gap: 8px; }
.large-title { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.01em; margin: 6px 0 2px; }
.subtitle { color: var(--label-2); margin: 0 0 22px; }
.section { font-size: 22px; line-height: 28px; font-weight: 700; margin: 34px 0 12px; display: flex; align-items: baseline; gap: 10px; }
.section small { font-size: 15px; font-weight: 400; color: var(--label-2); }

.btn { appearance: none; border: 0; border-radius: 999px; min-height: 44px; padding: 0 20px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s ease, opacity .12s ease, background .2s ease; }
.btn:active { transform: scale(0.97); opacity: .85; }
.btn.filled { background: var(--blue); color: #fff; }
.btn.tinted { background: var(--blue-tint); color: var(--blue); }
.btn.plain { background: transparent; color: var(--blue); padding: 0 10px; }
.btn.gray { background: var(--fill-2); color: var(--label); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }

.glass { background: var(--fill); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); border: 0.5px solid rgba(255, 255, 255, 0.08); }
.card { border-radius: var(--radius); padding: 18px; }

.create textarea { width: 100%; min-height: 84px; resize: vertical; border-radius: 14px; border: 0; background: rgba(118, 118, 128, 0.24); padding: 12px 14px; font-size: 17px; outline: none; }
.create textarea:focus { box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.45); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.row.space { justify-content: space-between; }
.chip { appearance: none; border: 0; border-radius: 999px; padding: 7px 14px; background: rgba(118, 118, 128, 0.24); color: var(--label); font-size: 15px; cursor: pointer; }
.chip.on { background: var(--label); color: #000; }
.ideas .chip { background: transparent; border: 0.5px solid var(--sep); color: var(--label-2); }
.seg { display: inline-flex; background: rgba(118, 118, 128, 0.24); border-radius: 10px; padding: 2px; }
.seg button { appearance: none; border: 0; background: transparent; border-radius: 8px; padding: 6px 12px; font-size: 15px; cursor: pointer; color: var(--label); }
.seg button.on { background: #636366; font-weight: 600; }
.meta { color: var(--label-2); font-size: 15px; }
.err { color: var(--red); font-size: 15px; min-height: 20px; margin-top: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile { position: relative; border-radius: var(--radius); overflow: hidden; background: #0b0b0c; border: 0.5px solid rgba(255, 255, 255, 0.08); cursor: pointer; transition: transform .15s ease; text-align: left; padding: 0; display: block; width: 100%; color: var(--label); }
.tile:active { transform: scale(0.98); }
.tile .poster { aspect-ratio: 16 / 9; width: 100%; display: block; object-fit: cover; background: radial-gradient(circle at 50% 55%, rgba(10,132,255,.25), transparent 60%), #000; }
.tile .body { padding: 12px 14px 14px; }
.tile h3 { font-size: 17px; margin: 0 0 2px; font-weight: 600; }
.tile p { margin: 0; color: var(--label-2); font-size: 15px; line-height: 20px; }
.tile .badge { position: absolute; top: 10px; left: 10px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.tile .del { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: var(--label-2); font-size: 17px; line-height: 30px; cursor: pointer; }
.progress { height: 4px; border-radius: 2px; background: rgba(118, 118, 128, 0.3); overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .6s ease; }
.shimmer { background: linear-gradient(100deg, #050505 30%, #14141a 50%, #050505 70%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.scene-art { aspect-ratio: 16 / 9; display: grid; place-items: center; font-size: 54px; background: #000; }
.scene-art.jelly { background: radial-gradient(circle at 50% 42%, rgba(80, 220, 255, .55), rgba(255, 60, 200, .18) 35%, transparent 60%), #000; }
.scene-art.planet { background: radial-gradient(circle at 50% 50%, rgba(140, 120, 255, .6), rgba(255, 190, 90, .15) 40%, transparent 62%), #000; }
.scene-art.galaxy { background: radial-gradient(ellipse 45% 22% at 50% 50%, rgba(255, 230, 180, .7), rgba(120, 140, 255, .3) 45%, transparent 70%), #000; }

.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.howto .card h4 { margin: 0 0 4px; font-size: 15px; color: var(--label-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.howto .card p { margin: 0; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; z-index: 50; padding: 20px; }
.sheet { width: min(420px, 100%); border-radius: 28px; padding: 26px 22px 22px; text-align: center; }
.sheet h2 { margin: 0 0 6px; font-size: 22px; }
.sheet p { color: var(--label-2); margin: 0 0 16px; }
.sheet input { width: 100%; text-align: center; font-size: 22px; letter-spacing: .08em; border-radius: 14px; border: 0; background: rgba(118, 118, 128, 0.24); padding: 12px; outline: none; margin-bottom: 12px; }
.qr { width: 220px; height: 220px; margin: 6px auto 10px; display: block; }

/* ---------- stage ---------- */
body.stage { overflow: hidden; position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
#hw { position: fixed; left: 50%; top: 50%; transform-origin: 50% 50%; }
#hw canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#outline { position: absolute; border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 6px; pointer-events: none; }
#src { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0.01; pointer-events: none; }
.ui { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; transition: opacity .35s ease; }
.ui.off { opacity: 0; }
.ui > * { pointer-events: auto; }
.ui.off > * { pointer-events: none; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left)); }
.bar .title { font-weight: 600; text-align: center; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar.bottom { padding-bottom: max(14px, env(safe-area-inset-bottom)); justify-content: center; flex-wrap: wrap; }
.center { display: grid; place-items: center; text-align: center; gap: 12px; padding: 0 24px; }
.play { width: 84px; height: 84px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.92); color: #000; display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 40px rgba(10, 132, 255, .35); }
.play svg { width: 34px; height: 34px; margin-left: 4px; }
.hint { color: var(--label-2); max-width: 340px; font-size: 15px; }
.countdown { position: fixed; inset: 0; display: grid; place-items: center; text-align: center; background: rgba(0, 0, 0, .78); z-index: 40; }
.countdown b { display: block; font-size: 96px; line-height: 1; font-weight: 700; }
.countdown span { color: var(--label-2); }
.setup { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(520px, calc(100% - 24px)); max-height: 78vh; overflow: auto; border-radius: 26px; padding: 18px; z-index: 30; }
.setup h3 { margin: 0 0 10px; font-size: 17px; }
.setup .field { margin: 14px 0; }
.setup .field label { display: block; font-size: 13px; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.setup input[type=range] { width: 100%; accent-color: var(--blue); }
.setup .seg { flex-wrap: wrap; }
.setup.compact > :not(.size) { display: none; }
.setup.compact .size { margin: 0; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
