:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #1d2130;
  --muted: #5b6170;
  --border: #e3e6ee;
  --accent: #2c5be8;
  --accent-ink: #ffffff;
  --ok: #16865a;
  --warn: #b26a00;
  --danger: #c62f3b;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(20 30 60 / 6%), 0 4px 16px rgb(20 30 60 / 5%);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101219;
    --surface: #191c26;
    --surface-2: #232736;
    --text: #e9ebf2;
    --muted: #9aa1b3;
    --border: #2c3142;
    --accent: #5b82ff;
    --ok: #3ccf8e;
    --warn: #f0a63a;
    --danger: #ff6b76;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Bengali", "Noto Sans Arabic", "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand img { border-radius: 8px; }
.lang-pick { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; color: var(--muted); }
.lang-pick select { border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; max-width: 150px; }

main { max-width: 640px; margin: 0 auto; padding: 8px 16px 24px; outline: none; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 14px; }
.view-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card > h2, .card > h3 { margin-bottom: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.hero { text-align: center; padding: 22px 16px; }
.hero .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.hero .big { font-size: 26px; font-weight: 700; margin: 6px 0 16px; }
.hero .muted { margin-top: 12px; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }

.clock { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.clock .time { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.xl { width: 100%; font-size: 18px; min-height: 56px; border-radius: 16px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 18px; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.link { text-decoration: none; color: var(--accent); font-size: 13px; padding: 6px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.s-armed, .s-ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.s-reminded, .s-pending, .s-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.s-releasing, .s-released { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.s-failed { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 8px; }
.row .ico { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); font-size: 20px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; border: 1.5px dashed var(--border); border-radius: var(--radius); }

.release header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.release p { margin: 4px 0; font-size: 14px; }
.deliveries { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.deliveries li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--border); }

.banner { padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; font-size: 14px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* forms */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input, select, textarea { font: inherit; color: var(--text); }
.field input, .field select, .field textarea, .inline-input {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); min-height: 44px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.field small { display: block; margin-top: 6px; color: var(--ok); font-size: 13px; }
.pair { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { flex: 1 1 auto; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 9px 10px; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; cursor: pointer; background: var(--surface); }
.seg input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.checklist { display: grid; gap: 6px; max-height: 220px; overflow: auto; padding: 2px; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; background: var(--surface); }
.checklist input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle input { width: 46px; height: 26px; accent-color: var(--accent); }
.form-error { color: var(--danger); font-size: 14px; margin: 0 16px 8px; }

dialog#sheet {
  width: 100%; max-width: 640px; max-height: 92vh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 22px 22px 0 0; background: var(--bg); color: var(--text);
}
@media (min-width: 700px) { dialog#sheet { margin: auto; border-radius: 22px; } }
dialog::backdrop { background: rgb(10 12 20 / 45%); }
#sheet-form { display: flex; flex-direction: column; max-height: 92vh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.sheet-body { overflow: auto; padding: 8px 16px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.sheet-foot .btn { flex: 1; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 6; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; max-width: 128px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px 8px; cursor: pointer; min-height: 60px;
}
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0;
  transition: .25s; pointer-events: none; max-width: calc(100% - 32px); z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }
.prose p { margin: 6px 0; font-size: 14px; }

/* lock screen, passwords, keys */
body.locked { padding-bottom: 24px; }
body.locked .tabbar { display: none; }
body.viewer { padding-bottom: 24px; }
.gate { max-width: 460px; margin: 24px auto; padding: 24px 20px; }
.gate h1 { margin: 6px 0 8px; }
.gate .btn.xl { margin-top: 8px; }
.gate-icon { font-size: 40px; text-align: center; }
.center { justify-content: center; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 48px; }
.pw-wrap .icon-btn { position: absolute; inset-inline-end: 2px; top: 2px; }
.meter { margin: -6px 0 14px; }
.meter .bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter .bar span { display: block; height: 100%; width: 10%; background: var(--danger); transition: width .2s; }
.meter[data-score="1"] .bar span { width: 30%; background: var(--danger); }
.meter[data-score="2"] .bar span { width: 55%; background: var(--warn); }
.meter[data-score="3"] .bar span { width: 80%; background: var(--ok); }
.meter[data-score="4"] .bar span { width: 100%; background: var(--ok); }
.meter-label { font-size: 13px; font-weight: 600; margin: 6px 0 2px; }
.meter-tips { margin: 0; padding-inline-start: 18px; font-size: 13px; color: var(--muted); }
.keybox { border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: var(--surface); }
.keybox legend { padding: 0 6px; }
.keycode { display: block; font: 600 18px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; text-align: center; padding: 12px; border-radius: 12px; background: var(--surface-2); word-break: break-all; user-select: all; direction: ltr; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); margin-top: 1px; }
.field small.warn-text, .warn-text { color: var(--warn); }
.pre { white-space: pre-wrap; }
.break { word-break: break-all; }
blockquote.card { margin: 0 0 12px; }

/* language picker */
button.lang-pick { font: inherit; font-size: 14px; color: var(--text); cursor: pointer; max-width: 55vw; }
button.lang-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-picker .lang-search { margin-bottom: 8px; position: sticky; top: 0; z-index: 1; }
.lang-list { display: grid; gap: 4px; max-height: 52vh; overflow: auto; padding: 2px; }
.lang-list label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; }
.lang-list label:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.lang-list input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.lang-list .lname { flex: 1; font-weight: 600; }
.lang-details summary { cursor: pointer; font-size: 14px; padding: 6px 0 10px; }
.lang-details summary span { font-weight: 600; }
.keybox h3 { margin: 0 0 6px; }

/* storage picker, tips, security page */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; }
.picker-list { max-height: 50vh; overflow: auto; }
button.pick-row { width: 100%; font: inherit; color: inherit; text-align: start; cursor: pointer; }
details.tips { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); margin-bottom: 14px; }
details.tips summary { cursor: pointer; font-size: 14px; font-weight: 600; }
details.tips ul, .prose ul { margin: 8px 0 0; padding-inline-start: 20px; font-size: 14px; }
.prose li { margin: 4px 0; }
.tabbar button { max-width: 110px; }

/* last days before a dead man's switch fires */
.countdown { margin: 0 0 14px; padding: 14px; border-radius: 14px; background: color-mix(in srgb, var(--danger) 14%, var(--surface)); border: 2px solid var(--danger); color: var(--danger); }
.countdown span { display: block; font-weight: 700; font-size: 14px; }
.countdown b { display: block; font-size: 32px; font-variant-numeric: tabular-nums; letter-spacing: .02em; margin-top: 4px; }
