*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg); color: var(--fg);
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  line-height: 1.5;
}

/* ── Auth (unchanged visual — leave as-is) ── */
#auth-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 2rem; gap: 1rem;
}
#auth-screen h1 { font-family: var(--font-serif); font-size: 1.75rem; font-weight: 700; color: var(--primary); }
#auth-screen input {
  font-size: 16px; padding: 0.75rem; width: 100%; max-width: 300px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--card-bg); color: var(--fg);
}
#auth-screen button {
  font-size: 1rem; padding: 0.75rem 2rem; border: none; border-radius: var(--r-sm);
  background: var(--primary); color: #fff; cursor: pointer; min-height: 44px; font-weight: 500;
}

/* ── Trust-this-device prompt ── */
#trust-screen {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 2rem 1.25rem; gap: 1rem;
}
#trust-screen .trust-card {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 1rem;
}
#trust-screen h1 {
  font-family: var(--font-serif); font-size: 1.5rem; font-weight: 700;
  color: var(--primary); text-align: center;
}
#trust-screen p { color: var(--fg); font-size: 0.95rem; line-height: 1.5; text-align: center; }
#trust-screen .trust-buttons { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }
#trust-screen button {
  font-size: 1rem; padding: 0.75rem 1rem; border-radius: var(--r-sm);
  cursor: pointer; min-height: 44px; font-weight: 500; font-family: inherit;
  width: 100%;
}
#trust-screen button.primary {
  background: var(--primary); color: #fff; border: none;
}
#trust-screen button.secondary {
  background: var(--card-bg); color: var(--primary);
  border: 1px solid var(--border);
}

/* ── Chat shell ── */
#chat-screen { display: none; flex-direction: column; flex: 1; height: 100%; min-height: 0; }

/* Header — Ledger pattern: serif "Coach" + muted "Sconce" caption, cal icon right */
#chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg);
  flex-shrink: 0;
}
#chat-header .title-block { display: flex; flex-direction: column; line-height: 1.1; }
#chat-header .coach-title {
  font-family: var(--font-serif); font-size: 18px; font-weight: 700;
  color: var(--primary); letter-spacing: 0.1px;
}
#chat-header .sconce-caption {
  font-size: 11px; color: var(--muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.6px; margin-top: 2px;
}
#chat-header .spacer { flex: 1; }
#chat-header #cal-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: transparent; border: none; color: var(--muted);
  border-radius: var(--r-sm); cursor: pointer; font-family: inherit;
}
#chat-header #cal-btn .cal-label { font-size: 13px; font-weight: 500; }
#chat-header #cal-btn.active { background: var(--accent-soft); color: var(--accent); }
#chat-header #signout-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: transparent; border: none; color: var(--muted);
  border-radius: var(--r-sm); cursor: pointer; font-family: inherit;
}
#chat-header #signout-btn .signout-label { font-size: 13px; font-weight: 500; }
/* iPhone 14/15/16 (390px) and similar narrow viewports: keep labels but
   tighten padding/gaps so the header fits without crowding. /angel 5/4
   estimated ~362px content vs ~358px usable at 390px before this rule. */
@media (max-width: 410px) {
  #chat-header { padding: 12px 12px; gap: 6px; }
  #chat-header #cal-btn,
  #chat-header #signout-btn { padding: 0 8px; gap: 4px; }
}
@media (max-width: 380px) {
  #chat-header #cal-btn .cal-label,
  #chat-header #signout-btn .signout-label { display: none; }
}

/* Body layout — chat main + calendar */
#chat-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }
#chat-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }

/* Messages scroller */
#messages {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
}

/* ── Turn types ── */

/* Day divider — inline serif rule */
.day-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 4px 0 14px;
}
.day-divider .rule { flex: 1; height: 1px; background: var(--border); }
.day-divider .label {
  font-family: var(--font-serif); font-size: 13.5px; font-weight: 600;
  color: var(--primary); letter-spacing: 0.1px;
}

