/* Fine Print — layout + three themes.
   Themes are sets of colour/font variables switched by <html data-theme="...">.
   Linen (default): warm beige, calm. Midnight: blue and black. Heirloom: maroon + olive, serif. */

@font-face { font-family: "Fredoka"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/fredoka-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/fredoka-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/fredoka-latin-700-normal.woff2") format("woff2"); }
/* Fonts are bundled with the app (Figtree + Lora, SIL Open Font License) so they work offline. */
@font-face { font-family: "Figtree"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/figtree-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/figtree-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/figtree-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/figtree-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/lora-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/lora-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/lora-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/lora-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Lora"; font-weight: 400; font-style: italic; font-display: swap; src: url("/fonts/lora-latin-400-italic.woff2") format("woff2"); }

:root,
[data-theme="linen"] {
  --bg: #F3EDE4;
  --surface: #FBF8F3;
  --surface-2: #EFE6D9;
  --ink: #3B342E;
  --muted: #7A6F64;
  --line: #E2D7C8;
  --accent: #7C8B6F;        /* sage */
  --accent-ink: #FFFFFF;
  --accent-soft: #E4E8DC;
  --second: #B98C6B;        /* clay */
  --flag: #C9853F;
  --suggest: #2F62C9;
  --flag-soft: #F6E6CF;
  --bubble-agent: #FFFFFF;
  --bubble-user: #7C8B6F;
  --bubble-user-ink: #FFFFFF;
  --font: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display-weight: 700;
  --radius: 18px;
  --shadow: 0 10px 28px -18px rgba(59, 52, 46, .45);
  color-scheme: light;
}

[data-theme="midnight"] {
  --bg: #0B0D12;
  --surface: #141A26;
  --surface-2: #1B2333;
  --ink: #F2F4F8;
  --muted: #9AA6BC;
  --line: #263044;
  --accent: #4C8DFF;
  --accent-ink: #FFFFFF;
  --accent-soft: #17284A;
  --second: #7FB0FF;
  --flag: #FFB547;
  --suggest: #8DB4FF;
  --flag-soft: #3A2C12;
  --bubble-agent: #1B2333;
  --bubble-user: #4C8DFF;
  --bubble-user-ink: #FFFFFF;
  --shadow: 0 12px 30px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

[data-theme="heirloom"] {
  /* Dusky and vampire-y: plum-mauve night, wine maroon, olive, candlelit cream text. */
  --bg: #2A1823;
  --surface: #3A2330;
  --surface-2: #4A2D3D;
  --ink: #F3E4E6;
  --muted: #C4A9B6;
  --line: #5A3A4B;
  --accent: #A8324D;        /* wine maroon */
  --accent-ink: #FFF1F3;
  --accent-soft: #5C2638;
  --second: #8F9459;        /* olive */
  --flag: #A9AE6C;
  --suggest: #A9C2FF;
  --flag-soft: #4A4A2A;
  --bubble-agent: #3A2330;
  --bubble-user: #A8324D;
  --bubble-user-ink: #FFF1F3;
  --font: "Lora", Georgia, "Times New Roman", serif;
  --font-display: "Lora", Georgia, "Times New Roman", serif;
  --display-weight: 600;
  --shadow: 0 12px 30px -16px rgba(10, 2, 8, .75);
  color-scheme: dark;
}

[data-theme="popstar"] {
  /* Bright and energetic: hot pink, electric blue, lime green on a candy-white background. */
  --bg: #FFF3FA;
  --surface: #FFFFFF;
  --surface-2: #E8F1FF;
  --ink: #1B1035;
  --muted: #6A5A8C;
  --line: #FFC6E4;
  --accent: #E6007E;        /* hot pink */
  --accent-ink: #FFFFFF;
  --accent-soft: #FFE0F1;
  --second: #1E6BFF;        /* electric blue */
  --flag: #00A85A;          /* lime-green (deep enough to read) */
  --suggest: #1E6BFF;
  --flag-soft: #D6FFE9;
  --bubble-agent: #FFFFFF;
  --bubble-user: #1E6BFF;
  --bubble-user-ink: #FFFFFF;
  --font: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Fredoka", "Figtree", system-ui, sans-serif;
  --display-weight: 700;
  --radius: 22px;
  --shadow: 0 10px 24px -14px rgba(230, 0, 126, .45);
  color-scheme: light;
}
[data-theme="popstar"] body {
  background:
    radial-gradient(circle at 6% 2%, rgba(255, 46, 147, .42), transparent 36%),
    radial-gradient(circle at 100% 26%, rgba(30, 107, 255, .36), transparent 34%),
    radial-gradient(circle at 12% 100%, rgba(57, 255, 136, .45), transparent 38%),
    radial-gradient(circle at 92% 92%, rgba(255, 46, 147, .22), transparent 30%),
    var(--bg);
  background-attachment: fixed;
}
[data-theme="popstar"] .home-header, [data-theme="popstar"] .composer { background: rgba(255, 243, 250, .72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
[data-theme="popstar"] .empty-upload, [data-theme="popstar"] .send-btn { background: linear-gradient(135deg, #FF2E93, #E6007E 45%, #1E6BFF); }
[data-theme="popstar"] .bubble-user { background: linear-gradient(135deg, #1E6BFF, #7A3CFF); }
[data-theme="popstar"] .choice-icon, [data-theme="popstar"] .row-icon, [data-theme="popstar"] .drawer-ico { background: linear-gradient(135deg, #FFE0F1, #E8F1FF 55%, #D6FFE9); }
[data-theme="popstar"] .progress-dots span.on { background: linear-gradient(90deg, #FF2E93, #1E6BFF); }
[data-theme="popstar"] .home-brand span:not(.brand-caret), [data-theme="popstar"] .home-title, [data-theme="popstar"] .brand-name { background: linear-gradient(90deg, #FF2E93, #1E6BFF 55%, #00C46A); -webkit-background-clip: text; background-clip: text; color: transparent; }

[data-theme="large"] {
  /* Large Script: everything bigger, high contrast. Hockey-night colours:
     deep navy for text and buttons, bright orange for highlights (never for small text). */
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #E9EEF6;
  --ink: #041E42;
  --muted: #2B3F5C;
  --line: #041E42;
  --accent: #041E42;
  --accent-ink: #FFFFFF;
  --accent-soft: #FFE3D6;
  --second: #FF4C00;
  --flag: #C23A00;
  --suggest: #0B4FB3;
  --flag-soft: #FFE3D6;
  --bubble-agent: #FFFFFF;
  --bubble-user: #041E42;
  --bubble-user-ink: #FFFFFF;
  --font: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Figtree", "Segoe UI", system-ui, sans-serif;
  --display-weight: 800;
  --radius: 16px;
  --shadow: none;
  color-scheme: light;
}
html[data-theme="large"] { font-size: 125%; }
[data-theme="large"] body { font-size: 1.15rem; line-height: 1.55; }
[data-theme="large"] .bubble, [data-theme="large"] .agreement-row, [data-theme="large"] .card,
[data-theme="large"] .choice-card, [data-theme="large"] .option-btn, [data-theme="large"] .btn-signin { border-width: 2px; border-color: var(--line); }
[data-theme="large"] .muted, [data-theme="large"] .row-sub, [data-theme="large"] .card-note, [data-theme="large"] .guidance-line, [data-theme="large"] .demo-note { color: var(--muted); }
[data-theme="large"] .tag { font-size: .7rem; }
[data-theme="large"] .home-header { background: #041E42; color: #FFFFFF; border-bottom: 6px solid #FF4C00; }
[data-theme="large"] .home-brand, [data-theme="large"] .brand-caret { color: #FFFFFF; }
[data-theme="large"] .composer { background: #041E42; border-top: 6px solid #FF4C00; }
[data-theme="large"] .composer .icon-btn { background: #FFFFFF; border-color: #FFFFFF; }
[data-theme="large"] .composer-input { border-color: #FFFFFF; }
[data-theme="large"] .theme-picker select { border: 2px solid #041E42; }
[data-theme="large"] .home-header .theme-picker select { border-color: #FFFFFF; color: #041E42; background-color: #FFFFFF; }
[data-theme="large"] .btn-signin { background: #041E42; color: #FFFFFF; border-color: #041E42; }
[data-theme="large"] .btn-signin .signin-logo:not(.signin-logo-f) { background: #FFFFFF; color: #041E42; }
[data-theme="large"] .choice-icon, [data-theme="large"] .row-icon, [data-theme="large"] .drawer-ico { background: #041E42; color: #FFFFFF; }
[data-theme="large"] .drawer-head { background: #041E42; color: #FFFFFF; margin: -18px -12px 8px; padding: 22px 16px 16px; border-bottom: 6px solid #FF4C00; }
[data-theme="large"] .about { border: 2px solid #041E42; }
[data-theme="large"] .option-btn.selected, [data-theme="large"] .chip.chip-strong { background: #041E42; color: #FFFFFF; }
[data-theme="large"] .send-btn, [data-theme="large"] .empty-upload { background: #FF4C00; color: #041E42; }
[data-theme="large"] .chip { border-color: #FF4C00; color: #041E42; border-width: 2px; }
[data-theme="large"] .agreement-row.has-action { border-color: #FF4C00; box-shadow: 0 0 0 3px #FFE3D6; }
[data-theme="large"] .progress-dots span.on { background: #FF4C00; }
[data-theme="large"] .bubble-user { box-shadow: 4px 4px 0 #FF4C00; }
[data-theme="large"] .brand-name { color: #041E42; }
[data-theme="large"] .brand-name::after { content: ""; display: block; height: 6px; width: 64%; margin: 6px auto 0; background: #FF4C00; border-radius: 3px; }
[data-theme="large"] .reset-link { opacity: .8; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s ease, color .35s ease;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
h1, h2 { font-family: var(--font-display); font-weight: var(--display-weight); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }

body.has-banner { padding-top: calc(env(safe-area-inset-top, 0px) + 22px); }
body.has-banner .screen, body.has-banner .home-header { padding-top: 16px; }
.practice-banner {
  position: fixed; inset: 0 0 auto; z-index: 50;
  padding: calc(env(safe-area-inset-top, 0px) + 4px) 12px 4px;
  background: #222; color: #ffd84d; text-align: center;
  font: 600 11px/1.4 ui-monospace, Menlo, monospace; letter-spacing: .08em;
}

/* ---------- Screens ---------- */
.screen {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) max(20px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 20px) max(20px, env(safe-area-inset-left, 0px));
  max-width: 560px; margin: 0 auto;
  animation: fade-in .35s ease both;
}
@keyframes fade-in { from { opacity: .001; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } body { transition: none; } }
.screen-top { display: flex; justify-content: flex-end; }
.screen-pad { display: flex; flex-direction: column; gap: 18px; padding-top: 6vh; }
.screen-title { font-size: 1.75rem; line-height: 1.2; }
.screen-lede { margin: 0; font-size: 1.1rem; color: var(--muted); }

/* Theme picker */
.theme-picker select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 32px 8px 14px; font-size: .9rem; font-weight: 500;
}

/* Welcome */
.welcome-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding-block: 24px; }
.brand-mark img { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); display: block; }
.brand-name { font-size: 2.4rem; line-height: 1.05; }
.brand-tag { margin: 0; color: var(--muted); font-size: 1.02rem; }
.welcome-ask { font-size: 1.15rem; font-weight: 600; margin-top: 18px; font-family: var(--font); }
.signin-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; }
.btn { border: 0; border-radius: 999px; padding: 14px 18px; font-weight: 600; }
.btn-signin { display: flex; align-items: center; gap: 10px; justify-content: center; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.signin-logo { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font: 700 14px/1 system-ui, sans-serif; background: var(--surface-2); color: var(--ink); }
.signin-logo-f { background: #1877F2; color: #fff; }
.tag { font: 600 10px/1 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; padding: 4px 6px; border-radius: 6px; }
.tag-demo { background: var(--flag-soft); color: var(--ink); }
.tag-soon { background: var(--surface-2); color: var(--muted); }
.demo-note { margin: 0; font-size: .82rem; color: var(--muted); }
.guidance-line { margin: 0 auto; max-width: 34ch; text-align: center; font-size: .82rem; color: var(--muted); }
.reset-link { margin: 10px auto 0; background: none; border: 0; color: var(--muted); opacity: .45; font-size: .72rem; text-decoration: underline; }

/* Start choice */
.choice-stack { display: flex; flex-direction: column; gap: 12px; }
.choice-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.choice-card:active { transform: scale(.99); }
.choice-icon { font-size: 1.6rem; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }

/* Profile */
.progress-dots { display: flex; gap: 6px; }
.progress-dots span { width: 28px; height: 5px; border-radius: 3px; background: var(--line); transition: background .3s; }
.progress-dots span.on { background: var(--accent); }
.step-label { margin: 0; font-size: .85rem; color: var(--muted); font-weight: 500; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.option-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 12px; font-weight: 600; text-align: center; box-shadow: var(--shadow);
}
.option-btn.selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.back-top { margin-bottom: 4px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* Side menu */
.drawer-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(15, 8, 12, .45); opacity: 0; transition: opacity .25s ease; }
.drawer {
  position: fixed; inset: 0 auto 0 0; z-index: 41; width: min(82vw, 320px);
  display: flex; flex-direction: column; gap: 2px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 12px calc(env(safe-area-inset-bottom, 0px) + 16px) max(12px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-right: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(-102%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto;
}
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-scrim { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer-scrim { transition: none; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.2rem; }
.drawer-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-radius: 12px; padding: 12px 10px; font-weight: 600; font-size: 1rem; }
.drawer-item:hover, .drawer-item:focus-visible { background: var(--surface-2); }
.drawer-ico { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); display: grid; place-items: center; font-size: .95rem; flex: none; }
.drawer-label { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.drawer-label small { font-weight: 400; font-size: .78rem; color: var(--muted); }
.drawer-count { font: 600 .75rem/1 var(--font); color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 4px 8px; }
.drawer-arrow { color: var(--muted); transition: transform .2s; }
.drawer-item[aria-expanded="true"] .drawer-arrow { transform: rotate(180deg); }
.drawer-cats { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 8px 42px; }
.drawer-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: none; border: 0; text-align: left; border-radius: 10px; padding: 10px 10px; font-size: .95rem; }
.drawer-sub:hover, .drawer-sub:focus-visible { background: var(--surface-2); }
.drawer-sub.current { background: var(--accent-soft); font-weight: 600; }
.drawer-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.drawer-quiet { font-weight: 500; justify-content: space-between; }
.drawer-note { margin: 0; padding: 0 10px; font-size: .75rem; color: var(--muted); }
.home-brand { background: none; border: 0; padding: 4px 6px 4px 0; border-radius: 10px; }
.brand-caret { font-size: .85rem; color: var(--muted); font-family: var(--font); font-weight: 400; }
.cat-empty { border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); padding: 22px 18px; text-align: center; color: var(--muted); }
.cat-empty p { margin: 0; }
.btn-text { align-self: flex-start; background: none; border: 0; color: var(--muted); padding: 6px 0; }

/* ---------- Home ---------- */
.screen-home { padding: 0; max-width: 560px; height: 100%; min-height: 0; }
.home-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.home-brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.1rem; }
.home-logo { width: 28px; height: 28px; border-radius: 8px; }
.home-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 16px; }
.home-intro { display: flex; flex-direction: column; gap: 6px; }
.home-title { font-size: 1.45rem; line-height: 1.2; }
.profile-chip { margin: 0; align-self: flex-start; font-size: .78rem; color: var(--muted); background: var(--surface-2); padding: 4px 10px; border-radius: 999px; }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 28px 16px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.empty-upload { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 2rem; line-height: 1; box-shadow: var(--shadow); }
.empty-title { margin: 6px 0 0; font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.15rem; }
.empty-state .muted { margin: 0; font-size: .9rem; max-width: 30ch; }

.agreement-list { display: flex; flex-direction: column; gap: 10px; }
.agreement-list:empty { display: none; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat:empty { display: none; }
.bubble { max-width: 88%; padding: 11px 14px; border-radius: 18px; font-size: .98rem; line-height: 1.45; box-shadow: var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-agent { align-self: flex-start; background: var(--bubble-agent); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble-user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-ink); border-bottom-right-radius: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; }
.chip { background: var(--surface); border: 1.5px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: .92rem; display: inline-flex; align-items: center; gap: 6px; }
.chip[disabled] { opacity: .5; cursor: default; }
.chip-soon { border-color: var(--line); color: var(--muted); }

/* Composer */
.composer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px max(12px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 10px) max(12px, env(safe-area-inset-left, 0px));
  background: var(--bg); border-top: 1px solid var(--line);
}
.icon-btn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1.15rem; display: grid; place-items: center; transition: box-shadow .3s; }
.icon-btn.circled { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px #F2C94C; animation: ring 1.4s ease-in-out infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 3px var(--bg), 0 0 0 8px #F2C94C; } }
@media (prefers-reduced-motion: reduce) { .icon-btn.circled { animation: none; } }
.composer-start { margin: auto calc(-1 * max(20px, env(safe-area-inset-left, 0px))) calc(-1 * (env(safe-area-inset-bottom, 0px) + 20px)); border-radius: 0; }
.composer-input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 11px 14px; font-size: 1rem; }
.send-btn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 1.15rem; font-weight: 700; }

/* Agreement rows */
.agreement-row { display: flex; align-items: flex-start; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.agreement-row.has-action { border-color: var(--flag); box-shadow: 0 0 0 2px var(--flag-soft), var(--shadow); }
.row-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 1.15rem; flex: none; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-name { margin: 0; font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.row-sub { margin: 0; font-size: .82rem; color: var(--muted); }
.row-action { margin: 4px 0 0; font-size: .82rem; font-weight: 600; color: var(--flag); }
.row-status { flex: none; font-size: .72rem; font-weight: 600; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }

/* Cards in the chat */
.card { align-self: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; max-width: 100%; }
.card-title { margin: 0; font-weight: 700; font-family: var(--font-display); }
.card-note { margin: 0; font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.contact-row { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.contact-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.contact-who .muted { font-size: .82rem; overflow-wrap: anywhere; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card-dates ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.card-dates li { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr); gap: 10px; font-size: .9rem; }
.card-dates li strong { font-variant-numeric: tabular-nums; }

/* "Reading…" loader */
.bubble-loading { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .bubble-loading { animation: none; } }

/* Agreement rows open their page */
.agreement-row[role="button"] { cursor: pointer; text-align: left; }
.agreement-row[role="button"]:active { transform: scale(.99); }

/* One agreement's page */
.agreement-detail { display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; }
.detail-head { display: flex; align-items: flex-start; gap: 12px; }
.detail-title { font-size: 1.15rem; line-height: 1.3; overflow-wrap: anywhere; }
.detail-summary { margin: 0; font-size: 1.02rem; }
.detail-facts { margin: 0; gap: 0; padding: 4px 14px; }
.detail-row { display: grid; grid-template-columns: minmax(0, 8.5em) minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--muted); font-size: .85rem; }
.detail-row dd { margin: 0; font-size: .92rem; overflow-wrap: anywhere; }
.convo-line { margin: 0; font-size: .9rem; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.convo-line strong { font-weight: 700; margin-right: 4px; }
.convo-user { background: var(--accent-soft); }
.detail-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-quiet { background: var(--surface); border: 1px solid var(--line); }
.btn-danger { background: #B3261E; color: #fff; }
.btn-danger-quiet { background: none; border: 1px solid var(--line); color: #C0392B; }
[data-theme="midnight"] .btn-danger-quiet, [data-theme="heirloom"] .btn-danger-quiet { color: #FF8A80; }
.confirm-delete { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1.5px solid #C0392B; border-radius: var(--radius); background: var(--surface); }
.confirm-delete p { margin: 0; }
.confirm-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Notice */
.guide-banner { margin: 0 0 12px; font-size: .88rem; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.notice-paper { background: #FFFFFF; color: #1F1A16; border-radius: 6px; padding: 22px 20px; box-shadow: var(--shadow); font-family: Georgia, "Times New Roman", serif; font-size: .95rem; line-height: 1.5; display: flex; flex-direction: column; gap: 10px; }
.notice-paper h2 { font-family: Georgia, "Times New Roman", serif; font-size: 1.12rem; font-weight: 700; margin: 0 0 6px; letter-spacing: 0; }
.notice-field { display: grid; grid-template-columns: minmax(0, 8.5em) minmax(0, 1fr); gap: 8px; }
.notice-field .k { color: #6B6158; font-size: .85rem; font-family: system-ui, sans-serif; }
.notice-field .v { overflow-wrap: anywhere; }
.notice-field .blank { color: #9A8F84; font-style: italic; }
.notice-body p { margin: 0 0 10px; }
.notice-sign { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; font-size: .9rem; }
.notice-paper input, .notice-paper textarea { width: 100%; font: inherit; color: #1F1A16; background: #FFFBEA; border: 1px solid #E2C96B; border-radius: 6px; padding: 6px 8px; }
.notice-paper textarea { min-height: 220px; resize: vertical; }
.notice-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding-bottom: 24px; }
.notice-card .notice-meta { margin: 0; font-size: .9rem; }
.notice-card .contact-actions { margin-top: 2px; }
.caption-guidance { align-self: flex-start; margin: -4px 0 0 6px; font-size: .72rem; color: var(--muted); opacity: .85; }

/* About section on the sign-in screen */
.about { margin: 22px auto 0; max-width: 34rem; display: flex; flex-direction: column; gap: 12px; padding: 18px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.about p { margin: 0; font-size: .9rem; }
.about-title { font-size: 1.1rem; }
.about-box { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.about-label { font-weight: 700; font-size: .85rem !important; }
.about-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.about-links a { text-decoration: none; }
.about-credit { color: var(--muted); font-size: .82rem !important; padding-top: 10px; border-top: 1px solid var(--line); }

/* Read aloud + mic */
.bubble-agent { position: relative; }
.speak-btn { display: inline-grid; place-items: center; margin: 6px 0 -2px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); font-size: .85rem; line-height: 1; vertical-align: middle; }
.speak-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.bubble-text { display: block; }
.mic-btn { font-size: 1rem; }

/* Agreement page: delete on top, collapsible conversations */
.detail-top { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-top: -40px; pointer-events: none; }
.detail-top > * { pointer-events: auto; }
.detail-top .confirm-delete { align-self: stretch; }
.btn-small { padding: 7px 12px; font-size: .82rem; }
.detail-convos { display: flex; flex-direction: column; gap: 10px; }
.convo { padding: 0; gap: 0; }
.convo summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; font-weight: 600; }
.convo summary::-webkit-details-marker { display: none; }
.convo summary::after { content: "▾"; color: var(--muted); }
.convo[open] summary::after { content: "▴"; }
.convo-body { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 14px; }

/* Celebration post */
.post-card { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%); }
.post-text { margin: 0; font-size: 1.02rem; line-height: 1.5; }

/* Camera: pages being photographed */
.camera-card { gap: 12px; }
.page-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.page-thumb { position: relative; margin: 0; flex: none; width: 76px; }
.page-thumb img { display: block; width: 76px; height: 100px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.page-thumb figcaption { position: absolute; left: 6px; bottom: 6px; background: var(--accent); color: var(--accent-ink); font: 700 .7rem/1 var(--font); padding: 3px 6px; border-radius: 999px; }
.thumb-remove { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .9rem; line-height: 1; }
.chip-strong { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.original-body { display: flex; flex-direction: column; gap: 8px; }
.original-open { text-align: center; text-decoration: none; }
.original-pages .page-thumb { text-decoration: none; }

/* Original viewer */
.screen-viewer { gap: 10px; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.viewer-top .btn { text-decoration: none; color: var(--ink); }
.viewer-title { margin: 0; font-weight: 600; font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
.viewer-pages { display: flex; flex-direction: column; gap: 12px; align-items: center; padding-bottom: 24px; }
.viewer-page { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 6px 18px -10px rgba(0,0,0,.45); }
.original-pages .page-thumb { border: 0; padding: 0; background: none; }

/* A file the agent made, shown in the chat like an attachment */
.file-card { display: flex; flex-direction: row; align-items: center; gap: 12px; width: 100%; max-width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.file-card .file-icon { font-size: 1.6rem; line-height: 1; }
.file-card .file-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.file-card .file-text strong { overflow-wrap: anywhere; }
.file-card .file-text .muted { font-size: .78rem; }
.file-card .file-open { font-weight: 600; color: var(--accent); white-space: nowrap; }

/* Calendar file opened in the app */
.cal-list { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.cal-event { gap: 6px; }
.cal-event .chip { align-self: flex-start; text-decoration: none; }
.cal-when { margin: 0; font-weight: 700; font-size: .9rem; }
.cal-what { margin: 0; }
.screen-viewer > .viewer-pages > .card-note { align-self: stretch; }

/* Pending action with a "mark complete" checkbox */
.action-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 0; }
.action-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.action-check.is-done { color: var(--muted); font-weight: 500; }

/* Suggested action (a tip, softer than a pending action) */
.suggest-wrap { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.suggest-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-suggest { color: var(--suggest); font-weight: 600; font-size: .82rem; }
.row-suggest input { accent-color: var(--suggest); }
.row-suggest.is-done { color: var(--muted); font-weight: 500; }
.suggest-how { border: 1px solid var(--suggest); color: var(--suggest); background: transparent; border-radius: 999px; padding: 2px 10px; font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; }
.suggest-detail { margin: 0 0 0 28px; font-size: .85rem; color: var(--ink); }
.card-suggest { border-color: var(--suggest); }
.card-suggest .card-title { color: var(--suggest); }
.card-suggest .suggest-wrap { margin-top: 0; }
.profile-demo-note { margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; }
