:root {
  --primary: #6757d9;
  --primary-dark: #3f348f;
  --primary-light: #b8aff5;
  --bg-start: #f7f5ff;
  --bg-end: #e3e8ff;
  --surface: #fff;
  --text: #23313d;
  --muted: #6b7782;
  --line: rgba(25, 40, 55, .12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
}
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary), white 45%); outline-offset: 2px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px max(16px, calc((100vw - 980px) / 2));
  background: rgba(255, 255, 255, .78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { margin-right: auto; color: var(--primary-dark); text-decoration: none; font-weight: 850; }
.topbar-note { color: var(--muted); font-size: .86rem; }

.shell { width: min(920px, calc(100% - 28px)); margin: 24px auto 56px; }
.page {
  display: none;
  min-height: 670px;
  padding: clamp(24px, 5vw, 52px);
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 26px;
  box-shadow: 0 24px 70px rgba(31, 50, 68, .12);
}
.page.active { display: flex; flex-direction: column; animation: enter .35s ease-out; }
.centered { align-items: center; justify-content: center; text-align: center; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.hero-mark { font-size: 4rem; line-height: 1; color: var(--primary); }
.eyebrow { margin: 12px 0 8px; color: var(--primary-dark); font-size: .76rem; font-weight: 850; letter-spacing: .16em; }
.eyebrow.light { color: rgba(255, 255, 255, .8); }
h1 { max-width: 700px; margin: 0; color: var(--primary-dark); font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.08; }
h2 { margin: 0 0 16px; }
h3 { margin: 0 0 15px; color: var(--primary-dark); font-size: 1.04rem; }
.subtitle { max-width: 650px; margin: 18px auto 32px; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }
.muted, .disclaimer { color: var(--muted); }
.disclaimer { margin-top: 22px; font-size: .78rem; }

.feature-grid, .result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; }
.feature-grid { margin-bottom: 34px; }
.feature-grid article, .content-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, .75);
}
.feature-grid article { text-align: left; }
.feature-grid strong, .feature-grid span { display: block; }
.feature-grid span { margin-top: 5px; color: var(--muted); font-size: .86rem; line-height: 1.5; }

.primary-button, .secondary-button, .download-link {
  min-height: 48px;
  padding: 13px 28px;
  border-radius: 999px;
  border: 0;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}
