:root {
  --green-950: #203313;
  --green-900: #2f481b;
  --green-800: #3e5f22;
  --green-700: #4d712c;
  --green-600: #62893a;
  --green-200: #d9e7cd;
  --green-100: #eaf2e4;
  --green-50: #f5f8f2;
  --ink: #182016;
  --muted: #5d6858;
  --line: #d9ded5;
  --surface: #ffffff;
  --surface-soft: #f8faf6;
  --warning: #8a4f05;
  --warning-bg: #fff7e8;
  --danger: #8a2d27;
  --danger-bg: #fff0ed;
  --blue: #244a86;
  --blue-bg: #edf4ff;
  --shadow-sm: 0 4px 14px rgba(28, 51, 16, 0.08);
  --shadow-md: 0 16px 44px rgba(28, 51, 16, 0.13);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #e7ede2;
  scroll-behavior: smooth;
}

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(119, 153, 74, 0.18), transparent 28rem),
    linear-gradient(180deg, #edf3e9 0%, #e7ede2 100%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #fff;
  color: var(--green-950);
  box-shadow: var(--shadow-md);
  font-weight: 800;
}

.skip-link:focus {
  top: 1rem;
}

.app-shell {
  width: min(100%, 960px);
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 60px rgba(30, 51, 18, 0.10);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 94px;
  padding: calc(0.65rem + env(safe-area-inset-top)) clamp(1rem, 4vw, 2.25rem) 0.65rem;
  border-bottom: 1px solid rgba(62, 95, 34, 0.18);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.brand-group {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.9rem;
}

.brand-logo {
  width: 66px;
  height: 66px;
  flex: 0 0 66px;
  border: 1px solid #d7dfd1;
  border-radius: 17px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 4px 12px rgba(42, 75, 24, 0.09);
}

.brand-copy {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.2rem;
  color: var(--green-700);
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  line-height: 1.2;
  text-transform: uppercase;
}

.brand-copy h1 {
  margin: 0;
  color: var(--green-950);
  font-size: clamp(1.42rem, 5vw, 1.85rem);
  font-weight: 900;
  letter-spacing: 0.025em;
  line-height: 1;
}

.brand-subtitle {
  margin: 0.25rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--green-900);
  font-size: 1.12rem;
  font-weight: 850;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.icon-button:hover {
  border-color: var(--green-600);
  background: var(--green-50);
}

.icon-button:active {
  transform: scale(0.96);
}

main {
  min-height: 520px;
  padding: clamp(1.1rem, 4vw, 2.4rem) clamp(1rem, 4vw, 2.25rem) 2rem;
  outline: none;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: screen-in 220ms ease both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: clamp(1.35rem, 5vw, 2.6rem);
  border: 1px solid rgba(62, 95, 34, 0.20);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(240, 247, 235, 0.94)),
    var(--surface);
  box-shadow: var(--shadow-md);
}

