:root {
  --bg: #f4f1ea;
  --bg-accent: #e8eef2;
  --surface: #ffffff;
  --ink: #1a2b33;
  --ink-muted: #5a6b73;
  --primary: #1a5f7a;
  --primary-hover: #144a5e;
  --secondary: #c45c26;
  --chip: #dfe8ec;
  --chip-active: #1a5f7a;
  --border: #d4dde2;
  --success: #2d6a4f;
  --extension: #7b2d8e;
  --shadow: 0 8px 28px rgba(26, 43, 51, 0.08);
  --radius: 14px;
  --font-zh: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-en: "Source Sans 3", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-zh);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #d9e8ef 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #f0e6d8 0%, transparent 50%),
    var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}
.app.is-locked { visibility: hidden; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #d9e8ef 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #f0e6d8 0%, transparent 50%),
    var(--bg);
}
.gate[hidden] { display: none !important; }
.gate-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem 1.35rem 1.4rem;
  text-align: center;
}
.gate-mark {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.85rem;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(26, 95, 122, 0.35);
}
.gate-card h1 {
  margin: 0 0 0.45rem;
  font-size: 1.25rem;
}
.gate-lead {
  margin: 0 0 1.1rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
}
.gate-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font-family: inherit;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-align: center;
  background: #fafbfc;
  color: var(--ink);
}
.gate-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.15);
  background: #fff;
}
.gate-error {
  margin: 0.55rem 0 0;
  color: #9b2c2c;
  font-size: 0.85rem;
  min-height: 1.2em;
}
.gate-submit {
  width: 100%;
  margin: 0.9rem 0 0;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(26, 95, 122, 0.35);
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.15rem, 3.5vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0.15rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
  font-family: var(--font-en);
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--bg-accent); border-color: var(--primary); }

.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.mode-tab {
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--ink-muted);
  border-radius: 10px;
  padding: 0.55rem 0.35rem;
  font-family: inherit;
  font-size: clamp(0.78rem, 2.4vw, 0.92rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-tab:hover { border-color: var(--primary); color: var(--primary); }
.mode-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.topic-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.topic-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1.5px solid var(--border);
  background: var(--chip);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--primary); }
.chip.active {
  background: var(--chip-active);
  border-color: var(--chip-active);
  color: #fff;
}

.progress-bar-wrap {
  margin-top: 0.85rem;
  height: 6px;
  background: var(--chip);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #3a8fa8);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.45rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.progress-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  font-family: var(--font-en);
}
.mode-hint {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.15rem 1.35rem;
  box-shadow: var(--shadow);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
}
.badge-soft {
  background: var(--bg-accent);
  color: var(--primary);
}
.badge-extension {
  background: var(--extension);
}
.badge-tip {
  background: #8b5a2b;
}

.question-text {
  margin: 0 0 1rem;
  font-size: clamp(1.2rem, 4vw, 1.55rem);
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

.answer-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 7rem;
  background: #fafbfc;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.answer-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.15);
  background: #fff;
}
.answer-input::placeholder { color: #9aa8af; }

.reveal-area { margin-top: 1rem; }

.sample-box {
  margin-top: 0.75rem;
  padding: 1rem 1.05rem;
  background: linear-gradient(180deg, #f7fafb 0%, #eef5f8 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
}
.sample-box.extension-tip {
  border-left-color: var(--extension);
  background: linear-gradient(180deg, #faf7fc 0%, #f3eef8 100%);
}
.sample-box h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.04em;
}
.sample-box.extension-tip h3 { color: var(--extension); }
.sample-box p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.75;
  white-space: pre-wrap;
}
.hidden { display: none !important; }

.nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.15rem;
}
.secondary-actions {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  margin-left: auto;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--bg-accent);
  color: var(--primary);
  border-color: var(--border);
  width: 100%;
}
.btn-secondary:hover { border-color: var(--primary); }
.btn-secondary.revealed {
  background: #e8f0e9;
  color: var(--success);
  border-color: #b7d4be;
}
.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--ink-muted);
  background: var(--bg);
}

.site-footer {
  margin-top: 1.5rem;
  text-align: center;
}
.site-footer p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 35, 42, 0.45);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-panel h2 { margin: 0 0 0.75rem; font-size: 1.2rem; }
.modal-panel ul {
  margin: 0 0 1.25rem;
  padding-left: 1.2rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
}
.modal-panel li { margin-bottom: 0.4rem; }
.modal-panel .btn { width: 100%; }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ink-muted);
}

@media (max-width: 480px) {
  .app { padding: 0.85rem 0.75rem 2rem; }
  .mode-tabs { grid-template-columns: 1fr; }
  .btn-primary { margin-left: 0; flex: 1; }
  .nav-row .btn { flex: 1 1 calc(50% - 0.25rem); }
  .secondary-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
