/* ========== Font-face declarations ========== */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0020-007F, U+00A0-00FF, U+0100-024F, U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0020-007F, U+00A0-00FF, U+2010-206F, U+2018-201F, U+2026;
}

/* ========== Family Quill — warm design tokens ========== */
:root {
  color-scheme: light;

  /* warm ivory canvas */
  --gallery: #e7e4da;
  --paper: #f1ebdd;
  --paper-2: #ece5d5;
  --sheet: #fbf8f1;
  --sheet-2: #f6f2e8;

  /* ink */
  --ink: #1f2c25;
  --ink-soft: #566159;
  --muted: #8c9089;
  --hairline: #e7e0d1;
  --hairline-soft: #efe9dc;

  /* friendly forest (primary) + sage */
  --green: #35664a;
  --green-lift: #40795a;
  --green-press: #2b5540;
  --sage: #5cab7d;
  --sage-tint: #e4f0e6;
  --sage-line: #cfe4d3;

  /* warm mauve-berry */
  --plum: #8a6a82;
  --plum-deep: #6b5468;
  --plum-tint: #efe6ec;
  --plum-line: #e4d6df;

  /* clay / peach */
  --clay: #b3795d;
  --clay-deep: #97634a;
  --clay-soft: #f1e4d7;

  /* warm brass topic */
  --brass: #a97f45;

  /* errors */
  --error: #9d352f;
  --pdf: #c07f70;

  /* type */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;

  /* shadows */
  --shadow-card: 0 2px 8px -7px rgba(56, 46, 30, .16);
  --shadow-fab: 0 5px 12px -8px rgba(31, 92, 61, .26);

  /* safe area (for iPhone notch / home indicator) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.guest-body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 12% 12%, rgba(179, 121, 93, .12), transparent 34%),
              radial-gradient(circle at 88% 86%, rgba(92, 171, 125, .12), transparent 36%),
              var(--gallery);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

/* ========== Typography helpers ========== */
.font-serif { font-family: var(--serif); font-optical-sizing: auto; }
.font-sans { font-family: var(--sans); }

/* ========== Auth / Session cards ========== */
.auth-card {
  width: min(100% - 32px, 520px);
  margin: clamp(24px, 8vh, 84px) auto;
  padding: clamp(28px, 7vw, 52px);
  background: rgba(251, 248, 241, .96);
  border: 1px solid var(--hairline);
  border-radius: 28px;
  box-shadow: 0 18px 50px rgba(32, 37, 31, .1);
}
.auth-card.compact { max-width: 460px; }

.signin-shell {
  width: min(100%, 804px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(54px, calc(var(--safe-top) + 28px)) 52px max(34px, calc(var(--safe-bottom) + 22px));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 44px;
  background: var(--paper);
}
.signin-content { width: 100%; }
.quill-mark {
  display: block;
  width: 104px;
  height: 104px;
  margin: 0 0 62px;
  border-radius: 30px;
  object-fit: cover;
  box-shadow: 0 18px 32px -20px rgba(31, 44, 37, .45);
}
.signin-shell h1 { margin-bottom: 26px; font-size: clamp(3.2rem, 9.5vw, 5.1rem); line-height: 1.04; }
.signin-context { max-width: 680px; margin: 0 0 62px; color: var(--ink-soft); font-size: clamp(1.25rem, 3.5vw, 1.75rem); line-height: 1.45; }
.signin-form { display: grid; gap: 24px; }
.signin-form input {
  width: 100%;
  height: 102px;
  padding: 0 30px;
  border: 2px solid var(--hairline);
  border-radius: 30px;
  outline: none;
  background: var(--sheet);
  color: var(--ink);
  font-size: 1.55rem;
}
.signin-form input:focus { border-color: var(--sage); box-shadow: 0 0 0 5px rgba(92, 171, 125, .12); }
.signin-form input[inputmode="numeric"] { text-align: center; letter-spacing: .28em; font-variant-numeric: tabular-nums; }
.signin-continue {
  height: 104px;
  border: 0;
  border-radius: 30px;
  background: var(--green);
  color: #fff;
  font-size: 1.55rem;
  font-weight: 750;
  cursor: pointer;
  box-shadow: var(--shadow-fab);
}
.signin-continue:hover { background: var(--green-press); }
.signin-continue:disabled { opacity: .48; cursor: not-allowed; }
.code-instruction { margin: 0; color: var(--ink-soft); font-size: 1.1rem; line-height: 1.5; }
.signin-back { border: 0; background: transparent; color: var(--green); font-weight: 700; cursor: pointer; }
.signin-error { margin: 22px 0 0; }
.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 28px 32px;
  border-radius: 28px;
  background: rgba(251, 248, 241, .9);
  color: var(--ink-soft);
  font-size: 1.15rem;
  line-height: 1.45;
}
.privacy-note > svg { width: 22px; height: 22px; flex: 0 0 auto; color: var(--green); fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.privacy-note p { margin: 0; }
.privacy-note strong { color: var(--ink-soft); }
.session-loading { min-height: 100vh; display: grid; place-content: center; padding: 32px; color: var(--ink-soft); text-align: center; background: var(--paper); }
.session-offline h1 { color: var(--ink); }

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.family-name {
  margin: 0 0 8px;
  color: var(--green);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
}

h1 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.035em;
}

.context { color: var(--ink-soft); font-size: 1.05rem; line-height: 1.55; }

/* ========== Forms ========== */
.field {
  display: grid;
  gap: 8px;
  margin: 20px 0;
  color: var(--ink-soft);
  font-size: .9rem;
  font-weight: 600;
}

.field input, .field textarea, .composer textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--sheet);
  color: var(--ink);
  padding: 14px 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .composer textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 4px rgba(92, 171, 125, .1);
}
.field input[inputmode="numeric"] {
  font-size: 1.65rem;
  letter-spacing: .32em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ========== Buttons ========== */
.primary, .secondary, .text-button, .back-btn { border: 0; cursor: pointer; font-family: var(--sans); }
.primary {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 15px 20px;
  border-radius: 14px;
  color: #fff;
  background: var(--green);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: background .15s;
}
.primary:hover { background: var(--green-press); }
.primary:disabled { opacity: .55; cursor: wait; }
.secondary {
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--sheet);
  color: var(--ink);
  font-weight: 650;
  transition: background .15s;
}
.secondary:hover { background: var(--sheet-2); }
.secondary:active { background: var(--paper-2); }
.text-button, .back-btn {
  display: block;
  margin: 18px auto 0;
  padding: 8px;
  color: var(--green);
  background: transparent;
  font-weight: 700;
}
.back-btn { margin: 0 0 18px; font-size: .95rem; }

