:root {
  --bg: #f3efe8;
  --ink: #1f2a2e;
  --muted: #67747a;
  --line: #e6e0d6;
  --card: #ffffff;
  --screen: #fbf9f5;
  --teal: #1f6f6b;
  --teal-soft: #e2efed;
  --amber-soft: #f7ead8;
  --amber-ink: #8a5418;
  --green: #2e9e5b;
  --red: #d94a4a;
  --call-bg: linear-gradient(180deg, #1d4e4b 0%, #10292a 55%, #0b1819 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  display: flex;
  justify-content: center;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
[hidden] { display: none !important; }

/* Phone: the app fills the screen. Wider screens: a phone-sized card in the middle. */
.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: var(--screen);
  transition: background 0.4s ease, color 0.4s ease;
}
@media (min-width: 640px) {
  body { align-items: center; padding: 32px 16px; }
  .app {
    min-height: min(800px, calc(100dvh - 64px));
    border-radius: 32px;
    padding: 24px 28px;
    box-shadow: 0 18px 40px rgba(31, 42, 46, 0.14);
  }
}
.app.calling { background: var(--call-bg); color: #fff; }

/* Personality selector */
.top { position: relative; z-index: 2; display: flex; justify-content: center; }
.persona { position: relative; }
.calling .persona { visibility: hidden; }
.persona-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); box-shadow: 0 1px 3px rgba(31, 42, 46, 0.08); text-align: left;
}
.persona-btn .dot { width: 34px; height: 34px; font-size: 15px; }
.persona-text { display: flex; flex-direction: column; line-height: 1.2; }
.persona-label { font-size: 11px; color: var(--muted); }
.persona-name { font-size: 15px; font-weight: 700; }
.chevron { width: 20px; height: 20px; color: var(--muted); transition: transform 0.2s ease; }
.persona-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.persona-menu {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: min(340px, calc(100vw - 32px)); padding: 6px; list-style: none;
  border: 1px solid var(--line); border-radius: 18px; background: var(--card);
  box-shadow: 0 18px 40px rgba(31, 42, 46, 0.18);
}
.persona-menu li { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; }
.persona-menu li:hover, .persona-menu li:focus-visible { background: #f4f0ea; outline: none; }
.persona-menu li[aria-selected="true"] { background: var(--teal-soft); }
.persona-menu .dot { flex: none; width: 42px; height: 42px; font-size: 18px; }
.opt-name { font-size: 15px; font-weight: 700; }
.opt-style { margin-top: 1px; font-size: 13px; color: var(--muted); }
.dot { display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; }
.dot.emoji { font-size: 20px; }
.persona-menu .dot.emoji { font-size: 24px; }

/* Coach and call status */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 0; text-align: center; }
.avatar-wrap { position: relative; display: grid; place-items: center; width: 200px; height: 200px; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(31, 111, 107, 0.14); }
.ring.r2 { inset: 24px; border-color: rgba(31, 111, 107, 0.26); }
.calling .ring { border-color: rgba(120, 220, 205, 0.28); }
.calling .ring.r2 { border-color: rgba(120, 220, 205, 0.5); }
.avatar-wrap.speaking .ring { animation: pulse 1.6s ease-in-out infinite; }
.avatar-wrap.speaking .ring.r2 { animation-delay: 0.25s; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.06); opacity: 0.55; } }
.avatar { display: grid; place-items: center; width: 120px; height: 120px; border-radius: 50%; color: #fff; font-size: 50px; font-weight: 700; }
.teal { background: linear-gradient(135deg, #3a9a92, #175450); }
.amber { background: linear-gradient(135deg, #e5a95a, #b46b20); }
.apple { background: linear-gradient(135deg, #a7d971, #4f9a2e); }
.avatar.emoji { font-size: 66px; }

/* Expressive coaches: current mood on the avatar */
.mood {
  position: absolute; right: 26px; bottom: 30px; display: grid; place-items: center;
  width: 54px; height: 54px; border-radius: 50%; background: #fff; font-size: 30px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); animation: pop 0.35s ease;
}
@keyframes pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
.caption .direction { margin-right: 0.3em; font-style: italic; opacity: 0.6; }

.name { margin-top: 18px; font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.sub { margin-top: 6px; font-size: 14px; color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--teal-soft); color: var(--teal); font-size: 11.5px; font-weight: 600; vertical-align: 1px; }
.session { margin-top: 18px; font-size: 15px; font-weight: 600; }
.status { margin-top: 6px; min-height: 20px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.caption { max-width: 360px; margin-top: 22px; padding: 14px 16px; border-radius: 16px; background: rgba(255, 255, 255, 0.1); font-size: 15px; line-height: 1.45; }
.note { max-width: 360px; margin-top: 18px; padding: 12px 14px; border-radius: 14px; background: var(--amber-soft); color: var(--amber-ink); font-size: 14px; line-height: 1.45; }
.note.error { background: #fbe4e4; color: #8f2a2a; }
.calling .sub, .calling .status { color: rgba(255, 255, 255, 0.72); }
.calling .tag { background: rgba(255, 255, 255, 0.14); color: #d3f1ec; }

/* Buttons */
.controls { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.buttons { display: flex; justify-content: center; align-items: flex-start; gap: 48px; width: 100%; }
.call-btn {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  width: 100%; max-width: 360px; padding: 16px; border: 0; border-radius: 18px;
  background: var(--green); color: #fff; font-size: 17px; font-weight: 700;
}
.call-btn svg { width: 22px; height: 22px; }
.round { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: none; font-size: 12.5px; color: rgba(255, 255, 255, 0.8); }
.round svg { width: 64px; height: 64px; padding: 18px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); color: #fff; }
.round[aria-pressed="true"] svg { background: #fff; color: var(--ink); }
.round.end svg { background: var(--red); }
.disclaimer { font-size: 12px; line-height: 1.4; color: var(--muted); text-align: center; }
.calling .disclaimer { color: rgba(255, 255, 255, 0.6); }
.linkish { border: 0; background: none; font-size: 12px; color: var(--muted); text-decoration: underline; }
.calling .linkish { visibility: hidden; }

/* First-visit notice */
dialog {
  width: min(420px, calc(100% - 32px)); margin: auto; padding: 24px; border: 0; border-radius: 24px;
  background: var(--screen); color: var(--ink); box-shadow: 0 24px 60px rgba(31, 42, 46, 0.3);
}
dialog::backdrop { background: rgba(31, 42, 46, 0.45); backdrop-filter: blur(3px); }
dialog h2 { font-size: 22px; letter-spacing: -0.01em; }
.checklist { list-style: none; margin-top: 12px; }
.checklist li { position: relative; padding: 9px 0 9px 26px; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.4; }
.checklist li::before { content: "✓"; position: absolute; left: 2px; top: 9px; color: var(--teal); font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; font-size: 14px; font-weight: 600; }
.field input { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font: inherit; font-weight: 400; }
.agree { display: flex; gap: 10px; align-items: center; margin-top: 16px; font-size: 14px; font-weight: 600; }
.agree input { width: 20px; height: 20px; accent-color: var(--teal); }
.form-error { margin-top: 12px; font-size: 13px; color: #8f2a2a; }
.primary { width: 100%; margin-top: 16px; padding: 14px; border: 0; border-radius: 14px; background: var(--teal); color: #fff; font-size: 15px; font-weight: 600; }
