/* Fonts live inside the app (no font service gets people's IP addresses, and they work offline). SIL Open Font License, see fonts/OFL.txt */
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-400.woff") format("woff"); font-weight: 400 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-700.woff") format("woff"); font-weight: 600 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/instrument-serif-400.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/instrument-serif-400-italic.woff") format("woff"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  /* Layout: one-screen app in a 760px column: header, tool row, scrolling stage, composer, bottom tab bar */
  --paper: #fbf1f3;
  --card: #ffffff;
  --ink: #2b1320;
  --muted: #7d5967;
  --line: #ecd5dc;
  --coach: #f6e2e8;
  --sweet: #a94365;
  --playful: #c42845;
  --bold: #a3112f;
  --on-heat: #ffffff;
  --good: #2f7d4f;
  --heat: var(--playful);
  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #190d13; --card: #251620; --ink: #f7e8ec; --muted: #bd95a4; --line: #3d2431; --coach: #2e1a25;
    --sweet: #f29ab1; --playful: #ff6380; --bold: #ff3a63; --on-heat: #22060f; --good: #6fd39a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #190d13; --card: #251620; --ink: #f7e8ec; --muted: #bd95a4; --line: #3d2431; --coach: #2e1a25;
  --sweet: #f29ab1; --playful: #ff6380; --bold: #ff3a63; --on-heat: #22060f; --good: #6fd39a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, select, textarea, input { font-family: var(--font-body); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--heat); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
}

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 6px; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.01em;
  position: relative;
  padding-right: 21px;
}
.wordmark .spark {
  position: absolute; right: 0; top: -5px;
  width: 19px; height: 19px;
  color: var(--heat);
  transition: color .3s;
  animation: flutter 1.6s cubic-bezier(.2,.8,.2,1) .2s both;
}
/* The butterfly lands, then beats its wings twice. */
@keyframes flutter {
  0% { transform: translate(-6px, 8px) scale(0) rotate(-20deg); opacity: 0; }
  35% { transform: translate(0, 0) scale(1.25) rotate(8deg); opacity: 1; }
  50% { transform: scale(.5, 1.05); }
  62% { transform: scale(1.1, 1); }
  76% { transform: scale(.6, 1.03); }
  100% { transform: scale(1); opacity: 1; }
}
.tagline { color: var(--muted); font-size: 13px; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 600; font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  text-decoration: none;
}
.ghost-btn:hover { border-color: var(--heat); }
.ghost-btn.danger { color: var(--bold); }
.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); border-radius: 50%;
  color: var(--ink); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Tool row: tone + read aloud */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0 8px; border-bottom: 1px solid var(--line); }
.tone {
  display: inline-flex; gap: 2px;
  padding: 3px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tone button {
  appearance: none; border: 0; background: transparent;
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 600; font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .25s, color .25s;
}
.tone button:hover { color: var(--ink); }
.tone button[aria-pressed="true"] { background: var(--heat); color: var(--on-heat); }
.toggle-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 13px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.toggle-btn svg { width: 16px; height: 16px; }
.toggle-btn[aria-pressed="true"] { color: var(--heat); border-color: var(--heat); }

/* Stage */
.stage { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 0 18px; -webkit-overflow-scrolling: touch; }
.thread { display: flex; flex-direction: column; gap: 14px; }
.example-tag {
  align-self: center;
  margin: 2px 0 0;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  text-align: center;
}
.welcome { padding: 14px 2px 4px; }
.welcome h2, .view-title, .learn-head h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.05;
  text-wrap: balance;
}
.welcome h2 em, .view-title em { color: var(--heat); }
.welcome p, .view-sub, .learn-head p { margin: 0; color: var(--muted); max-width: 54ch; }

.msg { max-width: 88%; overflow-wrap: anywhere; }
.msg.user {
  align-self: flex-end;
  background: var(--bubble, var(--heat));
  color: var(--on-heat);
  border-radius: 18px 18px 4px 18px;
  padding: 9px 14px;
  white-space: pre-wrap;
  font-weight: 500;
}
.msg.user .voice-mark { display: inline-block; width: 13px; height: 13px; margin-right: 6px; vertical-align: -1px; opacity: .85; }
.msg.coach { align-self: flex-start; background: var(--coach); border-radius: 4px 18px 18px 18px; padding: 11px 16px 13px; }
.msg.partner { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 4px 18px 18px 18px; padding: 9px 14px 11px; }
.msg-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.msg-label svg { width: 10px; height: 10px; color: var(--heat); }

