:root {
  --bg: #f5f6f8;
  --white: #ffffff;
  --border: #e5e7eb;
  --teal: #0ea5a0;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --orange: #f97316;
  --red: #ef4444;
  --green: #22c55e;
  --amber: #f59e0b;
  --text: #111827;
  --sub: #6b7280;
  --muted: #6b7280;
  --radius: 18px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover:not(:disabled), .quick-btn:hover, .year-btn:hover, .label-btn:hover { transform: none; }
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button, input {
  font: inherit;
}

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

:focus-visible {
  outline: 3px solid #1d4ed8;
  outline-offset: 3px;
}
.option:focus-visible, .num-btn:focus-visible, .knowledge-tag:focus-visible {
  outline-color: #1d4ed8;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px #1d4ed8;
}

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

/* Nav */
.nav {
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 800;
}

.nav-logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}

.nav-logo span:last-child strong {
  color: var(--teal);
  font-weight: 800;
}

.nav-links { display: flex; gap: 8px; align-items: center; }
.nav-links a {
  text-decoration: none;
  color: var(--sub);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  border-radius: 999px;
  padding: 8px 14px;
  transition: color .15s, background .15s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--teal);
  background: rgba(14, 165, 160, 0.08);
}

/* Bottom nav (mobile only) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 100;
  height: calc(58px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
}
.bottom-nav-inner { display: flex; height: 58px; }
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  gap: 4px;
  font-weight: 700;
  transition: color .15s;
}
.bottom-nav a.active,
.bottom-nav a:hover { color: var(--teal); }
.bottom-nav .bn-icon { width: 23px; height: 23px; display: block; }

/* Container */
.container {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 26px 22px 36px;
}

/* Card */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: none;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: transform .15s, opacity .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); opacity: .9; }
.btn-primary { background: linear-gradient(135deg, var(--teal), var(--blue)); color: #fff; }
.btn-secondary { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.btn-outline { background: transparent; color: var(--teal); border-color: var(--teal); }
.btn-outline:hover:not(:disabled) { background: rgba(14, 165, 160, 0.08); }
.btn-danger { background: #fee2e2; color: var(--red); border-color: #fecaca; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* Tag */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(14, 165, 160, 0.08);
  color: var(--teal);
}

/* Progress bar */
.progress-bar { height: 7px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--blue)); border-radius: 999px; transition: width .3s; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--white); border-radius: 24px; padding: 24px; max-width: 560px; width: 92%; max-height: 85vh; overflow-y: auto; }
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 16px; }

/* Toast */
#toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: auto;
  z-index: 999;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
#toast.show { opacity: 1; }
#toast .toast-action {
  background: transparent;
  border: none;
  color: #7dd3fc;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
#toast .toast-action:hover { color: #bae6fd; }

/* Watermark */
#globalWatermark {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
  opacity: .045;
  user-select: none;
}

#globalWatermark .wm-mark {
  position: absolute;
  transform: rotate(-24deg);
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  word-break: keep-all;
  white-space: nowrap;
}

/* Tablet */
@media (max-width: 900px) {
  .container { padding: 20px 16px 32px; }
}

/* Mobile */
@media (max-width: 640px) {
  .nav { padding: 0 16px; min-height: 58px; }
  .nav-logo { font-size: 15px; }
  .nav-logo-icon { width: 32px; height: 32px; }
  .nav-links { display: none; }
  .bottom-nav { display: block; }
  .container { padding: 14px 12px calc(90px + var(--safe-bottom)); }
  #toast { max-width: calc(100vw - 24px); white-space: normal; text-align: center; }
}
