:root {
  --bg: #f6f3ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-soft: #f4f0ff;
  --text: #171526;
  --muted: #69647b;
  --line: rgba(44, 34, 78, 0.12);
  --primary: #6f49d8;
  --primary-dark: #5630b8;
  --primary-soft: #eee7ff;
  --green: #247a52;
  --green-soft: #e7f6ee;
  --amber: #a76600;
  --amber-soft: #fff3dc;
  --red: #b33939;
  --red-soft: #ffe9e9;
  --blue: #2865a8;
  --blue-soft: #e9f2ff;
  --shadow: 0 20px 60px rgba(47, 31, 94, 0.10);
  --radius: 24px;
}

:root[data-theme="dark"] {
  --bg: #12101a;
  --surface: rgba(28, 24, 40, 0.92);
  --surface-solid: #1c1828;
  --surface-soft: #272137;
  --text: #f5f1ff;
  --muted: #b8b0c9;
  --line: rgba(232, 225, 255, 0.12);
  --primary: #a98bff;
  --primary-dark: #c3adff;
  --primary-soft: #322852;
  --green: #79d3a9;
  --green-soft: #1f3b30;
  --amber: #efbd64;
  --amber-soft: #40331e;
  --red: #ff9b9b;
  --red-soft: #432727;
  --blue: #8bbcff;
  --blue-soft: #21354f;
  --shadow: 0 22px 64px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}
button, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 3px; }
[hidden] { display: none !important; }

