:root {
  --bg: #f6f5f2; --surface: #ffffff; --ink: #1d1c1a; --muted: #6b6862; --line: #e3e0da;
  --accent: #1f6feb; --accent-ink: #ffffff; --mine: #1f6feb; --mine-ink: #ffffff; --theirs: #ffffff; --theirs-ink: #1d1c1a;
  --warn: #8a5a00; --warn-bg: #fff4dc; --tick: #c9d8f7; --tick-read: #ffffff;
  --radius: 18px; --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121315; --surface: #1c1d20; --ink: #ecebe8; --muted: #a3a09a; --line: #2c2d31;
    --accent: #5b9bff; --accent-ink: #0b1220; --mine: #2f6fd6; --mine-ink: #ffffff; --theirs: #24262a; --theirs-ink: #ecebe8;
    --warn: #ffcf7a; --warn-bg: #3a2e14; --tick: #b9cdf5; --tick-read: #ffffff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121315; --surface: #1c1d20; --ink: #ecebe8; --muted: #a3a09a; --line: #2c2d31;
  --accent: #5b9bff; --accent-ink: #0b1220; --mine: #2f6fd6; --mine-ink: #ffffff; --theirs: #24262a; --theirs-ink: #ecebe8;
  --warn: #ffcf7a; --warn-bg: #3a2e14; --tick: #b9cdf5; --tick-read: #ffffff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; overflow-x: hidden;
}
h1, h2 { font-family: "Lora", Georgia, serif; font-weight: 600; font-variant-ligatures: none; margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Sign-in */
.signin { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) var(--gutter) 32px; }
.signin h1 { font-size: 28px; }
.signin p { color: var(--muted); margin: 8px 0 24px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.field input:focus, .box textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.primary { min-height: 48px; width: 100%; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.primary:disabled { opacity: .55; cursor: default; }
.linkish { background: none; border: 0; color: var(--accent); padding: 12px 0; min-height: 44px; cursor: pointer; text-decoration: underline; }
.note { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 15px; }
.note:empty { display: none; }

/* Line */
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; }
.top { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.top h1 { font-size: 20px; flex: 1; }
.top small { display: block; font-family: system-ui, sans-serif; font-weight: 400; font-size: 13px; color: var(--muted); }
.thread { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px var(--gutter) 8px; display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); text-align: center; margin: auto 0; padding: 24px 8px; }
.msg { max-width: 84%; display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.who { font-size: 13px; color: var(--muted); margin: 0 6px 3px; font-weight: 600; }
.bubble { padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.mine .bubble { background: var(--mine); color: var(--mine-ink); border-bottom-right-radius: 6px; }
.theirs .bubble { background: var(--theirs); color: var(--theirs-ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.meta { font-size: 12px; color: var(--muted); margin: 3px 6px 0; display: flex; gap: 6px; align-items: center; }
.ticks { letter-spacing: -3px; font-weight: 700; color: var(--muted); }
.ticks.read { color: var(--accent); }
.box { border-top: 1px solid var(--line); background: var(--surface); padding: 8px var(--gutter) calc(env(safe-area-inset-bottom) + 10px); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; }
.chips[hidden] { display: none; }
.chip { flex: none; min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.box textarea { flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: calc(5 * 1.45em + 20px); padding: 10px 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--bg); line-height: 1.45; }
.send { flex: none; min-width: 64px; min-height: 44px; border: 0; border-radius: 22px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; padding: 0 16px; }
.send:disabled { opacity: .5; cursor: default; }
.under { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.count.near { color: var(--warn); font-weight: 600; }
.status { margin: 0 0 8px; }