/* Kid turn (user) — right-aligned navy-soft bubble */
.turn-kid { display: flex; justify-content: flex-end; margin: 8px 0; }
.turn-kid .kid-wrap { max-width: 82%; }
.turn-kid .bubble {
  background: var(--primary-soft); color: #faf8f4;
  padding: 9px 13px; border-radius: 10px 10px 4px 10px;
  font-size: 14.5px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
  -webkit-user-select: text; user-select: text;
}
.turn-kid .ts {
  font-size: 10.5px; color: var(--muted-2); margin-top: 3px;
  text-align: right; font-variant-numeric: tabular-nums;
}

/* Coach + tool turns share the copper-rail shell */
.turn-coach, .turn-tool, .turn-stream, .turn-error {
  display: flex; gap: 10px; margin: 8px 0; align-items: stretch;
}
.turn-coach .rail, .turn-tool .rail, .turn-error .rail {
  width: 3px; background: var(--copper); border-radius: 2px;
  flex-shrink: 0; align-self: stretch;
}
.turn-stream .rail {
  width: 3px; background: var(--copper); border-radius: 2px;
  flex-shrink: 0; height: 20px; align-self: flex-start;
}
.turn-coach .body, .turn-tool .body, .turn-stream .body, .turn-error .body {
  flex: 1; min-width: 0; padding: 2px 0 2px 2px;
}
.turn-coach .prose {
  font-size: 15px; line-height: 1.5; color: var(--fg);
  white-space: pre-wrap; word-wrap: break-word;
  -webkit-user-select: text; user-select: text;
}
.turn-coach .ts, .turn-tool .ts {
  font-size: 10.5px; color: var(--muted-2); margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

/* Tool turn — label chip + markdown body */
.turn-tool .tool-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted);
  margin-bottom: 6px;
}
.turn-tool .tool-body {
  font-size: 14.5px; line-height: 1.5; color: var(--fg);
  white-space: pre-wrap; word-wrap: break-word;
  -webkit-user-select: text; user-select: text;
}

/* Streaming pulse */
.turn-stream .body {
  display: flex; align-items: center; padding: 2px 0 2px 2px;
}
.stream-pulse {
  display: inline-flex; gap: 4px; align-items: center;
}
.stream-pulse .dot {
  width: 6px; height: 6px; border-radius: 99px; background: var(--copper);
  animation: sconce-breathe 2.4s ease-in-out infinite;
}
.stream-pulse .dot:nth-child(2) { animation-delay: 0.2s; }
.stream-pulse .dot:nth-child(3) { animation-delay: 0.4s; }

/* Error turn — copper-soft, never red */
.turn-error { background: transparent; }
.turn-error .rail { background: var(--copper-deep); }
.turn-error .body {
  background: var(--copper-soft);
  border: 1px solid rgba(196, 125, 60, 0.3);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  display: flex; gap: 10px; align-items: flex-start;
}
.turn-error .warn-icon {
  color: var(--copper-deep); flex-shrink: 0; padding-top: 1px;
}
.turn-error .err-text {
  flex: 1; font-size: 14px; line-height: 1.45; color: var(--fg);
}
.turn-error .err-retry {
  background: var(--copper-deep); color: #fff; border: none;
  padding: 6px 12px; border-radius: var(--r-sm); font-size: 13px;
  font-weight: 500; cursor: pointer; margin-top: 8px; font-family: inherit;
}

/* System line — centered muted */
.turn-system {
  text-align: center; color: var(--muted); font-size: 12.5px;
  margin: 8px 0; padding: 4px 12px;
}

