:root {
  color-scheme: dark;
  --bg: #0b0d12; --bg2: #111827; --line: #1f2937; --fg: #e5e7eb; --muted: #9ca3af; --dim: #6b7280;
  --accent: #3b82f6; --accent2: #1d4ed8; --ok: #16a34a; --warn: #f59e0b; --danger: #7f1d1d;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
a { color: #93c5fd; }
button, .btn { font: inherit; background: var(--line); color: var(--fg); border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-block; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-ok { background: var(--ok); color: #fff; font-weight: 600; }
input[type=text], textarea { width: 100%; background: var(--bg2); color: var(--fg); border: 1px solid #374151; border-radius: 10px; padding: 10px 12px; font: inherit; }
textarea { font-family: var(--mono); font-size: 14px; line-height: 1.45; resize: vertical; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 13px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
code { font-family: var(--mono); background: #0f172a; padding: 2px 6px; border-radius: 6px; font-size: .92em; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #ef4444; display: inline-block; margin-right: 6px; transition: background .3s; vertical-align: middle; }
.dot.on { background: #22c55e; }
.error { color: #fca5a5; }
.sr { position: absolute; left: -9999px; }

/* ---------- home ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 24px 20px 60px; }
header.top { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 28px; }
.brand { font-weight: 700; letter-spacing: -.02em; font-size: 20px; color: var(--fg); text-decoration: none; }
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; align-items: center; }
.hero h1 { font-size: clamp(30px, 4.5vw, 46px); line-height: 1.1; letter-spacing: -.025em; margin: 0 0 16px; }
.hero p { font-size: 17px; line-height: 1.55; color: var(--muted); margin: 0 0 12px; }
.steps { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; color: var(--fg); }
.steps b { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--accent2); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.phones { display: flex; gap: 22px; justify-content: center; }
.phone { width: 178px; height: 360px; background: #000; border: 6px solid #2a2f3a; border-radius: 30px; position: relative; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.5); flex: 0 0 auto; }
.phone::before { content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 56px; height: 16px; background: #2a2f3a; border-radius: 8px; z-index: 2; }
.phone .label { position: absolute; top: 30px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--dim); letter-spacing: .08em; text-transform: uppercase; }
.phone .screen { position: absolute; inset: 0; padding: 46px 10px 10px; display: flex; flex-direction: column; }
.p-admin .list { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 5px; }
.p-admin .blk { font-size: 9.5px; line-height: 1.3; padding: 6px 7px; border-radius: 7px; background: #111827; color: var(--muted); transition: background .25s, color .25s, opacity .25s; }
.p-admin .blk.cur { background: var(--accent2); color: #fff; }
.p-admin .blk.done { opacity: .45; }
.p-admin .bar { display: grid; grid-template-columns: 1fr 2fr; gap: 5px; margin-top: 8px; }
.p-admin .bar span { background: #374151; border-radius: 7px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
.p-admin .bar .next { background: var(--ok); font-weight: 700; position: relative; }
.p-admin .bar .next.tap::after { content: ""; position: absolute; inset: -4px; border-radius: 10px; border: 2px solid #fff; opacity: 0; animation: tap .5s ease-out; }
@keyframes tap { 0% { opacity: .9; transform: scale(.9);} 100% { opacity: 0; transform: scale(1.15);} }
.p-viewer .screen { justify-content: center; align-items: center; text-align: center; }
.p-viewer .sub { font-size: 13px; line-height: 1.35; font-weight: 500; padding: 0 6px; transition: opacity .18s; }
.p-viewer .sub.fade { opacity: 0; }
.p-viewer .sub.idle { color: var(--dim); font-size: 11px; font-weight: 400; }
.p-viewer .pos { position: absolute; top: 30px; right: 12px; font-size: 9px; color: var(--dim); }
.create { margin-top: 56px; }
.create h2 { font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; margin: 0 0 6px; }
.create-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; margin-top: 18px; }
.drop { border: 2px dashed #374151; border-radius: 14px; padding: 34px 20px; text-align: center; transition: border-color .15s, background .15s; cursor: pointer; }
.drop.over { border-color: var(--accent); background: #0f172a; }
.drop.ready { border-style: solid; border-color: var(--ok); }
.drop .big { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.format { line-height: 1.55; }
.format pre { background: #0f172a; border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--muted); overflow: auto; margin: 10px 0; }
.status { min-height: 22px; margin-top: 10px; }
footer.foot { margin-top: 60px; color: var(--dim); font-size: 13px; }
@media (max-width: 760px) {
  .hero, .create-grid { grid-template-columns: 1fr; }
  .phones { order: -1; }
  .phone { width: 150px; height: 306px; }
}

/* ---------- viewer ---------- */
body.viewer { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
body.viewer header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; font-size: 13px; color: var(--muted); }
body.viewer main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 20px 32px; }
#text { font-size: clamp(22px, 6vw, 40px); line-height: 1.35; font-weight: 500; text-align: center; max-width: 900px; text-wrap: balance; transition: opacity .18s; white-space: pre-wrap; }
#text.fade { opacity: 0; }
#text.idle { color: var(--muted); font-weight: 400; font-size: clamp(18px, 5vw, 28px); }
body.viewer footer { display: flex; justify-content: center; gap: 10px; padding: 8px; }
body.viewer footer button { padding: 8px 14px; font-size: 14px; }
.promo { display: flex; align-items: center; gap: 12px; margin: 4px 12px calc(10px + env(safe-area-inset-bottom)); padding: 10px 14px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); color: var(--fg); text-decoration: none; font-size: 14px; line-height: 1.3; }
.promo img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.promo span { display: flex; flex-direction: column; }
.promo small { color: var(--dim); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.promo b { font-weight: 600; }

/* ---------- admin ---------- */
body.admin { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
body.admin header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); gap: 8px; }
body.admin header button { font-size: 13px; padding: 7px 11px; }
.tabs { display: flex; gap: 6px; }
.tabs button.active { background: var(--accent2); color: #fff; }
.panel { display: none; flex: 1; overflow-y: auto; }
.panel.active { display: flex; flex-direction: column; }
#list { flex: 1; overflow-y: auto; padding: 8px 10px 150px; scroll-behavior: smooth; }
.blk { padding: 12px 14px; margin: 6px 0; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); font-size: 15px; line-height: 1.35; cursor: pointer; }
.blk small { color: var(--dim); margin-right: 8px; }
.blk.cur { background: var(--accent2); border-color: var(--accent); color: #fff; }
.blk.done { opacity: .55; }
#bar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
#bar button { font-size: 20px; padding: 18px 0; border-radius: 12px; color: #fff; background: #374151; user-select: none; }
#next { background: var(--ok); font-weight: 700; } #prev { background: #4b5563; } #blank { background: var(--danger); font-size: 15px; }
.pad { padding: 16px 14px 40px; display: flex; flex-direction: column; gap: 14px; max-width: 720px; width: 100%; margin: 0 auto; }
.notice { background: #1e3a8a; border: 1px solid #2563eb; color: #dbeafe; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; display: flex; gap: 12px; align-items: flex-start; }
.notice-pad { padding: 10px 10px 0; }
.qrbox { background: #fff; border-radius: 14px; padding: 14px; width: min(100%, 300px); margin: 0 auto; }
.qrbox img { width: 100%; height: auto; display: block; }
.urlbox { font-family: var(--mono); font-size: 16px; text-align: center; word-break: break-all; }
