/* ---------- Tokens ---------- */
:root {
  --ink: #14213D;
  --ink-2: #4A5878;
  --ink-3: #7C89A6;
  --blue: #1F4FB0;
  --blue-press: #173E8C;
  --blue-soft: #E6EDFA;
  --bubble-out: #1F4FB0;
  --bubble-in: #E8EDF6;
  --red: #D7263D;
  --red-soft: #FBE7EA;
  --silver: #A9B6CF;
  --line: #DFE5F0;
  --paper: #F3F6FB;
  --surface: #FFFFFF;
  --scrim: rgba(20, 33, 61, .45);
  --shadow: 0 1px 2px rgba(20,33,61,.06), 0 8px 24px rgba(20,33,61,.08);
  --display: "Red Hat Display", system-ui, sans-serif;
  --text: "Red Hat Text", system-ui, sans-serif;
  --tab-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E8EDF8; --ink-2: #AAB5CD; --ink-3: #7D8AA8;
    --blue: #5B88E8; --blue-press: #4A76D4; --blue-soft: #1B2C5A;
    --bubble-out: #3A68CC; --bubble-in: #1E2B55;
    --red: #FF5C70; --red-soft: #3A1A28;
    --silver: #5A6890; --line: #24325C;
    --paper: #0D1530; --surface: #141F42;
    --scrim: rgba(4, 8, 20, .6);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #E8EDF8; --ink-2: #AAB5CD; --ink-3: #7D8AA8;
  --blue: #5B88E8; --blue-press: #4A76D4; --blue-soft: #1B2C5A;
  --bubble-out: #3A68CC; --bubble-in: #1E2B55;
  --red: #FF5C70; --red-soft: #3A1A28;
  --silver: #5A6890; --line: #24325C;
  --paper: #0D1530; --surface: #141F42;
  --scrim: rgba(4, 8, 20, .6);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.45 var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Logo sits on a white chip in dark mode so the artwork keeps its colors */
.logo { display: block; height: 36px; width: auto; }
.logo-wrap { display: inline-flex; border-radius: 10px; }
:root[data-theme="dark"] .logo-wrap { background: #fff; padding: 3px 8px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-wrap { background: #fff; padding: 3px 8px; } }

/* ---------- Shell ---------- */
.shell { height: 100dvh; display: grid; grid-template-columns: 1fr; }
.rail { display: none; }
.pane-list, .pane-main { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.pane-main { background: var(--paper); }
.shell[data-detail="true"] .pane-list { display: none; }
.shell[data-detail="false"] .pane-main { display: none; }
.pane-list { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
}
.shell[data-detail="true"] .tabbar { display: none; }
.tab {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 500; color: var(--ink-3); text-decoration: none; position: relative;
}
.tab[aria-current="page"] { color: var(--blue); }
.tab .pip { position: absolute; top: 9px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }

@media (min-width: 760px) {
  .shell { grid-template-columns: 76px minmax(320px, 380px) 1fr; }
  .shell[data-detail] .pane-list, .shell[data-detail] .pane-main { display: flex; }
  .pane-list { border-right: 1px solid var(--line); padding-bottom: 0; }
  .tabbar { display: none !important; }
  .rail {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0;
    background: var(--ink); color: #C9D3EA;
  }
  :root[data-theme="dark"] .rail { background: #08102A; }
  .rail .tab { width: 60px; height: 60px; border-radius: 14px; color: #9FAED0; font-size: 11px; }
  .rail .tab:hover { background: rgba(255,255,255,.06); color: #fff; }
  .rail .tab[aria-current="page"] { background: rgba(255,255,255,.1); color: #fff; }
  .rail .tab .pip { top: 6px; left: auto; right: 6px; }
  .rail .spacer { flex: 1; }
  .rail .me { width: 40px; height: 40px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font: 700 13px var(--display); }
  .back-btn { display: none !important; }
  .fab { display: none !important; }
}
@media (prefers-color-scheme: dark) { @media (min-width: 760px) { :root:not([data-theme="light"]) .rail { background: #08102A; } } }

/* ---------- Generic pieces ---------- */
.bar {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-height: 64px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.bar h1 { font-size: 24px; font-weight: 700; flex: 1; }
.bar h2 { font-size: 17px; font-weight: 700; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--ink-2);
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--blue-soft); color: var(--blue); }
.icon-btn.primary { background: var(--blue); color: #fff; }
.icon-btn.primary:hover { background: var(--blue-press); color: #fff; }

.search {
  margin: 0 16px 10px; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px;
  background: var(--paper); border: 1px solid transparent; border-radius: 12px; color: var(--ink-3);
}
.search:focus-within { border-color: var(--blue); background: var(--surface); }
.search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; color: var(--ink); }
.search svg.i { width: 18px; height: 18px; }

.chips { display: flex; gap: 8px; padding: 0 16px 10px; }
.chip {
  height: 32px; padding: 0 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.avatar {
  --h: 220; width: 44px; height: 44px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font: 700 15px var(--display);
  background: hsl(var(--h) 60% 92%); color: hsl(var(--h) 55% 32%);
}
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 35% 25%); color: hsl(var(--h) 70% 85%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 35% 25%); color: hsl(var(--h) 70% 85%); } }
.avatar.unknown { background: var(--paper); color: var(--ink-3); border: 1px dashed var(--silver); }
.avatar.lg { width: 88px; height: 88px; font-size: 30px; }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; }

.btn {
  height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; text-decoration: none;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-press); }
.btn-quiet { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-quiet:hover { border-color: var(--silver); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--line); }
.btn-danger:hover { background: var(--red-soft); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }

.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none;
}
.field textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 96px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.field.invalid input { border-color: var(--red); }
.field.invalid .hint { color: var(--red); }

.empty { margin: auto; text-align: center; max-width: 320px; padding: 32px 24px; color: var(--ink-2); }
.empty h2 { font-size: 20px; margin: 16px 0 6px; color: var(--ink); }
.empty p { margin: 0 0 18px; }

/* The orbit: the swoosh from the logo, reused as the app's signature line */
.orbit { position: absolute; pointer-events: none; color: var(--silver); opacity: .7; }
.orbit ellipse { fill: none; stroke: currentColor; stroke-width: 1.5; }
.orbit .star { fill: currentColor; stroke: none; }

/* ---------- Thread list ---------- */
.thread-row {
  display: flex; gap: 12px; align-items: center; padding: 10px 16px; text-decoration: none; color: inherit; position: relative;
}
.thread-row:hover { background: var(--paper); }
.thread-row[aria-current="true"] { background: var(--blue-soft); }
.thread-row .body { flex: 1; min-width: 0; }
.thread-row .top { display: flex; align-items: baseline; gap: 8px; }
.thread-row .name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-row .time { font-size: 12.5px; color: var(--ink-3); flex: none; }
.thread-row .preview { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 14px; }
.thread-row .preview span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.thread-row .preview svg.i { width: 15px; height: 15px; }
.thread-row.unread .name { font-weight: 700; }
.thread-row.unread .preview { color: var(--ink); }
.thread-row.unread .time { color: var(--red); font-weight: 600; }
.unread-star { width: 18px; height: 18px; flex: none; color: var(--red); }
.thread-row + .thread-row::before { content: ""; position: absolute; top: 0; left: 72px; right: 0; border-top: 1px solid var(--line); }
.thread-row:hover::before, .thread-row:hover + .thread-row::before,
.thread-row[aria-current="true"]::before, .thread-row[aria-current="true"] + .thread-row::before { border-color: transparent; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); z-index: 15;
  height: 56px; padding: 0 20px 0 16px; border-radius: 18px; border: 0; background: var(--blue); color: #fff;
  display: inline-flex; align-items: center; gap: 8px; font-weight: 600; box-shadow: var(--shadow); text-decoration: none;
}

/* ---------- Conversation ---------- */
.convo-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 64px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.convo-head .who { flex: 1; min-width: 0; line-height: 1.25; }
.convo-head .who strong { display: block; font: 700 16px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-head .who span { font-size: 13px; color: var(--ink-3); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 46px; z-index: 30; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.menu button {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: none; border-radius: 10px; text-align: left;
}
.menu button:hover { background: var(--paper); }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

.notice {
  margin: 12px auto 0; width: min(560px, calc(100% - 24px)); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; color: var(--ink-2);
}
.notice p { margin: 0; flex: 1 1 200px; }
.notice .btn { height: 36px; padding: 0 12px; font-size: 14px; }

.messages { flex: 1; overflow-y: auto; padding: 8px 12px 16px; display: flex; flex-direction: column; }
.messages .inner { width: 100%; max-width: 760px; margin: auto auto 0; display: flex; flex-direction: column; gap: 2px; }
.day { align-self: center; margin: 18px 0 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.msg { max-width: min(78%, 520px); display: flex; flex-direction: column; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 9px 13px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.in .bubble { background: var(--bubble-in); color: var(--ink); }
.msg.out .bubble { background: var(--bubble-out); color: #fff; }
.msg.in + .msg.in .bubble { border-top-left-radius: 6px; }
.msg.out + .msg.out .bubble { border-top-right-radius: 6px; }
.msg.in.tail .bubble { border-bottom-left-radius: 6px; }
.msg.out.tail .bubble { border-bottom-right-radius: 6px; }
.msg.tail { margin-bottom: 10px; }
.msg .meta { font-size: 11.5px; color: var(--ink-3); margin: 3px 6px 0; display: none; }
.msg.tail .meta { display: block; }
.msg .meta.queued { color: var(--red); }
.bubble a { color: inherit; }
.mms { display: block; border-radius: 18px; overflow: hidden; width: 240px; max-width: 100%; aspect-ratio: 4 / 3; background: var(--bubble-in); border: 0; padding: 0; margin-bottom: 2px; }
.mms img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg.just-sent { animation: pop .22s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.97); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .msg.just-sent { animation: none; } }

.composer {
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.composer .row { max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; }
.composer .box {
  flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 22px;
}
.composer .box:focus-within { border-color: var(--blue); }
.composer textarea {
  border: 0; background: none; outline: none; resize: none; padding: 11px 16px; max-height: 140px; min-height: 44px; line-height: 1.4; display: block; width: 100%;
}
.composer .send { width: 46px; height: 46px; border-radius: 50%; }
.composer .send[disabled] { background: var(--line); color: var(--ink-3); cursor: default; }
.composer .attach-preview { display: flex; align-items: center; gap: 10px; padding: 10px 10px 0; }
.composer .attach-preview .thumb { width: 64px; height: 64px; border-radius: 12px; overflow: hidden; position: relative; }
.composer .attach-preview img { width: 100%; height: 100%; object-fit: cover; }
.composer .attach-preview .x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(20,33,61,.75); color: #fff; display: grid; place-items: center; padding: 0;
}
.composer .attach-preview .x svg.i { width: 14px; height: 14px; }
.composer .count { max-width: 760px; margin: 4px auto 0; padding: 0 64px 0 58px; font-size: 12px; color: var(--ink-3); text-align: right; }
.composer .count.warn { color: var(--red); }

/* ---------- Lists (contacts, groups, settings) ---------- */
.letter { position: sticky; top: 0; z-index: 1; padding: 6px 16px; font: 700 13px var(--display); color: var(--blue); background: var(--surface); }
.row-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: inherit; text-decoration: none; width: 100%; border: 0; background: none; text-align: left;
}
.row-link:hover { background: var(--paper); }
.row-link[aria-current="true"] { background: var(--blue-soft); }
.row-link .body { flex: 1; min-width: 0; }
.row-link .body strong { display: block; font-weight: 500; }
.row-link .body span { font-size: 13.5px; color: var(--ink-3); }
.row-link .chev { color: var(--ink-3); width: 18px; height: 18px; }

.detail { width: 100%; max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; }
.detail-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 12px 0 24px; }
.detail-hero h2 { font-size: 26px; margin-top: 10px; }
.detail-hero p { margin: 0; color: var(--ink-2); }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.card + .card, .section-title + .card { margin-top: 10px; }
.section-title { font: 700 15px var(--display); margin: 28px 4px 0; color: var(--ink); }
.section-title + p { margin: 4px 4px 0; color: var(--ink-3); font-size: 14px; }
.card .row-link + .row-link { border-top: 1px solid var(--line); }
.setting { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 14px 16px; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting .body { flex: 1 1 200px; min-width: 0; }
.setting .controls { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.setting .body strong { display: block; font-weight: 500; }
.setting .body span { font-size: 13.5px; color: var(--ink-3); }
.setting select { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 14px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.segmented button {
  height: 40px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented button svg.i { width: 18px; height: 18px; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(20,33,61,.18); }
.list-section { padding: 4px 16px 20px; }
.list-section .section-title { margin: 20px 0 10px; }
.list-section p { margin: 8px 2px 0; font-size: 13.5px; color: var(--ink-3); }
.form { display: grid; gap: 16px; }
.inline-add { display: flex; gap: 8px; padding: 12px; }
.inline-add input { flex: 1; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid var(--line); padding: 0 12px; background: var(--surface); outline: none; }
.inline-add input:focus { border-color: var(--blue); }
.inline-add .btn { height: 44px; }

/* ---------- New message ---------- */
.to-field { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; background: var(--surface); border-bottom: 1px solid var(--line); }
.to-field label { color: var(--ink-3); font-weight: 500; }
.to-field input { flex: 1; border: 0; outline: none; background: none; height: 100%; min-width: 0; font-size: 16px; }

/* ---------- Sheet / dialog ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 480px; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow); animation: up .22s ease-out;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font-size: 20px; }
.sheet p { color: var(--ink-2); margin: 6px 0 18px; }
.sheet .btns { display: flex; gap: 10px; margin-top: 18px; }
.sheet .btns .btn { flex: 1; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 760px) {
  .scrim { align-items: center; }
  .sheet { border-radius: 20px; padding: 24px; }
  .sheet .grab { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); z-index: 60; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--surface); font-weight: 500; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.toast svg.i { width: 18px; height: 18px; }
@media (min-width: 760px) { .toast { bottom: 28px; } }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 0%, var(--blue-soft), transparent 70%),
    var(--paper);
}
.login .orbit { width: 1100px; left: 50%; top: 50%; transform: translate(-50%, -54%) rotate(-12deg); }
.login-card {
  position: relative; width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 32px 24px 24px; box-shadow: var(--shadow);
}
.login-card .logo-wrap { margin: 0 auto 22px; display: flex; justify-content: center; width: fit-content; }
.login-card .logo { height: 58px; }
.login-card h1 { font-size: 22px; text-align: center; }
.login-card > p { text-align: center; color: var(--ink-2); margin: 6px 0 24px; }
.login-card .form { gap: 14px; }
.login-card .error {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--red-soft); color: var(--red); font-size: 14px;
}
.login-card .error svg.i { width: 18px; height: 18px; margin-top: 1px; }
.pw { position: relative; }
.pw input { width: 100%; padding-right: 48px; }
.pw button { position: absolute; right: 4px; top: 4px; }
.login footer { position: relative; margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--ink-3); }
.login-theme { width: 270px; margin: 0 auto 14px; }
.login-theme .segmented { background: var(--surface); }
.login-theme .segmented button { height: 32px; font-size: 13px; }
.login-theme .segmented button[aria-checked="true"] { background: var(--blue-soft); color: var(--blue); box-shadow: none; }

/* ---------- Live app states ---------- */
.login-card .info { padding: 12px 14px; border-radius: 12px; background: var(--blue-soft); color: var(--ink); font-size: 14px; }
.login-card .btn[disabled] { opacity: .7; }
.login-card .logo { width: auto; }

.skeleton { display: flex; gap: 12px; align-items: center; padding: 12px 16px; }
.skeleton i { display: block; border-radius: 8px; background: var(--paper); }
.skeleton .a { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.skeleton .l { flex: 1; display: grid; gap: 8px; }
.skeleton .l i:first-child { height: 12px; width: 45%; }
.skeleton .l i:last-child { height: 10px; width: 80%; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton i { animation: shimmer 1.2s ease-in-out infinite alternate; }
}
@keyframes shimmer { to { opacity: .45; } }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 13.5px; font-weight: 500;
  background: var(--red-soft); color: var(--red);
}
.banner svg.i { width: 16px; height: 16px; }
.banner button { margin-left: auto; border: 0; background: none; color: inherit; font-weight: 600; text-decoration: underline; padding: 4px; }

.msg .meta.failed { color: var(--red); display: block; }
.msg .meta.failed button { border: 0; background: none; padding: 0 0 0 4px; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; }
.msg.pending .bubble, .msg.pending .mms { opacity: .65; }
.msg.failed .bubble { background: var(--red-soft); color: var(--red); }

.composer .attach-preview .thumb.loading img { opacity: .4; }
.composer .attach-preview .thumb .spin { position: absolute; inset: 0; display: grid; place-items: center; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--blue); }
@media (prefers-reduced-motion: no-preference) { .spinner { animation: spin .8s linear infinite; } }
@keyframes spin { to { transform: rotate(360deg); } }
.btn .spinner { width: 16px; height: 16px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }

.error-box { margin: auto; max-width: 340px; text-align: center; padding: 32px 24px; color: var(--ink-2); }
.error-box h2 { font-size: 19px; color: var(--ink); margin-bottom: 6px; }
.error-box p { margin: 0 0 16px; }

a.mms { cursor: zoom-in; }
.field .hint.error { color: var(--red); }
.error-detail { margin-top: 18px; text-align: left; font-size: 13px; color: var(--ink-3); }
.error-detail summary { cursor: pointer; }
.error-detail pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; padding: 10px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); }
