@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&display=swap');

:root {
  --primary: #1a6b4a;
  --primary-light: #e8f5ef;
  --accent: #f4a261;
  --accent2: #e76f51;
  --bg: #f7faf8;
  --surface: #ffffff;
  --text: #1c2b24;
  --muted: #5c7268;
  --border: #dce8e2;
  --shadow: 0 8px 32px rgba(26, 107, 74, 0.08);
  --radius: 16px;
  --font: 'DM Sans', 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* Nav */
.top-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.top-nav .brand {
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.05rem; color: var(--primary);
  text-decoration: none;
}
.top-nav .links { display: flex; gap: 8px; flex-wrap: wrap; }
.top-nav .links a {
  text-decoration: none; color: var(--muted); font-size: 0.85rem;
  padding: 6px 14px; border-radius: 999px; transition: 0.2s;
}
.top-nav .links a:hover, .top-nav .links a.active {
  background: var(--primary-light); color: var(--primary);
}
.top-nav .nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.top-nav .site-home {
  text-decoration: none; color: var(--muted); font-size: 0.85rem;
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  transition: 0.2s; white-space: nowrap;
}
.top-nav .site-home:hover { background: var(--primary-light); color: var(--primary); border-color: transparent; }
.btn-icon {
  border: none; background: var(--primary-light); color: var(--primary);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: 0.2s; font-size: 0.95rem;
}
.btn-icon:hover { background: var(--primary); color: #fff; }
.btn-icon.sm { width: 28px; height: 28px; font-size: 0.75rem; }
.btn-icon.xs { width: 22px; height: 22px; font-size: 0.65rem; }

/* Buttons */
.btn {
  border: none; cursor: pointer; font-family: var(--font);
  padding: 10px 20px; border-radius: 999px; font-weight: 600;
  font-size: 0.9rem; transition: 0.2s; display: inline-flex;
  align-items: center; gap: 8px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--primary-light); color: var(--primary); }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 20px;
}
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
}
.badge-word { background: #dbeafe; color: #1d4ed8; }
.badge-verb { background: #fce7f3; color: #be185d; }
.badge-noun { background: #fef3c7; color: #b45309; }
.badge-adj { background: #ede9fe; color: #6d28d9; }
.badge-pattern { background: #ecfdf5; color: #047857; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 200; display: none; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 20px; max-width: 680px;
  width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.modal-header {
  padding: 24px 24px 0; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
}
.modal-body { padding: 16px 24px 24px; }
.modal-close {
  border: none; background: var(--bg); width: 36px; height: 36px;
  border-radius: 50%; cursor: pointer; font-size: 1.2rem; color: var(--muted);
}
.modal-close:hover { background: var(--accent2); color: #fff; }

/* Vocab modal content */
.vocab-word {
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  color: var(--primary);
}
.vocab-pos { color: var(--muted); font-size: 0.9rem; margin-left: 8px; }
.section-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin: 16px 0 8px;
}
.ex-box {
  background: var(--bg); border-radius: 12px; padding: 14px;
  margin-top: 10px; border-left: 4px solid var(--primary);
}
.ex-box.zk { border-left-color: #27ae60; }
.ex-box.g10 { border-left-color: #e67e22; }
.ex-box.article { border-left-color: var(--accent); }
.ex-sent { font-size: 1rem; margin-bottom: 6px; }
.ex-trans {
  font-size: 0.88rem; color: var(--muted);
  display: none; margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.ex-trans.show { display: block; }
.cn-reveal {
  background: var(--primary-light); color: var(--primary);
  border: none; padding: 6px 14px; border-radius: 999px;
  cursor: pointer; font-size: 0.82rem; font-weight: 600; margin-top: 8px;
}
.cn-reveal:hover { background: var(--primary); color: #fff; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  background: var(--primary-light); color: var(--primary);
  padding: 4px 10px; border-radius: 999px; font-size: 0.8rem;
}

/* Lookup popup */
.lookup-popup {
  position: fixed; z-index: 300; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  padding: 16px; max-width: 360px; min-width: 240px;
  display: none;
}
.lookup-popup.open { display: block; }
.lookup-loading { color: var(--muted); font-size: 0.85rem; }

/* Config panel */
.config-panel {
  position: fixed; bottom: 16px; right: 16px; z-index: 150;
}
.config-toggle {
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; cursor: pointer;
  box-shadow: var(--shadow); font-size: 1.2rem;
}
.config-drawer {
  display: none; position: absolute; bottom: 56px; right: 0;
  width: 320px; background: var(--surface); border-radius: 16px;
  border: 1px solid var(--border); padding: 16px; box-shadow: var(--shadow);
}
.config-drawer.open { display: block; }
.config-drawer label { display: block; font-size: 0.8rem; color: var(--muted); margin: 8px 0 4px; }
.config-drawer input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.85rem;
}

/* Toast */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 20px;
  border-radius: 999px; font-size: 0.85rem; z-index: 400;
  opacity: 0; transition: 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* AI result box */
.ai-result {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #bbf7d0; border-radius: 12px;
  padding: 16px; margin-top: 12px; font-size: 0.92rem;
  white-space: pre-wrap; line-height: 1.7;
}
.ai-result.loading { color: var(--muted); font-style: italic; }

/* Responsive */
@media (max-width: 768px) {
  .top-nav { padding: 10px 16px; }
  .top-nav .links a { font-size: 0.78rem; padding: 5px 10px; }
}
