:root {
  --bg: #f5f7fb; --surface: #ffffff; --surface-2: #eef2f8; --text: #0f172a; --muted: #5b6475; --border: #dbe1ea;
  --brand: #1f3a8a; --brand-2: #2f55d4; --accent: #facc15; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --ok-bg: #dcfce7; --warn-bg: #fef3c7; --bad-bg: #fee2e2; --radius: 14px; --shadow: 0 8px 30px rgba(15, 23, 42, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #131a2e; --surface-2: #1b2440; --text: #e6ebf5; --muted: #98a3ba; --border: #27324f;
    --brand: #6d8cff; --brand-2: #8aa2ff; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --ok-bg: #12301f; --warn-bg: #33270b; --bad-bg: #3a1414; --shadow: 0 8px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus-visible, button:focus-visible, select:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 1px; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
p { margin: .3em 0 .8em; }
a { color: var(--brand-2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand small { font-weight: 400; color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.banner { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 10px 16px; background: var(--warn-bg); flex-wrap: wrap; }
.banner.subtle { background: var(--surface-2); }
main { max-width: 1180px; margin: 0 auto; padding: 16px; }

.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 9px 14px; font-weight: 600; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand-2); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--surface-2); color: var(--muted); }
.err { color: var(--bad); font-weight: 600; min-height: 1.4em; }
.notice { border-left: 4px solid var(--warn); background: var(--warn-bg); padding: 10px 12px; border-radius: 8px; }
.notice.bad { border-color: var(--bad); background: var(--bad-bg); }
.notice.ok { border-color: var(--ok); background: var(--ok-bg); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Simulator layout */
.sim { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .sim { grid-template-columns: 1fr; } .phone { margin: 0 auto; } }
.phone { width: 360px; max-width: 100%; height: 720px; border-radius: 40px; background: #0b0f1a; padding: 12px; box-shadow: var(--shadow); position: relative; }
.screen { position: relative; height: 100%; border-radius: 30px; overflow: hidden; background: var(--bg); display: flex; flex-direction: column; color: var(--text); }
.statusbar { display: flex; justify-content: space-between; align-items: center; padding: 8px 18px 4px; font-size: 12px; font-weight: 600; cursor: pointer; }
.viewport { flex: 1; overflow-y: auto; position: relative; }
.navbar { display: flex; justify-content: space-around; padding: 8px 0 10px; border-top: 1px solid var(--border); background: var(--surface); }
.navbar button { background: none; border: 0; color: var(--text); font-size: 18px; width: 64px; height: 32px; border-radius: 8px; }
.home { padding: 18px 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 6px; align-content: start; }
.appicon { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; color: var(--text); font-size: 11px; text-align: center; }
.appicon .ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; color: #fff; position: relative; }
.appicon .dot { position: absolute; top: -3px; right: -3px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--bg); }
.appscreen { padding: 0; min-height: 100%; display: flex; flex-direction: column; }
.appscreen header { padding: 14px 16px; color: #fff; font-weight: 700; display: flex; gap: 10px; align-items: center; }
.appscreen .body { padding: 16px; flex: 1; }
.overlay { position: absolute; inset: 0; background: var(--bg); z-index: 5; display: flex; flex-direction: column; overflow-y: auto; }
.lock { padding: 28px 22px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.lock .big { width: 72px; height: 72px; border-radius: 22px; margin: 6px auto; display: grid; place-items: center; font-size: 36px; color: #fff; }
.shade { position: absolute; inset: 0; z-index: 6; background: rgba(10, 14, 26, .55); }
.shade .panel { background: var(--surface); padding: 14px; border-radius: 0 0 22px 22px; }
.notif { display: flex; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); margin-top: 8px; border: 0; width: 100%; text-align: left; color: var(--text); }
.recents { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.recents .rcard { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); text-align: left; padding: 0; color: var(--text); }
.recents .rcard div { padding: 10px 12px; }
.ta { padding: 16px; } /* TwoKey app pages */
.ta .seg { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 12px; overflow-x: auto; }
.ta .seg button { flex: 1; border: 0; background: none; padding: 7px 6px; border-radius: 9px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ta .seg button.on { background: var(--surface); color: var(--text); font-weight: 700; }
.applist { list-style: none; padding: 0; margin: 0; }
.applist li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); }
.applist .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; color: #fff; flex: none; }
.applist .meta { flex: 1; min-width: 0; }
.applist .meta div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat div { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.controls h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 14px; }
.log { max-height: 260px; overflow-y: auto; font-size: 12px; background: var(--surface-2); border-radius: 10px; padding: 8px; }
.log div { padding: 3px 0; border-bottom: 1px dashed var(--border); }
.log .deny { color: var(--bad); } .log .allow { color: var(--ok); } .log .gap { color: var(--warn); font-weight: 600; }
.code { font-family: ui-monospace, monospace; font-size: 20px; letter-spacing: 2px; text-align: center; padding: 12px; background: var(--surface-2); border-radius: 10px; user-select: all; }
.docs { max-width: 820px; }
.docs table { border-collapse: collapse; width: 100%; font-size: 14px; }
.docs th, .docs td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.steps { padding-left: 20px; } .steps li { margin: 6px 0; }
@media (max-width: 480px) {
  main { padding: 8px; }
  .phone { width: 100%; height: calc(100dvh - 76px); min-height: 560px; padding: 6px; border-radius: 28px; }
  .screen { border-radius: 22px; }
  .home { gap: 14px 2px; }
}
