:root {
  --bg: #f4f5f8; --card: #ffffff; --text: #171923; --text2: #5b6275; --line: #e3e6ee;
  --prim: #4f46e5; --prim-bg: #eef0ff; --on-prim: #ffffff;
  --succ: #15803d; --succ-bg: #e7f6ec; --warn: #b45309; --warn-bg: #fdf2e2;
  --err: #c81e1e; --err-bg: #fde8e8; --off: #6b7280; --off-bg: #eef0f3;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318; --card: #1c1f26; --text: #eceef4; --text2: #9aa1b2; --line: #2b2f3a;
    --prim: #818cf8; --prim-bg: #262a45; --on-prim: #111318;
    --succ: #4ade80; --succ-bg: #16301f; --warn: #fbbf24; --warn-bg: #3a2d12;
    --err: #f87171; --err-bg: #3d1a1a; --off: #9aa1b2; --off-bg: #262a33;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--text2); } .tiny { font-size: 12px; margin: 6px 2px; }
.err { color: var(--err); min-height: 1.2em; margin: 8px 0 0; }

/* login */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 20px; padding: 28px 22px;
  box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: 8px 0 2px; font-size: 22px; }
.login-icon { width: 84px; height: 84px; border-radius: 20px; }
.login-card input { margin-top: 18px; }

/* layout */
#main { min-height: 100vh; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
header.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.title { font-weight: 700; font-size: 18px; } .sub { color: var(--text2); font-size: 12px; }
main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.row { display: flex; align-items: center; } .gap { gap: 8px; margin-bottom: 10px; } .grow { flex: 1; min-width: 0; }
.small .btn { padding: 8px 10px; font-size: 13px; } .row.small { flex-wrap: wrap; }

/* controls */
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 11px;
  padding: 11px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--prim); border-color: var(--prim); color: var(--on-prim); }
.btn.danger { color: var(--err); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.icon { width: 46px; padding: 11px 0; }
.btn[disabled] { opacity: .45; }
input, select { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); }

/* status pill + chips */
.pill, .chip { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.k-work, .k-running, .k-starting { color: var(--succ); background: var(--succ-bg); }
.k-wait { color: var(--prim); background: var(--prim-bg); }
.k-attention, .k-error { color: var(--warn); background: var(--warn-bg); }
.k-captcha, .k-crashed { color: var(--err); background: var(--err-bg); }
.k-off { color: var(--off); background: var(--off-bg); }

/* captcha banner */
.captcha { margin: 12px 16px 0; padding: 14px; border-radius: var(--radius); background: var(--err); color: #fff; }
.captcha-text { display: flex; flex-direction: column; margin-bottom: 10px; }
.captcha-text span { opacity: .9; font-size: 13px; }
.captcha .row { gap: 8px; } .captcha .btn { flex: 1; border: 0; }
.captcha .btn.light { background: rgba(255,255,255,.18); color: #fff; }
.captcha .btn.solid { background: #fff; color: #b91c1c; }

/* bot cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--line); }
.bot { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center; border-left: 4px solid var(--c); }
.bot.off { border-left-color: var(--line); }
.bot img { width: 76px; height: 76px; object-fit: contain; border-radius: 10px; }
.bot .name { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; }
.bot .act { color: var(--text2); font-size: 13px; margin: 3px 0; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bot .next { font-size: 13px; font-variant-numeric: tabular-nums; }
.bot .stats { font-size: 12px; color: var(--text2); }
.bot .acts { grid-column: 1 / -1; display: flex; gap: 8px; }
.bot .acts .btn { flex: 1; padding: 9px 10px; }

/* screen */
.screen-wrap { position: relative; background: #000; border-radius: 12px; overflow: auto; min-height: 200px;
  -webkit-overflow-scrolling: touch; }
.screen-wrap img { display: block; width: 100%; height: auto; touch-action: pan-x pan-y pinch-zoom; }
.screen-wrap.mouse img { touch-action: none; -webkit-user-select: none; user-select: none; }
.screen-wrap.z2 img { width: 200%; } .screen-wrap.z3 img { width: 300%; }
.screen-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; opacity: .75; pointer-events: none; text-align: center; padding: 20px; }
.tap-dot { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  border: 3px solid #f43f5e; pointer-events: none; animation: tap .6s ease-out forwards; }
@keyframes tap { to { transform: scale(1.8); opacity: 0; } }

/* log */
.log { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 0;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.log div { padding: 3px 10px; border-bottom: 1px solid var(--line); word-break: break-word; }
.log div:last-child { border-bottom: 0; }
.log .ts { color: var(--text2); margin-right: 6px; } .log .b { font-weight: 700; margin-right: 6px; }
.log .err { color: var(--err); margin: 0; } .log .warn { color: var(--warn); } .log .good { color: var(--succ); }
.log .dim { color: var(--text2); }

.kv { display: flex; justify-content: space-between; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; } .kv span { color: var(--text2); }

/* bottom nav */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { flex: 1; border: 0; background: none; color: var(--text2); font: inherit; font-size: 11px;
  padding: 8px 0 9px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
nav.tabs button span { font-size: 20px; line-height: 1.2; }
nav.tabs button.active { color: var(--prim); font-weight: 700; }
nav.tabs button .dot { position: relative; }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 9; max-width: 90vw; }
.cursor { position: absolute; width: 16px; height: 24px; pointer-events: none; z-index: 2;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 24'%3E%3Cpath d='M1 1v18l4.5-4.2 3.2 7.4 3-1.3-3.2-7.2H15z' fill='%23fff' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat; background-size: contain; }
