:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #64706d;
  --paper: #fffdf8;
  --canvas: #f2efe7;
  --line: #dcd8ce;
  --brand: #0f6b58;
  --brand-deep: #102a25;
  --brand-soft: #dff2eb;
  --gold: #f2b84b;
  --gold-soft: #fff1cf;
  --danger: #a43a32;
  --surface: #ffffff;
  --surface-soft: rgba(255, 253, 248, 0.94);
  --field-label: #40504c;
  --script-ink: #382e16;
  --script-label: #71591e;
  --coach-bg: #edf5f2;
  --coach-ink: #23483f;
  --soft-line: #ebe7dd;
  --shadow: 0 18px 50px rgba(16, 42, 37, 0.12);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef5f2;
  --muted: #a7b4b0;
  --paper: #14231f;
  --canvas: #091310;
  --line: #30443e;
  --brand: #55cba6;
  --brand-deep: #07100e;
  --brand-soft: #173b32;
  --gold: #e8b84f;
  --gold-soft: #382d18;
  --danger: #ff928a;
  --surface: #172823;
  --surface-soft: rgba(20, 35, 31, 0.96);
  --field-label: #c4d1cd;
  --script-ink: #f6e8c6;
  --script-label: #e8c66f;
  --coach-bg: #17352e;
  --coach-ink: #cce9df;
  --soft-line: #2a3d37;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(242, 184, 75, 0.17), transparent 28rem),
    linear-gradient(180deg, #f8f5ed 0%, var(--canvas) 100%);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(15, 107, 88, 0.28);
  outline-offset: 2px;
}

.hidden { display: none !important; }
.app-shell { width: min(100%, 760px); margin: 0 auto; min-height: 100dvh; }

.topbar {
  min-height: 72px;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle { font-size: 18px; line-height: 1; }

.brand-button {
  display: flex;
  gap: 11px;
  align-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--brand-deep);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 7px 16px rgba(16, 42, 37, 0.2);
}

.brand-button strong, .brand-button small { display: block; }
.brand-button strong { font-size: 14px; letter-spacing: -0.01em; }
.brand-button small { margin-top: 1px; color: var(--muted); font-size: 11px; }

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  color: var(--ink);
  font-weight: 800;
}

#app { padding: 8px 16px calc(28px + env(safe-area-inset-bottom)); }