.primary-button { color: white; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 10px 22px color-mix(in srgb, var(--primary), transparent 70%); }
.secondary-button { color: var(--text); background: #eef2f4; }
.compact { min-width: 130px; }

#auth-code {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}

.quiz-head, .quiz-actions, .bottom-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.quiz-head { color: var(--muted); font-weight: 700; }
.progress { height: 9px; margin: 14px 0 44px; overflow: hidden; border-radius: 99px; background: rgba(0, 0, 0, .08); }
#progress-fill { height: 100%; width: 0; border-radius: inherit; background: var(--primary); transition: width .25s; }
.question { min-height: 75px; margin-bottom: 28px; text-align: center; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.5; }
.options { display: grid; gap: 12px; }
.option {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, .82);
  text-align: left;
}
.option-index { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #edf1f2; font-weight: 850; }
.option.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary), white 91%); }
.option.selected .option-index { color: white; background: var(--primary); }
.quiz-actions { margin-top: auto; padding-top: 32px; }
.spinner { width: 72px; height: 72px; margin-bottom: 24px; border: 7px solid rgba(0, 0, 0, .08); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-page { padding: 0; overflow: hidden; }
.result-capture { padding: clamp(18px, 4vw, 34px); background: linear-gradient(160deg, var(--bg-start), #fff 44%, var(--bg-end)); }
.result-hero { position: relative; padding: 38px 28px; border-radius: 22px; color: white; text-align: center; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); overflow: hidden; }
.result-hero::after { content: ""; position: absolute; right: -70px; bottom: -100px; width: 260px; height: 260px; border: 45px solid rgba(255, 255, 255, .08); border-radius: 50%; }
#result-main { position: relative; z-index: 1; margin: 0; font-size: clamp(2.1rem, 6vw, 4.1rem); }
#result-meta, #result-quote, .tags { position: relative; z-index: 1; }
#result-quote { max-width: 670px; margin: 22px auto 0; padding-top: 17px; border-top: 1px solid rgba(255, 255, 255, .25); opacity: .92; }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.tag { padding: 6px 11px; border-radius: 99px; background: rgba(255, 255, 255, .18); font-size: .82rem; }
.result-grid { margin-top: 17px; align-items: start; }
#methods-card, #actions-card { grid-column: 1 / -1; }
.content-card { background: rgba(255, 255, 255, .9); }
.chart-wrap { position: relative; height: 310px; }
.dimension-list { display: grid; gap: 9px; margin-top: 14px; }
.dimension-row { display: grid; grid-template-columns: 90px 1fr 36px; align-items: center; gap: 9px; font-size: .84rem; }
.dimension-bar { height: 8px; overflow: hidden; border-radius: 9px; background: #edf0f2; }
.dimension-bar span { display: block; height: 100%; background: var(--primary); }
.rich-copy { margin-bottom: 22px; color: #44515b; line-height: 1.75; }
.rich-copy .highlight { color: var(--primary-dark); font-weight: 800; }
.action-list { display: grid; gap: 10px; padding-left: 24px; line-height: 1.55; }
.method-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.method-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-align: left; }
.method-card h4 { margin: 9px 0; color: var(--primary-dark); font-size: 1rem; }
.method-card p, .method-card ol { color: #44515b; font-size: .86rem; line-height: 1.6; }
.method-card ol { margin: 10px 0; padding-left: 20px; }
.method-card small { display: block; color: var(--muted); line-height: 1.5; }
.method-priority { color: var(--primary-dark); font-size: .75rem; font-weight: 800; }
.bottom-actions { padding: 18px 24px 28px; background: #fff; }

dialog { width: min(430px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 24px 90px rgba(0, 0, 0, .28); }
dialog:not([open]) { display: none; }
dialog::backdrop { background: rgba(15, 25, 35, .56); backdrop-filter: blur(5px); }
html.dialog-fallback-open { overflow: hidden; }
html.dialog-fallback-open body::before { content: ""; position: fixed; inset: 0; z-index: 999; background: rgba(15, 25, 35, .56); }
dialog.dialog-fallback { display: block; position: fixed; inset: 50% auto auto 50%; z-index: 1000; max-height: calc(100vh - 28px); margin: 0; overflow: auto; transform: translate(-50%, -50%); }
.dialog-card, .poster-dialog-card { position: relative; display: grid; gap: 14px; padding: 30px; }
.dialog-card label { font-weight: 750; }
.purchase-box { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--primary), white 94%); }
.purchase-box p { margin: 7px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.purchase-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.purchase-actions .secondary-button { display: inline-grid; min-height: 40px; padding: 9px 16px; place-items: center; }
.dialog-close { position: absolute; top: 9px; right: 12px; border: 0; background: transparent; font-size: 1.7rem; }
.error { min-height: 1.2em; margin: 0; color: #c93131; }
.text-link { color: var(--primary-dark); text-align: center; }
code { padding: 3px 6px; border-radius: 5px; background: #f0f2f4; }
.poster-dialog-card { max-height: 90vh; overflow: auto; }
#poster-image { width: 100%; border: 1px solid var(--line); border-radius: 10px; }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  .topbar-note { font-size: .78rem; }
  .shell { width: 100%; margin: 0; }
  .page { min-height: calc(100vh - 58px); border-radius: 0; padding: 24px 18px; }
  .feature-grid, .result-grid { grid-template-columns: 1fr; }
  .method-list { grid-template-columns: 1fr; }
  .feature-grid { gap: 10px; }
  .progress { margin-bottom: 32px; }
  .bottom-actions { position: sticky; bottom: 0; }
}
