:root {
  --bg: #1a1a1a; --surface: rgba(34, 34, 34, .96); --surface2: #2f2f2f; --line: #3d3d3d;
  --text: #fff; --muted: #a8a8a8; --primary: #ff6b00; --ok: #00cc66; --err: #ff4d42; --warn: #ffb020;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }

#video { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#shade { position: fixed; inset: 0; display: grid; place-items: center; padding-bottom: 22vh; pointer-events: none; }
#frame { width: min(68vw, 300px); aspect-ratio: 1; position: relative; border-radius: 22px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); transition: box-shadow .15s; }
#frame i { position: absolute; width: 34px; height: 34px; border: 4px solid var(--primary); transition: border-color .15s; }
#frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 22px; }
#frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 22px; }
#frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 22px; }
#frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 22px; }
#frame.good i { border-color: var(--ok); } #frame.good { box-shadow: 0 0 0 100vmax rgba(0,204,102,.25); }
#frame.bad i { border-color: var(--err); } #frame.bad { box-shadow: 0 0 0 100vmax rgba(255,77,66,.28); }

header { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; }
.icon { width: 46px; height: 46px; border-radius: 50%; background: rgba(34,34,34,.85); font-size: 20px; }
.icon.on { background: var(--primary); }
.pill { display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: 15px; background: rgba(34,34,34,.9); }
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.pill.online { background: var(--ok); color: #03240f; } .pill.online .dot { background: #03240f; }
.pill.syncing { background: var(--primary); } .pill.syncing .dot { background: #fff; animation: pulse 1s infinite; }
.pill.error { background: var(--err); } .pill.error .dot { background: #fff; }
@keyframes pulse { 50% { opacity: .25; } }

#toast { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 72px); left: 16px; right: 16px; padding: 14px 16px; border-radius: 14px;
  background: var(--ok); color: #03240f; font-weight: 700; text-align: center; z-index: 5; }
#toast.bad { background: var(--err); color: #fff; }

#bottom { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); max-width: 520px; margin: 0 auto; }
.card { background: var(--surface); border-radius: 20px; padding: 18px; }
.card h1 { font-size: 21px; margin: 0 0 4px; text-align: center; }
.card p { margin: 0 0 12px; color: var(--muted); text-align: center; font-size: 15px; }
.steps { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.steps span { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--surface2); color: var(--muted); }
.steps span.on { background: var(--primary); color: #fff; } .steps span.done { background: rgba(0,204,102,.25); color: var(--ok); }
#chips { display: grid; gap: 6px; margin-bottom: 8px; }
.chip { background: rgba(0, 60, 30, .92); color: var(--ok); border-radius: 12px; padding: 9px 12px; font-size: 14px; display: flex; gap: 8px; }
.chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error { color: var(--err) !important; font-weight: 600; }
.muted { color: var(--muted); }

.row { display: flex; gap: 10px; }
.btn { flex: 1; min-height: 54px; border-radius: 99px; font-weight: 700; font-size: 17px; padding: 0 16px; }
.btn.primary { background: var(--primary); flex: 1.6; } .btn.ghost { background: var(--surface2); }
.btn.wide { width: 100%; margin-top: 12px; } .btn:active { opacity: .7; } .btn:disabled { opacity: .4; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; }
dt { color: var(--muted); } dd { margin: 0; font-weight: 600; word-break: break-all; font-family: ui-monospace, Menlo, monospace; }
.delegate { border-radius: 14px; padding: 12px; text-align: center; background: var(--surface2); }
.delegate.found { background: rgba(0,204,102,.16); } .delegate.found strong { font-size: 20px; display: block; }
.delegate.missing { background: rgba(255,176,32,.16); color: var(--warn); }
.warn { background: rgba(255,176,32,.16); color: var(--warn); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; font-weight: 600; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; z-index: 10; }
.sheet-body { width: 100%; max-width: 560px; margin: 0 auto; background: #222; border-radius: 22px 22px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px); max-height: 88vh; overflow-y: auto; }
.sheet-body.tall { min-height: 70vh; }
.sheet h2 { margin: 0 0 12px; font-size: 19px; }
input { width: 100%; min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: #151515; color: #fff; font-size: 18px; padding: 0 14px; margin-bottom: 12px; }
input:focus { outline: 2px solid var(--primary); }
label { display: block; color: var(--muted); font-size: 13px; } label input { margin-top: 4px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; align-items: center; }
.tabs button[data-tab] { flex: 1; padding: 10px 4px; border-radius: 12px; background: var(--surface2); font-weight: 600; font-size: 14px; }
.tabs button.on { background: var(--primary); } .tabs b { background: rgba(0,0,0,.3); border-radius: 99px; padding: 0 7px; }
.item { background: var(--surface2); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.item .grow { flex: 1; min-width: 0; } .item .mono { font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.item small { color: var(--muted); display: block; } .item.rejected { outline: 1px solid var(--err); }
.item button { background: #444; border-radius: 10px; padding: 8px 10px; font-size: 13px; font-weight: 600; } .item button.danger { background: var(--err); }
.result { width: 100%; text-align: left; background: var(--surface2); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; }
.result small { color: var(--muted); display: block; }
