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

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #333333;
  --text-muted: #888888;
  --accent: #4a90d9;
  --accent-dark: #357abd;
  --green: #4caf50;
  --green-dim: rgba(76,175,80,0.1);
  --pink: #e91e63;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.18);
  --radius: 4px;
  --radius-sm: 3px;
}

html { background: var(--bg); }

body {
  color: var(--text);
  background: var(--bg);
  font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-dark); }

[hidden] { display: none !important; }

/* ── HUB / LANDING ──────────────────────── */

.hub-shell {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  min-height: 100vh;
}

.hub-header {
  text-align: center;
  padding: 32px 16px 8px;
  background: var(--accent);
  color: #fff;
}

.hub-header .wordmark { font-size: 36px; color: #fff; }
.hub-header .wordmark span { color: #fff; opacity: 0.9; }
.hub-header .tagline { color: rgba(255,255,255,0.85); font-size: 15px; margin-top: 4px; }

.hub-main { padding: 16px; }

.hub-hero {
  text-align: center;
  margin-bottom: 32px;
  padding: 28px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hub-hero h1 { font-size: 24px; color: var(--text); margin-bottom: 8px; font-weight: 400; }
.hub-sub { color: var(--text-muted); font-size: 14px; max-width: 500px; margin: 0 auto; }

.hub-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.hub-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.15s;
  border-top: 3px solid var(--accent);
}
.hub-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  text-decoration: none;
}
.hub-card:nth-child(2) { border-top-color: var(--green); }
.hub-card:nth-child(3) { border-top-color: #ff9800; }
.hub-card-icon { font-size: 32px; margin-bottom: 10px; }
.hub-card h2 { font-size: 18px; color: var(--text); margin-bottom: 6px; font-weight: 500; }
.hub-card p { color: var(--text-muted); font-size: 13px; flex: 1; margin-bottom: 12px; }
.hub-card-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(74,144,217,0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  align-self: flex-start;
}

.hub-levels-info { margin-bottom: 32px; }
.hub-levels-info h2 { color: var(--text); font-size: 18px; margin-bottom: 14px; font-weight: 500; }

.levels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.level-card {
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.level-card p { color: var(--text-muted); font-size: 13px; margin-top: 8px; }

.hub-progress-section { margin-bottom: 32px; }
.hub-progress-section h2 { color: var(--text); font-size: 18px; margin-bottom: 14px; font-weight: 500; }

.hub-progress-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.progress-stat {
  flex: 1;
  min-width: 140px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
.progress-num { display: block; font-size: 26px; font-weight: 500; color: var(--accent); }
.progress-label { display: block; color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ── LEVEL BADGES ───────────────────────── */

.level-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.level-beginner { background: rgba(76,175,80,0.15); color: #388e3c; }
.level-intermediate { background: rgba(74,144,217,0.15); color: var(--accent); }
.level-advanced { background: rgba(233,30,99,0.15); color: var(--pink); }

/* ── SECTION PAGES (science/math) ───────── */

.section-page { padding: 0 16px 40px; }
.section-hero { text-align: center; padding: 20px 0 16px; }
.section-hero h1 { font-size: 24px; color: var(--text); margin-bottom: 4px; font-weight: 400; }
.section-hero p { color: var(--text-muted); font-size: 14px; }

.back-link {
  display: inline-block;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  transition: all 0.15s;
}
.back-link:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ── HEADER (shared) ────────────────────── */

.feed-shell {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 40px;
}

.feed-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--accent);
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.tagline-bar {
  text-align: center;
  padding: 6px 0 10px;
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  letter-spacing: 0.3px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
}

.wordmark {
  color: #fff;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.5px;
  text-decoration: none;
}
.wordmark span { color: rgba(255,255,255,0.85); }

.header-stats { display: flex; gap: 6px; }

.stat-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.2);
  font-size: 12px;
  font-weight: 500;
  color: #fff;
}
.stat-icon { font-size: 13px; }
#stat-streak .stat-icon, #stat-done .stat-icon { color: #fff; }
#stat-learned .stat-icon, #stat-solved .stat-icon { color: #fff; }
#stat-level .stat-icon { color: #fff; }

/* ── DICTIONARY SEARCH ──────────────────── */

.search-bar-row { padding: 0 16px 10px; background: var(--accent); }
.search-bar-row form {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.search-bar-row input {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search-bar-row input::placeholder { color: #aaa; }
.search-bar-row button {
  padding: 8px 14px;
  border: none;
  background: #333;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.search-bar-row button:hover { background: #444; }

/* ── DAILY WORD ─────────────────────────── */

.daily-word-slot { padding: 16px 16px 0; }
.daily-label {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 10px;
  border-radius: 3px;
  background: #ff9800;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── FEED ───────────────────────────────── */

.feed {
  padding: 8px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.sentinel-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── WORD CARD ──────────────────────────── */

.word-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.15s;
}
.word-card:hover {
  box-shadow: var(--shadow-hover);
}

.card-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
}
.tag-dictionary { background: #4a90d9; }
.tag-science { background: #4caf50; }
.tag-math { background: #ff9800; }

.card-category {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.card-index {
  color: #bbb;
  font-size: 11px;
  font-weight: 500;
}

.card-word-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.card-word {
  font-size: 24px;
  font-weight: 500;
  color: var(--text);
}

.card-pron {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.card-pos {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.card-defs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.card-def {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 4px;
  font-size: 14px;
  color: #555;
}

.card-def-num { color: var(--accent); font-weight: 500; }

.card-example {
  padding: 8px 12px;
  margin-bottom: 12px;
  border-left: 3px solid var(--accent);
  background: rgba(74,144,217,0.05);
  font-size: 13px;
  color: var(--text-muted);
}

.example-label {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(74,144,217,0.15);
  color: var(--accent);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.learn-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.learn-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-dim); }
.learn-btn.learned { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.learn-check { font-size: 14px; }

.detail-link {
  font-size: 12px;
  color: var(--accent);
}
.detail-link:hover { text-decoration: underline; }

.card-counter {
  margin-top: 8px;
  text-align: right;
  font-size: 11px;
  color: #ccc;
}

/* ── LESSON CARD (science) ──────────────── */

.topic-label {
  display: inline-block;
  margin-left: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.lesson-content {
  margin: 12px 0;
  padding: 12px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #555;
  line-height: 1.7;
}

.key-facts {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: rgba(76,175,80,0.05);
  border: 1px solid rgba(76,175,80,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.key-facts strong { color: #388e3c; display: block; margin-bottom: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.key-facts ul { margin: 0; padding-left: 16px; }
.key-facts li { margin-bottom: 3px; color: var(--text-muted); }
.key-facts li:last-child { margin-bottom: 0; }

/* ── QUIZ (inside lessons) ──────────────── */

.quiz-section { margin-top: 14px; }
.quiz-title { color: var(--text); font-size: 15px; margin-bottom: 10px; font-weight: 500; }
.quiz-question { color: var(--text); font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.quiz-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.quiz-opt {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.quiz-opt.correct { border-color: var(--green); background: var(--green-dim); color: #388e3c; }
.quiz-opt.wrong { border-color: var(--pink); background: rgba(233,30,99,0.08); color: var(--pink); }
.quiz-opt:disabled { cursor: default; opacity: 0.7; }
.quiz-feedback { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.quiz-correct { color: #388e3c; font-weight: 500; }
.quiz-wrong { color: var(--pink); font-weight: 500; }

/* ── MATH CARDS ─────────────────────────── */

.math-question {
  margin: 12px 0;
  padding: 16px;
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}

.math-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.math-opt {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.math-opt:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.math-opt.correct { border-color: var(--green); background: var(--green-dim); color: #388e3c; }
.math-opt.wrong { border-color: var(--pink); background: rgba(233,30,99,0.08); color: var(--pink); }
.math-opt:disabled { cursor: default; }

.math-feedback {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.5;
}

/* ── SEARCH RESULTS OVERLAY ─────────────── */

.search-results {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  background: var(--bg);
  overflow-y: auto;
}
.search-results-inner {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}
.search-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.search-results-header h2 { color: var(--text); font-size: 18px; font-weight: 500; }
.close-search-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-search-btn:hover { background: #f0f0f0; }
#search-results-list { display: flex; flex-direction: column; gap: 12px; }
.empty-msg { padding: 24px 0; color: var(--text-muted); text-align: center; font-size: 14px; }

/* ── FOOTER ─────────────────────────────── */

.site-footer {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.site-footer span { color: var(--accent); font-weight: 500; }

/* ── MEANING PAGE ───────────────────────── */

.meaning-page { max-width: 560px; margin: 0 auto; padding: 0 16px 30px; }
.meaning-page h1 { margin-bottom: 2px; color: var(--text); font-size: 28px; font-weight: 500; }
.meaning-page .pronunciation { color: var(--text-muted); font-size: 14px; font-style: italic; }
.meaning-page .part-of-speech { margin: 4px 0 16px; color: var(--text-muted); font-size: 13px; font-style: italic; }
.meaning-page .definition { display: grid; grid-template-columns: 22px 1fr; gap: 4px; margin: 4px 0; }
.meaning-page .definition-number { color: var(--accent); font-weight: 500; }
.meaning-page .example { margin: 10px 0 0 24px; padding-left: 8px; border-left: 2px solid var(--accent); color: var(--text-muted); font-size: 13px; }

/* ── RESPONSIVE ─────────────────────────── */

@media (max-width: 700px) {
  .hub-cards { grid-template-columns: 1fr; }
  .levels-grid { grid-template-columns: 1fr; }
  .math-opts { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .feed-shell { width: 100%; }
  .hub-shell { width: 100%; }
}