/* ── Input rail ── */
#input-area {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border); background: var(--bg);
  flex-shrink: 0;
}
.icon-btn {
  width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: inherit; padding: 0;
}
.icon-btn:hover { color: var(--fg-2); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#mic-btn.recording { color: var(--copper-deep); animation: sconce-breathe 1.2s ease-in-out infinite; }
#clip-btn.uploading { animation: sconce-breathe 1.2s ease-in-out infinite; }
#input-area .textarea-wrap {
  flex: 1; min-height: 44px; max-height: 120px;
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: 22px;
  padding: 0 14px; background: var(--card-bg);
}
#msg-input {
  flex: 1; border: none; outline: none; background: transparent;
  resize: none; font-size: 16px; line-height: 1.4; color: var(--fg);
  font-family: inherit; padding: 8px 0;
  min-height: 44px; max-height: 120px;
}
#send-btn {
  width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  border: none; border-radius: 22px;
  background: var(--primary); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: inherit; padding: 0;
}
#send-btn:disabled {
  background: var(--border); color: var(--muted-2); cursor: not-allowed;
}
#char-count {
  font-size: 11px; color: var(--muted); text-align: right;
  padding: 0 16px;
}

/* ── Calendar panel ── */
#calendar-panel {
  width: 0; overflow: hidden; border-left: 1px solid var(--border);
  background: var(--bg); transition: width 0.25s ease;
  display: flex; flex-direction: column; flex-shrink: 0;
}
#calendar-panel.open { width: 320px; }

.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  gap: 8px; flex-shrink: 0;
}
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav button {
  background: transparent; border: none; color: var(--fg); cursor: pointer;
  font-size: 16px; padding: 4px 8px; border-radius: var(--r-xs);
  min-width: 32px; min-height: 32px;
}
.cal-nav button:hover { background: var(--bg-sunk); }
.cal-date {
  font-family: var(--font-serif); font-size: 15px; font-weight: 700;
  color: var(--primary); min-width: 110px; text-align: center;
}
.cal-today-btn {
  font-size: 12px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--r-xs);
  background: transparent; color: var(--fg); cursor: pointer;
  font-family: inherit; font-weight: 500; min-height: 32px;
}
.cal-today-btn:hover { background: var(--bg-sunk); }

