:root {
  --bg: #efefed;
  --surface: #f6f6f4;
  --surface-strong: #ffffff;
  --surface-soft: #f1f1ef;
  --line: #d8d8d6;
  --line-strong: #c7c7c3;
  --text: #222326;
  --text-soft: #6d6d72;
  --text-faint: #8a8a90;
  --primary: #1f2025;
  --accent: #366d59;
  --danger: #8d463f;
  --success: #2f6b55;
  --shadow: 0 26px 60px rgba(28, 29, 31, 0.05);
  --radius-2xl: 36px;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-body:
    "SF Pro Display",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    "Noto Sans SC",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.76), transparent 34%),
    linear-gradient(180deg, #f3f2ef 0%, var(--bg) 100%);
  color: var(--text);
  font-family: var(--font-body);
}

body.is-gated {
  overflow: hidden;
}

body.mode-major,
body.mode-minor {
  overflow-x: hidden;
}

.lang-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 42;
  max-width: calc(100vw - 28px);
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.96);
}

.lang-toggle:active {
  transform: translateY(1px);
}

.lang-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(54, 109, 89, 0.16);
}

.entry-gate {
  display: none;
}

body.is-gated .entry-gate {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow-y: auto;
  padding: clamp(18px, 3vw, 40px);
  padding-top: max(72px, calc(env(safe-area-inset-top) + 18px));
  place-items: center;
  -webkit-overflow-scrolling: touch;
}

.entry-gate-card {
  width: min(980px, 100%);
  border: 1px solid var(--line);
  border-radius: clamp(28px, 4vw, 38px);
  padding: clamp(28px, 6vw, 58px) clamp(20px, 4vw, 46px) clamp(24px, 4vw, 40px);
  background:
    linear-gradient(180deg, rgba(249, 249, 247, 0.96) 0%, rgba(243, 243, 241, 0.92) 100%);
  box-shadow: var(--shadow);
  text-align: center;
}

.panel-kicker,
.gate-label {
  margin: 0;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-soft);
}

h1,
h2,
.minor-answer {
  margin: 0;
  letter-spacing: -0.04em;
}

h2 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.12;
}

.gate-summary,
.panel-desc,
.form-feedback,
.result-placeholder,
.result-text,
.mode-title,
.site-footer p,
.gate-block p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.75;
}

.gate-intro {
  max-width: 700px;
  margin: 0 auto 34px;
}

.gate-headline {
  max-width: 100%;
  font-size: clamp(38px, 6vw, 62px);
  line-height: 1.12;
  font-weight: 760;
  text-wrap: balance;
}

html[lang^="zh"] .gate-headline {
  white-space: nowrap;
  letter-spacing: -0.03em;
}

.gate-summary {
  width: min(760px, 100%);
  display: grid;
  justify-items: center;
  gap: 0.14em;
  margin: 12px auto 0;
  font-size: clamp(17px, 1.9vw, 20px);
  font-weight: 500;
  line-height: 1.68;
  text-wrap: pretty;
}

.gate-summary span {
  display: block;
  white-space: normal;
}

.gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  text-align: left;
}

.gate-block,
.tool-panel,
.mode-bar {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(243, 243, 241, 0.88);
}

.gate-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 250px;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(247, 247, 245, 0.98) 0%, rgba(242, 242, 240, 0.9) 100%);
}

.gate-label {
  color: var(--text-faint);
}

.gate-block h2 {
  font-size: clamp(30px, 3.6vw, 42px);
  line-height: 1.08;
}

.gate-block p {
  font-size: 16px;
  line-height: 1.72;
}

.gate-copy,
.panel-copy {
  display: grid;
  gap: 4px;
}

.gate-copy span,
.panel-copy span {
  display: block;
  text-wrap: pretty;
}

.gate-note {
  margin: 20px 0 0;
  font-size: 14px;
  line-height: 1.66;
  color: var(--text-soft);
}

