:root {
  --bg: #f4f5f2; --card: #ffffff; --fg: #111b21; --muted: #667781; --line: #e2e5e0;
  --accent: #128c5e; --accent-fg: #fff; --accent-soft: #d9f2e6; --warn: #b45309; --warn-soft: #fef3c7;
  --danger: #b91c1c; --me: #d9fdd3; --them: #ffffff; --chip: #eef1ec;
  --radius: 14px; --tap: 48px;
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b141a; --card: #111b21; --fg: #e9edef; --muted: #8696a0; --line: #222d34;
    --accent: #21c063; --accent-fg: #06210f; --accent-soft: #10331f; --warn: #fbbf24; --warn-soft: #3a2a07;
    --danger: #f87171; --me: #005c4b; --them: #202c33; --chip: #1f2c33;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-size: 17px; line-height: 1.4; }
body { padding-top: calc(52px + var(--safe-top)); padding-bottom: calc(66px + var(--safe-bottom)); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
h2 { font-size: 1.05rem; margin: 22px 4px 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
h3 { margin: 0 0 6px; font-size: 1.05rem; }
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(6px + var(--safe-top)) 12px 6px; min-height: calc(52px + var(--safe-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); }
.top h1 { font-size: 1.1rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: var(--accent); font-size: 2rem; min-width: var(--tap); min-height: 40px; padding: 0; line-height: 1; }
main { padding: 10px 12px 24px; max-width: 720px; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding-bottom: var(--safe-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px;
  color: var(--muted); font-size: .72rem; position: relative; }
.tabs a .ti { font-size: 1.3rem; line-height: 1.2; }
.tabs a.active { color: var(--accent); }
.badge { position: absolute; top: 6px; left: 55%; background: var(--danger); color: #fff; border-radius: 10px; font-size: .7rem;
  padding: 1px 6px; font-weight: 700; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 10px 0; border: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 12px;
  min-height: var(--tap); padding: 10px 16px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.big { width: 100%; font-size: 1.05rem; min-height: 54px; }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: .9rem; }
.btn[disabled] { opacity: .45; }
.btn.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btns .btn { flex: 1 1 auto; }
input, textarea, select { width: 100%; font: inherit; font-size: 17px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-height: var(--tap); }
textarea { min-height: 96px; resize: vertical; }
label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: .95rem; }
.chat-item { display: flex; gap: 10px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--chip); display: grid; place-items: center;
  font-weight: 700; color: var(--accent); flex: none; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .75rem; font-weight: 600; background: var(--chip); color: var(--muted); }
.pill.green { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.red { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.msgs { display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 86%; padding: 8px 11px; border-radius: 12px; background: var(--them); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--me); border-color: transparent; }
.msg .meta { font-size: .72rem; color: var(--muted); margin-top: 3px; }
.msg .sender { font-size: .78rem; font-weight: 700; color: var(--accent); }
.tr { margin-top: 5px; padding-top: 5px; border-top: 1px dashed var(--line); font-size: .9rem; color: var(--muted); }
details > summary { cursor: pointer; color: var(--muted); font-size: .85rem; min-height: 32px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.q-card .q-da { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.q-card.done { border-color: var(--accent); }
.q-card.skipped { opacity: .65; }
.draft-text { white-space: pre-wrap; font-size: 1.05rem; padding: 12px; border-radius: 12px; background: var(--me); }
.draft-da { white-space: pre-wrap; color: var(--muted); margin-top: 8px; font-size: .95rem; }
.warn-box { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 8px 10px; margin-top: 8px; font-size: .9rem; }
.err { color: var(--danger); }
#banner { margin: 8px 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: .92rem; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-bottom)); z-index: 20;
  background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: 90vw; text-align: center; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.seg { display: flex; gap: 4px; background: var(--chip); padding: 3px; border-radius: 12px; }
.seg button { flex: 1; border: 0; background: none; color: var(--fg); border-radius: 9px; min-height: 40px; font-size: .85rem; font-weight: 600; }
.seg button.on { background: var(--card); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.seg button.on.ex { color: var(--danger); }
.field { border-top: 1px solid var(--line); padding: 10px 0; }
.field:first-child { border-top: 0; }
.field .fname { font-weight: 700; font-size: .9rem; }
.field pre { white-space: pre-wrap; font-family: inherit; margin: 4px 0 0; font-size: .95rem; }
.diff-old { color: var(--danger); text-decoration: line-through; white-space: pre-wrap; font-size: .85rem; }
.diff-new { color: var(--accent); white-space: pre-wrap; font-size: .85rem; }
.qr { width: 100%; max-width: 320px; aspect-ratio: 1; display: block; margin: 10px auto; background: #fff; border-radius: 12px; }
.progress { height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.list-link { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); color: var(--fg); }
.list-link::after { content: "›"; color: var(--muted); font-size: 1.4rem; }
.login { display: grid; place-items: center; min-height: 100vh; padding: 0; }
.login-box { width: min(92vw, 380px); }
.login-box h1 { text-align: center; }
.login-box .btn { margin-top: 16px; }
