/* ===== RAM1128 Greek Theme ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f0f7f7;
  --bg-card: #ffffff;
  --text: #1a2e2e;
  --text-muted: #4a6a6a;
  --primary: #0d5c63;
  --primary-dark: #084448;
  --accent: #c9a227;
  --accent-light: #e8d48b;
  --border: #c5d9d9;
  --success: #2d8a6e;
  --danger: #c44536;
  --shadow: 0 4px 12px rgba(13,92,99,.12);
  --radius: 14px;
  --header-h: 58px;
}
body.dark {
  --bg: #0f1f1f;
  --bg-card: #1a3030;
  --text: #e8f4f4;
  --text-muted: #8ab0b0;
  --primary: #3db8c2;
  --primary-dark: #0d5c63;
  --accent: #e8d48b;
  --border: #2a4545;
  --shadow: 0 4px 12px rgba(0,0,0,.4);
}
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  padding-bottom: 80px;
  transition: background .3s, color .3s;
}
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }

/* Header - Mediterranean teal */
.header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  height: var(--header-h);
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; padding: 0 14px; max-width: 820px; margin: 0 auto;
}
.logo { font-size: 1.15rem; font-weight: 700; letter-spacing: .3px; }
.logo-sub { font-size: .75rem; opacity: .85; font-weight: 400; margin-left: 4px; }
.menu-btn, .icon-btn {
  background: none; border: none; color: #fff;
  font-size: 1.35rem; padding: 8px; cursor: pointer; border-radius: 10px;
}
.menu-btn:hover, .icon-btn:hover { background: rgba(255,255,255,.18); }
.header-actions { display: flex; gap: 2px; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: -290px; width: 290px; height: 100%;
  background: var(--bg-card); z-index: 200;
  transition: left .3s ease; box-shadow: 6px 0 24px rgba(0,0,0,.18);
  overflow-y: auto;
}
.sidebar.open { left: 0; }
.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 16px; background: var(--primary-dark); color: #fff;
}
.close-btn { background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; }
.nav-list { list-style: none; padding: 10px 0; }
.nav-link {
  display: block; padding: 13px 20px; color: var(--text);
  font-size: .98rem; border-left: 4px solid transparent; transition: all .2s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(13,92,99,.1); border-left-color: var(--accent);
  color: var(--primary);
}
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 150; opacity: 0; pointer-events: none; transition: opacity .3s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* Main */
.main { max-width: 820px; margin: 0 auto; padding: 18px 14px; }
.page { display: none; animation: fadeIn .3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.page-title { font-size: 1.35rem; margin-bottom: 14px; color: var(--primary-dark); }
body.dark .page-title { color: var(--primary); }
.page-desc { font-size: .9rem; color: var(--text-muted); margin-bottom: 16px; }

/* Hero - Greek inspired */
.hero {
  text-align: center; padding: 28px 16px;
  background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 50%, #1a7a82 100%);
  color: #fff; border-radius: var(--radius); margin-bottom: 22px;
  position: relative; overflow: hidden;
}
.hero::before {
  content: "α β γ δ ε ζ η θ";
  position: absolute; top: 10px; right: -10px;
  font-size: 2.5rem; opacity: .12; letter-spacing: 8px;
  transform: rotate(12deg);
}
.hero-flag { font-size: 2.8rem; margin-bottom: 6px; }
.hero h2 { font-size: 1.45rem; line-height: 1.3; margin-bottom: 6px; }
.subtitle { opacity: .92; font-size: .92rem; margin-bottom: 12px; }
.desc { font-size: .88rem; opacity: .88; max-width: 420px; margin: 0 auto; }

/* Cards */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 18px 12px; text-align: center; box-shadow: var(--shadow);
  border: 1px solid var(--border); transition: transform .2s, box-shadow .2s;
  color: var(--text);
}
.card:hover { transform: translateY(-4px); box-shadow: 0 10px 24px rgba(13,92,99,.18); }
.card-icon { font-size: 1.8rem; display: block; margin-bottom: 8px; color: var(--primary); }
.card h3 { font-size: .95rem; margin-bottom: 4px; }
.card p { font-size: .78rem; color: var(--text-muted); }

/* Info Box */
.info-box {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 16px; border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
}
.info-box h3 { font-size: 1.02rem; margin-bottom: 8px; color: var(--primary); }
.info-box p { font-size: .9rem; }

