:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0ea5a4;      /* teal-green */
  --accent2: #2563eb;     /* blue */
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}
a { color: var(--accent2); }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
}
.brand { font-weight: 800; letter-spacing: -.3px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 26px; display: grid; grid-template-columns: 300px 1fr; gap: 24px; }
@media (max-width: 820px) { .wrap { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .hd { padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 700; display:flex; justify-content:space-between; align-items:center; }
.card .bd { padding: 18px; }

.plist { display: flex; flex-direction: column; }
.pitem { padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; display:flex; gap:10px; align-items:center; }
.pitem:hover { background: #f8fafc; }
.pitem.active { background: #ecfeff; border-left: 3px solid var(--accent); }
.pitem .ic { width: 30px; height: 30px; border-radius: 8px; background:#e2e8f0; display:grid; place-items:center; overflow:hidden; flex:none; }
.pitem .ic img { width:100%; height:100%; object-fit:cover; }
.pitem b { font-size: 14px; }
.pitem span { display:block; color: var(--muted); font-size: 12px; word-break: break-all; }

label { display:block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=url], input[type=color], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background:#fff;
}
input[type=color] { padding: 4px; height: 42px; }
.row { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.btn { appearance:none; border:0; border-radius:10px; padding: 11px 18px; font: inherit; font-weight:700; cursor:pointer; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color:#fff; }
.btn.ghost { background:#fff; border:1px solid var(--line); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btnrow { display:flex; gap:10px; margin-top: 18px; flex-wrap: wrap; }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align:center; color: var(--muted); cursor:pointer; }
.drop.has { border-color: var(--accent); color: var(--ink); }
.drop img { max-height: 64px; border-radius: 8px; margin-bottom: 6px; }

.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.b-queued { background:#f1f5f9; color:#475569; }
.b-building { background:#fef3c7; color:#92400e; }
.b-success { background:#dcfce7; color:#166534; }
.b-failed { background:#fee2e2; color:#991b1b; }

.build { border:1px solid var(--line); border-radius:12px; padding:14px; margin-bottom:12px; }
.build .top { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.log {
  margin-top: 10px; background:#0b1220; color:#cbd5e1; border-radius:10px; padding:12px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 320px; overflow:auto; white-space:pre-wrap;
}
.empty { text-align:center; color:var(--muted); padding: 50px 20px; }
.steps { display:flex; gap:8px; margin-bottom: 18px; flex-wrap:wrap; }
.step { font-size:12px; font-weight:700; color:var(--muted); padding:6px 12px; border-radius:999px; background:#f1f5f9; }
.step.active { background:#ccfbf1; color:#0f766e; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background:#0f172a; color:#fff; padding:11px 18px; border-radius:10px; box-shadow: var(--shadow); z-index: 20; }

/* ---- Tier 1 device preview ---- */
.previewgrid { display:grid; grid-template-columns: 300px 1fr; gap: 20px; align-items:start; }
@media (max-width: 720px) { .previewgrid { grid-template-columns: 1fr; } }
.phone {
  width: 280px; height: 580px; margin: 0 auto; position: relative;
  background:#0b1220; border-radius: 40px; padding: 12px;
  box-shadow: 0 10px 40px rgba(15,23,42,.25), inset 0 0 0 2px #1e293b;
}
.phone .notch { position:absolute; top: 12px; left:50%; transform:translateX(-50%); width: 120px; height: 22px; background:#0b1220; border-radius: 0 0 14px 14px; z-index: 3; }
.phone .screen { width:100%; height:100%; border-radius: 30px; overflow:hidden; background:#fff; position:relative; }
.phone .screen iframe { width:100%; height:100%; border:0; }
.phone .statusbar { position:absolute; top:0; left:0; right:0; height:26px; display:flex; align-items:center; justify-content:space-between; padding:0 16px; font-size:11px; font-weight:600; color:#fff; mix-blend-mode:difference; z-index:2; pointer-events:none; }
.splashwrap { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; z-index:1; }
.splashwrap img.icon { width:96px; height:96px; border-radius:22px; box-shadow: var(--shadow); object-fit:cover; }
.splashwrap .fallback { text-align:center; padding:24px; }
.splashwrap .fallback a { display:inline-block; margin-top:12px; }
.previewmeta .tile { display:flex; gap:12px; align-items:center; padding:12px; border:1px solid var(--line); border-radius:12px; margin-bottom:12px; }
.previewmeta .tile img { width:56px; height:56px; border-radius:12px; object-fit:cover; background:#f1f5f9; }
.previewmeta .tile.empty { color:var(--muted); }
.previewmeta .tile .ph { width:56px; height:56px; border-radius:12px; background:#f1f5f9; display:grid; place-items:center; font-size:22px; }
.warnbox { background:#fffbeb; border:1px solid #fde68a; color:#92400e; padding:10px 12px; border-radius:10px; font-size:13px; margin-bottom:12px; }
.prohd { margin-top:18px; margin-bottom:8px; font-weight:700; }
.feature-row { display:flex; gap:12px; align-items:flex-start; margin-top:10px; padding:12px; border:1px solid var(--line); border-radius:12px; background:#f8fafc; }
.feature-row code { background:#e2e8f0; padding:1px 5px; border-radius:5px; font-size:12px; }
.pushstate { margin-top:8px; }
.switch { position:relative; display:inline-block; width:44px; height:26px; flex:none; margin-top:2px; }
.switch input { opacity:0; width:0; height:0; }
.switch .track { position:absolute; inset:0; background:#cbd5e1; border-radius:999px; transition:.2s; cursor:pointer; }
.switch .track::before { content:""; position:absolute; height:20px; width:20px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s; box-shadow:0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background:var(--accent); }
.switch input:checked + .track::before { transform:translateX(18px); }
.okbox { background:#ecfeff; border:1px solid #a5f3fc; color:#155e63; padding:10px 12px; border-radius:10px; font-size:13px; margin-bottom:12px; }
.shotwrap { position:absolute; inset:0; }
.shotwrap .shot { width:100%; height:100%; object-fit:cover; object-position:top center; }
.shotwrap .shotspin { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; color:var(--muted); font-size:13px; background:#fff; z-index:2; }
.spinner2 { width:28px; height:28px; border:3px solid rgba(128,128,128,.25); border-top-color: var(--accent); border-radius:50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- auth ---- */
.authpage { min-height: 100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; padding:24px;
  background: radial-gradient(1200px 500px at 50% -10%, #e0f2fe, transparent), var(--bg); }
.authcard { width:100%; max-width: 400px; padding: 26px; }
.authbrand { display:flex; align-items:center; gap:12px; margin-bottom:18px; }
.authtabs { display:flex; gap:6px; background:#f1f5f9; padding:5px; border-radius:12px; margin-bottom:18px; }
.authtab { flex:1; appearance:none; border:0; background:transparent; padding:9px; border-radius:9px; font:inherit; font-weight:700; color:var(--muted); cursor:pointer; }
.authtab.active { background:#fff; color:var(--ink); box-shadow: var(--shadow); }
.authcard .bd { padding:0; }
.authmsg { font-size:13px; margin-top:12px; min-height:0; }
.authmsg:empty { margin:0; }
.authmsg.err { color: var(--err); }
.authmsg.ok { color: var(--ok); }
.authlink { text-align:center; margin-top:14px; font-size:13px; }
.authfoot { color:var(--muted); font-size:12px; }

/* ---- user menu in topbar ---- */
.usermenu { position:relative; }
.useravatar { display:flex; align-items:center; gap:9px; cursor:pointer; padding:5px 10px 5px 5px; border:1px solid var(--line); border-radius:999px; background:#fff; }
.useravatar .av { width:28px; height:28px; border-radius:50%; background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; display:grid; place-items:center; font-weight:800; font-size:13px; }
.useravatar .nm { font-size:13px; font-weight:600; }
.usermenu .drop { position:absolute; right:0; top:44px; background:#fff; border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow); min-width:200px; padding:8px; display:none; z-index:10; }
.usermenu.open .drop { display:block; }
.usermenu .drop .who { padding:8px 10px; border-bottom:1px solid var(--line); margin-bottom:6px; }
.usermenu .drop .who b { display:block; font-size:14px; }
.usermenu .drop .who span { font-size:12px; color:var(--muted); }
.usermenu .drop button { width:100%; text-align:left; appearance:none; border:0; background:transparent; padding:9px 10px; border-radius:8px; font:inherit; cursor:pointer; }
.usermenu .drop button:hover { background:#f1f5f9; }
.modalbg { position:fixed; inset:0; background:rgba(15,23,42,.4); display:flex; align-items:center; justify-content:center; z-index:30; }
.modal { background:#fff; border-radius:16px; padding:22px; width:100%; max-width:380px; box-shadow:var(--shadow); }
.modal h3 { margin:0 0 14px; }
.modal.admin { max-width:760px; max-height:86vh; overflow:auto; }
.admin-hd { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.admin-hd h3 { margin:0; }
.atable { border:1px solid var(--line); border-radius:12px; overflow:hidden; }
.atr { display:grid; grid-template-columns: 2fr 1fr 0.6fr 1.6fr; gap:10px; align-items:center; padding:11px 14px; border-bottom:1px solid var(--line); }
.atr.apps { grid-template-columns: 2fr 1.4fr 0.6fr 1.4fr; }
.atr:last-child { border-bottom:0; }
.atr.ahead { background:#f8fafc; font-weight:700; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; }
.aact { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.btn.danger { color:var(--err); border-color:#fecaca; }
.btn.danger:hover { background:#fef2f2; }
@media (max-width:640px){ .atr,.atr.apps{ grid-template-columns:1fr 1fr; } .atr .aact{ grid-column:1/-1; justify-content:flex-start; } .atr.ahead{ display:none; } }