.rich p { margin: 0 0 8px; }
.rich p:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: 2px 0 10px; padding-left: 22px; display: grid; gap: 3px; }
.rich strong { font-weight: 700; }
.rich-h { font-weight: 700; margin-top: 4px !important; }
.next-step { border-top: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent); padding-top: 8px; font-weight: 600; }
.err { color: var(--bold); font-weight: 600; font-size: 14px; }

.say {
  margin: 10px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--heat);
  border-radius: 10px;
  padding: 9px 10px 10px 12px;
}
.say-label { grid-column: 1 / -1; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.say blockquote { margin: 0; font-family: var(--font-display); font-size: 21px; line-height: 1.25; }
.copy-btn {
  align-self: end;
  font-weight: 600; font-size: 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}
.copy-btn:hover { border-color: var(--heat); }

.dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Today */
.today { display: grid; gap: 14px; }
.today-hero { display: grid; gap: 6px; padding: 6px 2px 2px; }
.greeting { margin: 0; color: var(--muted); font-weight: 600; font-size: 14px; }
.level-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.level-name { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 36px; line-height: 1.05; }
.level-num { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--heat); }
.xp-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.xp-fill { height: 100%; border-radius: 999px; background: var(--heat); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.xp-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.streak-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: var(--ink); }
.streak-pill svg { width: 14px; height: 14px; color: var(--heat); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--heat); }
.challenge-text { margin: 6px 0 12px; font-family: var(--font-display); font-size: 25px; line-height: 1.15; text-wrap: balance; }
.challenge.done { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.challenge.done .card-label { color: var(--good); }
.done-note { margin: 0; font-weight: 600; color: var(--good); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .send { height: 40px; padding: 0 16px; font-size: 14px; }
.btn-row .ghost-btn { height: 40px; }

.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.chart-title { margin: 0; font-weight: 700; font-size: 15px; }
.chart-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.chart-wrap { position: relative; margin-top: 10px; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--heat); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--heat); opacity: .1; }
.chart-dot { fill: var(--heat); stroke: var(--card); stroke-width: 2; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-tip {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--ink); color: var(--paper);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 4px 8px; border-radius: 8px; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.chart-empty { margin: 10px 0 0; color: var(--muted); font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 10px 9px; display: grid; gap: 2px; }
.stat b { font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); line-height: 1.25; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 8px; margin-top: 10px; }
.badge { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: var(--paper); }
.badge svg { width: 18px; height: 18px; flex: none; color: var(--line); }
.badge b { display: block; font-size: 13px; }
.badge small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.badge.earned { border-color: var(--heat); background: var(--card); }
.badge.earned svg { color: var(--heat); }

/* Segmented control */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); margin-bottom: 4px; }
.seg button {
  appearance: none; border: 0; background: transparent; border-radius: 999px;
  padding: 8px 10px; font-weight: 600; font-size: 13.5px; line-height: 1.25; color: var(--muted); cursor: pointer;
}
.seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); }

