:root {
  --bg: #0b1020; --bg2: #0f1629; --card: #141c33; --card2: #1a2340; --line: #26304f;
  --tx: #e8ecf8; --mut: #8d97b5; --acc: #5b8cff; --acc2: #7c5cff; --ok: #2ecc8f; --warn: #f5b942; --bad: #ff5d6c;
  --r: 16px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 15px/1.5 system-ui, "Segoe UI", Arial, sans-serif; }
body { min-height: 100vh; overscroll-behavior-y: contain; }
.hidden { display: none !important; }
.muted { color: var(--mut); } .small { font-size: 13px; } .center { text-align: center; } .err { color: var(--bad); min-height: 1.2em; }
h1 { font-size: 26px; margin: 4px 0 6px; } h2.sec { font-size: 14px; color: var(--mut); font-weight: 600; margin: 18px 4px 8px; letter-spacing: .3px; }
h3 { margin: 0 0 8px; font-size: 16px; }
input, select, textarea { width: 100%; font: inherit; color: var(--tx); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; margin-top: 6px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--acc); }
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
label { display: block; color: var(--mut); font-size: 13px; margin: 10px 0 0; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card2); color: var(--tx); border-radius: 12px;
  padding: 12px 16px; cursor: pointer; }
.btn.primary { background: linear-gradient(135deg, var(--acc), var(--acc2)); border: 0; color: #fff; box-shadow: 0 6px 20px #5b8cff33; }
.btn.danger { color: var(--bad); border-color: #ff5d6c55; }
.btn.wide { width: 100%; margin-top: 14px; padding: 14px; font-size: 16px; }
.btn:disabled { opacity: .5; }
.btn.on { border-color: var(--acc); color: var(--acc); }
.link { background: none; border: 0; color: var(--acc); font: inherit; margin-top: 14px; cursor: pointer; }

/* gates */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, #23305e 0%, var(--bg) 60%); }
.gcard { width: min(400px, 100%); text-align: center; }
.gcard label { text-align: right; }
.logo img { width: 100%; height: 100%; border-radius: 26px; display: block; }
.logo { overflow: hidden; font-size: 46px; width: 84px; height: 84px; margin: 0 auto 6px; display: grid; place-items: center; border-radius: 26px;
  background: linear-gradient(135deg, #22305c, #151d38); border: 1px solid var(--line); box-shadow: 0 10px 40px #0008; }
.pin { text-align: center; font-size: 26px; letter-spacing: 12px; direction: ltr; }
.bio { margin: 26px auto 4px; width: 180px; height: 180px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  background: radial-gradient(circle at 50% 35%, #6d93ff, #5b3cff 70%); box-shadow: 0 0 0 10px #5b8cff1c, 0 0 0 22px #5b8cff0d, 0 18px 50px #3b4bff55;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font: 600 15px system-ui; }
.bio:active { transform: scale(.97); }
.bio.busy svg { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* app chrome */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; background: #0b1020e6; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.pc { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pc b { display: block; font-size: 16px; } .pc small, .jt small { display: block; color: var(--mut); font-size: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mut); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px #2ecc8f2a; } .dot.sleep { background: var(--warn); }
.actions { display: flex; gap: 6px; }
.ic { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--tx); font-size: 18px; cursor: pointer; }
main { padding: 12px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); z-index: 6;
  background: #0d1326f2; backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
nav.tabs button { position: relative; background: none; border: 0; color: var(--mut); font: 600 12px system-ui; padding: 9px 0 10px; cursor: pointer; }
nav.tabs button span { display: block; font-size: 21px; line-height: 1.3; filter: grayscale(1) opacity(.7); }
nav.tabs button.on { color: var(--tx); } nav.tabs button.on span { filter: none; }
.badge { position: absolute; top: 6px; right: calc(50% - 22px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--acc);
  color: #fff; font: 700 11px/18px system-ui; font-style: normal; padding: 0 5px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card.warn { border-color: #f5b94266; background: linear-gradient(180deg, #2b2410, var(--card)); }
.card.power { border-color: #ff5d6c66; background: linear-gradient(180deg, #33141c, var(--card)); text-align: center; }
.card.power .big { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.meter small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter b { font-size: 20px; font-variant-numeric: tabular-nums; } .meter small { color: var(--mut); font-size: 12px; display: block; }
.bar { height: 7px; background: var(--bg2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc2)); border-radius: 4px; transition: width .6s; }
.bar i.hot { background: linear-gradient(90deg, var(--warn), var(--bad)); }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv:last-child { border: 0; } .kv span:first-child { color: var(--mut); }
.proc { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; color: var(--mut); }
.proc b { color: var(--tx); font-weight: 600; }

/* presets */
.pgroup { margin-bottom: 4px; } .pgroup h4 { margin: 12px 4px 8px; color: var(--mut); font-size: 13px; font-weight: 600; }
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preset { text-align: right; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; color: var(--tx);
  font: inherit; cursor: pointer; min-height: 78px; position: relative; }
.preset:active, .pbtn:active { transform: scale(.98); }
.preset .pi { font-size: 22px; } .preset b { display: block; font-size: 14px; margin-top: 2px; line-height: 1.3; }
.preset small { color: var(--mut); font-size: 11px; display: block; margin-top: 2px; }
.preset .lockb { position: absolute; top: 10px; left: 10px; font-size: 12px; opacity: .8; }
.pbtn { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px; color: var(--tx); font: 600 15px system-ui; cursor: pointer; }
.pbtn span { display: block; font-size: 28px; } .pbtn small { display: block; color: var(--mut); font-weight: 400; font-size: 11px; margin-top: 2px; }
.pbtn.rec { border-color: var(--ok); box-shadow: inset 0 0 0 1px #2ecc8f44; } .pbtn.danger { border-color: #ff5d6c55; }
.chk { display: flex; align-items: center; gap: 8px; color: var(--tx); font-size: 14px; margin-top: 12px; }
.chk input { width: auto; margin: 0; }

/* jobs */
.job { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  margin-bottom: 10px; cursor: pointer; }
.job .jm { flex: 1; min-width: 0; } .job b { unicode-bidi: plaintext; text-align: right; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.job small { color: var(--mut); font-size: 12px; }
.chip { font: 700 12px system-ui; padding: 4px 10px; border-radius: 20px; background: var(--card2); color: var(--mut); white-space: nowrap; }
.chip.running, .chip.sent { color: var(--acc); background: #5b8cff22; } .chip.done { color: var(--ok); background: #2ecc8f22; }
.chip.failed, .chip.rejected { color: var(--bad); background: #ff5d6c22; } .chip.awaiting { color: var(--warn); background: #f5b94222; }
.chip.running::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-left: 6px; animation: pulse 1s infinite; }
.empty { text-align: center; color: var(--mut); padding: 40px 10px; }

/* new */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button { background: none; border: 0; color: var(--mut); font: 600 14px system-ui; padding: 10px; border-radius: 10px; cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--tx); box-shadow: 0 2px 8px #0006; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* sheet + pages */
.sheet { position: fixed; inset: 0; z-index: 20; background: #0009; display: flex; align-items: flex-end; }
.sheetBody { position: relative; width: 100%; max-width: 720px; margin: 0 auto; max-height: 88vh; overflow: auto; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + var(--safe-b)); animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.close { position: absolute; top: 12px; left: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--card2); color: var(--tx); cursor: pointer; }
.page { position: fixed; inset: 0; z-index: 15; background: var(--bg); display: flex; flex-direction: column; }
.page.dark { background: #000; }
.jt { flex: 1; min-width: 0; } .jt b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#jpLog { flex: 1; margin: 0; padding: 12px 16px; overflow: auto; font: 12.5px/1.55 ui-monospace, Consolas, "Cascadia Mono", monospace;
  white-space: pre-wrap; word-break: break-word; background: #070b16; color: #cfd8f0; unicode-bidi: plaintext; text-align: start; }
#jpPower, #jpAwait { margin: 10px 16px 0; }
#jpFiles { padding: 0 16px; }
.file { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.file b { font-size: 13px; direction: ltr; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jpbar { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg2); }
.shotWrap { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
.shotWrap img { width: 100%; height: auto; display: block; }
.shotWrap img.zoom { width: 250%; max-width: none; }
.toast { position: fixed; bottom: calc(86px + var(--safe-b)); left: 50%; transform: translateX(-50%); z-index: 40; background: #1f2a4d; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px #0008; max-width: 90vw; text-align: center; }
.list .it { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.audit { font: 12px/1.5 ui-monospace, Consolas, monospace; color: var(--mut); max-height: 300px; overflow: auto; direction: ltr; text-align: left; }
.fp { font: 13px ui-monospace, Consolas, monospace; direction: ltr; display: inline-block; color: var(--tx); }
@media (min-width: 560px) { .pgrid { grid-template-columns: repeat(3, 1fr); } }