.cal-timeline {
  flex: 1; overflow-y: auto; position: relative; padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.cal-hour {
  display: flex; min-height: 60px; border-bottom: 1px solid var(--border-soft);
}
.cal-hour-label {
  width: 48px; flex-shrink: 0; font-size: 10.5px;
  color: var(--muted-2); text-align: right; padding: 2px 8px 0 0;
  font-variant-numeric: tabular-nums; font-weight: 500;
}
.cal-hour-slot { flex: 1; position: relative; }

.cal-block {
  position: absolute; left: 52px; right: 8px;
  border-radius: var(--r-xs); padding: 4px 8px;
  font-size: 12px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; z-index: 1;
  line-height: 1.3;
}
.cal-block.schedule {
  background: var(--accent-soft); color: var(--accent);
  border-left: 3px solid var(--accent);
  font-weight: 500;
}
.cal-block.deadline {
  background: var(--copper); color: #fff;
  height: 20px; font-weight: 600;
}
.cal-block.workplan {
  background: var(--copper-soft); color: var(--copper-deep);
  border: 1.5px dashed var(--copper);
  display: flex; align-items: flex-start; gap: 2px;
  font-weight: 500;
}
.cal-block.workplan .wp-title { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cal-block.workplan button {
  background: transparent; border: none; cursor: pointer; font-size: 13px;
  padding: 0 3px; flex-shrink: 0; color: var(--copper-deep);
  min-height: 20px;
}
.cal-block.workplan button:hover { color: var(--primary); }
.cal-block.workplan.accepted {
  background: transparent; color: var(--primary);
  border: 1px solid var(--primary);
}
.cal-block.workplan.accepted { border-style: solid; }
.cal-block.workplan.dismissed { display: none; }

.cal-empty {
  padding: 2rem 1rem; text-align: center;
  color: var(--muted); font-size: 13px;
}

/* ── Kid transit block (4-state) ── */
.cal-block.transit {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 7px;
  background: var(--card-bg);
  border-left: 3px solid var(--accent);
  font-weight: 500; font-size: 11.5px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  min-height: 44px; line-height: 1.25;
  white-space: normal; text-overflow: unset;
  overflow: hidden;
}
.cal-block.transit.state-resolved {
  background: var(--card-bg); border-left-color: var(--accent);
}
.cal-block.transit.state-unresolved,
.cal-block.transit.state-unknown-location,
.cal-block.transit.state-kid-asked {
  background: var(--copper-soft);
  box-shadow: 0 1px 2px rgba(196,125,60,0.08);
}
.cal-block.transit.state-unresolved { border-left-color: var(--copper); }
.cal-block.transit.state-unknown-location { border-left-color: var(--copper); }
.cal-block.transit.state-kid-asked { border-left-color: var(--copper-soft); }

.cal-block.transit .tr-glyph {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-block.transit.state-resolved .tr-glyph {
  background: var(--accent-soft); color: var(--accent);
}
.cal-block.transit.state-unresolved .tr-glyph,
.cal-block.transit.state-unknown-location .tr-glyph,
.cal-block.transit.state-kid-asked .tr-glyph {
  background: rgba(196,125,60,0.14); color: var(--copper-deep);
}
.cal-block.transit .tr-content {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.cal-block.transit .tr-route {
  display: flex; align-items: baseline; gap: 6px; min-width: 0;
  font-size: 12px; font-weight: 500; color: var(--fg);
}
.cal-block.transit .tr-route .tr-time {
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.cal-block.transit .tr-route .tr-places {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-block.transit .tr-arrow { color: var(--muted-2); margin: 0 3px; }
.cal-block.transit .tr-dest-unknown {
  border-bottom: 1px dashed var(--copper); padding-bottom: 1px;
  color: var(--copper-deep); font-weight: 600;
}
.cal-block.transit .tr-status {
  display: flex; align-items: center; gap: 5px; font-size: 10.5px; min-width: 0;
}
.cal-block.transit .tr-status .tr-assignee {
  color: var(--fg-2); font-weight: 500;
}
.cal-block.transit .tr-status .tr-duration {
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.cal-block.transit .tr-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9.5px; font-weight: 600;
  padding: 2px 7px 2px 6px; border-radius: 99px;
  white-space: nowrap;
}
.cal-block.transit .tr-chip.needs-plan {
  background: var(--copper); color: #fff;
  text-transform: uppercase; letter-spacing: 0.35px;
}
.cal-block.transit .tr-chip.unknown-loc {
  background: var(--copper-deep); color: #fff;
}
.cal-block.transit .tr-chip.asked {
  background: var(--accent-soft); color: var(--accent);
}
.cal-block.transit[class*="state-unresolved"] .tr-chip,
.cal-block.transit[class*="state-unknown-location"] .tr-chip {
  animation: sconce-breathe 2.4s ease-in-out infinite;
}

/* ── Kid transit detail sheet (bottom sheet) ── */
#kid-ts-root {
  position: fixed; inset: 0; z-index: 120;
  display: none;
}
#kid-ts-root.open { display: block; }
#kid-ts-root .kid-ts-backdrop {
  position: absolute; inset: 0;
  background: rgba(30,50,82,0.4);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
#kid-ts-root .kid-ts-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-top-left-radius: 20px; border-top-right-radius: 20px;
  padding: 10px 18px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-sheet);
  max-height: 85%; overflow-y: auto;
  transform: translateY(100%);
  transition: transform 220ms ease-out;
}
#kid-ts-root.open .kid-ts-sheet { transform: translateY(0); }
#kid-ts-root .kid-ts-handle {
  width: 38px; height: 4px; background: var(--border);
  border-radius: 99px; margin: 0 auto 14px;
}
#kid-ts-root .kid-ts-kicker {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--copper-deep); margin-bottom: 6px;
}
#kid-ts-root.state-resolved .kid-ts-kicker { color: var(--accent); }
#kid-ts-root .kid-ts-title {
  font-family: var(--font-serif); font-size: 20px; font-weight: 700;
  color: var(--primary); line-height: 1.25; letter-spacing: -0.1px;
}
#kid-ts-root .kid-ts-meta {
  font-size: 13px; color: var(--muted); margin-top: 4px;
}
#kid-ts-root .kid-ts-facts {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 14px;
  margin-top: 14px; margin-bottom: 12px;
}
#kid-ts-root .kid-ts-row {
  display: grid; grid-template-columns: 72px 1fr; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--border-soft);
  align-items: baseline;
}
#kid-ts-root .kid-ts-row:last-child { border-bottom: none; }
#kid-ts-root .kid-ts-row .rlabel {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}
#kid-ts-root .kid-ts-row .rval {
  font-size: 14px; color: var(--fg); line-height: 1.3;
}
#kid-ts-root .kid-ts-row .rval.unknown {
  color: var(--copper-deep); font-weight: 600;
  border-bottom: 1px dashed var(--copper); display: inline-block;
  padding-bottom: 1px;
}
#kid-ts-root .kid-ts-primary {
  width: 100%; min-height: 48px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--r-md);
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 4px;
}
#kid-ts-root .kid-ts-secondary {
  width: 100%; min-height: 44px;
  background: transparent; color: var(--copper-deep);
  border: 1px solid var(--copper);
  border-radius: var(--r-md);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; margin-top: 8px;
}
#kid-ts-root .kid-ts-or {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0;
}
#kid-ts-root .kid-ts-or .line {
  flex: 1; height: 1px; background: var(--border-soft);
}
#kid-ts-root .kid-ts-or .text {
  font-size: 11px; color: var(--muted-2); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.5px;
}
#kid-ts-root .kid-ts-muted {
  font-size: 12.5px; color: var(--muted); line-height: 1.45; padding: 4px 2px;
}
#kid-ts-root .kid-ts-asked-card {
  background: var(--accent-soft); color: var(--accent);
  padding: 12px 14px; border-radius: var(--r-md);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px; line-height: 1.4;
}
#kid-ts-root .kid-ts-asked-card .asked-title { font-weight: 600; margin-bottom: 2px; }
#kid-ts-root .kid-ts-asked-card .asked-sub { color: var(--fg-2); }

