/* Layout: one phone-width column with a sticky top bar and a fixed bottom tab bar; on desktop the column centers at 640px.
   Look: a kitchen-fridge calendar, pine-green ink on cool paper, maple red for the one thing to tap. */
:root {
  --bg: #f1f4f1;
  --surface: #ffffff;
  --surface-2: #e7ece7;
  --ink: #17231d;
  --muted: #5a6a61;
  --faint: #8a988f;
  --line: #d6ddd7;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --accent-soft: #f7e3e1;
  --pine: #1f5c46;
  --pine-soft: #dcebe3;
  --bubble-me: #1f5c46;
  --bubble-me-2: #2f8a66;
  --bubble-me-ink: #ffffff;
  --shadow: 0 1px 2px rgb(23 35 29 / 0.06), 0 4px 16px rgb(23 35 29 / 0.06);
  --t-hockey: #2f5d9e;
  --t-birthday: #b0407a;
  --t-holiday: #c4561c;
  --t-dedication: #7351a8;
  --t-gathering: #1f7a55;
  --t-trip: #2b7c8c;
  --t-other: #6a7a71;
  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 14px;
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #101512;
    --surface: #18201b;
    --surface-2: #222b25;
    --ink: #e6ede8;
    --muted: #9caba2;
    --faint: #6f7d74;
    --line: #2c3730;
    --accent: #f0675b;
    --accent-ink: #210a07;
    --accent-soft: #3a1f1c;
    --pine: #7fcca8;
    --pine-soft: #1d3329;
    --bubble-me: #2b6e55;
    --bubble-me-2: #3b8a6b;
    --bubble-me-ink: #f2fbf6;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    --t-hockey: #7ea6e0;
    --t-birthday: #e483b4;
    --t-holiday: #f0955e;
    --t-dedication: #ad8fe0;
    --t-gathering: #6fcf9f;
    --t-trip: #6cc3d2;
    --t-other: #a3b1a8;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #101512;
  --surface: #18201b;
  --surface-2: #222b25;
  --ink: #e6ede8;
  --muted: #9caba2;
  --faint: #6f7d74;
  --line: #2c3730;
  --accent: #f0675b;
  --accent-ink: #210a07;
  --accent-soft: #3a1f1c;
  --pine: #7fcca8;
  --pine-soft: #1d3329;
  --bubble-me: #2b6e55;
  --bubble-me-2: #3b8a6b;
  --bubble-me-ink: #f2fbf6;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  --t-hockey: #7ea6e0;
  --t-birthday: #e483b4;
  --t-holiday: #f0955e;
  --t-dedication: #ad8fe0;
  --t-gathering: #6fcf9f;
  --t-trip: #6cc3d2;
  --t-other: #a3b1a8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--pine); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- shell ---------- */
.app { max-width: 640px; margin: 0 auto; min-height: 100%; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 24px); }
.app.no-tabs { padding-bottom: 0; }
.demo-banner { background: var(--pine-soft); color: var(--pine); font-size: 0.8125rem; padding: 6px 16px; text-align: center; }
.page { padding-inline: 16px; display: flex; flex-direction: column; gap: 4px; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 8px;
  margin-inline: -16px; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  min-height: 56px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { font: 700 1.375rem/1.2 var(--font-display); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: 0.8125rem; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 4px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 640px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; border: 0; background: none; color: var(--muted); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em; }
.tab.active { color: var(--accent); }
.tab-icon { position: relative; display: inline-flex; }
.badge { position: absolute; top: -5px; right: -10px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 0.6875rem; line-height: 17px; text-align: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 16px);
  max-width: min(520px, calc(100% - 32px));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 0.9375rem; box-shadow: var(--shadow);
  animation: rise 0.2s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- type & sections ---------- */
.display { font: 700 clamp(1.75rem, 6vw, 2.25rem)/1.1 var(--font-display); letter-spacing: -0.02em; }
.eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.home-head { padding-block: 22px 8px; display: flex; flex-direction: column; gap: 4px; }
.section { padding-block: 14px; display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2, .section-title { font: 700 1.125rem/1.2 var(--font-display); }
.group { display: flex; flex-direction: column; gap: 6px; }
.group + .group { margin-top: 8px; }
.group-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-list { gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.label { display: block; font-size: 0.8125rem; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 11px; padding: 10px 16px; border: 1px solid transparent; font-weight: 600; text-decoration: none; white-space: nowrap; line-height: 1.2; }
.btn.small { padding: 7px 11px; font-size: 0.875rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.danger { background: var(--accent); color: var(--accent-ink); }
.btn.danger-ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.google { background: var(--surface); border-color: var(--line); color: var(--ink); padding-block: 12px; }
.btn.light { color: #fff; border-color: rgb(255 255 255 / 0.3); background: rgb(255 255 255 / 0.08); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.confirm-row { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--ink); flex: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.light { color: #fff; }
.link.inline { font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--pine); font-weight: 600; font-size: 0.9375rem; }
.fab {
  position: fixed; z-index: 25;
  right: max(16px, calc((100vw - 640px) / 2 + 16px));
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 16px);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 18px 12px 14px; border-radius: 28px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  box-shadow: 0 6px 20px rgb(179 38 30 / 0.3);
}

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
input:not([type='checkbox']):not([type='file']), select, textarea {
  width: 100%; min-width: 0; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 16px; /* 16px stops iPhone from zooming in */
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 0; border-color: var(--accent); }
.hint { font-size: 0.8125rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.add-row { display: flex; gap: 8px; align-items: center; }
.add-row input, .add-row select { flex: 1; }
.add-row.card { padding: 8px; }
.form-error { color: var(--accent); font-size: 0.9375rem; }
.form-ok { color: var(--pine); font-size: 0.9375rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding: 4px 16px 10px; scrollbar-width: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.chip.soft { background: var(--accent-soft); color: var(--accent); margin-left: 6px; }
.chip.pick { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; font-size: 0.875rem; color: var(--ink); }
.chip.pick.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.chip .count { color: inherit; opacity: 0.6; }

/* ---------- events ---------- */
.t-hockey { --t: var(--t-hockey); }
.t-birthday { --t: var(--t-birthday); }
.t-holiday { --t: var(--t-holiday); }
.t-dedication { --t: var(--t-dedication); }
.t-gathering { --t: var(--t-gathering); }
.t-trip { --t: var(--t-trip); }
.t-other { --t: var(--t-other); }
.event-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.event-row:hover { border-color: var(--t); }
.dateblock { flex: none; width: 48px; display: flex; flex-direction: column; align-items: center; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--t); font-variant-numeric: tabular-nums; }
.db-month { width: 100%; background: var(--t); color: var(--surface); font-size: 0.6875rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; text-align: center; padding: 1px 0; }
.db-day { font: 700 1.25rem/1.3 var(--font-display); color: var(--ink); }
.er-body { min-width: 0; flex: 1; }
.er-title { display: flex; gap: 6px; font-weight: 700; line-height: 1.25; }
.er-title span:last-child { overflow: hidden; text-overflow: ellipsis; }
.er-meta { color: var(--muted); font-size: 0.875rem; margin-top: 2px; }

.event-hero { padding: 18px; border-radius: 18px; background: color-mix(in srgb, var(--t) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--t) 30%, var(--line)); display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.eh-type { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--t); }
.eh-facts { display: flex; flex-direction: column; gap: 6px; }
.fact { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9375rem; color: var(--ink); }
.fact svg { flex: none; margin-top: 3px; color: var(--t); }
.link-fact { text-decoration: none; }
.link-fact span { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.eh-notes { white-space: pre-wrap; color: var(--muted); border-top: 1px solid color-mix(in srgb, var(--t) 25%, var(--line)); padding-top: 10px; }

.eh-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* calendar export */
.cal-options { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; text-decoration: none; color: var(--ink); }
.cal-option:last-child { border-bottom: 0; }
.cal-option:hover { background: var(--surface-2); }
.cal-option > svg { flex: none; color: var(--faint); }
.co-logo { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font: 800 1.125rem/1 var(--font-body); }
.co-logo.google { background: var(--surface); border: 1px solid var(--line); color: #4285f4; }
.co-logo.apple { background: var(--ink); color: var(--bg); }
.co-logo.other { background: var(--surface-2); color: var(--muted); }
.co-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.co-text span { font-size: 0.8125rem; color: var(--muted); }
.sync-tip { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 10px; background: var(--pine-soft); color: var(--pine); font-size: 0.875rem; }
.sync-tip .link { align-self: flex-start; font-size: 0.875rem; text-decoration: underline; text-underline-offset: 3px; }
.tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 0.8125rem; color: var(--muted); }
.sync-row { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--pine); font-weight: 600; text-align: left; }
.sync-row:hover { border-color: var(--pine); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-block: 14px 10px; border-radius: 12px; background: var(--surface-2); }
.segmented.two { grid-template-columns: 1fr 1fr; margin-top: 4px; }
.month-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.month-head h2 { flex: 1; font: 700 1.125rem/1.2 var(--font-display); }
.app.chat-mode .toast { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 72px); }
.segmented button { border: 0; background: transparent; padding: 8px 4px; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 0.9375rem; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* sign-up lists */
.signup { display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 10px; }
.signup-head { display: flex; justify-content: space-between; align-items: baseline; }
.signup-head h3 { font: 700 1.0625rem/1.3 var(--font-display); }
.signup-foot { padding-top: 6px; }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-label { display: flex; gap: 8px; align-items: baseline; font-weight: 600; }
.item.full .item-label span:first-child { color: var(--muted); }
.spots { font-size: 0.75rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.claims { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.875rem; color: var(--pine); }
.claims.open { color: var(--accent); font-weight: 600; font-size: 0.8125rem; }
.claim::before { content: '✓ '; font-weight: 700; }
.claim.me { font-weight: 700; }
.claim em { color: var(--muted); font-style: normal; }
.item-actions { flex: none; padding-top: 1px; }
.spots-select { flex: 0 0 auto !important; width: auto !important; }
.signup > .add-row { padding-top: 8px; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.cal-wd { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.cal-cell { aspect-ratio: 1 / 1.05; max-width: 100%; border: 0; border-radius: 10px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding-top: 6px; font-variant-numeric: tabular-nums; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.blank { pointer-events: none; }
.cal-num { font-weight: 600; font-size: 0.9375rem; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-num { color: var(--accent); font-weight: 800; }
.cal-cell.selected .cal-num { background: var(--ink); color: var(--bg); }
.cal-dots { display: flex; gap: 3px; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--t); }

/* ---------- chats ---------- */
.chat-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--line); }
.chat-row:last-child { border-bottom: 0; }
.chat-row:hover { background: var(--surface-2); }
.chat-emoji { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); font-size: 1.3rem; }
.cr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cr-top { display: flex; justify-content: space-between; gap: 8px; }
.cr-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-name.bold { font-weight: 800; }
.cr-time { flex: none; font-size: 0.8125rem; color: var(--faint); }
.cr-last { color: var(--muted); font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.muted-mark { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); border: 2px solid var(--bg); }

.cr-last.bold { color: var(--ink); font-weight: 700; }

/* chat home: a full-height screen (header, chat row, messages, composer) above the tab bar */
.app.chat-mode { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); overflow: hidden; }
.app.chat-mode .screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-home { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ch-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 6px 16px; }
.ch-av { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 1.3rem; }
.ch-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-title h1 { font: 700 1.125rem/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-title span { font-size: 0.8125rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.strip { display: flex; gap: 4px; overflow-x: auto; padding: 4px 10px 8px; scrollbar-width: none; border-bottom: 1px solid var(--line); flex: none; }
.strip::-webkit-scrollbar { display: none; }
.strip-item { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; padding: 2px 0; color: var(--muted); }
.strip-av { position: relative; width: 50px; height: 50px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 1.45rem; box-shadow: 0 0 0 2px var(--bg), 0 0 0 2px transparent; transition: box-shadow 0.15s; }
.strip-item.active .strip-av { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4.5px var(--accent); }
.strip-av.add { background: transparent; border: 1.5px dashed var(--line); color: var(--muted); }
.strip-dot { position: absolute; top: 0; right: 0; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); border: 2.5px solid var(--bg); }
.strip-name { width: 100%; font-size: 0.71875rem; line-height: 1.2; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-item.active .strip-name { color: var(--ink); font-weight: 700; }
.strip-item.unread .strip-name { color: var(--ink); font-weight: 800; }

.context-bar { flex: none; display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 0.875rem; text-align: left; }
.context-bar .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.context-bar svg { flex: none; color: var(--muted); }
.cb-link { flex: none; color: var(--pine); font-weight: 700; }

.archived-bar { flex: none; display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 0.8125rem; }
.archived-bar svg { flex: none; }
.delete-confirm { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--accent); background: var(--accent-soft); }
.delete-confirm.wide { width: 100%; }
.archive-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-weight: 600; text-align: left; }
.archived-list { opacity: 0.85; }
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat.full { flex: 1; }
.chat.embedded { padding: 0; height: min(66vh, 580px); overflow: hidden; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; padding: 8px 12px 12px; }
.pinned { flex: none; display: flex; gap: 8px; align-items: center; width: auto; margin: 8px 12px 0; text-align: left; padding: 7px 12px; border: 0; border-radius: 12px; background: var(--pine-soft); color: var(--pine); font-size: 0.8125rem; font-weight: 600; }
.pinned span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinned svg { flex: none; }
.pinned.editing input { padding: 6px 10px; }
.chat.embedded .pinned { margin: 0; border-radius: 0; }
.pin-hint { align-self: center; display: inline-flex; gap: 6px; align-items: center; border: 0; background: none; color: var(--faint); font-size: 0.8125rem; padding: 4px 8px 8px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ce-emoji { width: 72px; height: 72px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 2.2rem; }

.time-sep { text-align: center; font-size: 0.75rem; font-weight: 600; color: var(--faint); margin: 16px 0 6px; }
.sys-msg { text-align: center; font-size: 0.8125rem; color: var(--muted); margin: 8px 24px; }

/* Messenger-style bubbles: consecutive messages from one person stack with tight corners */
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; margin-top: 2px; border-radius: 20px; transition: background 0.4s; }
.msg.pos-first, .msg.pos-single { margin-top: 8px; }
.msg.has-reacts { margin-bottom: 14px; }
.msg.mine { justify-content: flex-end; }
.msg.flash { background: var(--accent-soft); }
.msg-av { width: 28px; flex: none; }
.msg-col { position: relative; display: flex; flex-direction: column; max-width: 76%; min-width: 0; }
.msg.mine .msg-col { align-items: flex-end; }
.msg-name { font-size: 0.75rem; color: var(--muted); margin: 0 0 2px 12px; }
.msg-line { display: flex; align-items: center; gap: 4px; max-width: 100%; }
.msg.mine .msg-line { flex-direction: row-reverse; }
.bubble { padding: 8px 12px; border-radius: 18px; background: var(--surface-2); color: var(--ink); overflow-wrap: anywhere; min-width: 0; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; cursor: default; }
.msg.mine .bubble { background: linear-gradient(160deg, var(--bubble-me-2), var(--bubble-me)); color: var(--bubble-me-ink); }
.msg.theirs.pos-first .bubble { border-bottom-left-radius: 5px; }
.msg.theirs.pos-middle .bubble { border-top-left-radius: 5px; border-bottom-left-radius: 5px; }
.msg.theirs.pos-last .bubble { border-top-left-radius: 5px; }
.msg.mine.pos-first .bubble { border-bottom-right-radius: 5px; }
.msg.mine.pos-middle .bubble { border-top-right-radius: 5px; border-bottom-right-radius: 5px; }
.msg.mine.pos-last .bubble { border-top-right-radius: 5px; }
.msg.mine .bubble a { color: inherit; }
.bubble.removed { background: transparent; border: 1px solid var(--line); color: var(--faint); font-style: italic; }
.msg.mine .bubble.removed { background: transparent; color: var(--faint); }
.msg-text { white-space: pre-wrap; }
.bubble.has-photo { padding: 0; overflow: hidden; background: transparent; }
.bubble.has-photo .msg-text { display: block; padding: 8px 12px; }
.msg-photo img { display: block; width: 240px; max-width: 100%; max-height: 320px; object-fit: cover; background: var(--surface-2); }
.emoji-big { font-size: 2.6rem; line-height: 1.15; padding: 2px 4px; -webkit-touch-callout: none; user-select: none; }
.mention { font-weight: 700; color: var(--accent); }
.msg.mine .mention { color: inherit; text-decoration: underline; }
.msg-tools { display: none; flex: none; }
.tool { width: 30px; height: 30px; border-radius: 50%; border: 0; background: none; color: var(--faint); display: grid; place-items: center; }
.tool:hover { background: var(--surface-2); color: var(--ink); }
@media (hover: hover) { .msg:hover .msg-tools { display: inline-flex; } }

.reacts { position: absolute; bottom: -15px; display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; border-radius: 99px; border: 0; background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 0.18); font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }
.msg.theirs .reacts { left: 10px; }
.msg.mine .reacts { right: 10px; }
.reacts span { font-size: 0.75rem; margin-left: 2px; }

.reply-quote { display: flex; flex-direction: column; gap: 2px; max-width: 100%; border: 0; background: none; padding: 0; margin-top: 6px; text-align: left; color: var(--muted); }
.msg.mine .reply-quote { align-items: flex-end; text-align: right; }
.rq-label { font-size: 0.75rem; display: inline-flex; align-items: center; gap: 4px; padding-inline: 4px; }
.rq-text { font-size: 0.875rem; padding: 7px 12px 14px; margin-bottom: -10px; border-radius: 16px; background: var(--surface-2); opacity: 0.7; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.seen { display: flex; justify-content: flex-end; gap: 2px; margin: 3px 2px 0; align-items: center; font-size: 0.6875rem; color: var(--faint); }
.seen .avatar { font-size: 7px !important; box-shadow: 0 0 0 1px var(--bg); }

.composer-wrap { flex: none; background: var(--bg); border-top: 1px solid var(--line); }
.chat.embedded .composer-wrap { background: var(--surface); }
.replying { display: flex; align-items: center; gap: 8px; padding: 8px 8px 0 16px; font-size: 0.8125rem; }
.replying .grow { display: flex; flex-direction: column; overflow: hidden; }
.replying span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { display: flex; gap: 4px; align-items: flex-end; padding: 8px 8px 8px 4px; }
.composer textarea { flex: 1; resize: none; border-radius: 20px; padding: 9px 14px; max-height: 140px; line-height: 1.35; background: var(--surface-2); border-color: transparent; }
.icon-btn.accent { color: var(--accent); }
.send-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: var(--accent); display: grid; place-items: center; }
.like-btn { flex: none; width: 40px; height: 40px; border: 0; background: none; font-size: 1.6rem; line-height: 1; display: grid; place-items: center; }
.like-btn:active { transform: scale(1.25); }

/* long-press menu */
.mm-wrap { position: fixed; inset: 0; z-index: 65; background: rgb(10 15 12 / 0.5); display: flex; align-items: flex-end; justify-content: center; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); animation: fade 0.12s ease-out; }
.mm { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; animation: slide 0.16s ease-out; }
.mm-reacts { align-self: center; display: flex; gap: 2px; padding: 6px 8px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow); }
.mm-reacts button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; font-size: 1.7rem; line-height: 1; transition: transform 0.1s; }
.mm-reacts button:hover, .mm-reacts button:active { transform: scale(1.2); }
.mm-reacts button.on { background: var(--surface-2); }
.mm-preview { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 16px; background: var(--surface); max-height: 30vh; overflow: auto; }
.mm-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.mm-meta { font-size: 0.75rem; color: var(--muted); }
.mm-actions { display: flex; flex-direction: column; border-radius: 16px; background: var(--surface); overflow: hidden; }
.mm-actions > button, .mm-actions .confirm-row > button, .mm-danger { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-weight: 600; color: var(--ink); border-radius: 0; }
.mm-actions > :last-child, .mm-actions > :last-child > button:last-child { border-bottom: 0; }
.mm-danger, .mm-actions .confirm-row .btn.danger { color: var(--accent); background: none; }
.mm-actions .confirm-row { display: flex; flex-direction: column; gap: 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.emoji-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.emoji-pick button { aspect-ratio: 1; max-width: 100%; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 1.35rem; }
.emoji-pick button.on { border: 2px solid var(--ink); }
.radio-list { display: flex; flex-direction: column; gap: 6px; }
.radio-list button { text-align: left; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.radio-list button.on { border: 2px solid var(--ink); font-weight: 700; padding: 10px 11px; }
.seg-mini { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--surface-2); flex: none; }
.seg-mini button { border: 0; background: transparent; padding: 5px 9px; border-radius: 7px; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.seg-mini button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.mute-list { margin-top: 10px; gap: 4px; }
.mute-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mute-row:last-of-type { border-bottom: 0; }
.mute-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9375rem; }
.mute-row .field { flex: none; }

/* ---------- photos ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; border-radius: var(--radius); overflow: hidden; }
.photo-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.photo-strip .thumb { border-radius: 10px; overflow: hidden; }
.thumb { border: 0; padding: 0; aspect-ratio: 1; max-width: 100%; background: var(--surface-2); display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.preview-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.preview-row .more { font-weight: 700; color: var(--muted); }
.lightbox { position: fixed; inset: 0; z-index: 70; background: #0b0f0d; color: #fff; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); outline: none; }
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; }
.lb-img { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; }
.lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgb(255 255 255 / 0.14); color: #fff; display: grid; place-items: center; }
.lb-nav.prev { left: 10px; }
.lb-nav.next { right: 10px; }
.lb-info { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; max-width: 640px; width: 100%; margin: 0 auto; }
.lb-info input { background: #1b221e; color: #fff; border-color: #333; }
.lb-caption { background: none; border: 0; padding: 0; color: #fff; text-align: left; font-size: 1rem; font-weight: 600; }
.lb-caption .faint { color: #8a988f; font-weight: 400; }
.lb-meta { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: #b9c4bd; }
.lb-info .btn.danger-ghost { align-self: flex-start; color: #ff8f85; border-color: #3a3a3a; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgb(10 15 12 / 0.45); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 92%; display: flex; flex-direction: column; background: var(--bg); border-radius: 20px 20px 0 0; animation: slide 0.2s ease-out; }
@keyframes slide { from { transform: translateY(24px); } }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 18px; }
.sheet-head h2 { font: 700 1.25rem/1.2 var(--font-display); }
.sheet-body { overflow-y: auto; padding: 8px 18px 16px; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.sheet-foot > .btn.primary:only-child { margin-left: auto; }

/* ---------- settings ---------- */
.profile-row { display: flex; align-items: center; gap: 12px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.swatches button.on { box-shadow: 0 0 0 2px var(--ink); }
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.member-list li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.member-list li .grow { overflow-wrap: anywhere; }
.status { display: flex; gap: 6px; align-items: flex-start; font-size: 0.9375rem; }
.status.ok { color: var(--pine); }
.status.warn { color: var(--accent); }
.status svg { flex: none; margin-top: 3px; }
.url { display: block; padding: 10px; border-radius: 8px; background: var(--surface-2); font-size: 0.8125rem; overflow-wrap: anywhere; }
.steps { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; color: var(--muted); }

.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; object-fit: cover; letter-spacing: 0.02em; }
.avatar.ghost { background: var(--surface-2); color: var(--muted); }

.empty { text-align: center; padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-title { font: 700 1.125rem/1.3 var(--font-display); }
.empty-text { color: var(--muted); max-width: 34ch; }

/* ---------- auth ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: 48px 16px 32px; display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 800 1.75rem/1 var(--font-display); transform: rotate(-4deg); }
.brand-name { font: 800 1.75rem/1.1 var(--font-display); letter-spacing: -0.02em; }
.brand-tag { color: var(--muted); font-size: 0.9375rem; }
.h2 { font: 700 1.25rem/1.25 var(--font-display); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 0.8125rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.error-card { border-color: var(--accent); display: flex; flex-direction: column; gap: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