.ambient { position: fixed; z-index: -1; border-radius: 999px; filter: blur(90px); opacity: .44; pointer-events: none; }
.ambient-one { width: 420px; height: 420px; background: #b59aff; top: -170px; left: -120px; }
.ambient-two { width: 360px; height: 360px; background: #9ee7d3; bottom: -160px; right: -80px; opacity: .24; }

.topbar {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { color: var(--text); text-decoration: none; font-weight: 800; display: inline-flex; align-items: center; gap: 10px; letter-spacing: -0.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(145deg, var(--primary), #8d70e9); color: white; box-shadow: 0 8px 24px rgba(111, 73, 216, .28); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.language-control { min-height: 42px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 0 10px 0 12px; background: var(--surface); color: var(--text); }
.language-icon { color: var(--primary-dark); font-size: 1.05rem; font-weight: 850; line-height: 1; }
.language-select { min-height: 40px; max-width: 125px; border: 0; outline: 0; color: var(--text); background: transparent; cursor: pointer; font-weight: 700; }
.language-select:disabled { opacity: .55; cursor: wait; }
.language-select option { color: #171526; background: #fff; }
.icon-button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }

.page { width: min(900px, calc(100% - 32px)); margin: 40px auto 80px; }
.intro { text-align: center; max-width: 760px; margin: 54px auto 28px; }
.eyebrow { color: var(--primary-dark); font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 12px; }
h1 { font-size: clamp(2.4rem, 7vw, 5.2rem); line-height: .98; letter-spacing: -.055em; margin: 0; }
.subhead { max-width: 680px; margin: 22px auto 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.2rem); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.composer-card { padding: clamp(18px, 4vw, 30px); }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 18px; padding: 20px; resize: vertical; background: var(--surface-solid); color: var(--text); min-height: 190px; }
textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
.composer-meta, .composer-actions, .update-actions { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.composer-meta { margin-top: 10px; color: var(--muted); font-size: .84rem; }
.composer-actions { margin-top: 18px; }
.button { min-height: 48px; border-radius: 14px; padding: 0 18px; border: 1px solid transparent; font-weight: 750; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { color: #fff; background: linear-gradient(145deg, var(--primary), var(--primary-dark)); box-shadow: 0 10px 24px rgba(111, 73, 216, .24); }
.button-ghost { background: transparent; border-color: var(--line); }
.status { min-height: 1.4em; margin: 12px 2px 0; color: var(--red); }

.loading { padding: 34px; display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.loading-mark { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; color: white; font-size: 1.4rem; font-weight: 850; background: linear-gradient(145deg, var(--primary), #8d70e9); animation: pulse 1.6s ease-in-out infinite; }
.loading-label, .card-kicker { color: var(--primary-dark); font-size: .75rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 8px; }
.loading h2 { margin: 0; font-size: clamp(1.15rem, 3vw, 1.7rem); }
.loading-bar { margin-top: 16px; height: 7px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; }
.loading-bar span { display: block; width: 38%; height: 100%; border-radius: inherit; background: var(--primary); animation: loading 1.4s ease-in-out infinite; }

.result-stack { display: grid; gap: 18px; }
.output-card { padding: clamp(22px, 4vw, 34px); }
.lead-card { background: linear-gradient(145deg, color-mix(in srgb, var(--surface-solid) 90%, var(--primary-soft)), var(--surface)); }
.lead-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.lead-heading h2 { margin: 0; font-size: clamp(1.75rem, 4vw, 2.7rem); line-height: 1.08; letter-spacing: -.035em; }
.lead-copy, .recommendation-copy { font-size: clamp(1.03rem, 2vw, 1.18rem); margin: 20px 0 0; color: var(--text); }
.confidence { flex: 0 0 auto; border-radius: 999px; padding: 8px 12px; font-size: .78rem; font-weight: 800; display: inline-flex; gap: 7px; align-items: center; }
.confidence-dot { width: 8px; height: 8px; border-radius: 50%; }
.confidence-high { background: var(--green-soft); color: var(--green); }
.confidence-high .confidence-dot { background: var(--green); }
.confidence-moderate { background: var(--amber-soft); color: var(--amber); }
.confidence-moderate .confidence-dot { background: var(--amber); }
.confidence-low { background: var(--red-soft); color: var(--red); }
.confidence-low .confidence-dot { background: var(--red); }

.recommendation-card { border-color: color-mix(in srgb, var(--green) 30%, var(--line)); }
.step-list { margin: 22px 0 0; padding: 0; counter-reset: steps; display: grid; gap: 12px; list-style: none; }
.step-list li { counter-increment: steps; display: grid; grid-template-columns: 32px 1fr; gap: 11px; align-items: start; }
.step-list li::before { content: counter(steps); width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); font-weight: 850; }

.insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.insight-card { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-solid); }
.insight-card h3, .gap-body h3, .question-body h3 { margin: 0 0 8px; font-size: 1rem; }
.insight-card p, .gap-body p, .question-body p { margin: 0; color: var(--muted); font-size: .92rem; }
.insight-card .why-line { margin-top: 10px; color: var(--text); font-weight: 650; }

.gap-list, .question-list { display: grid; gap: 12px; }
.gap-row, .question-row { display: grid; gap: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-solid); }
.gap-row { grid-template-columns: 140px 1fr; }
.question-row { grid-template-columns: 36px 1fr; }
.priority { align-self: start; border-radius: 999px; padding: 7px 10px; font-size: .72rem; font-weight: 850; text-align: center; }
.priority-decision_changing { color: var(--red); background: var(--red-soft); }
.priority-important { color: var(--amber); background: var(--amber-soft); }
.question-index { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: var(--primary-dark); background: var(--primary-soft); font-weight: 850; }
.source-line { margin-top: 8px !important; font-size: .8rem !important; }

.analysis-details { overflow: hidden; }
.analysis-details summary { min-height: 76px; padding: 0 24px; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; list-style: none; }
.analysis-details summary::-webkit-details-marker { display: none; }
.details-plus { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-dark); font-weight: 850; }
.analysis-details[open] .details-plus { transform: rotate(45deg); }
.details-title { font-weight: 850; }
.details-note { color: var(--muted); font-size: .82rem; }
.analysis-body { border-top: 1px solid var(--line); padding: 26px; }
.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.analysis-section { border: 1px solid var(--line); border-radius: 16px; padding: 17px; background: var(--surface-solid); }
.analysis-section h3 { margin: 0 0 10px; font-size: .95rem; }
.plain-list { margin: 0; padding-inline-start: 20px; display: grid; gap: 8px; }
.positive { border-color: color-mix(in srgb, var(--green) 32%, var(--line)); }
.warning { border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); }
.evidence-list { display: grid; gap: 9px; }
.evidence-row { display: grid; grid-template-columns: 100px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.evidence-row:last-child { border-bottom: 0; }
.evidence-row p { margin: 0; }
.evidence-kind { padding: 5px 8px; border-radius: 999px; font-size: .72rem; font-weight: 800; text-align: center; background: var(--primary-soft); color: var(--primary-dark); }
.confidence-word { color: var(--muted); font-size: .76rem; }

.update-card textarea { min-height: 120px; margin-top: 16px; }
.update-card h2 { margin: 0; font-size: 1.35rem; }
.update-intro { margin: 8px 0 0; color: var(--muted); }
.update-actions { margin-top: 14px; }

.footer { width: min(900px, calc(100% - 32px)); margin: 0 auto 30px; color: var(--muted); text-align: center; font-size: .84rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.empty-note { color: var(--muted); margin: 0; }

@keyframes pulse { 50% { transform: scale(1.06) rotate(2deg); } }
@keyframes loading { 0% { transform: translateX(-120%); } 100% { transform: translateX(330%); } }

@media (max-width: 760px) {
  .page { margin-top: 18px; }
  .intro { margin-top: 30px; text-align: start; }
  h1 { font-size: clamp(2.7rem, 15vw, 4rem); }
  .subhead { margin-left: 0; }
  .composer-actions, .update-actions { align-items: stretch; }
  .composer-actions .button-primary, .update-actions .button-primary { flex: 1; }
  .lead-header { display: grid; }
  .confidence { width: fit-content; }
  .insight-grid, .analysis-grid { grid-template-columns: 1fr; }
  .gap-row { grid-template-columns: 1fr; }
  .priority { width: fit-content; }
  .details-note { display: none; }
  .analysis-details summary { grid-template-columns: auto 1fr; }
  .evidence-row { grid-template-columns: 1fr; }
  .evidence-kind { width: fit-content; }
}

@media (max-width: 480px) {
  .topbar, .page, .footer { width: min(100% - 20px, 900px); }
  .topbar { padding-top: 14px; }
  .brand > span:last-child { display: none; }
  .language-select { max-width: 106px; }
  .composer-card, .output-card { border-radius: 20px; }
  .composer-actions, .update-actions { display: grid; grid-template-columns: 1fr; }
  .button { width: 100%; }
  .question-row { grid-template-columns: 30px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* v2.4 two-mode advisory experience */
.mode-fieldset { margin: 0; padding: 0; border: 0; }
.mode-fieldset legend { width: 100%; margin: 0 0 12px; font-size: .82rem; font-weight: 800; color: var(--muted); }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode-card {
  position: relative;
  min-height: 150px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-solid);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.mode-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.mode-card.is-selected { border-color: color-mix(in srgb, var(--primary) 58%, var(--line)); background: color-mix(in srgb, var(--surface-solid) 84%, var(--primary-soft)); box-shadow: 0 12px 30px rgba(111, 73, 216, .11); }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--primary-dark); background: var(--primary-soft); font-size: 1.2rem; font-weight: 850; }
.mode-copy { display: grid; gap: 7px; }
.mode-copy strong { font-size: 1.02rem; line-height: 1.25; }
.mode-copy span { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.mode-check { width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); color: transparent; background: transparent; font-size: .74rem; font-weight: 900; }
.mode-card.is-selected .mode-check { color: white; background: var(--primary); border-color: var(--primary); }
.situation-divider { height: 1px; background: var(--line); margin: 24px 0; }
.input-heading { display: block; margin: 0 0 12px; font-weight: 850; font-size: 1.05rem; }
.button-secondary { background: var(--primary-soft); color: var(--primary-dark); border-color: color-mix(in srgb, var(--primary) 18%, var(--line)); }
.button-secondary:hover { border-color: color-mix(in srgb, var(--primary) 42%, var(--line)); }

.reading-card { border-color: color-mix(in srgb, var(--blue) 26%, var(--line)); }
.tension-copy { margin: 8px 0 0; color: var(--text); font-size: 1rem; }
.section-label { margin: 24px 0 8px; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.judgment-card { border-color: color-mix(in srgb, var(--green) 32%, var(--line)); background: linear-gradient(145deg, color-mix(in srgb, var(--surface-solid) 91%, var(--green-soft)), var(--surface)); }
.reason-list { margin: 0; padding-inline-start: 20px; display: grid; gap: 9px; }
.reason-list li::marker { color: var(--green); }
.path-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.path-card { border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: var(--surface-solid); }
.path-card h3 { margin: 0 0 14px; font-size: 1.03rem; }
.labeled-text { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.labeled-text:first-of-type { margin-top: 0; }
.labeled-text-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: .74rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.labeled-text p { margin: 0; font-size: .9rem; }
.hinge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.key-question-copy { font-size: 1.08rem; font-weight: 760; margin: 0 0 10px; }
.muted-copy { color: var(--muted); margin: 8px 0 0; }

.progress-card { padding-top: 20px; padding-bottom: 20px; border-color: color-mix(in srgb, var(--blue) 25%, var(--line)); }
.progress-copy { margin: 0; font-size: 1rem; }
.assumption-card { border-color: color-mix(in srgb, var(--amber) 35%, var(--line)); }
.assumption-card h3 { margin: 0; font-size: 1.12rem; }
.question-focus-card { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); background: linear-gradient(145deg, color-mix(in srgb, var(--surface-solid) 88%, var(--primary-soft)), var(--surface)); }
.focus-question { margin: 0; font-size: clamp(1.55rem, 4vw, 2.45rem); line-height: 1.12; letter-spacing: -.03em; }
.why-label { margin: 24px 0 0; color: var(--muted); font-size: .76rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.question-focus-card textarea { min-height: 128px; margin-top: 20px; }
.conversation-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.synthesis-card { border-color: color-mix(in srgb, var(--green) 32%, var(--line)); }
.start-over-card { display: flex; justify-content: center; }

@media (max-width: 760px) {
  .mode-grid, .path-grid, .hinge-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: auto; }
  .conversation-actions { display: grid; grid-template-columns: 1fr; }
  .conversation-actions .button { width: 100%; }
}