/* ── Kid-side toast ── */
#kid-toast {
  position: fixed; left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120%);
  background: var(--copper-deep); color: #fff;
  padding: 10px 16px; border-radius: 99px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-sheet);
  opacity: 0; pointer-events: none;
  transition: transform 220ms ease-out, opacity 220ms ease-out;
  z-index: 130;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
#kid-toast.visible {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
#kid-toast.tone-accent { background: var(--accent); }

/* Mobile: bottom sheet instead of sidebar */
@media (max-width: 767px) {
  #calendar-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    width: 100%; height: 0;
    border-left: none; border-top: 1px solid var(--border);
    border-top-left-radius: var(--r-xl); border-top-right-radius: var(--r-xl);
    transition: height 0.25s ease;
    z-index: 100;
    box-shadow: var(--shadow-sheet);
  }
  #calendar-panel.open { height: 62vh; }
}

/* ── Install banner (leave as-is visually; refresh tokens) ── */
#install-banner {
  display: none;
  background: var(--primary); color: #faf8f4;
  padding: 0.55rem 0.75rem; font-size: 0.85rem; line-height: 1.35;
  align-items: center; gap: 0.75rem; flex-shrink: 0;
  border-bottom: 1px solid rgba(0,0,0,0.15);
}
#install-banner.visible { display: flex; }
#install-banner .install-msg { flex: 1; }
#install-banner .install-msg strong { color: var(--copper); font-weight: 600; }
#install-banner .install-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
#install-banner button {
  background: transparent; color: #faf8f4;
  border: 1px solid rgba(255,255,255,0.35);
  padding: 0.3rem 0.7rem; border-radius: var(--r-xs);
  font: inherit; font-size: 0.8rem; cursor: pointer;
}
#install-banner button.primary { background: var(--copper); border-color: var(--copper); }
#install-banner button.close-btn {
  border: none; font-size: 1.25rem; line-height: 1;
  padding: 0.1rem 0.45rem; opacity: 0.7;
}
#install-banner button.close-btn:hover { opacity: 1; }