/* ========== Feedback ========== */
.form-error { color: var(--error); font-weight: 700; line-height: 1.4; }
.success { padding: 14px; border-radius: 12px; background: var(--sage-tint); color: var(--green-press); }
.record-note { margin: 24px 0 0; color: var(--muted); font-size: .83rem; line-height: 1.45; }

/* ========== App layout — full-height shell ========== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  overflow: hidden;
  width: min(100%, 540px);
  margin: 0 auto;
  background: var(--paper);
  position: relative;
}

/* ========== Screen container ========== */
.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 78px; /* tab bar height */
}

/* ========== Messages tab / Tab bar ========== */
.tab-bar {
  position: fixed;
  z-index: 30;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 540px);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  height: 78px;
  padding: 10px 14px calc(20px + var(--safe-bottom));
  border-top: 1px solid var(--hairline);
  background: rgba(251, 248, 241, .92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.tab-bar-tab {
  display: grid;
  place-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab-bar-tab.active { color: var(--green); }
.tab-bar-tab svg { width: 22px; height: 22px; }

/* ========== Inbox — warm ledger ========== */
.inbox-shell {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 18px;
}

.inbox-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: calc(var(--safe-top) + clamp(16px, 4vw, 28px)) 4px 16px;
}
.inbox-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: clamp(1.8rem, 6vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1;
}
.inbox-header p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 12.5px;
}
.new-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  box-shadow: var(--shadow-fab);
  font-size: 12.5px;
  font-weight: 650;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.new-button:hover { background: var(--green-press); }
