:root {
  color-scheme: light;
  --bg: #f7f4ed;
  --panel: #fffdf8;
  --text: #24211d;
  --muted: #6f675c;
  --line: #e8ded0;
  --primary: #256f68;
  --primary-dark: #174f4a;
  --secondary: #7b5b22;
  --danger: #b83b35;
  --warning: #c77616;
  --safe: #23784a;
  --shadow: 0 10px 28px rgba(67, 56, 39, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(37, 111, 104, 0.08), transparent 280px),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 111, 104, 0.13);
}

label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

label span,
.field-label {
  color: var(--muted);
  font-size: 14px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 28px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 19px;
  letter-spacing: 0;
}

.container {
  width: min(100% - 28px, 760px);
  margin-inline: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(8px, env(safe-area-inset-top)) 0 8px;
  background: rgba(247, 244, 237, 0.94);
  border-bottom: 1px solid rgba(232, 222, 208, 0.85);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge,
.warn-chip,
.mini-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge {
  color: #fff;
  background: var(--danger);
}

.warn-chip {
  color: #653900;
  background: #ffe2ad;
}

.mini-label {
  color: var(--primary-dark);
  background: rgba(37, 111, 104, 0.12);
}

.topbar-text {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.hero,
.card {
  margin-top: 16px;
  padding: 20px;
  border: 1px solid rgba(232, 222, 208, 0.9);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.hero {
  margin-top: 18px;
  padding-top: 24px;
}

.subtitle {
  margin-bottom: 14px;
  color: var(--primary-dark);
  font-size: 18px;
  font-weight: 700;
}

.notice {
  padding: 14px;
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  color: #4f3b1c;
  background: #fff5e2;
}

.plain-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.plain-list li + li {
  margin-top: 8px;
}

.primary {
  padding: 0 18px;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

.primary:active {
  background: var(--primary-dark);
}

.secondary {
  padding: 0 18px;
  color: #fff;
  background: var(--secondary);
  font-weight: 800;
}

.ghost {
  padding: 0 14px;
  color: var(--primary-dark);
  background: rgba(37, 111, 104, 0.1);
  font-weight: 700;
}

.wide {
  width: 100%;
  margin-top: 10px;
}

.small {
  min-height: 38px;
  padding-inline: 12px;
  font-size: 14px;
}

.back {
  min-width: 76px;
}

.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 12px;
  margin-top: 18px;
}

.section-head h1 {
  margin-bottom: 4px;
  font-size: 24px;
}

.section-head p,
.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

.field-group {
  margin-top: 16px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.segmented button {
  color: var(--text);
  background: #f2eadf;
  border: 1px solid transparent;
  font-weight: 700;
}

.segmented button.active {
  color: #fff;
  background: var(--primary);
}

.card-title-row,
.choice-header,
.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.school-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.school-pill {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.school-pill span {
  color: var(--muted);
  font-size: 13px;
}

.choice-list {
  display: grid;
  gap: 12px;
}

.choice-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.reference-options {
  display: grid;
  gap: 9px;
}

.radio-card,
.check-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.radio-card input,
.check-card input {
  width: 20px;
  min-height: 20px;
  margin: 0;
  box-shadow: none;
}

.radio-card span,
.check-card span {
  color: var(--text);
  font-weight: 700;
}

.check-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.small-notice {
  margin: 12px 0 0;
  padding: 11px;
}

.manual-lines {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.manual-lines p {
  margin-bottom: 0;
}

.choice-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.choice-header {
  align-items: baseline;
}

.choice-header .muted {
  font-size: 12px;
  text-align: right;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 18px;
  border-radius: 8px;
  color: #fff;
}

.result-summary span {
  font-size: 15px;
}

.result-summary strong {
  font-size: 28px;
}

.alert-card {
  border-color: #efb2a9;
  background: #fff4f2;
}

.alert-card p {
  margin-bottom: 10px;
  color: #7c221d;
  font-weight: 700;
}

.ok-card {
  border-color: #b9dbc8;
  background: #f1fff6;
}

.result-list {
  display: grid;
  gap: 12px;
}

.result-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.result-item p {
  margin-bottom: 7px;
}

.risk-tag {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.risk-safe {
  background: var(--safe);
}

.risk-good {
  background: #4f8b38;
}

.risk-edge {
  background: #b88718;
}

.risk-watch {
  background: var(--warning);
}

.risk-high {
  background: var(--danger);
}

.risk-unknown {
  background: #6f675c;
}

.positive-text {
  color: var(--safe);
  font-weight: 800;
}

.risk-text {
  color: var(--danger);
  font-weight: 800;
}

.suggestions {
  padding-left: 22px;
}

.suggestions li + li {
  margin-top: 8px;
}

.copy-message {
  margin: 12px 0 0;
  color: var(--primary-dark);
  font-weight: 700;
  text-align: center;
}

.disclaimer-card p,
.footer {
  color: var(--muted);
  font-size: 13px;
}

.manual-card {
  border-color: #d9c28c;
  background: #fff7df;
}

.manual-card p {
  margin: 0;
  color: #694a11;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.detail-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-grid dd {
  margin: 3px 0 0;
  word-break: break-word;
  font-weight: 700;
}

.source-text {
  color: var(--muted);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
  padding: 16px;
  background: rgba(28, 24, 18, 0.45);
}

.modal {
  width: min(100%, 760px);
  max-height: min(82vh, 760px);
  margin-inline: auto;
  overflow: auto;
  padding: 18px;
  border-radius: 8px 8px 0 0;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.footer {
  padding: 20px 0 calc(24px + env(safe-area-inset-bottom));
}

@media (max-width: 560px) {
  .container {
    width: min(100% - 20px, 760px);
  }

  h1 {
    font-size: 25px;
  }

  .hero,
  .card {
    padding: 16px;
  }

  .grid.two,
  .grid.three,
  .actions {
    grid-template-columns: 1fr;
  }

  .detail-grid,
  .check-row {
    grid-template-columns: 1fr;
  }

  .card-title-row {
    align-items: flex-start;
  }

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

  .topbar-inner {
    align-items: flex-start;
  }

  .choice-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