.gate-button,
.primary-button,
.mode-back {
  appearance: none;
  width: fit-content;
  min-width: 182px;
  min-height: 48px;
  border: none;
  border-radius: 999px;
  padding: 16px 22px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

.gate-button {
  margin-top: auto;
  min-width: 188px;
  align-self: flex-start;
}

.primary-button {
  color: #ffffff;
  background: var(--primary);
}

.primary-button-accent {
  background: var(--accent);
}

.primary-button:hover,
.mode-back:hover {
  filter: brightness(1.02);
}

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

.primary-button:focus-visible,
.mode-back:focus-visible,
.field-control:focus,
.choice-option input:focus-visible + span {
  outline: none;
  box-shadow: 0 0 0 4px rgba(54, 109, 89, 0.16);
}

.page-shell {
  width: min(1040px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

body.mode-major .page-shell,
body.mode-minor .page-shell {
  padding-top: 68px;
}

body.is-gated .page-shell {
  display: none;
}

.mode-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 132px 12px 14px;
}

body.mode-major .mode-bar,
body.mode-minor .mode-bar {
  display: flex;
}

.mode-back {
  min-width: 120px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.75);
}

.mode-title {
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  margin-left: auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tool-layout {
  display: grid;
  gap: 18px;
}

.tool-panel {
  box-shadow: var(--shadow);
  padding: clamp(20px, 3.4vw, 32px);
}

.tool-panel-minor {
  background: rgba(242, 245, 242, 0.92);
}

.panel-head {
  margin-bottom: 20px;
  max-width: 42rem;
}

.panel-kicker {
  margin-bottom: 12px;
}

.panel-head h2 {
  margin-bottom: 8px;
}

.panel-desc {
  max-width: 40rem;
  font-size: 15.5px;
  line-height: 1.72;
}

.tool-form {
  display: grid;
  gap: 16px;
}

.field-grid,
.decision-grid {
  display: grid;
  gap: 14px;
}

.field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.decision-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-field {
  display: block;
  min-width: 0;
}

.field-label,
.choice-fieldset legend {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.field-label em,
.choice-fieldset legend em {
  color: var(--accent);
  font-style: normal;
}

.field-control {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.field-control::placeholder {
  color: #9b9ba1;
}

.textarea-control {
  min-height: 118px;
  resize: vertical;
}

.choice-fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px 16px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.44);
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
}

.choice-option input {
  margin: 0;
  accent-color: var(--accent);
}

.choice-option span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

.action-row {
  display: grid;
  gap: 8px;
}

.action-row .primary-button {
  width: 100%;
}

.form-feedback {
  min-height: 22px;
  font-size: 14px;
}

.form-feedback.is-error {
  color: var(--danger);
}

.form-feedback.is-success {
  color: var(--success);
}

.result-panel {
  margin-top: 8px;
  min-height: 210px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(239, 242, 239, 0.7);
  transition: opacity 0.12s ease;
}

.result-panel-minor {
  background: rgba(230, 237, 232, 0.68);
}

.result-panel.is-resetting {
  opacity: 0.68;
}

.result-title {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  max-width: 100%;
  white-space: normal;
  text-align: left;
  overflow-wrap: anywhere;
}

.result-badge.is-stop {
  background: rgba(141, 70, 63, 0.13);
  color: var(--danger);
}

.result-badge.is-wait {
  background: rgba(54, 109, 89, 0.12);
  color: var(--accent);
}

.result-block + .result-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line-strong);
}

.result-block h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.result-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.result-text {
  color: var(--text);
  overflow-wrap: anywhere;
}