/* Reply help + profile review */
.tool-form { display: grid; gap: 8px; padding: 12px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tool-form .view-sub { margin-bottom: 6px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.field-label small { font-weight: 500; color: var(--muted); font-size: 13px; }
.tool-form textarea, .tool-form input[type="text"] {
  width: 100%;
  font-size: 16px; line-height: 1.4;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  resize: vertical;
}
.tool-form textarea:focus, .tool-form input[type="text"]:focus { border-color: var(--heat); outline: none; }
.tool-form ::placeholder { color: var(--muted); }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.form-actions.start { justify-content: flex-start; }
.form-actions.end { justify-content: flex-end; }
.hint { font-size: 13px; color: var(--muted); }
.file-btn { height: 46px; padding: 0 16px; font-size: 14px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 72px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--card); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-edit { all: unset; display: block; width: 100%; height: 100%; cursor: pointer; position: relative; }
.thumb-edit:focus-visible { outline: 2px solid var(--heat); outline-offset: -2px; }
.thumb-rm {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 15px; line-height: 24px; padding: 0; cursor: pointer;
}
.thumb-badge {
  position: absolute; left: 4px; right: 4px; bottom: 4px; text-align: center;
  font-size: 10.5px; font-weight: 700; color: #fff; background: rgba(0,0,0,.72); border-radius: 6px; padding: 2px 4px;
}
.result { display: grid; gap: 6px; }
.result-quote { align-self: flex-start; margin: 0; font-size: 14px; color: var(--muted); border-left: 2px solid var(--line); padding: 0 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.result .msg.coach { max-width: 100%; }

/* Practice */
.practice-head { display: grid; gap: 10px; padding: 0 0 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  font-weight: 600; font-size: 13px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--heat); }
.chip[aria-pressed="true"] { border-color: var(--heat); box-shadow: inset 0 0 0 1px var(--heat); }
.scene { margin: 0; font-size: 14px; color: var(--muted); }
.scene b { color: var(--ink); font-weight: 700; }
.tip { align-self: flex-start; max-width: 88%; margin-top: -6px; padding: 7px 12px 8px; border-left: 2px solid var(--heat); font-size: 14px; }
.tip-top { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.tip p { margin: 2px 0 0; }
.meter { display: inline-flex; gap: 2px; }
.meter svg { width: 11px; height: 11px; color: var(--heat); }
.meter svg.off { opacity: .22; }

/* Learn */
.learn-head { padding: 6px 2px 14px; }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.lesson { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 14px; }
.lesson.read { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.lesson-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lesson-num { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--heat); font-variant-numeric: tabular-nums; }
.read-pill { font-size: 11.5px; font-weight: 700; color: var(--good); }
.lesson h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 27px; line-height: 1.1; text-wrap: balance; }
.lesson-lead { margin: 0; font-weight: 600; }
.lesson ul { margin: 2px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: 15px; }
.lesson .say { margin: 8px 0 4px; background: var(--paper); }
.lesson-actions { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ask-btn { text-align: left; font-weight: 600; font-size: 14px; color: var(--heat); background: none; border: 0; padding: 4px 0; cursor: pointer; }
.ask-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Composer */
.composer { border-top: 1px solid var(--line); padding: 10px 0 10px; background: var(--paper); }
.starters { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 10px; scrollbar-width: none; }
.starters::-webkit-scrollbar { display: none; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; margin: 0; }
#composer-input {
  flex: 1; min-width: 0; resize: none;
  font-size: 16px; line-height: 1.4;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 22px;
  padding: 11px 16px; max-height: 140px;
}
#composer-input::placeholder { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#composer-input:focus { border-color: var(--heat); outline: none; }
.mic-btn {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; position: relative;
}
.mic-btn svg { width: 20px; height: 20px; }
.mic-btn.listening { color: var(--on-heat); background: var(--heat); border-color: var(--heat); }
.mic-btn.listening::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--heat); animation: pulse 1.3s ease-out infinite;
}
@keyframes pulse { from { transform: scale(.9); opacity: .9; } to { transform: scale(1.25); opacity: 0; } }
.send {
  flex: none; height: 46px; padding: 0 20px; border: 0; border-radius: 999px;
  background: var(--heat); color: var(--on-heat);
  font-weight: 700; font-size: 15px; cursor: pointer;
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--heat) 70%, transparent);
  transition: background-color .25s, transform .15s;
}
.send:active { transform: scale(.97); }
.send:disabled { opacity: .55; cursor: default; }
.send.stop { background: var(--ink); color: var(--paper); box-shadow: none; }
.note { margin: 7px 4px 0; font-size: 12.5px; color: var(--muted); }
.note:empty { display: none; }
.note.warn { color: var(--bold); font-weight: 600; }

/* Bottom tab bar */
.bottom-nav {
  display: grid; grid-template-columns: repeat(5, 1fr);
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-left)));
  padding: 4px 6px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.bottom-nav button {
  appearance: none; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 4px; color: var(--muted);
  font-size: 11.5px; font-weight: 600; min-width: 0;
}
.bottom-nav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav svg { width: 24px; height: 24px; }
.bottom-nav button[aria-selected="true"] { color: var(--heat); }