.hero-card::after {
  position: absolute;
  right: -3.5rem;
  bottom: -5.5rem;
  width: 13rem;
  height: 13rem;
  border: 2.8rem solid rgba(93, 132, 51, 0.09);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.hero-card h2,
.question-heading h2,
.results-heading h2,
.dialog-card h2 {
  margin: 0;
  color: var(--green-950);
  font-size: clamp(1.75rem, 7vw, 2.65rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.hero-lead {
  max-width: 43rem;
  margin: 0.9rem 0 0;
  color: #3d4839;
  font-size: clamp(1rem, 3.7vw, 1.14rem);
  line-height: 1.62;
}

.scope-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 1.5rem 0;
}

.scope-grid div {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.85rem 0.55rem;
  border: 1px solid #dce7d4;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.83);
  color: var(--green-900);
  text-align: center;
  box-shadow: 0 3px 10px rgba(46, 75, 27, 0.04);
}

.scope-grid span {
  font-size: 1.45rem;
}

.scope-grid strong {
  font-size: 0.86rem;
  line-height: 1.22;
}

.hero-actions,
.result-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.primary-button,
.secondary-button {
  min-height: 50px;
  padding: 0.82rem 1.2rem;
  border-radius: 13px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button {
  border: 1px solid var(--green-800);
  background: linear-gradient(180deg, var(--green-700), var(--green-800));
  color: #fff;
  box-shadow: 0 8px 18px rgba(62, 95, 34, 0.22);
}

.primary-button:hover {
  background: linear-gradient(180deg, #587d33, #36541e);
  box-shadow: 0 10px 22px rgba(62, 95, 34, 0.27);
}

.secondary-button {
  border: 1px solid #c9d6c0;
  background: #fff;
  color: var(--green-900);
}

.secondary-button:hover {
  border-color: var(--green-600);
  background: var(--green-50);
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
.option-card:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(47, 91, 153, 0.38);
  outline-offset: 3px;
}

.data-note {
  display: flex;
  gap: 0.85rem;
  margin-top: 1rem;
  padding: 1rem 1.05rem;
  border: 1px solid #dce5d6;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
}

.data-note-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-800);
  font-weight: 900;
}

.data-note strong {
  color: var(--green-950);
}

.data-note p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.wizard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.text-button {
  min-height: 42px;
  padding: 0.4rem 0.15rem;
  border: 0;
  background: transparent;
  color: var(--green-800);
  font-weight: 800;
  cursor: pointer;
}

.step-counter {
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.progress-track {
  height: 7px;
  margin: 0.4rem 0 1.55rem;
  overflow: hidden;
  border-radius: 99px;
  background: #dce5d7;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-700), #7ca448);
  transition: width 240ms ease;
}

.question-panel {
  max-width: 760px;
  margin: 0 auto;
}

.question-heading {
  margin-bottom: 1.1rem;
}

.question-heading h2 {
  font-size: clamp(1.55rem, 6vw, 2.35rem);
}

.question-help {
  margin: 0.7rem 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.72rem;
}

.option-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 24px;
  min-height: 86px;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.option-card:hover {
  transform: translateY(-1px);
  border-color: #8aa873;
  background: var(--green-50);
  box-shadow: 0 8px 20px rgba(35, 63, 21, 0.11);
}

.option-card.selected {
  border-color: var(--green-700);
  background: var(--green-100);
  box-shadow: 0 0 0 2px rgba(77, 113, 44, 0.13);
}

.option-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 13px;
  background: var(--green-100);
  font-size: 1.4rem;
}

.option-copy {
  display: block;
  min-width: 0;
}

.option-title {
  display: block;
  color: var(--green-950);
  font-weight: 850;
  line-height: 1.24;
}

.option-description {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.38;
}

.option-arrow {
  color: var(--green-700);
  font-size: 1.65rem;
  line-height: 1;
}

.results-heading {
  margin-bottom: 1.25rem;
}

.results-heading h2 {
  font-size: clamp(1.65rem, 6vw, 2.45rem);
}

.results-heading > p:not(.section-kicker) {
  margin: 0.65rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.answer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.8rem;
}

.answer-chips span {
  padding: 0.4rem 0.62rem;
  border: 1px solid #d5e1cd;
  border-radius: 999px;
  background: #f3f8ef;
  color: var(--green-900);
  font-size: 0.76rem;
  font-weight: 750;
}

.results-list {
  display: grid;
  gap: 1rem;
}

.result-card {
  position: relative;
  overflow: hidden;
  padding: clamp(1rem, 4vw, 1.45rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.result-card.top-result {
  border-color: rgba(77, 113, 44, 0.55);
  box-shadow: var(--shadow-md);
}

.result-card.top-result::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--green-700), #88aa50);
  content: "";
}

.result-rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.result-rank {
  color: var(--green-700);
  font-size: 0.69rem;
  font-weight: 900;
  letter-spacing: 0.11em;
}

.fit-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.32rem 0.58rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 850;
}

.fit-very {
  background: #deefcf;
  color: #294816;
}

.fit-suitable {
  background: var(--blue-bg);
  color: var(--blue);
}

.fit-trial {
  background: #f3eee5;
  color: #6b5129;
}

.result-card h3 {
  margin: 0;
  color: var(--green-950);
  font-size: clamp(1.3rem, 5vw, 1.7rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.18;
}

.latin {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.92rem;
  font-style: italic;
  line-height: 1.35;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.detail-tag {
  padding: 0.32rem 0.55rem;
  border-radius: 8px;
  background: #f0f4ed;
  color: #4b5945;
  font-size: 0.73rem;
  font-weight: 720;
}

.result-facts {
  display: grid;
  gap: 0;
  margin: 1rem 0 0;
}

.fact-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0.72rem;
  padding: 0.82rem 0;
  border-top: 1px solid #e6eae2;
}

.fact-row.rate-fact {
  margin: 0 -0.45rem;
  padding: 0.82rem 0.45rem;
  border-top: 0;
  border-radius: 12px;
  background: #f2f7ee;
}

.fact-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  background: var(--green-100);
  font-size: 1rem;
}

.fact-row dt {
  color: var(--green-900);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.015em;
  line-height: 1.2;
}

.fact-row dd {
  margin: 0.2rem 0 0;
  color: #364032;
  font-size: 0.91rem;
  line-height: 1.52;
}

.result-notices {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.notice {
  padding: 0.78rem 0.85rem;
  border-radius: 12px;
  font-size: 0.84rem;
  line-height: 1.48;
}

.caution-notice {
  border: 1px solid #f1d8ad;
  background: var(--warning-bg);
  color: #714608;
}

.rotation-notice {
  border: 1px solid #e8c6c2;
  background: var(--danger-bg);
  color: var(--danger);
}

.ffs-notice {
  border: 1px solid #cbdcf1;
  background: var(--blue-bg);
  color: var(--blue);
}

.result-actions {
  margin-top: 1.1rem;
}

.result-actions button {
  flex: 1 1 170px;
}

.empty-state {
  padding: 1.4rem;
  border: 1px dashed #aab8a2;
  border-radius: var(--radius-md);
  background: #f8faf6;
  text-align: center;
}

.empty-state h3 {
  margin: 0;
  color: var(--green-950);
}

.empty-state p {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.app-footer {
  padding: 1rem clamp(1rem, 4vw, 2.25rem) calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(62, 95, 34, 0.16);
  background: #fff;
  text-align: center;
}

.app-footer p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.funding-banner {
  width: min(100%, 820px);
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  background: #fff;
}

dialog {
  width: min(calc(100% - 1.5rem), 600px);
  max-height: min(88vh, 780px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(13, 25, 8, 0.34);
}

dialog::backdrop {
  background: rgba(20, 31, 15, 0.58);
  backdrop-filter: blur(3px);
}

.dialog-card {
  padding: clamp(1rem, 4vw, 1.55rem);
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-card h2 {
  font-size: 1.8rem;
}

.dialog-card h3 {
  margin: 1.2rem 0 0.35rem;
  color: var(--green-950);
  font-size: 1rem;
}

.dialog-card > p {
  color: #4d5848;
  line-height: 1.58;
}

.model-meta {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: var(--green-50);
}

.model-meta dl {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.model-meta div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.75rem;
}

.model-meta dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.model-meta dd {
  margin: 0;
  color: var(--green-950);
  font-size: 0.84rem;
  font-weight: 800;
}

.version-note {
  margin-top: 1.25rem !important;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  color: var(--muted) !important;
  font-size: 0.75rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  left: 1rem;
  z-index: 100;
  width: min(calc(100% - 2rem), 420px);
  margin: 0 auto;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--green-950);
  color: #fff;
  box-shadow: var(--shadow-md);
  text-align: center;
  font-size: 0.88rem;
  font-weight: 750;
}

.fatal-error {
  width: min(100% - 2rem, 580px);
  min-height: auto;
  margin: 3rem auto;
  padding: 2rem;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-md);
}

@media (min-width: 640px) {
  .options-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-card {
    min-height: 105px;
  }

  .results-list {
    gap: 1.2rem;
  }

  .fact-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .app-header {
    min-height: 82px;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
    border-radius: 14px;
  }

  .eyebrow {
    font-size: 0.61rem;
  }

  .brand-subtitle {
    display: none;
  }

  .scope-grid {
    gap: 0.45rem;
  }

  .scope-grid div {
    min-height: 96px;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.7rem 0.25rem;
  }

  .scope-grid strong {
    font-size: 0.77rem;
  }

  .hero-actions button,
  .result-actions button {
    width: 100%;
    flex-basis: 100%;
  }

  .model-meta div {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

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

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    box-shadow: none;
  }

  .app-header,
  #startScreen,
  #wizardScreen,
  .result-actions,
  .app-footer,
  .icon-button {
    display: none !important;
  }

  #resultsScreen {
    display: block !important;
  }

  main {
    padding: 0;
  }

  .result-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