.minor-answer {
  margin: 4px 0 2px;
  font-size: clamp(34px, 7.6vw, 56px);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.minor-answer-long {
  font-size: clamp(26px, 6.4vw, 40px);
  line-height: 1.22;
  letter-spacing: -0.012em;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 18px 4px 0;
}

.site-footer p {
  font-size: 14px;
  line-height: 1.66;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html[lang^="en"] .panel-kicker,
html[lang^="en"] .gate-label {
  letter-spacing: 0.12em;
}

html[lang^="en"] .gate-intro {
  max-width: 860px;
}

html[lang^="en"] .gate-headline {
  max-width: none;
  display: inline-block;
  margin-inline: auto;
  font-size: clamp(34px, 3.9vw, 50px);
  letter-spacing: -0.014em;
  line-height: 1.16;
  white-space: pre;
}

html[lang^="en"] .gate-summary {
  width: min(720px, 100%);
  display: grid;
  justify-items: center;
  row-gap: 0.18em;
  line-height: 1.58;
}

html[lang^="en"] .gate-summary span {
  white-space: nowrap;
}

html[lang^="en"] .gate-block h2 {
  font-size: clamp(32px, 3.4vw, 38px);
  letter-spacing: -0.025em;
}

html[lang^="en"] .gate-block p,
html[lang^="en"] .panel-desc,
html[lang^="en"] .result-list,
html[lang^="en"] .result-text {
  line-height: 1.68;
}

html[lang^="en"] .panel-head h2 {
  letter-spacing: -0.02em;
  line-height: 1.18;
}

html[lang^="en"] .panel-desc {
  max-width: 44rem;
  font-size: 16px;
}

html[lang^="en"] .gate-button {
  min-width: 236px;
  padding-inline: 24px;
}

html[lang^="en"] .mode-title {
  letter-spacing: 0.01em;
}

body.mode-major #minor-section,
body.mode-minor #major-section,
body.mode-major .site-footer,
body.mode-minor .site-footer {
  display: none;
}

@media (max-width: 900px) {
  body.is-gated .entry-gate {
    place-items: start center;
    padding-top: max(16px, env(safe-area-inset-top));
  }

  body.mode-major .page-shell,
  body.mode-minor .page-shell {
    padding-top: 14px;
  }

  .mode-bar {
    padding-right: 14px;
  }

  .gate-grid,
  .field-grid,
  .decision-grid {
    grid-template-columns: 1fr;
  }

  .gate-block {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .lang-toggle {
    top: max(10px, env(safe-area-inset-top));
    right: 9px;
    padding: 7px 11px;
    font-size: 12px;
  }

  body.is-gated .entry-gate {
    padding: calc(env(safe-area-inset-top) + 50px) 12px 14px;
    align-items: start;
  }

  .entry-gate-card {
    padding: 24px 18px 20px;
    border-radius: 22px;
  }

  .gate-intro {
    margin-bottom: 22px;
  }

  .gate-headline {
    font-size: clamp(30px, 8.6vw, 36px);
    line-height: 1.18;
    letter-spacing: -0.03em;
  }

  html[lang^="zh"] .gate-headline {
    font-size: clamp(24px, 6.8vw, 28px);
    line-height: 1.2;
    white-space: nowrap;
    letter-spacing: -0.02em;
  }

  html[lang^="en"] .gate-headline {
    max-width: none;
    font-size: clamp(19px, 5.2vw, 22px);
    line-height: 1.24;
    white-space: pre;
    letter-spacing: -0.01em;
    text-align: center;
  }

  .gate-summary {
    max-width: 24rem;
    font-size: 15px;
    line-height: 1.64;
    gap: 0.16em;
  }

  .gate-copy {
    display: block;
  }

  .gate-copy span {
    display: inline;
    white-space: normal;
  }

  html[lang^="zh"] .gate-summary {
    width: min(19em, 100%);
  }

  html[lang^="en"] .gate-summary {
    width: 100%;
    font-size: clamp(11.8px, 3.25vw, 12.8px);
    line-height: 1.5;
    letter-spacing: -0.005em;
  }

  html[lang^="en"] .gate-summary span {
    white-space: nowrap;
    text-wrap: nowrap;
  }

  .gate-grid {
    gap: 14px;
  }

  .gate-block,
  .tool-panel {
    padding: 20px 16px;
    border-radius: 20px;
  }

  .gate-block {
    min-height: auto;
    gap: 12px;
  }

  .gate-label {
    font-size: 11px;
    line-height: 1.24;
    letter-spacing: 0.16em;
  }

  html[lang^="en"] .gate-label {
    letter-spacing: 0.09em;
    white-space: nowrap;
    font-size: 10.5px;
    line-height: 1.25;
  }

  .gate-block h2 {
    line-height: 1.1;
  }

  .gate-block p {
    font-size: 15px;
    line-height: 1.72;
  }

  html[lang^="en"] .gate-block p {
    font-size: 14px;
    line-height: 1.62;
  }

  .gate-button {
    width: 100%;
    min-height: 52px;
    padding: 14px 18px;
  }

  html[lang^="en"] .gate-button {
    min-width: 0;
    font-size: 15px;
  }

  .gate-note {
    margin-top: 14px;
    font-size: 13px;
    line-height: 1.6;
  }

  html[lang^="zh"] .gate-note {
    white-space: nowrap;
    font-size: 10.5px;
    line-height: 1.25;
    letter-spacing: -0.01em;
  }

  .page-shell {
    width: min(100vw - 16px, 100%);
    padding: calc(env(safe-area-inset-top) + 48px) 0 18px;
  }

  .mode-bar {
    flex-direction: column;
    align-items: stretch;
    border-radius: 20px;
    padding-right: 14px;
  }

  .mode-back {
    width: 100%;
  }

  .mode-title {
    text-align: center;
    margin-left: 0;
  }

  .panel-head h2 {
    font-size: clamp(26px, 8vw, 34px);
    line-height: 1.16;
  }

  .choice-fieldset {
    padding: 12px 14px 8px;
  }

  .choice-fieldset legend {
    line-height: 1.42;
  }

  .result-panel {
    min-height: 180px;
    padding: 16px;
  }

  .result-badge {
    width: fit-content;
  }

  .minor-answer {
    font-size: clamp(28px, 9vw, 42px);
  }

  .minor-answer-long {
    font-size: clamp(22px, 7.4vw, 32px);
  }

  .site-footer {
    padding-top: 12px;
  }
}

@media (max-width: 380px) {
  .lang-toggle {
    font-size: 11px;
    padding: 7px 9px;
  }

  .entry-gate-card {
    border-radius: 22px;
    padding: 20px 14px 18px;
  }

  .gate-headline {
    font-size: clamp(28px, 8.8vw, 32px);
    line-height: 1.18;
  }

  html[lang^="zh"] .gate-headline {
    font-size: clamp(22px, 7vw, 25px);
    white-space: nowrap;
  }

  html[lang^="en"] .gate-headline {
    max-width: none;
    font-size: clamp(17px, 5vw, 19px);
    line-height: 1.26;
    white-space: pre;
  }

  .gate-summary {
    font-size: 14.5px;
    line-height: 1.6;
  }

  html[lang^="zh"] .gate-note {
    font-size: 9.4px;
  }

  html[lang^="en"] .gate-summary {
    font-size: clamp(10.8px, 3.25vw, 11.8px);
    line-height: 1.48;
  }

  .panel-kicker,
  .gate-label {
    font-size: 10.5px;
    letter-spacing: 0.14em;
  }

  html[lang^="en"] .panel-kicker,
  html[lang^="en"] .gate-label {
    letter-spacing: 0.07em;
    font-size: 10.5px;
  }

  .gate-block,
  .tool-panel {
    border-radius: 18px;
    padding: 18px 14px;
  }

  .field-control {
    padding: 13px 14px;
  }

  .gate-button,
  .primary-button,
  .mode-back {
    font-size: 15px;
    padding: 14px 16px;
    min-height: 50px;
  }
}

@media (min-width: 1200px) {
  .entry-gate-card {
    width: min(1060px, 100%);
    padding: 56px 48px 40px;
  }

  .gate-grid {
    gap: 20px;
  }

  .gate-block {
    min-height: 268px;
    padding: 30px;
  }

  .page-shell {
    width: min(1100px, calc(100vw - 40px));
  }

  html[lang^="en"] .gate-headline {
    max-width: none;
    white-space: pre;
    font-size: clamp(32px, 2.6vw, 44px);
  }
}