/* Toast */
.toast {
  position: fixed; left: 50%; top: calc(58px + env(safe-area-inset-top)); transform: translateX(-50%);
  z-index: 20; background: var(--ink); color: var(--paper);
  font-weight: 700; font-size: 14px; padding: 9px 16px; border-radius: 999px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  animation: toast-in .3s cubic-bezier(.2,.8,.2,1) both; max-width: calc(100% - 32px); text-align: center;
}
@keyframes toast-in { from { transform: translate(-50%, -12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Sheets */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  padding: 16px;
}
.sheet {
  width: min(100%, 460px); max-height: 100%; overflow-y: auto;
  background: var(--paper); border-radius: 22px;
  padding: 24px 22px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.45);
  animation: rise .35s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 8px; font-family: var(--font-display); font-weight: 400; font-size: 34px; line-height: 1.05; }
.sheet p { margin: 0 0 12px; }
.sheet-small { font-size: 14px; color: var(--muted); }
.sheet-spark { width: 22px; height: 22px; color: var(--heat); margin-bottom: 6px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sheet-actions .send { flex: 1 1 auto; }
.lang-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.field-grid { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 12px; margin: 10px 0 14px; }
.field-grid .field-label { margin: 0; }
select {
  font-size: 15px; font-weight: 500; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; cursor: pointer; width: 100%;
}

@media (min-width: 640px) {
  .overlay { align-items: center; }
}
@media (max-width: 420px) {
  .tagline { display: none; }
  .wordmark { font-size: 29px; }
  .tone button { padding: 5px 10px; }
  .welcome h2, .learn-head h2, .view-title, .level-name { font-size: 30px; }
  .msg, .tip { max-width: 94%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .challenge-text { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Daily reminder + streak warning */
.risk { margin: 6px 0 0; padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--heat) 12%, transparent); color: var(--ink); font-size: 14px; font-weight: 600; }
.rem-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.rem-time { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.rem-time input { font-size: 16px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font-family: var(--font-body); }
.rem-row .send { height: 40px; padding: 0 16px; font-size: 14px; }
.rem-row .ghost-btn { height: 40px; }
.ghost-btn.on { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, var(--line)); }
.rem-hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.rem-note { margin: 8px 0 0; font-size: 13px; font-weight: 600; color: var(--good); }
.rem-note.warn { color: var(--bold); }

/* Version 3: four-part Reply tab, report button, refine buttons, hiding, practice goals, first-date kit */
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg-4 button { padding: 8px 4px; }
.hide-hint { margin: 0; }
.style-row:empty { display: none; }
.style-chip {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--muted); background: none; border: 1px dashed var(--line); border-radius: 999px; padding: 6px 12px;
}
.style-chip:hover { border-color: var(--heat); color: var(--ink); }
.style-chip.on { color: var(--good); border-style: solid; border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }

.ai-tag {
  font-size: 9.5px; font-weight: 800; letter-spacing: .06em; color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 5px; padding: 0 4px; line-height: 15px;
}
.flag-btn {
  margin-left: auto; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin-top: -6px; margin-bottom: -6px; margin-right: -8px;
  color: var(--muted); background: none; border: 0; border-radius: 50%; cursor: pointer; opacity: .75;
}
.flag-btn svg { width: 14px !important; height: 14px !important; color: currentColor !important; }
.flag-btn:hover, .flag-btn:focus-visible { opacity: 1; color: var(--bold); background: color-mix(in srgb, var(--bold) 10%, transparent); }
.reported-msg p { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); font-style: italic; }
.reported-msg svg { width: 14px; height: 14px; flex: none; }

.vibe {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 14.5px;
}
.vibe-label { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--heat); }
.vibe-label svg { width: 10px; height: 10px; }

.refine-row { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 2px; }
.chip.refine { font-size: 12.5px; padding: 6px 11px; }
.chip.refine:disabled { opacity: .5; cursor: default; }

/* Hide names and faces */
.redact-stage { display: flex; justify-content: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
#redact-canvas {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 56vh;
  touch-action: none; cursor: crosshair; border-radius: 6px;
}