/* ── Extracted inline style="" attributes ──
   CSP is style-src 'self': inline style attributes are blocked, so the
   declarations that used to live on elements moved here. Initial-hidden
   elements use the `hidden` attribute; the [hidden] rule needs !important
   because source order only breaks specificity TIES — an ID display rule
   (e.g. #persona-screen { display: flex }) beats the attribute selector
   regardless of order. !important here mirrors the UA-stylesheet pattern
   (HTML spec §15.3.1). */
.auth-logo { margin-bottom: 0.5rem; }
.trust-logo { margin: 0 auto 0.25rem; }
#auth-message { color: var(--muted); }
.cal-dot-sep { color: var(--muted-2); }
.fact-note { font-style: italic; }
[hidden] { display: none !important; }

/* ── Persona picker ── */
#persona-screen {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  overflow-y: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           calc(env(safe-area-inset-bottom) + 24px) env(safe-area-inset-left);
  -webkit-overflow-scrolling: touch;
}
#persona-inner {
  width: 100%; max-width: 480px;
  padding: 28px 16px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
#persona-header { text-align: center; }
.persona-title {
  font-family: var(--font-serif); font-size: 1.6rem; font-weight: 700;
  color: var(--primary); margin-bottom: 6px;
}
.persona-sub {
  font-size: 14px; color: var(--muted); line-height: 1.45;
}

/* 2-col grid, 375px minimum width */
#persona-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

/* Each persona card */
.persona-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px;
  padding: 16px 12px;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  min-height: 150px;
  text-align: center;
  transition: border-color 160ms, box-shadow 160ms, background 160ms;
  -webkit-tap-highlight-color: transparent;
}
.persona-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-card);
}
.persona-card:active {
  background: var(--bg-sunk);
  border-color: var(--primary);
}
.persona-card.selected {
  border-color: var(--primary);
  background: var(--accent-soft);
}
.persona-card.disabled {
  opacity: 0.6; pointer-events: none;
}
.persona-card .p-name {
  font-family: var(--font-serif); font-size: 17px; font-weight: 700;
  color: var(--primary); line-height: 1.1;
}
.persona-card .p-voice {
  font-size: 12.5px; color: var(--muted);
  line-height: 1.4; font-style: italic;
}

/* Tile avatar (SVG) */
.persona-tile {
  width: 72px; height: 72px; flex-shrink: 0;
  border-radius: 16px; overflow: visible;
  display: block;
}

/* "Make up your own" section */
#persona-custom {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.persona-custom-btn {
  background: transparent; border: none;
  font-size: 14px; color: var(--accent); cursor: pointer;
  font-family: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
  min-height: 44px; padding: 0 8px;
}
.persona-custom-btn:hover { color: var(--primary); }
#persona-custom-form {
  width: 100%; display: flex; flex-direction: column; gap: 8px;
}
#persona-custom-input {
  width: 100%; font-size: 16px; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  background: var(--card-bg); color: var(--fg);
  font-family: inherit; outline: none;
}
#persona-custom-input:focus { border-color: var(--primary); }
.persona-confirm-btn {
  width: 100%; min-height: 48px; font-size: 15px; font-weight: 600;
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--r-sm); cursor: pointer; font-family: inherit;
}
.persona-confirm-btn:hover { background: var(--primary-soft); }
.persona-inline-err {
  font-size: 13px; color: var(--red-dot); text-align: center;
}
/* Card-pick error slot — sits under the grid, visible regardless of the
   custom form's hidden state. */
#persona-err { width: 100%; margin: 0 0 4px; }

/* "skip for now" */
.persona-skip-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 13px; color: var(--muted-2); font-family: inherit;
  text-decoration: underline; text-underline-offset: 2px;
  min-height: 44px; padding: 4px 8px;
}
.persona-skip-btn:hover { color: var(--muted); }

/* Header persona avatar chip */
.persona-chip {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 8px; overflow: visible;
  display: block;
}
