/* Family chat — chat.liu-lu.com */

:root {
  --pine: #1F4D3F;
  --pine-deep: #173B30;
  --pine-hover: rgba(243, 235, 216, .08);
  --pine-current: rgba(243, 235, 216, .15);
  --rice: #F3EBD8;
  --rice-dim: rgba(243, 235, 216, .70);
  --rice-line: rgba(243, 235, 216, .16);

  --bg: #EDF1F0;
  --surface: #FFFFFF;
  --surface-2: #F4F7F5;
  --ink: #16302A;
  --ink-2: #4A5D55;
  --ink-3: #6E8078;
  --line: #D5DEDB;

  --me: #1F4D3F;
  --me-ink: #F5F8F6;
  --them: #FFFFFF;
  --them-ink: #14251F;
  --link-mine: #F3EBD8;
  --link: #1D6A50;
  --focus: #2E7A60;

  --warn-bg: #FBF1DB;
  --warn-ink: #5C400A;
  --warn-line: #E2C17A;
  --danger: #A13626;
  --ok: #1D6A50;

  --shadow-bubble: 0 1px 1px rgba(20, 37, 31, .06);
  --shadow-float: 0 18px 48px rgba(12, 30, 24, .22);
  --scrim: rgba(12, 26, 21, .46);

  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --serif: "Noto Serif", Georgia, "Liberation Serif", "DejaVu Serif", "Noto Serif TC", "Songti TC", "PMingLiU", "Noto Serif CJK TC", serif; /* Latin and punctuation first, so quotes aren’t full-width */

  --rail-w: 340px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pine: #1B4437;
    --pine-deep: #14342A;
    --bg: #0F1A17;
    --surface: #182723;
    --surface-2: #1B2925;
    --ink: #E2EBE6;
    --ink-2: #A0B3AA;
    --ink-3: #75897F;
    --line: #2A3C37;
    --me: #2A5E4D;
    --me-ink: #F2F7F4;
    --them: #1C2B26;
    --them-ink: #E2EBE6;
    --link: #8FD0B4;
    --focus: #8FD0B4;
    --warn-bg: #362B12;
    --warn-ink: #F1DCAA;
    --warn-line: #6A5320;
    --danger: #EE9483;
    --ok: #8FD0B4;
    --shadow-bubble: none;
    --shadow-float: 0 18px 48px rgba(0, 0, 0, .5);
    --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --pine: #1B4437;
  --pine-deep: #14342A;
  --bg: #0F1A17;
  --surface: #182723;
  --surface-2: #1B2925;
  --ink: #E2EBE6;
  --ink-2: #A0B3AA;
  --ink-3: #75897F;
  --line: #2A3C37;
  --me: #2A5E4D;
  --me-ink: #F2F7F4;
  --them: #1C2B26;
  --them-ink: #E2EBE6;
  --link: #8FD0B4;
  --focus: #8FD0B4;
  --warn-bg: #362B12;
  --warn-ink: #F1DCAA;
  --warn-line: #6A5320;
  --danger: #EE9483;
  --ok: #8FD0B4;
  --shadow-bubble: none;
  --shadow-float: 0 18px 48px rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 400 16px/1.45 var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rail :focus-visible { outline-color: var(--rice); }

/* icons */
.ic { width: 22px; height: 22px; display: block; flex: none; }
[data-icon] > .ic { pointer-events: none; }

/* ───────── Splash & gate ───────── */
.splash, .gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--pine);
}
.splash img { border-radius: 16px; box-shadow: 0 0 0 1px var(--rice-line); }
.gate { background: var(--bg); padding: 24px; }
.gate-card, .plain-page .gate-card {
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 28px 28px;
  box-shadow: var(--shadow-float);
}
.gate-card img { border-radius: 14px; display: block; margin-bottom: 18px; }
.gate-card h1 { font: 600 24px/1.25 var(--serif); margin: 0 0 12px; }
.gate-card p { margin: 0 0 12px; color: var(--ink-2); }
.gate-card .gate-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.plain-page { display: grid; place-items: center; min-height: 100%; padding: 24px; background: var(--bg); }
.plain-page .btn { text-decoration: none; }
.plain-page .gate-card b { color: var(--ink); }

/* ───────── Layout ───────── */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: var(--app-h, 100dvh);
  overflow: hidden;
}