/* Report sheet */
.reasons { display: grid; gap: 6px; margin: 4px 0 12px; }
.reason {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-weight: 600; font-size: 15px;
}
.reason input { accent-color: var(--heat); width: 18px; height: 18px; margin: 0; }
.reason:has(input:checked) { border-color: var(--heat); }
#report-comment, #set-style {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical; margin-top: 4px;
}
#report-comment:focus, #set-style:focus { border-color: var(--heat); outline: none; }
.contact-line { margin-top: 12px !important; }
.contact-line a { color: var(--ink); font-weight: 600; }
.style-field { margin: 4px 0 14px; display: grid; gap: 4px; }
.style-field .sheet-small { margin: 0; font-size: 13px; }

/* Practice: goal, hint, end-of-chat report */
.goal-line { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 14px; font-weight: 600; }
.goal-label { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--heat); }
.goal-label svg { width: 10px; height: 10px; }
.goal-line.reached .goal-label { color: var(--good); }
.goal-pill { font-size: 11.5px; font-weight: 700; color: var(--good); text-transform: none; letter-spacing: 0; }
.practice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 2px; }
.practice-actions .ghost-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; font-size: 13.5px; }
.practice-actions .ghost-btn:disabled { opacity: .5; cursor: default; }
.practice-actions svg { width: 15px; height: 15px; }
.practice-actions.done p { margin: 0; color: var(--muted); font-size: 14px; flex: 1 1 200px; }
.msg.note-hint, .msg.note-debrief { background: var(--card); border: 1px dashed color-mix(in srgb, var(--heat) 55%, var(--line)); }
.msg.note-hint .msg-label > svg:first-child { width: 13px; height: 13px; color: var(--heat); }

/* First-date kit */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two-col .field { display: grid; gap: 4px; min-width: 0; align-content: start; }
.safety { display: grid; gap: 6px; margin-bottom: 14px; }
.safety-sub { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.safety-form { display: grid; gap: 6px; }
.safety-form input, #date-where, #date-likes {
  width: 100%; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
}
#date-where, #date-likes { background: var(--card); }
.safety-form input:focus { border-color: var(--heat); outline: none; }
#safety-note { white-space: pre-wrap; }
.safety-tips { margin: 8px 0 10px; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }
.safety-emergency { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--bold); }
#dateideas-results { margin-bottom: 18px; }
#lessons-pane .learn-head { padding-top: 12px; }

@media (max-width: 420px) {
  .seg-4 button { font-size: 12.5px; padding: 8px 2px; }
  .two-col { grid-template-columns: 1fr; }
}