/* Unit List */
.unit-list { display: flex; flex-direction: column; gap: 10px; }
.unit-item {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 14px 16px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.unit-item:hover { background: rgba(13,92,99,.07); border-color: var(--primary); }
.unit-num {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #1a7a82);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; font-size: 1.05rem;
}
.unit-title { font-weight: 600; font-size: .95rem; }
.unit-sub { font-size: .8rem; color: var(--text-muted); }

/* Unit Content */
.unit-content {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px 16px; border: 1px solid var(--border); margin-top: 16px;
}
.unit-content h3 { color: var(--primary); margin: 18px 0 8px; font-size: 1.08rem; }
.unit-content h3:first-of-type { margin-top: 0; }
.unit-content p, .unit-content li { font-size: .92rem; margin-bottom: 8px; }
.unit-content ul, .unit-content ol { padding-left: 20px; margin-bottom: 12px; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; color: var(--text); margin-bottom: 14px;
  font-size: .9rem;
}
.grammar-box, .culture-box, .ref-box {
  background: rgba(13,92,99,.06); border-left: 4px solid var(--accent);
  padding: 12px 14px; border-radius: 0 10px 10px 0; margin: 14px 0;
  font-size: .9rem;
}
body.dark .grammar-box, body.dark .culture-box { background: rgba(61,184,194,.1); }
.speak-btn {
  background: var(--primary); color: #fff; border: none;
  border-radius: 8px; padding: 5px 11px; font-size: .8rem;
  cursor: pointer; margin-left: 6px;
}

/* Alphabet Grid */
.alphabet-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
}
.alpha-card {
  background: var(--bg-card); border-radius: 12px;
  padding: 14px 8px; text-align: center; border: 1px solid var(--border);
  cursor: pointer; transition: transform .15s, border-color .15s;
}
.alpha-card:hover { transform: scale(1.04); border-color: var(--primary); }
.alpha-upper { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.alpha-lower { font-size: 1.3rem; color: var(--text-muted); margin: 2px 0; }
.alpha-name { font-size: .72rem; color: var(--text-muted); }
.alpha-sound { font-size: .7rem; color: var(--accent); margin-top: 2px; }

/* Vocab */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input {
  flex: 1; min-width: 120px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-card); color: var(--text); font-size: .95rem;
}
.vocab-list { display: flex; flex-direction: column; gap: 8px; }
.vocab-item {
  background: var(--bg-card); border-radius: 12px;
  padding: 13px 14px; border: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.vocab-word { font-weight: 700; color: var(--primary); font-size: 1.08rem; }
.vocab-greek { font-size: 1.15rem; color: var(--accent); margin-right: 6px; }
.vocab-pos { font-size: .72rem; color: var(--text-muted); margin-left: 4px; }
.vocab-meaning { font-size: .9rem; margin-top: 3px; }
.vocab-example { font-size: .8rem; color: var(--text-muted); font-style: italic; margin-top: 4px; }

/* Notes */
.notes-content .note-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 16px; border: 1px solid var(--border); margin-bottom: 12px;
  border-top: 3px solid var(--accent);
}
.note-card h3 { color: var(--primary); font-size: 1.05rem; margin-bottom: 8px; }
.note-card ul { padding-left: 18px; font-size: .9rem; }
.note-card li { margin-bottom: 6px; }

/* Quiz / Exam */
.quiz-select, .exam-options {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px;
}
.quiz-select select {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text);
}
.btn {
  padding: 11px 18px; border: none; border-radius: 10px;
  font-size: .95rem; cursor: pointer; font-weight: 600;
  background: var(--border); color: var(--text);
  transition: background .2s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.success { background: var(--success); color: #fff; }
.exam-btn { flex: 1; min-width: 120px; }

.quiz-area { margin-top: 12px; }
.question-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 16px; border: 1px solid var(--border); margin-bottom: 14px;
}
.q-num { font-size: .78rem; color: var(--text-muted); margin-bottom: 6px; }
.q-text { font-weight: 600; margin-bottom: 12px; font-size: .95rem; }
.option {
  display: block; width: 100%; text-align: left;
  padding: 11px 13px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); cursor: pointer;
  font-size: .9rem; transition: background .2s;
}
.option:hover { background: rgba(13,92,99,.1); }
.option.selected { border-color: var(--primary); background: rgba(13,92,99,.14); }
.option.correct { border-color: var(--success); background: rgba(45,138,110,.15); }
.option.wrong { border-color: var(--danger); background: rgba(196,69,54,.12); }
.quiz-result {
  text-align: center; padding: 24px;
  background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
}
.quiz-result .score { font-size: 2.6rem; font-weight: 700; color: var(--primary); }
.progress-bar {
  height: 7px; background: var(--border); border-radius: 4px;
  margin: 12px 0; overflow: hidden;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .3s; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-content {
  background: var(--bg-card); border-radius: 18px;
  padding: 26px 20px; max-width: 370px; width: 100%;
  text-align: center; box-shadow: 0 24px 48px rgba(0,0,0,.3);
}
.rest-modal h3 { margin-bottom: 12px; color: var(--primary); }
.dua { font-size: 1.35rem; direction: rtl; margin: 12px 0 4px; }
.dua-th { font-size: .85rem; color: var(--text-muted); margin-bottom: 12px; }
.rest-msg { font-size: .95rem; margin-bottom: 12px; }
.health-tip {
  font-size: .8rem; background: rgba(201,162,39,.12);
  border-radius: 10px; padding: 11px; margin-bottom: 16px; text-align: left;
}

/* Print */
@media print {
  .header, .sidebar, .overlay, .menu-btn, .icon-btn,
  .filter-bar, .quiz-select, .exam-options, .btn, .speak-btn,
  #restModal { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .main { max-width: 100%; padding: 0; }
  .page { display: block !important; }
}

@media (min-width: 600px) {
  .hero h2 { font-size: 1.7rem; }
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .alphabet-grid { grid-template-columns: repeat(6, 1fr); }
}
