:root {
  --ink: #1f1d1a;
  --muted: #77706a;
  --paper: #fbf8f2;
  --rule: #e4ddd0;
  --accent: #8c2f1b;      /* terracotta – red-figure pottery */
  --hl: #f6e2b8;
  --hl-strong: #efc976;
  --english: #3b4f63;
  --greek: "Gentium Book Plus", "Gentium Plus", "GFS Didot", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
}

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(251, 248, 242, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.top-inner {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
h1 {
  margin: 0;
  font-family: var(--greek);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
}
.subtitle { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--muted); text-wrap: balance; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slider {
  width: 2.6rem; height: 1.5rem; border-radius: 1rem;
  background: #cfc6b8; position: relative; transition: background 0.15s;
  flex: none;
}
.slider::after {
  content: ""; position: absolute; top: 0.2rem; left: 0.2rem;
  width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff;
  transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(1.1rem); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-size: 0.9rem; }

.controls { display: flex; align-items: center; gap: 1rem; }
.quiz-button {
  font: inherit; font-size: 0.9rem; font-weight: 600;
  color: var(--accent); background: #fff;
  border: 1px solid var(--accent); border-radius: 1rem;
  padding: 0.3rem 0.9rem; cursor: pointer;
}
.quiz-button:hover { background: #f8ece6; }

/* Text */
.text {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 1rem;
}
.intro, .gap {
  font-size: 0.92rem;
  line-height: 1.5;
  color: #4a4540;
  background: #f3eee4;
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 0 0 1.5rem;
  border-radius: 0 6px 6px 0;
}
.gap { margin: 1.75rem 0; }
.gap strong, .intro strong { color: var(--accent); }

.line {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  column-gap: 0.5rem;
  margin: 0 0 0.35rem;
}
.num {
  grid-row: 1 / span 2;
  font-size: 0.75rem;
  color: #b3aa9d;
  text-align: right;
  padding-top: 0.5rem;
  background: none;
  border: 0;
  font-family: var(--ui);
  cursor: pointer;
  align-self: start;
}
.num.five { color: var(--muted); font-weight: 600; }
.num:hover { color: var(--accent); }

.greek {
  font-family: var(--greek);
  font-size: 1.3rem;
  line-height: 1.6;
  margin: 0.2rem 0;
  padding-left: 1.2em;     /* a wrapped line is indented, so it can't be mistaken for the next line */
  text-indent: -1.2em;
}
.w {
  cursor: pointer;
  border-radius: 3px;
  padding: 0.05em 0.08em;
  margin: 0 -0.08em;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.w:hover { background: #efe8da; }
.w.hl { background: var(--hl); }
.w.hl.tapped { background: var(--hl-strong); }

.english {
  display: none;
  margin: 0 0 0.6rem;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--english);
}
body.show-english .english,
.line.reveal .english { display: block; }

.loading, .error { color: var(--muted); }
.error { color: #a12; white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }

.foot {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1rem 14rem;   /* room for the panel */
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
}
.source { font-size: 0.75rem; }

/* Word panel – a bottom sheet on every screen size */
.panel {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(46rem, 100%);
  max-height: 45vh;
  overflow-y: auto;
  z-index: 10;
  background: #fff;
  border: 1px solid var(--rule);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.12);
  padding: 1rem 2.75rem calc(1rem + env(safe-area-inset-bottom)) 1.25rem;
}
.panel[hidden] { display: none; }
.panel-close {
  position: absolute; top: 0.4rem; right: 0.5rem;
  width: 2.25rem; height: 2.25rem;
  border: 0; background: none; font-size: 1.6rem; line-height: 1;
  color: var(--muted); cursor: pointer;
}
.gloss + .gloss { border-top: 1px solid var(--rule); margin-top: 0.75rem; padding-top: 0.75rem; }
.gloss-greek { font-family: var(--greek); font-size: 1.3rem; margin: 0; color: var(--accent); }
.gloss-lit { font-size: 1.1rem; margin: 0.2rem 0 0; font-weight: 600; }
.gloss-note { font-size: 0.9rem; line-height: 1.45; margin: 0.35rem 0 0; color: #4a4540; }
.gloss-empty { color: var(--muted); font-style: italic; }
.panel-line { font-size: 0.75rem; color: var(--muted); margin: 0 0 0.4rem; }

/* Quiz */
body.quizzing .english { display: none !important; }
body.quizzing .w { cursor: default; }
body.quizzing .w:hover:not(.hl) { background: none; }
.qtitle { font-size: 1.15rem; font-weight: 700; margin: 0 0 0.4rem; }
.qhelp { font-size: 0.9rem; color: #4a4540; margin: 0 0 0.9rem; line-height: 1.45; }
.qrow { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin: 0 0 0.9rem; font-size: 0.95rem; }
.qselect { font: inherit; padding: 0.25rem 0.4rem; border: 1px solid var(--rule); border-radius: 6px; background: #fff; }
.qcheck { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.qhead { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin: 0 0 0.35rem; }
.qbar { height: 4px; background: var(--rule); border-radius: 2px; margin: 0 0 0.8rem; overflow: hidden; }
.qfill { height: 100%; background: var(--accent); transition: width 0.2s; }
.qgreek { font-size: 1.6rem; }
.qanswer { margin: 0.2rem 0 0; }
.qline { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 0.9rem; color: var(--english); margin: 0.5rem 0 0; }
.qactions { display: flex; gap: 0.75rem; margin-top: 0.9rem; }
.qbtn {
  font: inherit; font-size: 1rem; font-weight: 600;
  padding: 0.65rem 1.2rem; min-width: 7rem;
  border-radius: 8px; border: 1px solid var(--rule); background: #fff; color: var(--ink);
  cursor: pointer;
}
.qbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.qbtn.primary:disabled { opacity: 0.4; cursor: default; }
.qbtn.no { border-color: #c98a7c; color: #8c2f1b; flex: 1; }
.qbtn.yes { background: #3f6e48; border-color: #3f6e48; color: #fff; flex: 1; }

@media (max-width: 520px) {
  .greek { font-size: 1.08rem; }
  .english { font-size: 0.92rem; }
  .num { padding-top: 0.35rem; }
  .line { grid-template-columns: 2rem 1fr; column-gap: 0.4rem; }
  h1 { font-size: 1.15rem; }
  .controls { gap: 0.6rem; }
  .switch-label { font-size: 0.85rem; }
}

@media print {
  .top { position: static; }
  .panel, .foot p:first-child { display: none; }
  body.show-english .english { display: block; }
}

/* ---- Site menu (nav.js) ---- */
.sitebar {
  max-width: 46rem; margin: 0 auto; padding: 0.45rem 1rem 0;
  display: flex; align-items: center; justify-content: space-between;
}
.sitename { font-family: var(--greek); color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.sitename:hover { color: var(--accent); }
.menu-button {
  font: inherit; font-size: 0.85rem; color: var(--ink); background: none;
  border: 1px solid var(--rule); border-radius: 1rem; padding: 0.2rem 0.75rem; cursor: pointer;
}
.menu-button[aria-expanded="true"] { background: #f3eee4; }
.menu {
  position: absolute; right: max(1rem, calc(50% - 22rem)); top: 2.4rem; z-index: 20;
  width: min(22rem, calc(100% - 2rem));
  background: #fff; border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14); padding: 0.4rem 0 0.6rem;
}
.menu[hidden] { display: none; }
.menu-head { margin: 0.6rem 1rem 0.2rem; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.menu a { display: block; padding: 0.45rem 1rem; color: var(--ink); text-decoration: none; font-size: 0.95rem; }
.menu a:hover { background: #f8f3ea; }
.menu a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---- Home page ---- */
.home-head { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 1.5rem 0 0.6rem; }
.home-head:first-child { margin-top: 0.5rem; }
.home-card {
  display: block; text-decoration: none; color: var(--ink);
  background: #fff; border: 1px solid var(--rule); border-radius: 10px;
  padding: 0.85rem 1rem; margin: 0 0 0.7rem;
}
.home-card:hover { border-color: var(--accent); }
.home-title { display: block; font-family: var(--greek); font-size: 1.2rem; color: var(--accent); }
.home-meta { display: block; font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0 0.3rem; }
.home-desc { display: block; font-size: 0.92rem; line-height: 1.4; }
.page-home .foot, .page-guide .foot, .page-vocab .foot { padding-bottom: 2rem; }

/* ---- Prose (Lysias) ---- */
body.prose .line.sec-start { margin-top: 0.9rem; }
body.prose .num { font-size: 0.78rem; }
body.prose .num.sec { color: var(--accent); }
body.prose .greek { padding-left: 0; text-indent: 0; }
.outro { margin-top: 1.75rem; }

/* ---- Vocabulary ---- */
.card-box { background: #fff; border: 1px solid var(--rule); border-radius: 12px; padding: 1rem 1.1rem 1.1rem; }
.vprompt { font-size: 1.25rem; line-height: 1.4; margin: 0.6rem 0 0.2rem; min-height: 2rem; }
.vprompt.greekish { font-size: 1.55rem; color: var(--accent); }
.greekish { font-family: var(--greek); }
.vanswer { margin: 0.4rem 0 0; }
.vans { font-size: 1.15rem; font-weight: 600; margin: 0; }
.vans.greekish { font-size: 1.4rem; font-weight: 400; color: var(--accent); }
.score { margin: 0.9rem 0 0; color: var(--muted); }
.linkish { font: inherit; font-size: 0.75rem; color: var(--muted); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 0; }
.filter { flex: 1; min-width: 12rem; padding: 0.45rem 0.6rem; }
.vlist { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.vlist td { padding: 0.4rem 0.4rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.vlist td.greekish { font-size: 1.1rem; }
.vmark { width: 1.2rem; text-align: center; color: var(--muted); }
.vmark.yes { color: #3f6e48; }
.vmark.no { color: var(--accent); font-weight: 700; }

/* ---- Exam guide ---- */
.guide h2 { font-size: 1.15rem; color: var(--accent); margin: 1.6rem 0 0.5rem; }
.guide h2:first-child { margin-top: 0.4rem; }
.guide h3 { font-size: 1rem; margin: 1.2rem 0 0.4rem; }
.guide p, .guide li { line-height: 1.55; font-size: 0.97rem; }
.guide li { margin: 0 0 0.35rem; }
.guide [lang="grc"] { font-family: var(--greek); font-size: 1.08em; }
.grid { border-collapse: collapse; margin: 0.4rem 0 0.8rem; font-size: 0.93rem; }
.grid th { width: 2rem; text-align: center; color: #fff; background: var(--accent); border-bottom: 1px solid #fff; padding: 0.4rem; }
.grid td { background: #fff; border: 1px solid var(--rule); padding: 0.4rem 0.6rem; }

/* GCSE-list box in the word panel */
.dvl { margin: 0.6rem 0 0; padding: 0.45rem 0.7rem; background: #eef3ea; border-left: 3px solid #3f6e48; border-radius: 0 6px 6px 0; }
.dvl-label { margin: 0; font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: #3f6e48; }
.dvl-entry { margin: 0.15rem 0 0; font-size: 0.92rem; }
.dvl-gk { font-family: var(--greek); font-size: 1.08rem; }

/* Practice: tabs, and the translation exercise (practise.js) */
.qtabs { display: flex; gap: 0.4rem; margin: 0 0 0.8rem; }
.qtab {
  font: inherit; font-size: 0.9rem; padding: 0.35rem 0.8rem; border-radius: 1rem;
  border: 1px solid var(--rule); background: #fff; color: var(--ink); cursor: pointer;
}
.qtab.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
body.practising .line.passage { background: var(--hl); border-radius: 6px; }
body.practising .line:not(.passage) .greek { opacity: 0.45; }
.ptext {
  width: 100%; font: inherit; font-size: 1rem; line-height: 1.45; padding: 0.5rem 0.6rem;
  border: 1px solid var(--rule); border-radius: 8px; resize: vertical;
}
.plabel { margin: 0.6rem 0 0.1rem; font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.pmine { margin: 0; font-size: 0.98rem; line-height: 1.45; white-space: pre-wrap; }
.pours { margin-top: 0; font-size: 1rem; }
.pgrid { display: grid; gap: 0.4rem; }
.pmark {
  display: flex; align-items: center; gap: 0.7rem; text-align: left;
  font: inherit; font-size: 0.9rem; padding: 0.45rem 0.7rem; min-width: 0;
  border: 1px solid var(--rule); border-radius: 8px; background: #fff; cursor: pointer;
}
.pmark strong { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.pmark:hover { border-color: var(--accent); }
.qactions.wrap { flex-wrap: wrap; }
.pours + .qhelp { margin-top: 0.8rem; }

/* Sync page */
.sync-code { font-family: ui-monospace, Menlo, monospace; font-size: 1.35rem; font-weight: 600; color: var(--accent); background: #f3eee4; border-radius: 8px; padding: 0.5rem 0.8rem; display: inline-block; margin: 0.2rem 0 0.4rem; user-select: all; }
.card-box h2 { font-size: 1rem; margin: 1.2rem 0 0.4rem; }
.card-box p { line-height: 1.5; }
