:root {
  --bg: #0b0d12; --panel: #12151d; --panel-2: #181c26; --panel-3: #1f2430; --line: #252a36;
  --text: #e8ebf2; --muted: #8b93a7; --accent: #ff6b35; --accent-2: #ffb547; --good: #3ddc97; --bad: #ff4d6d; --warn: #ffc23d;
  --radius: 14px; --panel-w: 340px; --top-h: 58px;
  --font: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif; --display: 'Space Grotesk', var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-2); text-decoration: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; }

/* ---------- top bar ---------- */
.topbar { height: var(--top-h); display: flex; align-items: center; gap: 8px; padding: 0 14px; background: rgba(11,13,18,.92); border-bottom: 1px solid var(--line); position: relative; z-index: 30; backdrop-filter: blur(10px); }
.logo { font: 600 19px var(--display); color: var(--text); display: flex; align-items: center; gap: 9px; margin-right: 10px; letter-spacing: -.3px; white-space: nowrap; }
.logo b { color: var(--accent); font-weight: 700; }
.logo .dot { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe1d2 0 12%, var(--accent) 45%, #b8380b 100%); box-shadow: 0 0 18px rgba(255,107,53,.45); }
.spacer { flex: 1; }
.grp { display: flex; gap: 4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; color: var(--text); }
.btn:hover { background: var(--panel-3); border-color: #333a4a; }
.btn:active { transform: translateY(1px); }
.btn.icon { width: 36px; padding: 0; font-size: 16px; }
.btn.ghost { background: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.wide { width: 100%; margin-top: 6px; }
.btn.primary { background: linear-gradient(180deg, #ff7d4d, var(--accent)); border-color: #ff8a5e; color: #1b0d05; font-weight: 600; }
.btn.primary:hover { background: linear-gradient(180deg, #ff8f66, #ff7440); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.tgl.on { background: rgba(255,107,53,.16); border-color: rgba(255,107,53,.6); }
.only-mobile { display: none; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-wrap { position: relative; }
.dropdown { position: absolute; top: 44px; left: 0; min-width: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 20px 50px rgba(0,0,0,.5); z-index: 40; }
.dropdown.right { left: auto; right: 0; min-width: 300px; display: none; }
.dropdown.right.open { display: block; }
.dropdown button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.dropdown button:hover { background: var(--panel-2); }
.dropdown button small { display: block; color: var(--muted); font-size: 12px; }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 360px; }
.preset { display: flex !important; align-items: center; gap: 8px; font-weight: 500; }
.preset span { font-size: 18px; }

/* ---------- layout ---------- */
.app { display: flex; height: calc(100% - var(--top-h)); }
.panel { width: var(--panel-w); flex: none; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: #2d3342 transparent; display: flex; flex-direction: column; }
.panel-head { position: sticky; top: 0; z-index: 2; display: flex; gap: 8px; padding: 12px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.panel-head input { flex: 1; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); padding: 0 10px; outline: none; }
.panel-head input:focus { border-color: var(--accent); }
.panel-foot { margin-top: auto; padding: 16px; color: var(--muted); font-size: 11px; text-align: center; display: grid; gap: 6px; }
.credit a { color: var(--muted); text-decoration: none; }
.credit a:hover { color: var(--text); }
.credit .heart { color: var(--accent); }
.stage { flex: 1; position: relative; min-width: 0; background: radial-gradient(120% 90% at 50% 15%, #283043 0%, #141822 45%, #0b0d12 100%); }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; outline: none; touch-action: none; }

/* ---------- sections & controls ---------- */
.sec { border-bottom: 1px solid var(--line); }
.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 13px 16px; font: 600 13px var(--display); letter-spacing: .3px; text-transform: uppercase; color: #cfd4e0; user-select: none; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary:hover { color: #fff; }
.sec .ico { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); font-size: 12px; }
.sec .chev { margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; }
.sec[open] .chev { transform: rotate(45deg); }
.sec .body { padding: 2px 16px 16px; display: grid; gap: 12px; }
.row > label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #b9c0cf; margin-bottom: 6px; font-weight: 500; }
.row.filtered { display: none; }
.help { font-style: normal; width: 15px; height: 15px; border-radius: 50%; background: var(--panel-3); color: var(--muted); font-size: 10px; display: inline-grid; place-items: center; cursor: help; position: relative; }
.help:hover::after, .help:focus::after { content: attr(data-tip); position: absolute; left: 50%; top: 20px; transform: translateX(-50%); width: 230px; padding: 9px 11px; background: #0a0c11; border: 1px solid var(--line); border-radius: 9px; color: var(--text); font-size: 12px; line-height: 1.4; font-weight: 400; z-index: 50; text-transform: none; letter-spacing: 0; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
select, .row input[type=text], .seedrow input { width: 100%; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); padding: 0 10px; outline: none; }
select:focus, .row input[type=text]:focus { border-color: var(--accent); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 26px; cursor: pointer; }
.seedrow { display: flex; gap: 6px; }

.rng { display: flex; align-items: center; gap: 10px; }
.rng input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; outline: none; background: linear-gradient(90deg, var(--accent) var(--f, 50%), #2b3140 var(--f, 50%)); cursor: pointer; }
.rng input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.rng input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.num { display: flex; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; height: 28px; padding: 0 7px; min-width: 86px; }
.num input { width: 46px; border: 0; background: none; outline: none; text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.num input::-webkit-inner-spin-button { display: none; }
.num em { font-style: normal; color: var(--muted); font-size: 11px; margin-left: 3px; white-space: nowrap; }

.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; height: 28px; border: 0; background: none; border-radius: 7px; cursor: pointer; color: #b9c0cf; font-weight: 500; font-size: 12.5px; }
.seg button.on { background: var(--panel-3); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,107,53,.55); }
.seg.mini button { height: 26px; padding: 0 8px; }

.tog { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; }
.tog input { display: none; }
.tog .sw { width: 34px; height: 20px; border-radius: 20px; background: #2b3140; position: relative; flex: none; transition: background .2s; }
.tog .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #c7ccd8; transition: transform .2s, background .2s; }
.tog input:checked + .sw { background: var(--accent); }
.tog input:checked + .sw::after { transform: translateX(14px); background: #fff; }
.colrow { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.colrow input { width: 34px; height: 26px; border: 1px solid var(--line); border-radius: 7px; background: none; padding: 2px; cursor: pointer; }
.t-color { display: inline-block; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.card { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 8px 6px 9px; cursor: pointer; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; transition: border-color .15s, background .15s; }
.card:hover { border-color: #3a4152; }
.card.on { border-color: var(--accent); background: rgba(255,107,53,.09); }
.card b { font-size: 12px; font-weight: 600; }
.card small { font-size: 10px; color: var(--muted); line-height: 1.25; }
.cimg { width: 54px; height: 44px; display: block; background-repeat: no-repeat; background-position: center; background-size: contain; }
.c-tower { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 44' fill='none' stroke-linecap='round'%3E%3Crect x='22' y='4' width='10' height='36' rx='2' fill='%23e9e4da' opacity='.25'/%3E%3Cpath d='M14 8c8 4 18 4 26 0M14 17c8 4 18 4 26 0M14 26c8 4 18 4 26 0M14 35c8 4 18 4 26 0' stroke='%23ff6b35' stroke-width='3'/%3E%3C/svg%3E"); }
.c-zigzag { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 44' fill='none' stroke-linecap='round'%3E%3Crect x='6' y='3' width='42' height='38' rx='2' fill='%23e9e4da' opacity='.18'/%3E%3Cpath d='M9 8l34 5M45 17l-34 5M9 26l34 5M45 35l-34 5' stroke='%23ff6b35' stroke-width='3'/%3E%3C/svg%3E"); }
.c-freeform { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 54 44' fill='none' stroke-linecap='round'%3E%3Cpath d='M12 40V27M24 40V22M36 40V30M46 40V18' stroke='%23e9e4da' stroke-width='2' opacity='.4'/%3E%3Cpath d='M6 9c10-6 20 10 30 4s14-8 12 4-26 6-30 14 14 8 26 4' stroke='%23ff6b35' stroke-width='3'/%3E%3C/svg%3E"); }

/* ---------- HUD ---------- */
.hud-card { position: absolute; top: 14px; left: 14px; width: 250px; padding: 14px 16px; border-radius: var(--radius); background: rgba(14,17,24,.78); border: 1px solid rgba(255,255,255,.06); backdrop-filter: blur(12px); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.hud-card .big span { font: 700 30px/1 var(--display); letter-spacing: -.5px; }
.hud-card .big small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 4px; text-transform: uppercase; letter-spacing: .6px; }
.hud-card dl { margin: 12px 0 0; display: grid; gap: 5px; }
.hud-card dl div { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.hud-card dt { color: var(--muted); }
.hud-card dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.warnings { position: absolute; top: 14px; right: 14px; width: 290px; max-height: calc(100% - 120px); overflow: auto; }
.warnings ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.warnings li { padding: 10px 12px 10px 14px; border-radius: 12px; background: rgba(14,17,24,.82); border: 1px solid rgba(255,255,255,.06); border-left: 3px solid var(--warn); backdrop-filter: blur(12px); font-size: 12.5px; }
.warnings li[data-x] { cursor: pointer; }
.warnings li[data-x]:hover { background: rgba(24,28,38,.92); }
.warnings li.sev3 { border-left-color: var(--bad); }
.warnings li.sev1, .warnings li.note { border-left-color: #6b8cff; }
.warnings li b { display: block; font-size: 12.5px; margin-bottom: 2px; }
.warnings li span { color: #aab2c3; }
.allgood { padding: 9px 13px; border-radius: 12px; background: rgba(61,220,151,.12); border: 1px solid rgba(61,220,151,.35); color: #9ff0cb; font-size: 12.5px; font-weight: 500; backdrop-filter: blur(12px); }
.shared { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 16px; border-radius: 30px; background: rgba(14,17,24,.85); border: 1px solid var(--line); font-size: 13px; backdrop-filter: blur(12px); z-index: 5; white-space: nowrap; }
.chip { height: 28px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.chip.like.on { color: #ff5d7a; border-color: rgba(255,77,109,.5); background: rgba(255,77,109,.12); }

.dock { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 18px; background: rgba(14,17,24,.86); border: 1px solid rgba(255,255,255,.07); backdrop-filter: blur(14px); box-shadow: 0 16px 50px rgba(0,0,0,.45); z-index: 5; }
.dock select { width: auto; height: 36px; }
.dock .sep { width: 1px; height: 24px; background: var(--line); }
.btn.drop { height: 42px; padding: 0 18px 0 10px; border-radius: 13px; font-weight: 700; background: linear-gradient(180deg, #ff7d4d, var(--accent)); color: #1b0d05; border-color: #ff8a5e; font-size: 14px; }
.btn.drop .ball { width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 10%, #c9ced8 40%, #59606e 100%); box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.btn.drop.playing .ball { animation: roll .6s linear infinite; }
@keyframes roll { to { transform: rotate(360deg); } }
.hud-live { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; gap: 14px; font: 600 13px var(--display); font-variant-numeric: tabular-nums; color: #cfd4e0; opacity: .85; pointer-events: none; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.legend { position: absolute; right: 14px; bottom: 22px; display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; background: rgba(14,17,24,.82); font-size: 11px; color: var(--muted); }
.legend i { width: 110px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #30123b, #2678fa, #1ad9bf, #8cf74d, #fac726, #f24d1a, #9e0d0d); }

.busy { position: absolute; top: 14px; left: 50%; transform: translate(-50%, -10px); opacity: 0; transition: opacity .2s, transform .2s; display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 10px; border-radius: 20px; background: rgba(14,17,24,.85); font-size: 12px; color: var(--muted); pointer-events: none; z-index: 6; }
.busy.on { opacity: 1; transform: translate(-50%, 0); transition-delay: .15s; }
.busy span { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #3a4152; border-top-color: var(--accent); animation: roll .7s linear infinite; }

/* ---------- modals, toast, loader ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,6,10,.65); backdrop-filter: blur(6px); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.open { display: flex; }
.sheet { position: relative; width: 460px; max-width: 100%; max-height: 92vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.sheet.wide { width: 760px; }
.sheet h2 { margin: 0 0 14px; font: 600 22px var(--display); }
.sheet h3 { font: 600 15px var(--display); color: var(--accent-2); margin: 6px 0; }
.sheet ul { padding-left: 18px; margin: 0; display: grid; gap: 6px; color: #c3c9d6; }
.sheet .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sheet label { display: grid; gap: 5px; margin: 10px 0; font-size: 12.5px; color: #b9c0cf; }
.sheet input { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); padding: 0 12px; outline: none; }
.sheet input:focus { border-color: var(--accent); }
.sheet img { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #0b0d12; aspect-ratio: 480/315; object-fit: cover; }
.sheet .x { position: absolute; top: 12px; right: 14px; width: 32px; height: 32px; border: 0; background: none; font-size: 24px; color: var(--muted); cursor: pointer; }
.row-btns, .copyrow { display: flex; gap: 8px; margin-top: 14px; }
.copyrow input { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: all .25s; background: #f3f4f7; color: #111; padding: 10px 16px; border-radius: 12px; font-weight: 500; z-index: 200; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.loader { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 300; transition: opacity .4s; }
.loader.gone { opacity: 0; pointer-events: none; }
.loader .spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #2a3040; border-top-color: var(--accent); animation: roll .8s linear infinite; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .warnings { width: 240px; } .hud-card { width: 220px; } }
@media (max-width: 860px) {
  :root { --top-h: 54px; }
  .hide-sm { display: none !important; }
  .only-mobile { display: inline-flex; }
  .topbar { padding: 0 10px; gap: 6px; }
  .logo { font-size: 16px; margin-right: 2px; }
  .logo .dot { display: none; }
  .panel { position: fixed; top: var(--top-h); bottom: 0; left: 0; width: min(92vw, 380px); z-index: 25; transform: translateX(-102%); transition: transform .25s; box-shadow: 20px 0 50px rgba(0,0,0,.5); }
  body.panel-open .panel { transform: none; }
  .hud-card { top: 10px; left: 10px; width: auto; max-width: calc(50% - 15px); padding: 10px 12px; }
  .hud-card dl { display: none; }
  .hud-card .big span { font-size: 22px; }
  .warnings { top: 10px; right: 10px; width: calc(50% - 15px); max-height: 40%; }
  .warnings li span { display: none; }
  .dock { bottom: 10px; left: 10px; right: 10px; transform: none; flex-wrap: wrap; justify-content: center; }
  .dock select, .dock .seg.mini, .dock .sep { display: none; }
  .hud-live { bottom: 74px; }
  .presets { width: 300px; grid-template-columns: 1fr; }
  .sheet .cols { grid-template-columns: 1fr; }
  .shared { top: auto; bottom: 74px; }
}

/* ---- Pro ---- */
.btn.pro { background: linear-gradient(180deg, #ffd27a, var(--accent-2)); color: #2a1a00; border-color: #ffc96b; font-weight: 700; }
.btn.pro.owned { background: rgba(255,181,71,.12); color: var(--accent-2); border-color: rgba(255,181,71,.45); }
.probadge { font-style: normal; font-size: 10px; font-weight: 700; color: #2a1a00; background: var(--accent-2); border-radius: 6px; padding: 1px 5px; margin-left: 4px; letter-spacing: .2px; }
body.is-pro .probadge { background: rgba(255,181,71,.18); color: var(--accent-2); }
#upUsed ul { list-style: none; padding: 0; margin: 6px 0 14px; display: grid; gap: 4px; color: var(--accent-2); }
#upUsed p { margin: 0 0 6px; color: #c3c9d6; }
.upgrade-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 12px; }
.upplan { display: grid; gap: 4px; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; color: var(--text); }
.upplan:hover { border-color: #3a4152; }
.upplan.hot { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.upplan .pr { font: 700 24px var(--display); }
.upplan .pr small, .upplan > small { color: var(--muted); font-size: 12px; font-weight: 500; }
@media (max-width: 860px) { .btn.pro { padding: 0 10px; } }
.sheet img#shareThumb, .sheet img#shareCardImg { aspect-ratio: 1200/630; }
.sharebtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sharebtns .btn { height: 32px; }