.new-button svg { width: 16px; height: 16px; }

.threads-card {
  overflow: hidden;
  border-radius: 20px;
  background: var(--sheet);
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--hairline);
  margin-bottom: 16px;
}

.thread-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 12px;
  row-gap: 4px;
  padding: 15px 16px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--sans);
}
.thread-row + .thread-row {
  box-shadow: inset 0 1px 0 var(--hairline-soft);
}
.thread-row:active {
  background: rgba(0, 0, 0, .02);
}

.thread-title {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 550;
  letter-spacing: -.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink);
}
.thread-row.unread .thread-title { font-weight: 700; }

.thread-time {
  grid-column: 2;
  grid-row: 1;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.thread-row.unread .thread-time { font-weight: 600; }

.thread-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.35;
}
.thread-row.unread .thread-preview { color: #46554c; font-weight: 500; }
.thread-preview .preview-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.thread-preview .clip-icon {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  stroke: var(--muted);
  stroke-width: 1.9;
  fill: none;
}

.thread-trail {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.unread-badge {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--sage);
  font-size: 11px;
  font-weight: 700;
  box-shadow: var(--shadow-fab);
}

/* ========== Empty state ========== */
.empty-state {
  padding: 56px 18px;
  color: var(--muted);
  text-align: center;
}
.empty-state h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1.4rem;
  font-weight: 600;
}
.empty-state p { margin: 0; }
.empty-state .primary { width: auto; margin: 24px auto 0; }