/* ───────── Rail (pine panel) ───────── */
.rail {
  background: var(--pine);
  color: var(--rice);
  display: flex; flex-direction: column;
  min-height: 0;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
}
.rail-head { display: flex; align-items: center; gap: 12px; padding: 18px 12px 12px 18px; }
.rail-logo { border-radius: 10px; box-shadow: 0 0 0 1px var(--rice-line); flex: none; }
.rail-title { font: 600 21px/1.2 var(--serif); margin: 0; flex: 1; letter-spacing: .01em; }

.push-banner {
  margin: 4px 14px 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--pine-deep);
  border: 1px solid var(--rice-line);
}
.push-banner p { margin: 0 0 10px; font-size: 15px; }
.push-banner-actions { display: flex; gap: 8px; }

.conv-list { flex: 1; overflow-y: auto; padding: 2px 8px 12px; scrollbar-width: thin; scrollbar-color: var(--rice-line) transparent; }
.conv {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 10px 10px;
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
}
.conv:hover { background: var(--pine-hover); }
.conv[aria-current="page"] { background: var(--pine-current); }
.conv > .avatar, .conv > .avatar-group { grid-row: 1 / span 2; }
.conv-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 13px; color: var(--rice-dim); justify-self: end; }
.conv-preview { grid-column: 2; font-size: 14.5px; color: var(--rice-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-badge { grid-column: 3; justify-self: end; }
.conv.unread .conv-preview { color: var(--rice); }
.conv.unread .conv-time { color: var(--rice); font-weight: 600; }
.badge {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 11px;
  background: var(--rice); color: #1F4D3F;
  font-size: 12.5px; font-weight: 700; line-height: 1;
}
.rail-empty { padding: 24px 12px; color: var(--rice-dim); }
.rail-empty p { margin: 0 0 14px; }

.rail-foot { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rice-line); }
.me-btn {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 8px; border: 0; border-radius: 14px; background: none; text-align: left;
}
.me-btn:hover { background: var(--pine-hover); }
.me-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-gear { color: var(--rice-dim); }

/* ───────── Avatars ───────── */
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  color: #14251F; font-weight: 700; font-size: 18px; line-height: 1;
  user-select: none;
}
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }
.avatar.md { width: 40px; height: 40px; font-size: 16px; }
.avatar-group { position: relative; display: inline-block; width: 46px; height: 46px; flex: none; }
.avatar-group .avatar { position: absolute; width: 28px; height: 28px; font-size: 12.5px; box-shadow: 0 0 0 2px var(--ring, var(--pine)); }
.avatar-group .avatar:first-child { top: 0; left: 0; }
.avatar-group .avatar:last-child { bottom: 0; right: 0; }
.avatar-group.md { width: 40px; height: 40px; }
.avatar-group.md .avatar { width: 24px; height: 24px; font-size: 11px; }
.chat-head .avatar-group { --ring: var(--surface); }
#chat-avatar { display: inline-flex; flex: none; }
.avatar-spacer { width: 30px; flex: none; }

/* ───────── Pane ───────── */
.pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.pane-empty { margin: auto; text-align: center; padding: 24px; color: var(--ink-2); }
.pane-empty img { border-radius: 18px; opacity: .92; }
.pane-empty p { margin: 18px 0; font-size: 17px; }

.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.chat-head .back { display: none; margin-left: -8px; }
.chat-titles { flex: 1; min-width: 0; border: 0; background: none; padding: 4px 6px; text-align: left; border-radius: 10px; }
.chat-titles h2 { font: 600 19px/1.2 var(--serif); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-titles p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  padding: 12px clamp(12px, 4vw, 44px) 10px;
  overscroll-behavior: contain;
}
.messages > :first-child { margin-top: auto; }

.day, .time-sep { align-self: center; font-size: 13px; color: var(--ink-3); margin: 18px 0 6px; }
.time-sep { margin: 14px 0 4px; }
.sender { font-size: 13px; color: var(--ink-2); margin: 12px 0 3px 40px; }
.start-note { align-self: center; text-align: center; color: var(--ink-2); font-size: 14.5px; max-width: 34ch; margin: 24px auto 8px; }
.loading { align-self: center; color: var(--ink-3); font-size: 14px; margin: 24px 0; }
.older { align-self: center; margin: 6px 0 10px; }

