:root {
  --green: #1EB53A; --yellow: #FCD116; --black: #000; --blue: #00A3DD;
  --bg: #efeae2; --panel: #ffffff; --bar: #0b1f14; --bar-ink: #f4f7f2;
  --ink: #111b21; --muted: #667781; --me: #d9fdd3; --them: #ffffff;
  --line: rgba(0,0,0,.08); --btn: #0a7c2f; --chip: #e7f8ea;
  --shadow: 0 1px 0.5px rgba(11,20,26,.13);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b141a; --panel: #111b21; --bar: #0d1f15; --bar-ink: #e9edef;
    --ink: #e9edef; --muted: #8696a0; --me: #005c4b; --them: #1f2c34;
    --line: rgba(255,255,255,.08); --btn: #4cd964; --chip: #133a22;
    --shadow: 0 1px 0.5px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; background: var(--bg); position: relative; }

.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bar); color: var(--bar-ink); padding-top: max(10px, env(safe-area-inset-top)); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 22px;
  background: conic-gradient(var(--green) 0 25%, var(--yellow) 0 50%, var(--black) 0 75%, var(--blue) 0); }
.who { flex: 1; min-width: 0; }
.name { font-weight: 650; }
.status { font-size: 12.5px; opacity: .8; }
.flag { display: flex; gap: 3px; }
.flag i { width: 6px; height: 18px; border-radius: 2px; }
.flag i:nth-child(1) { background: var(--green); } .flag i:nth-child(2) { background: var(--yellow); }
.flag i:nth-child(3) { background: #444; } .flag i:nth-child(4) { background: var(--blue); }

.log { flex: 1; overflow-y: auto; padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.intro { margin: auto; text-align: center; max-width: 440px; padding: 24px 8px; }
.intro-badge { font-size: 46px; }
.intro h1 { font-size: 24px; margin: 8px 0; }
.intro p { color: var(--muted); }
.intro .sw { font-style: italic; }
.fine { font-size: 12px; }
.chip { border: 0; background: var(--btn); color: #fff; font: inherit; font-weight: 600; padding: 10px 22px; border-radius: 999px; cursor: pointer; margin: 6px 0 4px; }

.row { display: flex; flex-direction: column; max-width: 82%; }
.row.me { align-self: flex-end; align-items: flex-end; }
.row.them { align-self: flex-start; align-items: flex-start; }
.bubble { position: relative; padding: 7px 10px 8px; border-radius: 8px; box-shadow: var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; }
.me .bubble { background: var(--me); border-top-right-radius: 2px; }
.them .bubble { background: var(--them); border-top-left-radius: 2px; }
.row + .row.me, .row + .row.them { margin-top: 2px; }
.row.me + .row.them, .row.them + .row.me { margin-top: 8px; }
.bubble a { color: var(--blue); }
.react { position: absolute; bottom: -12px; right: 6px; background: var(--panel); border-radius: 999px; padding: 0 5px; font-size: 13px; box-shadow: var(--shadow); }
.me .bubble.has-react { margin-bottom: 12px; }
.btns { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; width: 100%; min-width: 220px; }
.btns button { border: 0; border-radius: 8px; background: var(--them); color: var(--btn); font: inherit; font-weight: 600; padding: 9px 12px; cursor: pointer; box-shadow: var(--shadow); }
.btns button:disabled { opacity: .55; cursor: default; }
.typing { align-self: flex-start; background: var(--them); border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); display: flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer { display: flex; gap: 8px; padding: 8px 12px; background: var(--bg); }
.composer input { flex: 1; min-width: 0; border: 0; border-radius: 22px; padding: 11px 16px; font: inherit; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.composer input:focus { outline: 2px solid var(--green); }
.composer button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--green); color: #fff; font-size: 18px; cursor: pointer; flex: none; }
.foot { text-align: center; font-size: 12px; padding: 0 0 max(8px, env(safe-area-inset-bottom)); }
.foot a { color: var(--muted); }

.sheet { position: absolute; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 5; }
.sheet[hidden] { display: none; }
.sheet-card { position: relative; width: 100%; background: var(--panel); border-radius: 16px 16px 0 0; padding: 18px 16px 24px; max-height: 70%; overflow: auto; }
.sheet-title { font-weight: 650; margin-bottom: 10px; padding-right: 30px; }
.sheet-rows button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font: inherit; padding: 12px 4px; cursor: pointer; }
.sheet-rows small { display: block; color: var(--muted); }
.sheet-close { position: absolute; top: 12px; right: 12px; border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
@media (max-width: 480px) { .row { max-width: 90%; } }