/* Couples: relationship help */
.bottom-nav { grid-template-columns: repeat(6, 1fr); }
.bottom-nav button { font-size: 11px; }
@media (max-width: 380px) { .bottom-nav button { font-size: 10px; } .bottom-nav svg { width: 22px; height: 22px; } }
.couples-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  margin: 10px 0 14px; padding: 9px 12px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); font-size: 13.5px; color: var(--muted);
}
.link-btn { font: inherit; font-weight: 700; color: var(--bold); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.msg-label > svg:first-child { flex: none; }
.exercise ol { margin: 2px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: 15px; }
.exercise .lesson-num { display: inline-flex; align-items: center; gap: 5px; }
.exercise .lesson-num svg { width: 11px; height: 11px; }
.exercise .say { margin: 8px 0 4px; background: var(--paper); }

.safety-alert {
  align-self: stretch; display: grid; gap: 8px;
  border: 1.5px solid color-mix(in srgb, var(--bold) 55%, var(--line)); border-radius: 16px;
  background: color-mix(in srgb, var(--bold) 6%, var(--card)); padding: 14px 14px 12px;
}
.safety-alert p { margin: 0; font-size: 14.5px; }
.safety-alert-title { font-family: var(--font-display); font-size: 24px !important; line-height: 1.1; color: var(--ink); }
.safety-alert-emergency { font-weight: 700; color: var(--bold); }
.safety-alert .ghost-btn { justify-self: start; height: 38px; }
.help-lines { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.help-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.help-line div { display: grid; gap: 1px; min-width: 0; }
.help-line b { font-size: 14.5px; }
.help-line span { font-size: 13px; color: var(--muted); line-height: 1.35; }
.call-btn {
  flex: none; text-decoration: none; font-weight: 700; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums;
  color: var(--on-heat); background: var(--heat); border-radius: 999px; padding: 8px 12px;
}
#help-body { display: grid; gap: 12px; }
#help-body .card p { margin: 6px 0 0; }
.help-country { display: grid; gap: 6px; }
.help-country .chips { flex-wrap: wrap; overflow: visible; }
.help-safety { border-color: color-mix(in srgb, var(--bold) 50%, var(--line)); }
.help-safety .card-label { color: var(--bold); }
.help-emergency a { font-weight: 800; color: var(--bold); }
.help-note { font-size: 13.5px; color: var(--muted); }
.help-link { display: inline-flex; align-items: center; height: 38px; margin-top: 10px; text-decoration: none; }
.help-when { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 5px; font-size: 15px; }
.help-small { margin: 0; font-size: 13px; color: var(--muted); }
.help-small a { color: var(--ink); font-weight: 600; }

/* Couples v4: home, SOS, about, check-up, questions, both sides, lock */
#view-couples.locked > * { display: none; }
#couples-home, #home-rest { display: grid; gap: 14px; }
#couples-home { padding-top: 10px; }
.sos-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  font: inherit; color: var(--ink); background: color-mix(in srgb, var(--heat) 10%, var(--card));
  border: 1.5px solid color-mix(in srgb, var(--heat) 45%, var(--line)); border-radius: 16px; padding: 12px 14px;
}
.sos-btn > span:nth-child(2) { flex: 1; display: grid; gap: 1px; }
.sos-btn b { font-size: 16px; }
.sos-btn small { font-size: 13px; color: var(--muted); }
.sos-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--heat); color: var(--on-heat); flex: none; }
.sos-icon svg { width: 16px; height: 16px; }
.about-card summary { list-style: none; cursor: pointer; display: grid; gap: 2px; }
.about-card summary::-webkit-details-marker { display: none; }
.about-sum { font-weight: 600; }
.about-card[open] summary { margin-bottom: 6px; }
.about-sub { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }
.about-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; margin-bottom: 8px; }
.about-grid .field-label { margin: 0; }
.about-card input[type="text"] {
  width: 100%; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.about-card input[type="text"]:focus { border-color: var(--heat); outline: none; }
.about-card > .field-label { display: block; margin-bottom: 4px; }

.cu-card { display: grid; gap: 10px; }
.cu-card > p { margin: 0; }
.cu-card .send, .cu-card .ghost-btn { justify-self: start; }
.cu-overall { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.cu-overall b { font-family: var(--font-display); font-size: 40px; font-weight: 400; line-height: 1; }
.cu-overall span { color: var(--muted); font-size: 14px; }
.cu-overall em { font-style: normal; font-weight: 700; font-size: 13px; }
.cu-overall em.up { color: var(--good); }
.cu-overall em.down { color: var(--bold); }
.cu-legend { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.cu-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--heat); display: inline-block; }
.cu-legend i.p { background: color-mix(in srgb, var(--ink) 55%, transparent); margin-left: 8px; }
.cu-bars { display: grid; gap: 7px; }
.cu-bar { display: grid; grid-template-columns: minmax(96px, 38%) 1fr auto; align-items: center; gap: 8px; font-size: 13.5px; }
.cu-bar b { font-variant-numeric: tabular-nums; font-size: 13px; }
.cu-track { display: grid; gap: 3px; }
.cu-track i { display: block; height: 7px; border-radius: 999px; background: var(--heat); }
.cu-track i.p { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.cu-sg p { margin: 0 0 4px; font-size: 14.5px; }
.cu-sg .card-label { margin-right: 6px; }
.cu-gap { margin: 0; font-weight: 600; font-size: 14.5px; }
.cu-focus { border-top: 1px dashed var(--line); padding-top: 8px; }
.cu-focus p { margin: 2px 0 0; }
.cu-focus .link-btn { color: var(--heat); text-decoration: none; }
.checkup .cu-q { font-family: var(--font-display); font-size: 26px; line-height: 1.15; margin: 8px 0 14px; }
.cu-who { margin: 0 0 6px; font-weight: 800; color: var(--heat); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; }
.cu-progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.cu-progress i { display: block; height: 100%; background: var(--heat); transition: width .3s; }
.cu-count { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.cu-scale { display: grid; gap: 6px; }
.cu-opt {
  display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer; font: inherit; font-weight: 600; font-size: 15.5px;
  color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.cu-opt b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); font-size: 13px; flex: none; }
.cu-opt:hover, .cu-opt.on { border-color: var(--heat); }
.cu-opt.on b { background: var(--heat); color: var(--on-heat); border-color: var(--heat); }
.cu-choices { display: grid; gap: 8px; margin: 8px 0 12px; }
.cu-choices button { width: 100%; height: 46px; }
.checkup .cu-overall b { font-size: 46px; }
.checkup .cu-plan { margin-top: 10px; }

.q-card { display: grid; gap: 10px; }
.q-text { margin: 0; font-family: var(--font-display); font-size: 25px; line-height: 1.2; text-wrap: balance; }
.q-decks { flex-wrap: wrap; overflow: visible; }
.q-decks .chip { font-size: 12.5px; padding: 6px 11px; }
.q-card .btn-row .ghost-btn, .q-card .btn-row .send { height: 38px; font-size: 13.5px; }
.q-card .done-note { align-self: center; }
.q-list .say { margin: 8px 0; }
.tool-form.compact { border-bottom: 0; padding-top: 4px; }

.situations h3 { margin: 6px 0 2px; font-family: var(--font-display); font-weight: 400; font-size: 28px; }
.sit-group { margin-top: 12px; display: grid; gap: 6px; }
.sit-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sit-chips .chip { white-space: normal; text-align: left; }

.tool-chips { margin: 12px 0 2px; flex-wrap: wrap; overflow: visible; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--heat); margin: 0; }

.sos .breath { display: grid; justify-items: center; gap: 6px; margin: 10px 0 14px; }
.breath-circle {
  width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, color-mix(in srgb, var(--heat) 30%, var(--card)) 0%, color-mix(in srgb, var(--heat) 12%, var(--card)) 70%);
  border: 2px solid color-mix(in srgb, var(--heat) 50%, transparent);
  transform: scale(.72); transition-property: transform; transition-timing-function: ease-in-out;
}
.breath-circle.grow { transform: scale(1); }
.breath-circle.shrink { transform: scale(.72); }
.breath-circle span { font-weight: 700; font-size: 15px; }
.breath-hint { margin: 0 !important; font-size: 13px; color: var(--muted); }
.sos-timer { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 10px 0 12px; }
.timer-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.timer-time { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; flex: 1; }
.timer-row .send, .timer-row .ghost-btn { height: 40px; }
.sos-back { margin: 14px 0 0 !important; }
#sos-repair .say { margin: 8px 0; }
.sos-unsafe { margin-top: 12px !important; font-size: 14px; font-weight: 600; }
.sos-unsafe a { color: var(--bold); }