/* ========== Conversation — bubble transcript ========== */
.convo-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.convo-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 8px) 14px 12px;
  background: linear-gradient(180deg, var(--paper) 62%, rgba(241, 235, 221, 0));
}
.convo-back {
  display: inline-flex;
  min-width: 44px;
  height: 44px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0 8px 0 4px;
  color: var(--green);
  background: none;
  border: none;
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
}
.convo-back:hover { background: var(--sage-tint); }
.convo-back:focus-visible {
  outline: 3px solid rgba(92, 171, 125, .48);
  outline-offset: 2px;
}
.convo-back svg { width: 20px; height: 20px; }
.peer-info {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
}
.peer-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(150deg, var(--plum), #847fa8);
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 3px 8px -7px rgba(108, 105, 141, .4);
}
.peer-copy { min-width: 0; }
.peer-copy strong {
  display: block;
  overflow: hidden;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.peer-copy span {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== Transcript (scrollable) ========== */
.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 7px;
  padding: 18px 15px 14px;
}

.date-divider {
  align-self: center;
  margin: 4px 0 10px;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(246, 242, 232, .7);
  box-shadow: inset 0 0 0 1px var(--hairline-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
}

.chat-row {
  display: flex;
  max-width: 85%;
}
.chat-row.incoming { align-self: flex-start; }
.chat-row.outgoing { align-self: flex-end; }

.bubble {
  position: relative;
  padding: 10px 13px 9px;
  border-radius: 20px 20px 20px 7px;
  color: var(--ink);
  background: var(--sheet);
  box-shadow: inset 0 0 0 1px rgba(60, 50, 35, .05);
  font-size: 14px;
  line-height: 1.45;
}
.chat-row.outgoing .bubble {
  border-radius: 20px 20px 7px 20px;
  color: #223f30;
  background: #dde5da;
  box-shadow: inset 0 0 0 1px rgba(92, 138, 109, .14);
}

@media (pointer: coarse) {
  .bubble,
  .message-inspector {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

.msg-stamp {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  transform: translateY(1px);
  white-space: nowrap;
}
.chat-row.outgoing .msg-stamp { color: #5a8a6d; }
.msg-stamp svg { width: 13px; height: 13px; stroke-width: 2.2; }

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-height: 18px;
  margin: 3px -3px -3px 0;
}
.message-details-trigger {
  display: grid;
  min-width: 28px;
  min-height: 26px;
  padding: 0 4px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  letter-spacing: 1px;
  line-height: 1;
  cursor: pointer;
}
.chat-row.outgoing .message-details-trigger { color: #5a8a6d; }
.message-details-trigger:hover { background: rgba(84, 70, 55, .08); }
.message-details-trigger:focus-visible {
  outline: 2px solid var(--plum);
  outline-offset: 1px;
}

/* Reply quote */
.reply-quote {
  margin-bottom: 7px;
  padding: 7px 9px;
  border-radius: 6px 11px 11px 6px;
  border-left: 2.5px solid var(--plum);
  background: rgba(255, 253, 248, .6);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
}
.reply-quote strong {
  display: block;
  margin-bottom: 2px;
  color: var(--plum-deep);
  font-size: 11px;
  font-weight: 650;
}
/* Message body text */
.msg-body { margin: 0; white-space: pre-wrap; }

/* ========== Message inspector ========== */
.message-inspector {
  width: min(calc(100% - 32px), 430px);
  max-width: 430px;
  max-height: min(78dvh, 680px);
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: transparent;
  box-shadow: 0 24px 70px rgba(35, 29, 24, .28);
}
.message-inspector::backdrop {
  background: rgba(39, 34, 30, .42);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.message-inspector-card {
  display: grid;
  max-height: min(78dvh, 680px);
  gap: 18px;
  padding: 24px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, .68);
  border-radius: 22px;
  background: rgba(251, 248, 241, .98);
}
.message-inspector-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -.01em;
}
.message-inspector-preview {
  max-height: 180px;
  padding: 13px 15px;
  overflow-y: auto;
  border-radius: 18px 18px 18px 7px;
  background: var(--sheet);
  box-shadow: inset 0 0 0 1px rgba(60, 50, 35, .06);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.message-inspector-preview.outgoing {
  border-radius: 18px 18px 7px 18px;
  color: #223f30;
  background: #dde5da;
  box-shadow: inset 0 0 0 1px rgba(92, 138, 109, .14);
}
.message-inspector-details {
  display: grid;
  gap: 13px;
  margin: 0;
}
.message-inspector-details > div {
  display: grid;
  gap: 3px;
}
.message-inspector-details dt {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.message-inspector-details dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.4;
}
.message-inspector-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.message-inspector-actions button {
  min-height: 44px;
  border-radius: 14px;
  font-weight: 750;
  cursor: pointer;
}
.message-inspector-reply {
  border: 1px solid var(--green);
  color: #fff;
  background: var(--green);
}
.message-inspector-close {
  border: 1px solid var(--hairline);
  color: var(--ink);
  background: var(--sheet-2);
}
.message-inspector-actions button:focus-visible {
  outline: 3px solid rgba(92, 171, 125, .48);
  outline-offset: 2px;
}

@media (max-width: 430px) {
  .message-inspector { width: calc(100% - 24px); }
  .message-inspector-card { padding: 20px; }
}

/* Attachment tiles inside bubbles */
.msg-attachments {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.attachment-tile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 13px;
  background: rgba(255, 253, 248, .72);
  box-shadow: inset 0 0 0 1px var(--hairline);
  text-decoration: none;
  color: var(--ink);
  transition: background .15s;
}
.attachment-tile:hover { background: rgba(255, 253, 248, .9); }
.attachment-tile .tile-icon {
  display: grid;
  width: 38px;
  height: 44px;
  flex: 0 0 auto;
  place-items: end center;
  padding-bottom: 6px;
  border-radius: 8px;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .04em;
}
.attachment-tile .tile-icon.image-icon {
  background: linear-gradient(160deg, #8ab89e, var(--sage));
}
.attachment-tile .tile-icon.pdf-icon {
  background: linear-gradient(160deg, #cb8b7d, var(--pdf));
}
.attachment-tile .tile-meta strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
}
.attachment-tile .tile-meta span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
}

/* ========== Composer (DOM fallback — overridden by native on iOS) ========== */
.composer {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--hairline);
  background: rgba(251, 248, 241, .95);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.composer-attach {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--plum-deep);
  background: var(--plum-tint);
  border: none;
  cursor: pointer;
}
.composer-attach svg { width: 20px; height: 20px; }
.composer-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 16px;
  border-radius: 22px;
  border: 1px solid var(--hairline);
  background: var(--sheet);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  resize: none;
  outline: none;
  transition: border-color .15s;
  font-family: var(--sans);
}
.composer-input:focus { border-color: var(--sage); }
.composer-send {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #eaf5ec;
  background: linear-gradient(150deg, var(--green), var(--green-lift));
  box-shadow: var(--shadow-fab);
  border: none;
  cursor: pointer;
  transition: opacity .15s;
}
.composer-send:disabled { opacity: .5; cursor: wait; }
.composer-send svg { width: 22px; height: 22px; }
.composer-reply {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-left: 3px solid var(--plum);
  border-radius: 8px;
  background: var(--sheet-2);
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.35;
}
.composer-reply span { display: grid; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-reply strong { color: var(--plum-deep); font-size: 10.5px; }
.composer-reply button { border: 0; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }
/* Composer — pending attachment queue */
.composer-pending {
  display: grid;
  gap: 6px;
  padding: 8px 14px;
  background: var(--sheet);
  border-top: 1px solid var(--hairline);
}
.pending-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--sheet);
}
.pending-item span, .pending-item strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .8rem;
}
.pending-item small { color: var(--muted); font-size: .72rem; }
.pending-remove {
  border: 0;
  background: transparent;
  color: var(--error);
  font-size: .75rem;
  font-weight: 800;
  cursor: pointer;
}

/* ========== Settings ========== */
.settings-shell {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + clamp(16px, 4vw, 28px)) 18px;
  padding-bottom: 78px;
}
.settings-shell h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -.015em;
}
.settings-section {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: var(--sheet);
  box-shadow: var(--shadow-card);
}
.settings-section h3 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0;
}
.toggle-row + .toggle-row { border-top: 1px solid var(--hairline-soft); }
.toggle-row span { display: grid; gap: 4px; }
.toggle-row strong { font-size: 14px; }
.toggle-row small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.toggle-row input { width: 44px; height: 26px; accent-color: var(--green); cursor: pointer; }
.signout-button { width: 100%; padding: 12px 16px; border: 1px solid #dbc6bf; border-radius: 12px; background: #fff8f4; color: var(--error); font-weight: 750; cursor: pointer; }
.signout-button:disabled { opacity: .55; }

/* New thread form */
.new-thread-shell {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + clamp(16px, 4vw, 28px)) 18px;
  padding-bottom: 78px;
}
.new-thread-shell h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -.015em;
}
.attachment-picker {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.attachment-button {
  position: relative;
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--hairline);
  border-radius: 11px;
  background: var(--sheet);
  color: var(--green);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
}
.attachment-button:hover { background: var(--sage-tint); }
.attachment-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.retention-disclosure {
  margin: 0;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.35;
}
.attachment-queue {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.attachment-queue li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--sheet);
}
.attachment-queue li span { display: grid; min-width: 0; gap: 2px; }
.attachment-queue strong {
  overflow: hidden;
  font-size: .8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-queue small { color: var(--muted); font-size: .72rem; }
.attachment-queue button {
  border: 0;
  background: transparent;
  color: var(--error);
  font-size: .75rem;
  font-weight: 800;
  cursor: pointer;
}

/* ========== Loading / Spinner ========== */
.loading-text { padding: 56px 18px; color: var(--muted); text-align: center; }

/* ========== Foreground calling ========== */
.inbox-actions { display: flex; align-items: center; gap: 8px; }
.call-start-button {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--hairline);
  border-radius: 11px;
  background: var(--sheet);
  color: var(--green);
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}
.call-start-button:disabled { opacity: .45; cursor: default; }
.incoming-call {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px 18px max(18px, var(--safe-bottom));
  background: rgba(31, 39, 32, .46);
  backdrop-filter: blur(8px);
}
.incoming-call-card {
  width: min(100%, 520px);
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: 24px;
  background: var(--sheet);
  box-shadow: 0 24px 80px rgba(18, 28, 20, .28);
}
.incoming-call-card h2, .call-room h1 { margin: 4px 0 10px; font-family: var(--serif); font-weight: 600; }
.call-eyebrow { margin: 0; color: var(--green); font-size: .72rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.call-disclosure, .call-recording-notice { color: var(--muted); font-size: .84rem; line-height: 1.5; }
.call-actions, .call-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.call-actions button, .call-controls button {
  min-height: 46px;
  padding: 11px 16px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--sheet);
  font-weight: 800;
  cursor: pointer;
}
.call-actions button:disabled, .call-controls button:disabled { opacity: .55; }
.call-accept { flex: 1; background: var(--green) !important; color: white; }
.call-decline { border-color: #d7bdb7 !important; background: #fff4f0 !important; color: var(--error); }
.call-room {
  min-height: 100%;
  overflow-y: auto;
  padding: max(20px, calc(var(--safe-top) + 12px)) 18px max(24px, calc(var(--safe-bottom) + 18px));
  background: #17231c;
  color: #f5f1e8;
}
.call-room-header { text-align: center; }
.call-room-header .call-eyebrow { color: #a9d0b2; }
.call-room-header h1 { font-size: 2rem; }
.call-status { min-height: 1.3em; color: #c7d1c9; font-size: .86rem; text-transform: capitalize; }
.call-stage {
  position: relative;
  width: min(100%, 720px);
  aspect-ratio: 3 / 4;
  max-height: 58vh;
  margin: 18px auto;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 26px;
  background: #223329;
}
.remote-video { width: 100%; height: 100%; object-fit: cover; }
.remote-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #d9e8dd; font-family: var(--serif); font-size: 5rem; }
.local-video {
  position: absolute;
  z-index: 2;
  right: 14px;
  bottom: 14px;
  width: 28%;
  aspect-ratio: 3 / 4;
  border: 2px solid rgba(255,255,255,.72);
  border-radius: 16px;
  background: #101a14;
  object-fit: cover;
}
.call-recording-notice { max-width: 620px; margin: 8px auto; color: #bbc7be; text-align: center; }
.call-error { max-width: 620px; margin: 12px auto; }
.call-transcript { max-width: 620px; margin: 18px auto; padding: 16px; border-radius: 16px; background: rgba(255,255,255,.08); }
.call-transcript h2 { margin: 0 0 10px; font-family: var(--serif); font-size: 1.1rem; }
.call-transcript p { margin: 7px 0; color: #e6ebe7; font-size: .84rem; line-height: 1.45; }
.call-controls button { border-color: rgba(255,255,255,.24); background: rgba(255,255,255,.1); color: white; }

/* ========== Icon system ========== */
.ic-sm { width: 20px; height: 20px; }

/* ========== Accessibility ========== */
.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;
}

/* ========== Responsive ========== */
@media (max-width: 540px) {
  .auth-card {
    width: calc(100% - 20px);
    margin: 10px auto;
    border-radius: 22px;
  }
  .inbox-header {
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }
  .inbox-actions { width: 100%; }
  .inbox-actions .new-button { margin-left: auto; }
  .signin-shell { padding: max(26px, calc(var(--safe-top) + 26px)) 26px max(26px, calc(var(--safe-bottom) + 26px)); gap: 26px; }
  .quill-mark { width: 52px; height: 52px; margin-bottom: 30px; border-radius: 16px; }
  .signin-shell h1 { margin-bottom: 14px; font-size: 2.5rem; line-height: 1.02; letter-spacing: -.025em; }
  .signin-context { max-width: 300px; margin-bottom: 30px; font-size: .875rem; line-height: 1.5; }
  .signin-form { gap: 12px; }
  .signin-form input, .signin-continue { height: 52px; border-radius: 15px; font-size: .90625rem; }
  .signin-form input { padding: 0 16px; border-width: 1px; }
  .privacy-note { gap: 10px; padding: 14px 15px; border-radius: 15px; font-size: .71875rem; line-height: 1.45; }
  .privacy-note > svg { width: 16px; height: 16px; }
}
