:root {
  --bg: #0b1020; --surface: #131a2e; --surface2: #1a2340; --line: rgba(255,255,255,.08); --text: #eef1f8; --muted: #93a0bd;
  --accent: #5b8cff; --accent-press: #4776f0; --good: #33d6a6; --bad: #ff6b6b; --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(11,16,32,.88); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { width: 28px; height: 28px; }
.tabs { margin-left: auto; display: flex; background: var(--surface); border-radius: 12px; padding: 4px; }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab.active { background: var(--surface2); color: var(--text); }

#view { padding-top: 20px; padding-bottom: 120px; }
h2 { font-size: 22px; margin: 8px 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.lead { color: var(--muted); margin: -6px 0 18px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 650;
  background: var(--surface2); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid rgba(255,107,107,.35); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* Form fields */
label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=url], input[type=number], input[type=datetime-local], input[type=password], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,140,255,.2); }
textarea { min-height: 110px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 480px) { .fields { grid-template-columns: 1fr; } }

.code-input { text-transform: uppercase; letter-spacing: 8px; font-size: 26px !important; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

/* Lists */
.item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 10px; cursor: pointer; }
.item:active { background: var(--surface2); }
.item .meta { color: var(--muted); font-size: 14px; }
.item .title { font-weight: 650; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #56607a; flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 10px var(--good); }
.thumb { width: 112px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; flex: none; background: #000; position: relative; }
.thumb .screen-root { pointer-events: none; }
.chev { margin-left: auto; color: var(--muted); font-size: 22px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface2); color: var(--muted); }

/* Templates */
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tpl { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 10px; cursor: pointer; }
.tpl .thumb { width: 100%; margin-bottom: 8px; }
.tpl b { display: block; font-size: 14px; }
.tpl small { color: var(--muted); font-size: 12px; }

/* Editor */
.editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.preview-wrap { position: sticky; top: 60px; z-index: 10; background: var(--bg); padding: 10px 0 12px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.preview { aspect-ratio: 16 / 9; width: 100%; border-radius: 12px; overflow: hidden; background: #000; position: relative; border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.preview-cap { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg button { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 6px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; }
.seg button.on { border-color: var(--accent); color: var(--text); background: rgba(91,140,255,.12); }
.seg svg { display: block; width: 100%; height: 34px; margin-bottom: 6px; }
.seg svg rect { fill: currentColor; opacity: .55; }
.seg button.on svg rect { fill: var(--accent); opacity: .9; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 64px; height: 44px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; position: relative; overflow: hidden; }
.swatch.on { border-color: #fff; }
.swatch span { position: absolute; left: 6px; bottom: 3px; font-size: 10px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #0008; }
.sw-midnight { background: linear-gradient(135deg, #0b1020, #1d2b5a); }
.sw-aurora { background: linear-gradient(135deg, #3d5fd9, #23b98c 60%, #8b5cf6); }
.sw-ember { background: linear-gradient(135deg, #2a140c, #ff8a3d); }
.sw-daylight { background: linear-gradient(135deg, #f4f6fa, #c9d6f5); }
.sw-daylight span { color: #0f172a; text-shadow: none; }

.slot-card { border-left: 4px solid var(--accent); }
.slot-card .slot-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.slot-card .slot-n { width: 26px; height: 26px; border-radius: 8px; background: var(--surface2); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.slot-card select.type { font-weight: 650; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(11,16,32,.92); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); }
.savebar .wrap { display: flex; gap: 10px; }

/* Sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 760px; max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up .25s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -6px auto 14px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 50; background: #1f2a4d; color: #fff; padding: 12px 18px;
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-weight: 600; max-width: 90vw; animation: up .2s ease; }
.toast.err { background: #5a1f2a; }

.tvlink { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.tvlink code { background: var(--bg); padding: 6px 10px; border-radius: 8px; color: var(--text); word-break: break-all; }

.board-check { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.board-check:last-child { border-bottom: 0; }

/* Channels & encryption */
.hero { text-align: center; padding: 18px 0 8px; }
.hero .lock { font-size: 40px; }
.hero .lead { margin: 0 auto 18px; max-width: 520px; }
.banner { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; font-size: 15px; }
.banner.warn { background: rgba(255,176,32,.1); border: 1px solid rgba(255,176,32,.35); }
.banner .row { flex-wrap: wrap; }
.secure-note { font-size: 14px; color: var(--good); }
.join-code { font-size: 34px; font-weight: 800; letter-spacing: 4px; text-align: center; padding: 8px 0; font-variant-numeric: tabular-nums; }
.wrap-row { flex-wrap: wrap; }
.qr-box { width: min(78vw, 320px); margin: 8px auto 6px; border-radius: 14px; overflow: hidden; background: #fff; }
.qr-box svg { display: block; width: 100%; height: auto; }
.digits { font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.digits.big { font-size: 34px; font-weight: 800; text-align: center; padding: 10px 0; letter-spacing: 4px; }
.item.static { cursor: default; }
.pending-card { border-color: rgba(91,140,255,.45); }
.meter { height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.hint.full { grid-column: 1 / -1; margin-top: -6px; }
code { font-size: 13px; background: var(--surface2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