.welcome { padding: 34px 2px 10px; }
.welcome-hero { margin-bottom: 30px; }
.eyebrow {
  display: inline-block;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 640px;
  margin: 12px 0 13px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(37px, 10vw, 58px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.welcome-hero p { max-width: 570px; color: var(--muted); line-height: 1.55; font-size: 15px; }

.privacy-pill {
  width: fit-content;
  margin-top: 18px;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: #28564d;
  font-size: 12px;
  font-weight: 700;
}

.card {
  border: 1px solid rgba(220, 216, 206, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.start-card { padding: 22px; }
.start-card h2 { margin-bottom: 6px; font-family: Georgia, serif; font-size: 24px; }
.start-card > p { color: var(--muted); font-size: 13px; line-height: 1.45; }

.field-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field span { font-size: 12px; font-weight: 750; color: #40504c; }
.field b { color: var(--danger); }

input[type="text"], input[type="tel"], input[type="date"], input[type="time"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  padding: 13px 14px;
  line-height: 1.35;
  resize: vertical;
}

textarea::placeholder, input::placeholder { color: #9a9f9c; }

.button-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.button {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}
.button.primary { border-color: var(--brand); background: var(--brand); color: #fff; box-shadow: 0 9px 18px rgba(15,107,88,.18); }
.button.secondary { background: var(--brand-soft); border-color: transparent; color: #174b40; }
.button.ghost { background: transparent; }
.button.full { width: 100%; }
.start-card .button { margin-top: 18px; }

.resume-card { margin-bottom: 14px; padding: 17px; display: grid; gap: 12px; background: var(--brand-deep); color: white; }
.resume-card p { margin: 0; color: rgba(255,255,255,.74); font-size: 12px; }
.resume-card .button { margin: 0; border: 0; }

.progress-wrap { margin: 4px 2px 17px; }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 750; }
.progress-track { height: 5px; overflow: hidden; border-radius: 99px; background: #ddd9cf; }
.progress-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #27a27f); transition: width .25s ease; }

.conversation-card { padding: 21px; }
.stage-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 17px; }
.stage-number { color: var(--muted); font-size: 11px; font-weight: 750; }
.conversation-card h1 { margin: 0 0 18px; font-family: Georgia, serif; font-size: clamp(29px, 7.5vw, 43px); line-height: 1.06; letter-spacing: -0.035em; }

.script-card {
  position: relative;
  margin: 0 0 18px;
  padding: 17px 16px 15px 18px;
  border-left: 4px solid var(--gold);
  border-radius: 4px 14px 14px 4px;
  background: var(--gold-soft);
}
.script-card span { display: block; margin-bottom: 6px; color: #71591e; font-size: 10px; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.script-card p { margin: 0; color: #382e16; line-height: 1.52; font-size: 15px; }

.hint { margin: -5px 0 17px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.options { display: grid; gap: 9px; margin: 2px 0 19px; }
.option {
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.option:active { transform: scale(.992); }
.option.selected { border-color: var(--brand); background: var(--brand-soft); }
.option-control {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin-top: 1px;
  border: 2px solid #aeb5b1;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  font-weight: 900;
}
.multi .option-control { border-radius: 6px; }
.option.selected .option-control { border-color: var(--brand); background: var(--brand); }
.option-copy strong { display: block; font-size: 14px; line-height: 1.35; }
.option-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; }

.coach-card { margin: -7px 0 18px; padding: 13px 14px; border-radius: 13px; background: #edf5f2; color: #23483f; font-size: 12px; line-height: 1.48; }
.coach-card strong { display: block; margin-bottom: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }

.notes-panel { border-top: 1px solid var(--line); padding-top: 17px; }
.notes-toggle { border: 0; background: transparent; padding: 0; color: var(--brand); font-size: 12px; font-weight: 800; }
.notes-fields { display: grid; gap: 12px; margin-top: 13px; }

.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin-top: 12px;
  padding: 11px 0 max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--canvas) 25%);
}
.action-bar .button { margin-top: 12px; }
.micro-actions { display: flex; justify-content: center; gap: 18px; margin-top: 5px; }
.link-button { border: 0; background: transparent; color: var(--muted); padding: 8px 2px; font-size: 11px; font-weight: 750; text-decoration: underline; text-decoration-color: transparent; }
.link-button:hover { text-decoration-color: currentColor; }

.terminal-card { padding: 24px; }
.outcome-badge { display: inline-flex; padding: 7px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 850; text-transform: uppercase; }
.terminal-card h1 { font-size: 38px; margin-top: 14px; }
.terminal-card > p { color: var(--muted); line-height: 1.55; }

.report { padding: 2px 0 30px; }
.report-header { margin: 18px 2px 18px; }
.report-header h1 { font-size: 42px; }
.report-header p { color: var(--muted); }
.report-grid { display: grid; gap: 12px; }
.report-section { padding: 18px; }
.report-section h2 { margin-bottom: 12px; font-family: Georgia, serif; font-size: 21px; }
.report-list { display: grid; gap: 10px; }
.report-row { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid #ebe7dd; }
.report-row:last-child { padding-bottom: 0; border-bottom: 0; }
.report-row strong { color: var(--muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.report-row span { font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 15px; }
.report-actions .primary { grid-column: 1 / -1; }

.sheet-dialog {
  width: min(100% - 20px, 620px);
  max-height: min(86dvh, 760px);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  box-shadow: 0 -20px 70px rgba(0,0,0,.2);
}
.sheet-dialog::backdrop { background: rgba(8,20,18,.55); backdrop-filter: blur(3px); }
.dialog-card { padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); overflow-y: auto; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.dialog-header h2 { margin: 4px 0 0; font-family: Georgia, serif; font-size: 25px; }
.dialog-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dialog-option { min-height: 80px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: white; text-align: left; font-weight: 800; }
.dialog-option small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1.35; }
.check-row { display: flex; gap: 10px; align-items: center; margin: 15px 0; font-size: 13px; font-weight: 700; }
.compact-dialog { display: grid; gap: 8px; }
.menu-action { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #fff; text-align: left; font-weight: 750; }
.danger-text { color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20; transform: translate(-50%, 18px); padding: 10px 14px; border-radius: 999px; background: var(--brand-deep); color: white; font-size: 12px; font-weight: 750; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 8% 0%, rgba(232, 184, 79, 0.09), transparent 28rem),
    linear-gradient(180deg, #101d19 0%, var(--canvas) 100%);
}

:root[data-theme="dark"] .brand-mark { background: #0f342b; }
:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="tel"],
:root[data-theme="dark"] input[type="date"],
:root[data-theme="dark"] input[type="time"],
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .button,
:root[data-theme="dark"] .option,
:root[data-theme="dark"] .dialog-option,
:root[data-theme="dark"] .menu-action { background: var(--surface); color: var(--ink); }
:root[data-theme="dark"] .privacy-pill { color: #bfe4d8; }
:root[data-theme="dark"] .field span { color: var(--field-label); }
:root[data-theme="dark"] .script-card span { color: var(--script-label); }
:root[data-theme="dark"] .script-card p { color: var(--script-ink); }
:root[data-theme="dark"] .coach-card { background: var(--coach-bg); color: var(--coach-ink); }
:root[data-theme="dark"] .report-row { border-bottom-color: var(--soft-line); }
:root[data-theme="dark"] .button.primary { background: var(--brand); color: #07130f; }
:root[data-theme="dark"] .button.secondary { background: var(--brand-soft); color: #c6ebe0; }
:root[data-theme="dark"] .option.selected { background: var(--brand-soft); }
:root[data-theme="dark"] .option.selected .option-control { color: #07130f; }
:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: #74837e; }
:root[data-theme="dark"] .sheet-dialog::backdrop { background: rgba(0, 0, 0, 0.72); }

@media (min-width: 620px) {
  #app { padding-left: 26px; padding-right: 26px; }
  .topbar { padding-left: 28px; padding-right: 28px; }
  .field-grid.two { grid-template-columns: 1fr 1fr; }
  .conversation-card { padding: 30px; }
  .report-grid { grid-template-columns: 1fr 1fr; }
  .report-section.full { grid-column: 1 / -1; }
  .sheet-dialog { margin-bottom: auto; border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