.msg { display: flex; align-items: flex-end; gap: 10px; max-width: min(80%, 580px); margin-top: 2px; }
.msg.run-start { margin-top: 10px; }
.sender + .msg.run-start { margin-top: 0; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .col { display: flex; flex-direction: column; min-width: 0; }
.msg.mine .col { align-items: flex-end; }
.msg.theirs .col { align-items: flex-start; }

.bubble {
  padding: 8px 14px 9px;
  border-radius: 20px;
  background: var(--them); color: var(--them-ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: var(--shadow-bubble);
  font-size: 16.5px;
}
.bubble a { color: var(--link); text-underline-offset: 2px; }
.mine .bubble { background: var(--me); color: var(--me-ink); }
.mine .bubble a { color: var(--link-mine); }
.theirs.cont .bubble, .theirs.cont .photo { border-top-left-radius: 6px; }
.theirs.more .bubble, .theirs.more .photo { border-bottom-left-radius: 6px; }
.mine.cont .bubble, .mine.cont .photo { border-top-right-radius: 6px; }
.mine.more .bubble, .mine.more .photo { border-bottom-right-radius: 6px; }
.big-emoji .bubble { background: none; box-shadow: none; padding: 0 2px; font-size: 42px; line-height: 1.15; }

.photo {
  display: block; padding: 0; border: 0;
  border-radius: 20px; overflow: hidden;
  background: var(--surface-2);
  max-width: min(300px, 64vw);
  cursor: zoom-in;
}
.photo img { display: block; width: 100%; height: auto; object-fit: cover; }
.photo + .bubble { margin-top: 3px; }

.status { font-size: 12.5px; color: var(--ink-3); margin: 3px 6px 0; border: 0; background: none; padding: 0; }
.status.failed { color: var(--danger); text-decoration: underline; text-underline-offset: 2px; }
.mine.sending .bubble, .mine.sending .photo { opacity: .7; }

.sys {
  align-self: center; text-align: center;
  font-size: 13.5px; color: var(--ink-2);
  margin: 12px 0 4px; max-width: 88%;
}
.sys.emailed {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--warn-ink); background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 999px; padding: 5px 14px 5px 10px;
}
.sys.emailed .ic { width: 17px; height: 17px; }
.seen { align-self: flex-end; font-size: 12.5px; color: var(--ink-3); margin: 4px 6px 0; }
.seen.theirs-seen { align-self: flex-start; margin-left: 40px; }

@media (prefers-reduced-motion: no-preference) {
  .msg.arrive { animation: arrive .22s ease-out; }
  @keyframes arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

.jump {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px 8px 10px; border-radius: 999px; border: 0;
  background: var(--pine); color: var(--rice);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-float);
}
.jump .ic { width: 18px; height: 18px; }

/* ───────── Composer ───────── */
.composer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  padding-right: calc(10px + env(safe-area-inset-right));
}
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
#input {
  flex: 1; min-width: 0;
  resize: none; overflow-y: auto;
  font: inherit; font-size: 16.5px; line-height: 1.4;
  padding: 10px 16px; margin: 0 2px;
  border-radius: 22px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
  max-height: 10em; min-height: 44px;
}
#input::placeholder { color: var(--ink-3); }
#input:focus { outline: none; border-color: var(--focus); }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: none;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.on-pine { color: var(--rice); }
.icon-btn.on-pine:hover { background: var(--pine-hover); color: var(--rice); }
.icon-btn.on-dark { color: #fff; }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.send-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--pine); color: var(--rice);
}
:root[data-theme="dark"] .send-btn { background: #2F6C58; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .send-btn { background: #2F6C58; } }
.send-btn:disabled { opacity: .35; cursor: default; }

.tray { display: flex; gap: 8px; overflow-x: auto; padding: 4px 4px 10px; }
.tray-item { position: relative; flex: none; width: 76px; height: 76px; border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.tray-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tray-item .wait { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--ink-3); }
.tray-item button {
  position: absolute; top: 4px; right: 4px;
  width: 26px; height: 26px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: rgba(10, 20, 16, .68); color: #fff;
}
.tray-item button .ic { width: 15px; height: 15px; }

.drop-hint {
  position: absolute; inset: 12px; border-radius: 20px;
  border: 2px dashed var(--focus);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  display: grid; place-items: center;
  font-size: 18px; font-weight: 600; color: var(--ink);
  pointer-events: none;
}

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15.5px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--pine); border-color: transparent; color: var(--rice); }
.btn.primary:hover { background: var(--pine-deep); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14.5px; }
.btn.rice { background: var(--rice); color: #1F4D3F; border-color: transparent; }
.btn.ghost-pine { background: transparent; color: var(--rice); border-color: var(--rice-line); }
.btn.ghost-pine:hover { background: var(--pine-hover); }
.link-btn { border: 0; background: none; padding: 0; color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ───────── Dialogs ───────── */
dialog.dlg {
  border: 0; padding: 0;
  width: min(480px, calc(100vw - 24px));
  max-height: min(760px, calc(var(--app-h, 100dvh) - 32px));
  border-radius: 22px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
dialog.dlg[open] { display: flex; flex-direction: column; }
dialog.dlg::backdrop { background: var(--scrim); }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 18px 12px 6px 22px; }
.dlg-head h3 { flex: 1; margin: 0; font: 600 21px/1.25 var(--serif); }
.dlg-body { padding: 6px 22px 8px; overflow-y: auto; }
.dlg-body > p { margin: 0 0 12px; color: var(--ink-2); }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.dlg-actions .spacer { flex: 1; }

@media (max-width: 560px) {
  dialog.dlg {
    width: 100%; max-width: 100%;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    max-height: calc(var(--app-h, 100dvh) - 24px);
  }
  .dlg-actions { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .dlg-actions .btn { flex: 1; }
  .dlg-actions .spacer { display: none; }
}

.field { display: block; margin: 14px 0; }
.field > span { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field small { display: block; color: var(--ink-3); font-size: 13.5px; margin-top: 6px; }
.input {
  width: 100%; min-height: 46px;
  font: inherit; font-size: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink);
}
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input-suffix { display: flex; align-items: stretch; gap: 8px; }
.input-suffix > .input { flex: 1; width: auto; min-width: 0; }
.input-suffix > .btn { flex: none; }
.input-suffix .addr { display: flex; align-items: center; flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding-right: 12px; }
.input-suffix .addr:focus-within { border-color: var(--focus); }
.input-suffix .addr input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 16px; padding: 10px 4px 10px 14px; color: var(--ink); outline: none; }
.input-suffix .addr span { color: var(--ink-3); font-size: 15px; white-space: nowrap; }

.people { list-style: none; margin: 6px 0 0; padding: 0; }
.people li + li { border-top: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 2px; cursor: pointer; }
.person .who { flex: 1; min-width: 0; }
.person .who b { display: block; font-weight: 600; }
.person .who small { display: block; color: var(--ink-3); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--pine); flex: none; }
.person .btn.small { flex: none; }
/* People from outside the family carry the same amber as "Send as email": both mean "beyond the family" */
.pill {
  display: inline-block; vertical-align: 2px; margin-left: 8px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.5;
  background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line);
}
.settings-note { margin: 12px 0 0 !important; }
.field > small { display: block; color: var(--ink-3); font-size: 13.5px; margin-top: 6px; }
.section-title { font-weight: 600; font-size: 15px; margin: 18px 0 4px; }

