:root {
  --bg: #0a0f1a;
  --bg-2: #0f1626;
  --card: #141c2e;
  --card-2: #1a2438;
  --line: #24304a;
  --text: #eef2fb;
  --muted: #8d99b4;
  --faint: #5d6a86;
  --accent: #8fa8ff;
  --accent-2: #b59cff;
  --accent-ink: #0a0f1a;
  --good: #4fd6a0;
  --warn: #ffc25c;
  --bad: #ff6b7d;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

/* Appearance: follows the phone unless chosen in Settings (data-theme="light" / "dark" on <html>). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f5fa;
    --bg-2: #e9edf6;
    --card: #ffffff;
    --card-2: #f4f6fb;
    --line: #dfe4ef;
    --text: #0d1424;
    --muted: #5b6680;
    --faint: #98a2b8;
    --accent: #4a63e8;
    --accent-2: #7b55e6;
    --accent-ink: #ffffff;
    --shadow: 0 8px 24px rgba(20, 30, 60, .08);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
    --bg: #f3f5fa;
    --bg-2: #e9edf6;
    --card: #ffffff;
    --card-2: #f4f6fb;
    --line: #dfe4ef;
    --text: #0d1424;
    --muted: #5b6680;
    --faint: #98a2b8;
    --accent: #4a63e8;
    --accent-2: #7b55e6;
    --accent-ink: #ffffff;
    --shadow: 0 8px 24px rgba(20, 30, 60, .08);
    color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ------------------------------------------------------------- boot + shield */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot-logo { width: 72px; height: 72px; border-radius: 22px; background: url(/static/icons/icon.svg) center/cover; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .6; } }
#shield { position: fixed; inset: 0; z-index: 100; background: var(--bg) url(/static/icons/icon.svg) center/96px no-repeat; display: none; }
body.hidden-app #shield { display: block; }

/* ------------------------------------------------------------- auth screens */
.auth {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--top) + 32px) 22px calc(var(--bottom) + 32px); max-width: 440px; margin: 0 auto;
}
.auth .logo { width: 76px; height: 76px; border-radius: 24px; background: url(/static/icons/icon.svg) center/cover; box-shadow: 0 16px 40px rgba(120, 140, 255, .25); margin-bottom: 22px; }
.auth h1 { font-size: 34px; letter-spacing: -.02em; margin: 0 0 6px; line-height: 1.1; }
.auth p.lead { color: var(--muted); margin: 0 0 26px; }
.auth form { display: grid; gap: 14px; }
.auth .foot { margin-top: 22px; text-align: center; color: var(--muted); font-size: 14px; }
.auth .foot button { background: none; border: 0; color: var(--accent); padding: 6px; }
.qr { background: #fff; border-radius: 16px; padding: 10px; width: 210px; margin: 4px auto; display: block; }
.secret-code { font: 600 15px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; text-align: center; word-break: break-all; color: var(--muted); user-select: all; -webkit-user-select: all; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { height: 4px; flex: 1; border-radius: 4px; background: var(--line); }
.steps span.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ------------------------------------------------------------- inputs & buttons */
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.input, select.input, textarea.input {
  width: 100%; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 14px 15px; font-size: 17px; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: var(--faint); }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.input.code { font: 600 26px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .35em; text-align: center; padding: 16px; }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 52px; }
.pw-wrap .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px;
  padding: 15px 18px; font-weight: 700; font-size: 16px; background: var(--card-2); color: var(--text); transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.danger { background: color-mix(in srgb, var(--bad) 16%, var(--card)); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 9px 13px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:active { background: var(--card-2); }
.icon-btn svg, .btn svg { width: 21px; height: 21px; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }
.hint { color: var(--muted); font-size: 13px; }
.meter { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 6px; transition: width .2s, background .2s; }

/* ------------------------------------------------------------- shell */
.shell { min-height: 100dvh; padding-bottom: calc(var(--bottom) + 84px); }
.topbar {
  position: sticky; top: 0; z-index: 20; padding: calc(var(--top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  display: flex; align-items: center; gap: 8px; min-height: 56px;
}
.topbar h1 { font-size: 28px; letter-spacing: -.02em; margin: 0; flex: 1; }
.topbar h2 { font-size: 17px; margin: 0; flex: 1; text-align: center; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { padding: 4px 16px 24px; max-width: 760px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  padding: 8px 10px calc(var(--bottom) + 8px); background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px); border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; max-width: 120px; background: none; border: 0; color: var(--faint); display: grid; justify-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 4px; }
.tabbar button svg { width: 25px; height: 25px; }
.tabbar button.on { color: var(--accent); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--bottom) + 84px); z-index: 25; width: 60px; height: 60px; border-radius: 20px; border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 45%, transparent);
}
.fab svg { width: 28px; height: 28px; }

/* ------------------------------------------------------------- list */
.search { position: relative; margin: 2px 0 12px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--faint); }
.search .input { padding-left: 42px; border-radius: 14px; background: var(--card); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 600; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip b { font-weight: 700; opacity: .6; font-size: 12px; }

.section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 18px 4px 8px; }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 13px; padding: 12px 14px; border: 0; width: 100%; background: transparent; text-align: left; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 70px; right: 0; height: 1px; background: var(--line); }
.row:active { background: var(--card-2); }
.tile { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; color: #fff; }
.tile svg { width: 23px; height: 23px; }
.row .body { flex: 1; min-width: 0; }
.row .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 13px; flex: none; }
.row .meta svg { width: 15px; height: 15px; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.badge.plain { background: var(--card-2); color: var(--muted); }

.alert-card { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--radius); background: linear-gradient(135deg, color-mix(in srgb, var(--warn) 18%, var(--card)), var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); margin-bottom: 8px; width: 100%; text-align: left; color: var(--text); }
.alert-card.bad { background: linear-gradient(135deg, color-mix(in srgb, var(--bad) 18%, var(--card)), var(--card)); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert-card .body { flex: 1; min-width: 0; }
.alert-card .t { font-weight: 700; }
.alert-card .s { font-size: 13.5px; color: var(--muted); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 26px; background: var(--card); display: grid; place-items: center; color: var(--accent); }
.empty .big svg { width: 40px; height: 40px; }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 20px; }