.lock input#lock-code, #set-lock {
  width: 100%; font: inherit; font-size: 22px; letter-spacing: .3em; text-align: center; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.lock-forgot { display: block; margin: 12px auto 0; font-size: 14px; }
.lock-field { margin: 4px 0 14px; display: grid; gap: 6px; }
.ai-field { margin: 4px 0 14px; display: grid; gap: 6px; justify-items: start; }
.ai-field .sheet-small, .ai-field .note { margin: 0; }
.ai-points { margin: 0 0 10px; padding-left: 1.2em; display: grid; gap: 6px; }
.lock-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#set-lock { flex: 1 1 140px; width: auto; font-size: 18px; padding: 8px 10px; }
.lock-field .sheet-small { margin: 0; font-size: 13px; }
.cu-sg { margin-top: 6px; }

/* Version 5: relationship status */
.status-q { display: block; margin: 12px 0 6px; }
.status-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.status-chips .chip { font-size: 14px; padding: 9px 14px; }
.status-chips .chip[aria-checked="true"] { border-color: var(--heat); box-shadow: inset 0 0 0 1px var(--heat); background: color-mix(in srgb, var(--heat) 8%, var(--card)); }
.status-card { border-color: color-mix(in srgb, var(--heat) 40%, var(--line)); }
.status-card .rem-hint { margin: 4px 0 2px; }
.two-card { display: grid; gap: 10px; }
.two-card .q-text { font-size: 23px; }
.two-card .btn-row .send, .two-card .btn-row .ghost-btn { height: 40px; font-size: 14px; }
.cu-mini { display: grid; gap: 8px; }
.cu-mini p { margin: 0; }
.cu-mini .send, .cu-mini .ghost-btn { justify-self: start; }
