:root {
  --ink: #1d2926;
  --muted: #687773;
  --line: #dce4e1;
  --canvas: #f4f7f5;
  --surface: #fff;
  --primary: #176b5b;
  --primary-dark: #105346;
  --primary-soft: #e8f3f0;
  --accent: #c97917;
  --correct: #19724f;
  --correct-soft: #e7f5ee;
  --wrong: #bd3f37;
  --wrong-soft: #fbeceb;
  --shadow: 0 16px 48px rgba(22, 47, 40, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); }
body { min-width: 320px; min-height: 100vh; min-height: 100dvh; margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(23, 107, 91, 0.22); outline-offset: 2px; }
[hidden] { display: none !important; }

.app-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.site-header { display: flex; align-items: center; justify-content: space-between; width: min(100% - 40px, 880px); min-height: 76px; margin: 0 auto; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; text-align: left; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 7px; color: #fff; background: var(--primary); font-size: 19px; font-weight: 700; }
.brand strong, .brand small { display: block; letter-spacing: 0; }
.brand strong { font-size: 15px; line-height: 1.2; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.header-context, .tag { padding: 6px 9px; border-radius: 4px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 700; }
.main-content { display: flex; flex: 1; width: min(100% - 40px, 720px); margin: 0 auto; padding: 44px 0 56px; }
.screen { width: 100%; min-width: 0; margin: auto; }
.eyebrow { margin: 0 0 9px; color: var(--primary); font-size: 13px; font-weight: 700; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 28px; line-height: 1.35; letter-spacing: 0; }

.loading-screen { text-align: center; color: var(--muted); font-size: 13px; }
.loading-mark { display: block; width: 28px; height: 28px; margin: 0 auto 14px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-screen, .setup-screen, .result-screen { max-width: 620px; padding: 38px; border: 1px solid var(--line); border-top: 4px solid var(--primary); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.auth-copy { text-align: center; }
.auth-copy > p:last-child, .setup-heading > p:last-child { margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.activation-form { margin-top: 30px; }
.activation-form label, .setup-section label, .field-label { display: block; margin-bottom: 8px; color: #4f5e5a; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 48px; border: 1px solid #becac6; border-radius: 6px; color: var(--ink); background: #fff; }
input { padding: 0 14px; }
select { padding: 0 38px 0 14px; }
.activation-form input { margin-bottom: 12px; text-align: center; text-transform: uppercase; }
.form-error { margin: 0 0 12px; color: var(--wrong); font-size: 13px; }
.demo-code { margin: 16px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
.demo-code button { padding: 0; border: 0; color: var(--primary); background: transparent; cursor: pointer; font-weight: 700; }

.primary-button, .secondary-button, .text-button, .icon-button, .back-button { min-height: 46px; border-radius: 6px; cursor: pointer; font-weight: 700; transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, opacity 160ms ease; }
.primary-button { padding: 0 22px; border: 0; color: #fff; background: var(--primary); }
.primary-button:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.primary-button:disabled, .secondary-button:disabled { cursor: not-allowed; opacity: .42; }
.secondary-button { padding: 0 22px; border: 1px solid #bfcac6; color: var(--ink); background: var(--surface); }
.secondary-button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.text-button, .back-button { border: 0; color: var(--muted); background: transparent; }
.text-button:hover, .back-button:hover { color: var(--primary); }
.back-button { min-height: 36px; margin: -8px 0 18px; padding: 0; }
.wide-button { width: 100%; }
.compact-button { min-height: 38px; padding: 0 14px; font-size: 12px; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.product-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.product-card { display: flex; flex-direction: column; min-height: 235px; padding: 24px; border: 1px solid var(--line); border-top: 3px solid var(--primary); border-radius: 7px; background: var(--surface); box-shadow: 0 10px 30px rgba(22, 47, 40, .05); }
.product-card .product-meta { margin-bottom: 16px; color: var(--primary); font-size: 12px; font-weight: 700; }
.product-card h2 { margin: 0; font-size: 18px; line-height: 1.5; letter-spacing: 0; }
.product-card p { margin: 9px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.product-card .product-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; }
.product-card .question-count { color: var(--muted); font-size: 12px; }

.setup-heading { padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.setup-section { margin-top: 24px; }
.search-field { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; }
.search-field input { min-width:0; }
.search-field .secondary-button { min-height:48px; }
.search-suggestions { display:flex; flex-wrap:wrap; gap:7px; min-height:0; margin-top:10px; }
.suggestion-button { min-height:30px; padding:0 9px; border:1px solid var(--line); border-radius:4px; color:#4f5e5a; background:#fff; cursor:pointer; font-size:11px; }
.suggestion-button:hover { border-color:var(--primary); color:var(--primary); }
.suggestion-button span { margin-left:4px; color:var(--muted); }
.search-state { min-height:18px; margin:8px 0 0; color:var(--muted); font-size:11px; }
.search-state.no-results { color:var(--wrong); }
.segmented-control { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; border: 1px solid #bfcac6; border-radius: 6px; }
.segment-button { min-height: 44px; border: 0; border-right: 1px solid #bfcac6; color: var(--ink); background: #fff; cursor: pointer; font-weight: 700; }
.segment-button:last-child { border-right: 0; }
.segment-button.selected { color: #fff; background: var(--primary); }
.setup-summary { display: flex; justify-content: space-between; gap: 20px; margin: 27px 0 16px; padding: 14px 0; border-block: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.setup-summary strong { color: var(--ink); }

.quiz-screen { max-width: 680px; }
.quiz-status { margin-bottom: 20px; }
.status-row { display: flex; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 13px; font-weight: 700; }
.progress-track { height: 6px; overflow: hidden; border-radius: 3px; background: #dce5e2; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 220ms ease; }
.question-panel { min-height: 430px; padding: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; color: var(--muted); font-size: 12px; }
.question-panel h2 { min-height: 66px; margin: 0 0 26px; font-size: 20px; line-height: 1.65; letter-spacing: 0; }
.answer-area { display: grid; gap: 12px; }
.option-button { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; width: 100%; min-height: 58px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; cursor: pointer; text-align: left; transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease; }
.option-button:hover { border-color: #8ca69f; transform: translateX(2px); }
.option-button.selected { border-color: var(--primary); background: var(--primary-soft); }
.option-letter { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid #c9d4d0; border-radius: 50%; color: var(--muted); font-size: 12px; font-weight: 700; }
.selected .option-letter { border-color: var(--primary); color: #fff; background: var(--primary); }
.option-text { min-width: 0; padding-left: 4px; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.fill-answer { min-height: 54px; }
.quiz-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.quiz-actions button { min-width: 124px; }

.result-screen { text-align: center; }
.result-hero .eyebrow { margin-bottom: 16px; }
.score-ring { display: flex; align-items: baseline; justify-content: center; width: 150px; height: 150px; margin: 0 auto 20px; padding-top: 42px; border: 9px solid var(--primary-soft); border-top-color: var(--primary); border-right-color: var(--accent); border-radius: 50%; }
.score-ring strong { font-size: 48px; line-height: 1; }
.score-ring span { margin-left: 4px; color: var(--muted); font-size: 12px; }
.result-screen h1 { font-size: 24px; }
.result-hero > p:last-child { min-height: 24px; margin: 9px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 30px 0; border-block: 1px solid var(--line); }
.result-stats div { display: flex; flex-direction: column; gap: 6px; padding: 17px 6px; }
.result-stats div + div { border-left: 1px solid var(--line); }
.result-stats span { color: var(--muted); font-size: 12px; }
.result-stats strong { font-size: 16px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-screen .text-button { margin-top: 9px; }

.review-screen { max-width: 720px; }
.icon-button { display: grid; width: 42px; min-height: 42px; padding: 0; place-items: center; border: 1px solid var(--line); color: var(--muted); background: var(--surface); font-size: 26px; font-weight: 400; }
.review-list { display: grid; gap: 14px; margin-bottom: 18px; }
.review-item { padding: 24px; border: 1px solid var(--line); border-left: 4px solid var(--correct); border-radius: 6px; background: var(--surface); }
.review-item.wrong { border-left-color: var(--wrong); }
.review-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.review-tag { padding: 4px 7px; border-radius: 4px; color: var(--muted); background: #eef2f0; font-size: 11px; font-weight: 700; }
.review-state { color: var(--correct); font-size: 12px; font-weight: 700; }
.wrong .review-state { color: var(--wrong); }
.review-question { margin: 0 0 14px; font-size: 16px; line-height: 1.65; }
.answer-line { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.answer-line strong { color: var(--ink); }
.explanation { margin: 0; padding-top: 14px; border-top: 1px solid var(--line); color: #4e5d59; font-size: 13px; line-height: 1.75; }

.site-footer { width: min(100% - 40px, 880px); margin: 0 auto; padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: #87938f; font-size: 11px; text-align: center; }
.toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; z-index: 20; max-width: min(90vw, 380px); padding: 10px 16px; border-radius: 5px; color: #fff; background: rgba(29, 41, 38, .95); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .site-header, .main-content, .site-footer { width: min(100% - 28px, 720px); }
  .site-header { min-height: 66px; }
  .main-content { padding: 24px 0 36px; }
  .auth-screen, .setup-screen, .result-screen { padding: 28px 20px; }
  h1 { font-size: 25px; }
  .product-list { grid-template-columns: 1fr; }
  .product-card { min-height: 210px; }
  .question-panel { min-height: 420px; padding: 24px 18px; }
  .question-panel h2 { min-height: 78px; font-size: 18px; }
  .quiz-actions button { min-width: 0; flex: 1; padding-inline: 12px; }
  .result-actions { grid-template-columns: 1fr; }
  .review-item { padding: 20px 16px; }
}

@media (max-width: 380px) {
  .header-context { display: none; }
  .segmented-control { grid-template-columns: repeat(2, 1fr); }
  .segment-button:nth-child(2) { border-right: 0; }
  .segment-button:nth-child(-n+2) { border-bottom: 1px solid #bfcac6; }
  .search-field { grid-template-columns:1fr; }
}

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