/* ------------------------------------------------------------- item view */
.hero { display: flex; gap: 16px; align-items: center; margin: 6px 0 18px; }
.hero .tile { width: 64px; height: 64px; border-radius: 19px; }
.hero .tile svg { width: 32px; height: 32px; }
.hero h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 6px; line-height: 1.15; word-break: break-word; }
.hero .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.kv { padding: 12px 15px; display: flex; align-items: center; gap: 8px; position: relative; }
.kv + .kv::before { content: ""; position: absolute; top: 0; left: 15px; right: 0; height: 1px; background: var(--line); }
.kv .body { flex: 1; min-width: 0; }
.kv .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kv .v { font-size: 17px; word-break: break-word; white-space: pre-wrap; }
.kv .v.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 16px; letter-spacing: .02em; }
.kv .v a { color: var(--accent); text-decoration: none; }
.notes { padding: 14px 15px; white-space: pre-wrap; word-break: break-word; }
.footnote { color: var(--faint); font-size: 13px; text-align: center; margin: 18px 0; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.file { position: relative; aspect-ratio: 4/3; border-radius: 15px; overflow: hidden; background: var(--card); border: 0; padding: 0; box-shadow: var(--shadow); color: var(--muted); }
.file img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file .ph { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 6px; padding: 10px; }
.file .ph svg { width: 30px; height: 30px; color: var(--accent); }
.file .name { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 9px 7px; font-size: 12px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.file .x { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 10px; border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; }
.file .x svg { width: 16px; height: 16px; }
.file.add { border: 2px dashed var(--line); box-shadow: none; background: transparent; display: grid; place-items: center; align-content: center; gap: 6px; font-weight: 600; font-size: 14px; }
.file.add svg { width: 28px; height: 28px; color: var(--accent); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- viewer overlay */
.viewer { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.viewer .bar { display: flex; align-items: center; gap: 6px; padding: calc(var(--top) + 8px) 10px 8px; color: #fff; }
.viewer .bar .name { flex: 1; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.viewer .bar .icon-btn { color: #fff; }
.viewer .stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 8px calc(var(--bottom) + 8px); overflow: auto; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 6px; }

/* ------------------------------------------------------------- edit */
.form { display: grid; gap: 14px; }
.seg { display: flex; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 10px; padding: 10px 6px; font-weight: 650; color: var(--muted); font-size: 15px; }
.seg button.on { background: var(--text); color: var(--bg); }
.field-row { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 10px; display: grid; gap: 8px; }
.field-row .top { display: flex; gap: 8px; align-items: center; }
.field-row .top .input { padding: 9px 11px; font-size: 14px; font-weight: 600; color: var(--muted); background: transparent; border-color: transparent; }
.field-row .top .input:focus { border-color: var(--line); box-shadow: none; }
.field-row select.input { flex: none; width: 112px; }
.field-row .val { display: flex; gap: 6px; align-items: center; }
.field-row .val .input { background: var(--bg-2); }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.template { border: 0; background: var(--card); border-radius: 16px; padding: 14px; display: flex; gap: 11px; align-items: center; text-align: left; font-weight: 650; font-size: 15px; box-shadow: var(--shadow); }
.template .tile { width: 38px; height: 38px; border-radius: 11px; }
.template .tile svg { width: 20px; height: 20px; }
.sticky-actions { position: sticky; bottom: calc(var(--bottom) + 76px); display: flex; gap: 10px; padding-top: 10px; }
.sticky-actions .btn { flex: 1; }

/* ------------------------------------------------------------- generator */
.gen-out { background: var(--card); border-radius: 22px; padding: 26px 18px; text-align: center; box-shadow: var(--shadow); margin-bottom: 14px; }
.gen-out .pw { font: 600 23px/1.35 ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; letter-spacing: .02em; min-height: 62px; display: flex; align-items: center; justify-content: center; user-select: all; -webkit-user-select: all; }
.gen-out .pw .d { color: var(--accent); }
.gen-out .pw .s { color: var(--accent-2); }
.gen-out .meter { margin: 18px auto 8px; max-width: 260px; }
.gen-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: center; }
.opt { display: flex; align-items: center; justify-content: space-between; padding: 14px 15px; gap: 12px; position: relative; }
.opt + .opt::before { content: ""; position: absolute; top: 0; left: 15px; right: 0; height: 1px; background: var(--line); }
.opt .lbl { font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 31px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ------------------------------------------------------------- settings */
.menu .row .tile { width: 34px; height: 34px; border-radius: 10px; }
.menu .row .tile svg { width: 19px; height: 19px; }
.menu .row + .row::before { left: 61px; }
.profile { display: flex; align-items: center; gap: 14px; padding: 16px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 22px; flex: none; }
.log { font-size: 14px; }
.log .kv .v { font-size: 15px; }
.ok-dot, .bad-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ok-dot { background: var(--good); }
.bad-dot { background: var(--bad); }
.link-box { background: var(--bg-2); border: 1.5px dashed var(--line); border-radius: 14px; padding: 12px; font: 13px/1.4 ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; user-select: all; -webkit-user-select: all; }
.info { background: color-mix(in srgb, var(--accent) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); border-radius: 16px; padding: 14px 15px; font-size: 14px; color: var(--muted); }
.info b { color: var(--text); }

/* ------------------------------------------------------------- modal + toast */
.modal-back { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@media (min-width: 640px) { .modal-back { align-items: center; } }
.modal { background: var(--card); width: 100%; max-width: 460px; border-radius: 24px 24px 0 0; padding: 22px 18px calc(var(--bottom) + 18px); display: grid; gap: 14px; max-height: 92dvh; overflow: auto; animation: up .2s ease-out; }
@media (min-width: 640px) { .modal { border-radius: 24px; } }
.modal h3 { margin: 0; font-size: 20px; }
.modal p { margin: 0; color: var(--muted); }
.modal .actions { display: flex; gap: 10px; }
.modal .actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: calc(var(--bottom) + 96px); transform: translate(-50%, 20px); z-index: 90; background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 650; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 900px) {
  .page { padding-top: 10px; }
  .fab { right: calc(50% - 360px); }
}
.badge svg { width: 13px; height: 13px; flex: none; }

/* ------------------------------------------------------------- AI */
.ai-status { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--muted); background: color-mix(in srgb, var(--accent-2) 10%, var(--card)); border-radius: 12px; padding: 10px 12px; }
.ai-status svg { width: 18px; height: 18px; flex: none; color: var(--accent-2); }
.ai-status.busy svg { animation: pulse 1.2s ease-in-out infinite; }
.ai-status.bad { color: var(--bad); }
.doc-text summary { padding: 12px 15px; cursor: pointer; display: grid; gap: 3px; font-size: 14px; color: var(--muted); list-style: none; }
.doc-text summary::-webkit-details-marker { display: none; }
.doc-text summary b { color: var(--text); font-size: 15px; }
.doc-text + .doc-text { border-top: 1px solid var(--line); }
.doc-text .notes { font-size: 14px; color: var(--muted); border-top: 1px dashed var(--line); max-height: 50vh; overflow: auto; }
.chat { display: grid; gap: 12px; padding-bottom: 90px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 18px; font-size: 16px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg.user { justify-self: end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.assistant { justify-self: start; background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 6px; white-space: normal; }
.answer .p { min-height: .6em; }
.answer .li { padding-left: 16px; position: relative; }
.answer .li::before { content: "•"; position: absolute; left: 3px; color: var(--accent); }
.chat-empty { text-align: center; padding: 30px 6px; color: var(--muted); }
.chat-empty .big { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 24px; background: var(--card); display: grid; place-items: center; color: var(--accent-2); }
.chat-empty .big svg { width: 34px; height: 34px; }
.chat-empty h3 { color: var(--text); margin: 0 0 6px; font-size: 20px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.suggest .chip { white-space: normal; text-align: left; }
.chat-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--bottom) + 66px); z-index: 25; display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); max-width: 760px; margin: 0 auto; }
.chat-input { min-height: 46px !important; max-height: 140px; resize: none; padding: 11px 14px; border-radius: 22px; font-size: 16px; }
.send { width: 46px; height: 46px; border-radius: 50%; border: 0; flex: none; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); display: grid; place-items: center; }
.send[disabled] { opacity: .5; }
.send svg { width: 21px; height: 21px; }
.ai-badge { margin-left: 6px; font-size: 10px; font-weight: 800; letter-spacing: .05em; padding: 1px 5px; border-radius: 5px; background: color-mix(in srgb, var(--accent-2) 20%, transparent); color: var(--accent-2); vertical-align: 1px; }

/* ------------------------------------------------------------- emergency kit */
.kit-screen { justify-content: flex-start; gap: 14px; }
.kit-screen h1 { margin: 0; }
.kit-screen .lead { margin: 0; }
.kit { background: #fff; color: #0d1424; border-radius: 18px; padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.kit-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.kit-head .logo { width: 48px; height: 48px; border-radius: 14px; margin: 0; box-shadow: none; }
.kit-head h2 { margin: 0; font-size: 20px; }
.kit .hint { color: #5b6680; }
.kit dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 0; font-size: 15px; }
.kit dt { color: #5b6680; font-weight: 600; }
.kit dd { margin: 0; overflow-wrap: break-word; min-width: 0; }
.kit dd.sk { font: 700 17px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; background: #eef1ff; border-radius: 8px; padding: 6px 8px; }
.kit dd.blank { border-bottom: 1.5px solid #98a2b8; min-height: 26px; }
.kit-note { font-size: 13px; color: #5b6680; margin: 14px 0 0; line-height: 1.5; }
.kit-actions { display: flex; gap: 10px; }
.kit-actions .btn { flex: 1; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; color: var(--muted); }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.input.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .03em; font-size: 15px; }
@media print {
  body { background: #fff !important; }
  body * { visibility: hidden !important; }
  .kit, .kit * { visibility: visible !important; }
  .kit { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: 0; }
  #shield { display: none !important; }
}

/* ------------------------------------------------------------- offline */
body.offline [data-online] { display: none !important; }
.offline-bar { margin: 0 16px 10px; display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 12px; font-size: 14px; font-weight: 650;
  background: color-mix(in srgb, var(--warn) 16%, var(--card)); color: var(--warn); }
.offline-bar svg, .offline-note svg { width: 18px; height: 18px; flex: none; }
.offline-note { display: flex; gap: 8px; align-items: center; color: var(--warn); font-weight: 600; margin: 0 0 18px; }
.auth > .btn.primary.block + form { margin-top: 18px; }

/* ------------------------------------------------------------- iOS Safari fixes */
/* iOS zooms into any focused field under 16px and leaves the page shifted: keep every field >= 16px. */
input, select, textarea { font-size: max(16px, 1em); }
.input.mono { font-size: 16px; }
.field-row .top .input { font-size: 16px; }
.opt select.input { font-size: 16px !important; }
/* iOS date inputs ignore width:100% and can overflow the screen. */
input[type="date"].input { display: block; min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; }
/* clip (not hidden): hidden turns <body> into its own scroll box, which broke mouse-wheel scrolling */
html, body { max-width: 100%; overflow-x: clip; }

/* ------------------------------------------------------------- PDF viewer */
.viewer .stage.pdf { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pdf-pages { display: grid; gap: 10px; justify-items: center; padding: 4px 0 24px; }
.pdf-pages canvas { background: #fff; border-radius: 4px; box-shadow: 0 4px 16px rgba(0, 0, 0, .4); max-width: 100%; height: auto !important; }
.file img.pdf-thumb { object-position: top; background: #fff; }

/* Light mode on iPhone: the home-screen app always shows white status-bar text (black-translucent),
   so give the status-bar area a navy band to keep the clock/battery readable. */
:root[data-theme="light"] body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: #141c2e; z-index: 95; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: #141c2e; z-index: 95; }
}
