:root {
  --ink: #14213d;
  --muted: #5f6b7a;
  --line: #d8dee7;
  --panel: #ffffff;
  --page: #f4f7f6;
  --soft: #edf4f2;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --blue: #2563eb;
  --orange: #c2410c;
  --red: #b42318;
  --shadow: 0 18px 48px rgba(20, 33, 61, 0.09);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(244, 247, 246, 0.96)),
    var(--page);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 18px;
}

.topbar h1,
.panel-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.08;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-meta span,
.event-count,
.chip,
.rule-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: 18px;
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto 32px;
  align-items: start;
}

.quiz-panel,
.data-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quiz-panel {
  min-height: calc(100vh - 130px);
  padding: 26px;
}

.data-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.panel-heading h2 {
  font-size: 18px;
}

.identity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.identity-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafb;
}

.identity-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.identity-grid strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-actions,
.quiz-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.event-actions {
  margin-bottom: 14px;
}

.event-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100vh - 286px);
  min-height: 360px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.event-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.event-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 850;
}

.event-title span:last-child {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
}

.event-item pre {
  overflow: auto;
  max-height: 190px;
  margin: 0;
  color: #334155;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaef;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width 180ms ease;
}

.step-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.question-block {
  max-width: 940px;
}

.question-kicker {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 850;
}

.question-title {
  max-width: 760px;
  margin: 0;
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: 0;
}

.question-subtitle {
  max-width: 640px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.option-button {
  position: relative;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease,
    background 150ms ease;
}

.option-button:hover {
  border-color: rgba(15, 118, 110, 0.65);
  box-shadow: 0 12px 30px rgba(20, 33, 61, 0.1);
  transform: translateY(-1px);
}

.option-button.is-selected {
  border-color: var(--teal);
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.option-button strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
  line-height: 1.25;
}

.option-button span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.option-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: #e6f2f0;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.quiz-actions {
  justify-content: space-between;
  margin-top: 28px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 15px;
  font-weight: 850;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.primary-button:disabled {
  border-color: #b8c4cf;
  background: #b8c4cf;
  cursor: not-allowed;
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: #aeb8c4;
  background: #f8fafb;
}

.ghost-button {
  min-height: 36px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.ghost-button.danger {
  color: var(--red);
}

.email-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 0.7fr);
  gap: 26px;
  align-items: start;
}

.email-form {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.email-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.email-form input[type="email"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
}

.email-form input[type="email"]:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--teal);
}

.checkbox-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.checkbox-line input {
  margin-top: 3px;
}

.answer-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fafb;
}

.answer-summary h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.answer-summary dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.answer-summary div {
  display: grid;
  gap: 3px;
}

.answer-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.answer-summary dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.result-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 24px;
}

.result-header h2 {
  max-width: 720px;
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.product-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.product-card:first-child {
  border-color: rgba(15, 118, 110, 0.62);
  box-shadow: 0 14px 32px rgba(15, 118, 110, 0.12);
}

.product-media {
  display: grid;
  place-items: center;
  aspect-ratio: 1.18;
  padding: 16px;
  background:
    linear-gradient(150deg, rgba(15, 118, 110, 0.1), rgba(37, 99, 235, 0.08)),
    #f7faf9;
}

.product-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: #e9eef4;
  color: var(--ink);
  font-size: 30px;
  font-weight: 900;
}

.product-card.has-image-error .product-media img {
  display: none;
}

.product-card.has-image-error .product-fallback {
  display: flex;
}

.product-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 15px;
}

.rank-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.product-body h3 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0;
}

.product-body p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: #f8fafb;
  color: #405064;
  font-size: 12px;
  font-weight: 750;
}

.product-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.product-actions a,
.product-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.product-actions a {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.product-actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.rule-detail {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fafb;
}

.rule-detail h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.rule-detail p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .data-panel {
    position: static;
  }

  .event-log {
    height: 380px;
  }
}

@media (max-width: 820px) {
  .topbar,
  .app-shell {
    width: min(100% - 28px, 720px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .quiz-panel {
    min-height: auto;
    padding: 18px;
  }

  .question-title,
  .result-header h2 {
    font-size: 28px;
  }

  .email-layout,
  .result-header,
  .product-grid {
    grid-template-columns: 1fr;
  }

  .product-media {
    aspect-ratio: 1.45;
  }
}

@media (max-width: 540px) {
  .topbar h1 {
    font-size: 25px;
  }

  .option-grid {
    grid-template-columns: 1fr;
  }

  .quiz-actions,
  .result-actions,
  .product-actions {
    grid-template-columns: 1fr;
  }

  .quiz-actions {
    flex-direction: column-reverse;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