.warn {
  display: flex; gap: 12px;
  background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid var(--warn-line);
  border-radius: 14px; padding: 14px 16px;
  margin: 4px 0 6px;
}
.warn .ic { flex: none; margin-top: 2px; }
.warn p { margin: 0 0 8px; font-size: 15px; }
.warn p:last-child { margin-bottom: 0; }
.warn strong { font-weight: 700; }
.preview {
  background: var(--surface-2); border-radius: 14px; padding: 12px 14px;
  font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9em; overflow-y: auto;
}
.preview .muted { color: var(--ink-3); }
.check { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0 6px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--pine); flex: none; }
.error-text { color: var(--danger); font-size: 14px; margin: 6px 0 0; }

.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 9px 8px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--ink-2); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); }
.settings-block { padding: 14px 0; }
.settings-block + .settings-block { border-top: 1px solid var(--line); }
.settings-block h4 { margin: 0 0 10px; font-size: 16px; }
.settings-block p { margin: 0 0 10px; color: var(--ink-2); font-size: 15px; }
.settings-row { display: flex; flex-wrap: wrap; gap: 8px; }
.me-card { display: flex; align-items: center; gap: 14px; }
.me-card b { display: block; font-size: 17px; }
.me-card small { color: var(--ink-2); font-size: 14px; }

/* ───────── Lightbox, toasts, network ───────── */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(6, 12, 10, .94); display: grid; place-items: center; }
.lightbox img { max-width: 100vw; max-height: var(--app-h, 100dvh); object-fit: contain; }
.lightbox-bar { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); display: flex; gap: 6px; }

