:root {
  --bg: #f6f3ea;
  --ink: #152626;
  --muted: #4d635e;
  --accent: #0f766e;
  --accent-soft: #d3f0e6;
  --accent-2: #d97706;
  --card: rgba(255, 255, 255, 0.82);
  --line: rgba(20, 40, 40, 0.16);
  --ok: #166534;
  --bad: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 15% 10%, #fef3c7 0, transparent 36%),
    radial-gradient(circle at 82% 18%, #bae6fd 0, transparent 32%), var(--bg);
  font-family: "IBM Plex Sans", "PingFang SC", "Noto Sans SC", sans-serif;
  position: relative;
}

.bg {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.45;
}

.bg-a {
  width: 360px;
  height: 360px;
  right: -110px;
  top: 16vh;
  background: #86efac;
}

.bg-b {
  width: 280px;
  height: 280px;
  left: -100px;
  bottom: 12vh;
  background: #fcd34d;
}

.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: "Noto Serif SC", "STSong", serif;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.8vw, 2.4rem);
}

.sub {
  margin: 10px 0 16px;
  color: var(--muted);
  max-width: 760px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.tab:hover {
  transform: translateY(-1px);
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px 28px;
}

.panel {
  display: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.05);
}

.panel.active {
  display: block;
  animation: rise 0.24s ease;
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

input,
button {
  font: inherit;
}

input[type="search"] {
  flex: 1;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.85);
}

button {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  cursor: pointer;
}

button:hover {
  background: #f8fafc;
}

.map-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  min-height: 58vh;
}

.root-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  overflow: auto;
  max-height: 64vh;
  background: rgba(255, 255, 255, 0.78);
}

.root-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 7px;
  cursor: pointer;
  background: #fff;
}

.root-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.root-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
}

.root-key {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.root-gloss {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.root-detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.detail-root {
  font-size: 1.3rem;
  font-weight: 700;
}

.examples {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.example-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: #fff;
}

.example-word {
  font-size: 1.05rem;
  font-weight: 700;
}

.example-meaning {
  margin-top: 4px;
}

.example-decomp {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.flash-wrap,
.quiz-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.flash-meta,
.quiz-score {
  color: var(--muted);
  margin-bottom: 12px;
}

.flash-card {
  min-height: 240px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(150deg, #fff, #f0fdfa);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.flash-root {
  font-size: 2rem;
  font-weight: 700;
}

.flash-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

#flashKnow {
  background: #dcfce7;
}

#flashAgain {
  background: #fef3c7;
}

.quiz-question {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.quiz-option.correct {
  border-color: var(--ok);
  background: #dcfce7;
}

.quiz-option.wrong {
  border-color: var(--bad);
  background: #fee2e2;
}

.quiz-feedback {
  min-height: 48px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .map-layout {
    grid-template-columns: 1fr;
  }

  .root-list {
    max-height: 36vh;
  }

  .flash-actions {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .toolbar {
    flex-direction: column;
  }

  .quiz-options {
    grid-template-columns: 1fr;
  }
}
