:root { --bg:#f4f7f4; --card:#fff; --ink:#14301f; --muted:#5b6b60; --accent:#1f7a45; --line:#06c755; --border:#d9e2db; }
@media (prefers-color-scheme: dark) { :root { --bg:#0f1a13; --card:#16251b; --ink:#e8f1ea; --muted:#9db0a3; --border:#2a3d31; } }
* { box-sizing: border-box; }
body { margin:0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background:var(--bg); color:var(--ink); line-height:1.5; }
main { max-width: 480px; margin: 0 auto; padding: 24px 16px 48px; }
.badge { display:inline-block; font-size:12px; font-weight:600; letter-spacing:.04em; text-transform:uppercase; background:var(--accent); color:#fff; padding:2px 8px; border-radius:99px; }
h1 { font-size: 28px; margin: 12px 0 4px; }
p.lead { color:var(--muted); margin-top:0; }
.card { background:var(--card); border:1px solid var(--border); border-radius:12px; padding:20px; margin-top:20px; }
.btn { display:block; width:100%; text-align:center; text-decoration:none; font:inherit; font-weight:600; padding:12px 16px; border-radius:10px; border:1px solid var(--border); background:var(--card); color:var(--ink); cursor:pointer; margin-top:10px; }
.btn.primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.btn.line { background:var(--line); color:#fff; border-color:var(--line); }
.btn[disabled] { opacity:.5; cursor:not-allowed; }
h2 { font-size: 18px; margin: 0 0 4px; }
.card h2 + p.lead { font-size: 14px; margin-bottom: 4px; }
ol { padding-left: 20px; } li { margin: 6px 0; }
dl { display:grid; grid-template-columns: max-content 1fr; gap:6px 14px; margin:0; }
dt { color:var(--muted); } dd { margin:0; word-break:break-all; }
.avatar { width:56px; height:56px; border-radius:50%; object-fit:cover; background:var(--border); }
#status { min-height:1.4em; color:var(--muted); font-size:14px; margin-top:12px; }
label { display:block; font-size:14px; color:var(--muted); margin-top:12px; }
input[type=email] { display:block; width:100%; font:inherit; padding:12px; margin-top:6px; border:1px solid var(--border); border-radius:10px; background:var(--bg); color:var(--ink); }
.field-wrap { position:relative; }
.field-wrap input { padding-right:48px; }
.field-wrap input.code-input { padding-left:48px; }
.eye-btn { position:absolute; right:4px; top:50%; transform:translateY(-50%); width:44px; height:44px; margin-top:3px; display:flex; align-items:center; justify-content:center; background:none; border:0; border-radius:10px; color:var(--muted); cursor:pointer; }
.eye-btn:hover, .eye-btn:focus-visible { color:var(--ink); }
input.code-input { display:block; width:100%; font:inherit; font-size:28px; font-variant-numeric:tabular-nums; letter-spacing:.5em; text-align:center; padding:12px 8px 12px calc(8px + .5em); margin-top:6px; border:1px solid var(--border); border-radius:10px; background:var(--bg); color:var(--ink); }
.msg { min-height:1.4em; color:var(--muted); font-size:14px; margin-top:10px; }
.msg.error { color:#b3261e; }
@media (prefers-color-scheme: dark) { .msg.error { color:#ffb4ab; } }
.link-btn { display:block; margin:14px auto 0; padding:8px; background:none; border:0; font:inherit; font-size:14px; color:var(--accent); text-decoration:underline; cursor:pointer; }
.divider { text-align:center; color:var(--muted); font-size:13px; margin:14px 0 0; }
#email-flow { margin-top:4px; }
#recovery-msg { min-height:1.4em; color:var(--muted); font-size:14px; margin-top:10px; }
ul.help { color:var(--muted); font-size:14px; padding-left:20px; margin:10px 0 0; }
.hint { color:var(--muted); font-size:13px; line-height:1.4; margin:6px 2px 0; }
footer { color:var(--muted); font-size:13px; margin-top:28px; text-align:center; }
a { color:var(--accent); }

/* ---- Messaging / app pages ---- */
body.app-page { padding-bottom: env(safe-area-inset-bottom); }
.site-header { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--border); padding: calc(8px + env(safe-area-inset-top)) 16px 0; }
.hdr-top { display:flex; align-items:center; justify-content:space-between; }
.hdr-brand { font-weight:700; text-decoration:none; color:var(--accent); font-size:18px; }
.chip { font-size:13px; padding:2px 0 6px; display:flex; flex-wrap:wrap; gap:4px 8px; align-items:baseline; }
.chip-label, .chip-meta { color:var(--muted); }
.hdr-nav { display:flex; flex-wrap:wrap; gap:0 2px; margin:0 -8px; }
.hdr-nav a { padding:10px 12px; text-decoration:none; color:var(--muted); font-weight:600; font-size:14px; border-bottom:3px solid transparent; display:inline-flex; align-items:center; gap:6px; }
.hdr-nav a.active { color:var(--accent); border-bottom-color:var(--accent); }
@media (max-width: 420px) { .hdr-nav a { padding:10px 9px; font-size:13px; } }
.bell { position:relative; width:44px; height:44px; display:flex; align-items:center; justify-content:center; background:none; border:0; border-radius:10px; color:var(--ink); cursor:pointer; }
.count { min-width:18px; height:18px; padding:0 5px; border-radius:9px; background:#b3261e; color:#fff; font-size:11px; font-weight:700; display:inline-flex; align-items:center; justify-content:center; }
.bell .count { position:absolute; top:4px; right:2px; }
.count[hidden] { display:none; }
.count.inline { position:static; }
.bell-panel { position:absolute; right:8px; left:8px; top:100%; max-width:420px; margin-left:auto; background:var(--card); border:1px solid var(--border); border-radius:12px; box-shadow:0 8px 28px rgba(0,0,0,.25); max-height:70vh; overflow:auto; }
.bell-panel[hidden] { display:none; }
.bp-head { display:flex; justify-content:space-between; align-items:center; padding:10px 14px; border-bottom:1px solid var(--border); }
.bp-item { display:grid; width:100%; text-align:left; gap:2px; padding:10px 14px; background:none; border:0; border-bottom:1px solid var(--border); color:var(--ink); font:inherit; cursor:pointer; }
.bp-item.unread { background:rgba(31,122,69,.12); }
.bp-item.unread .bp-title { font-weight:700; }
.bp-body, .bp-time { color:var(--muted); font-size:13px; }
.pad { padding:10px 14px; }
.link-btn.small { margin:0; padding:4px; font-size:13px; }
.link-btn[disabled] { opacity:.4; cursor:default; }
main.app { max-width: 960px; margin:0 auto; padding: 12px 16px 32px; }
main.app.narrow { max-width: 520px; }
.msg-layout { display:grid; grid-template-columns: 300px 1fr; gap:16px; }
.pane { background:var(--card); border:1px solid var(--border); border-radius:12px; padding:12px; min-width:0; }
.pane h2 { font-size:15px; color:var(--muted); margin:6px 4px 6px; text-transform:uppercase; letter-spacing:.04em; }
ul.list, ul.plain { list-style:none; margin:0; padding:0; }
ul.plain li { margin:4px 0; font-size:14px; }
.row { display:block; width:100%; text-align:left; padding:10px; border-radius:10px; border:1px solid transparent; background:none; color:var(--ink); font:inherit; cursor:pointer; min-height:44px; }
.row:hover, .row.active { background:var(--bg); border-color:var(--border); }
.row-top, .row-bottom { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.row-time { color:var(--muted); font-size:12px; white-space:nowrap; }
.row-preview { color:var(--muted); font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pill { font-size:11px; background:var(--bg); border:1px solid var(--border); border-radius:99px; padding:0 8px; color:var(--muted); }
.thread-pane { display:flex; flex-direction:column; min-height:60vh; }
.thread-head { display:flex; align-items:center; gap:8px; padding-bottom:8px; border-bottom:1px solid var(--border); }
.back-btn { display:none; min-height:44px; padding:0 14px 0 8px; font:inherit; font-weight:600; color:var(--accent); background:none; border:1px solid var(--border); border-radius:10px; cursor:pointer; white-space:nowrap; }
.empty-thread { margin:auto; text-align:center; max-width:28ch; }
.thread { flex:1; overflow-y:auto; padding:10px 2px; display:flex; flex-direction:column; gap:8px; max-height:60vh; }
.bubble { max-width:80%; padding:8px 12px; border-radius:14px; background:var(--bg); border:1px solid var(--border); overflow-wrap:anywhere; }
.bubble.mine { align-self:flex-end; background:var(--accent); border-color:var(--accent); color:#fff; }
.bubble .who { font-size:12px; font-weight:700; opacity:.85; }
.bubble .text { white-space:pre-wrap; }
.bubble .when { font-size:11px; opacity:.75; text-align:right; margin-top:2px; }
#composer { display:flex; gap:8px; align-items:flex-end; padding-top:8px; border-top:1px solid var(--border); }
#composer[hidden] { display:none; }
#composer textarea { flex:1; font:inherit; font-size:16px; padding:10px; border:1px solid var(--border); border-radius:10px; background:var(--bg); color:var(--ink); resize:none; }
#composer .btn { width:auto; margin:0; min-height:44px; }
label.check { display:flex; gap:12px; align-items:flex-start; margin-top:14px; color:var(--ink); font-size:16px; }
label.check input { width:22px; height:22px; margin-top:2px; flex:none; }
h3 { font-size:15px; margin:16px 0 4px; }
code.uid { word-break:break-all; font-size:13px; }
.table-wrap { overflow-x:auto; margin-top:10px; }
table { border-collapse:collapse; width:100%; font-size:13px; }
th, td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--border); vertical-align:top; }
.st-ok { color:#1f7a45; font-weight:700; } .st-failed { color:#b3261e; font-weight:700; } .st-skipped { color:var(--muted); }
#toasts { position:fixed; left:0; right:0; bottom:calc(16px + env(safe-area-inset-bottom)); display:flex; flex-direction:column; align-items:center; gap:8px; z-index:30; pointer-events:none; }
.toast { pointer-events:auto; background:var(--ink); color:var(--bg); border:0; border-radius:10px; padding:12px 16px; font:inherit; font-weight:600; cursor:pointer; box-shadow:0 4px 16px rgba(0,0,0,.3); }
@media (max-width: 759px) {
  .msg-layout { grid-template-columns: 1fr; }
  .msg-layout .thread-pane { display:none; }
  .msg-layout.show-thread .list-pane { display:none; }
  .msg-layout.show-thread .thread-pane { display:flex; }
  .back-btn { display:inline-flex; align-items:center; }
  .thread { max-height:none; min-height:50vh; }
}