.toasts {
  position: fixed; z-index: 60;
  top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 16px; border-radius: 16px; border: 0;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-float);
  text-align: left; font-size: 15px;
}
.toast strong { display: block; font-weight: 700; }
.toast .toast-text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.toast.error { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast.error { color: #2A0F0A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast.error { color: #2A0F0A; } }

.net {
  position: fixed; z-index: 55; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  padding: 8px 16px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600;
}

/* ───────── Phones ───────── */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app.in-chat .rail { display: none; }
  .app:not(.in-chat) .pane { display: none; }
  .chat-head .back { display: grid; }
  .rail-head { padding: 14px 10px 10px 16px; }
  .rail-title { font-size: 23px; }
  .messages { padding-left: 10px; padding-right: 10px; }
  .msg { max-width: 86%; }
  .jump { bottom: calc(86px + env(safe-area-inset-bottom)); }
}
@media (min-width: 761px) {
  .toasts { left: calc(50% + var(--rail-w) / 2); width: min(420px, calc(100vw - var(--rail-w) - 24px)); }
}
@media (min-width: 761px) and (max-width: 980px) {
  :root { --rail-w: 300px; }
}

/* ───────── Home Screen sign-in ───────── */
.gate-card .field { margin: 6px 0 0; }
.code-input { font-size: 28px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; max-width: 220px; }
.pair-code {
  font: 700 46px/1.1 var(--font); letter-spacing: .3em; font-variant-numeric: tabular-nums;
  color: var(--ink) !important; background: var(--surface-2); border-radius: 16px;
  padding: 18px 0 18px .3em; text-align: center; margin: 8px 0 4px !important;
}
.muted-small { font-size: 14px; color: var(--ink-3); margin: 0; }
.people + .check, .field + .check { margin-top: 10px; }
.sender .pill { font-size: 11px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
/* Guests the auth page hasn't let in yet */
.pill { font-family: var(--font); white-space: nowrap; }
.pill.danger { background: #FBE2DD; color: #8C2617; border-color: #E9A396; }
.rail .pill.danger { background: #F8D7D0; color: #7A1C10; border-color: transparent; font-size: 11px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.chat-titles h2 .pill { font-size: 11.5px; vertical-align: 3px; }
:root[data-theme="dark"] .pill.danger:not(.rail .pill) { background: #3B1C17; color: #F4B3A6; border-color: #6F2F25; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.danger:not(.rail .pill) { background: #3B1C17; color: #F4B3A6; border-color: #6F2F25; } }

/* ───────── Chats with guests from outside the family: yellow header with an External label ───────── */
:root { --ext-bg: #FCE49A; --ext-ink: #4A3405; --ext-line: #E0B94E; --ext-hover: rgba(74, 52, 5, .1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ext-bg: #4A3B10; --ext-ink: #F8E3A3; --ext-line: #7A6320; --ext-hover: rgba(248, 227, 163, .12); }
}
:root[data-theme="dark"] { --ext-bg: #4A3B10; --ext-ink: #F8E3A3; --ext-line: #7A6320; --ext-hover: rgba(248, 227, 163, .12); }
.chat-head.external { background: var(--ext-bg); border-bottom-color: var(--ext-line); }
.chat-head.external .chat-titles h2, .chat-head.external .chat-titles p, .chat-head.external .icon-btn { color: var(--ext-ink); }
.chat-head.external .chat-titles p { opacity: .85; }
.chat-head.external .icon-btn:hover { background: var(--ext-hover); color: var(--ext-ink); }
.chat-head.external .avatar-group { --ring: var(--ext-bg); }
.ext-chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 5px 11px 5px 8px; border-radius: 999px;
  background: var(--ext-ink); color: var(--ext-bg);
  font-size: 13px; font-weight: 700; line-height: 1; letter-spacing: .01em;
}
.ext-chip .ic { width: 16px; height: 16px; }
@media (max-width: 420px) { .ext-chip { padding: 5px 9px 5px 7px; font-size: 12px; } .ext-chip .ic { width: 14px; height: 14px; } }
/* on phones the warning moves to a strip under the header, so the name keeps its room */
.ext-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px 8px; font-size: 13.5px; font-weight: 600; line-height: 1.3;
  background: var(--ext-bg); color: var(--ext-ink); border-bottom: 1px solid var(--ext-line);
}
.ext-strip .ic { width: 16px; height: 16px; flex: none; }
@media (min-width: 561px) { .ext-strip { display: none !important; } }
@media (max-width: 560px) {
  .ext-chip { display: none !important; }
  .chat-head.external { border-bottom: 0; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.rail .pill:not(.danger) { font-size: 11px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
/* the yellow badge on the yellow External header keeps a clear outline */
.chat-head.external .pill:not(.danger) { background: #FFF6D8; border-color: var(--ext-ink); color: var(--ext-ink); }
:root[data-theme="dark"] .chat-head.external .pill:not(.danger) { background: #2B220A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat-head.external .pill:not(.danger) { background: #2B220A; } }
