:root {
  --paper: #f3ede1; --card: #fbf8f2; --ink: #2a2622; --muted: #75695b; --line: #e2d8c8;
  --accent: #8b2e1f; --accent-soft: rgba(139, 46, 31, .14); --ok: #3d6b3a; --bad: #9a3a2a;
  --serif: 'IM Fell English', Georgia, serif; --sans: 'Source Sans 3', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1c1916; --card: #25211d; --ink: #ece4d6; --muted: #a89a88; --line: #3a332c;
    --accent: #e08a6d; --accent-soft: rgba(224, 138, 109, .16); --ok: #8cc084; --bad: #e0907a;
  }
}
:root[data-theme="dark"] {
  --paper: #1c1916; --card: #25211d; --ink: #ece4d6; --muted: #a89a88; --line: #3a332c;
  --accent: #e08a6d; --accent-soft: rgba(224, 138, 109, .16); --ok: #8cc084; --bad: #e0907a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.55 var(--sans); }
main { max-width: 880px; margin: 0 auto; padding: 8px 16px 40px; }
.top { max-width: 880px; margin: 0 auto; padding: 14px 16px 0; font-size: .9rem; }
.top a { color: var(--muted); text-decoration: none; }
hgroup { margin: 18px 0 8px; }
hgroup h1 { font: 400 2.6rem/1.1 var(--serif); margin: 2px 0; }
.roman { color: var(--accent); font: italic 1rem var(--serif); margin: 0; letter-spacing: .04em; }
.sub { color: var(--muted); margin: 0; font: italic 1.15rem var(--serif); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 16px; margin: 18px 0; }
h2 { font: 400 1.5rem var(--serif); margin: 0 0 6px; }
.hint { color: var(--muted); margin: 0 0 12px; font-size: .95rem; }
button { font: inherit; color: inherit; cursor: pointer; }

/* plate */
.plate { position: relative; width: 100%; border-radius: 6px; overflow: hidden; }
.plate img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plate .raw { opacity: 0; transition: opacity .25s; }
.plate.show-raw .raw { opacity: 1; }
.dot { position: absolute; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; padding: 0;
  border: 2px solid var(--accent); background: rgba(251, 248, 242, .55); display: grid; place-items: center; transition: transform .15s; }
.dot span { font-size: .8rem; font-weight: 600; color: #6e2416; }
.dot.unsure { border-style: dashed; }
.dot:hover, .dot.on { transform: translate(-50%, -50%) scale(1.15); background: var(--accent); }
.dot.on span, .dot:hover span { color: #fff; }
.dot.right { background: var(--ok); border-color: var(--ok); }
.dot.wrong { background: var(--bad); border-color: var(--bad); }
.label { position: absolute; transform: translate(-50%, calc(-100% - 24px)); background: var(--ink); color: var(--paper);
  padding: 4px 10px; border-radius: 6px; font-size: .95rem; white-space: nowrap; pointer-events: none; }
.label i { font-family: var(--serif); font-size: 1.1rem; }
.switch { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: .95rem; margin: 10px 16px 0 0; cursor: pointer; }
.chips { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 5px 12px; display: flex; gap: 6px; align-items: baseline; }
.chip b { color: var(--accent); font-size: .85rem; }
.chip small { color: var(--muted); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }

/* reading */
.tools { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.tools .switch { margin-top: 0; }
.btn { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 999px; padding: 5px 14px; margin-right: 16px; }
.btn:hover { background: var(--accent-soft); }
.lines { list-style: none; padding: 0; margin: 0; }
.line { display: grid; grid-template-columns: 36px 1fr; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.play { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--accent); background: transparent; position: relative; }
.play::after { content: ""; position: absolute; left: 12px; top: 9px; border-left: 10px solid var(--accent); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.line.on .play { background: var(--accent); }
.line.on .play::after { border-left-color: var(--card); }
.line.on:not(.paused) .play::after { left: 10px; top: 9px; width: 10px; height: 12px; border: 0;
  border-left: 3px solid var(--card); border-right: 3px solid var(--card); box-sizing: border-box; }
.line.on .la { color: var(--accent); }
.la { font: 1.3rem/1.45 var(--serif); margin: 0; }
.la em { font-style: italic; }
.en { margin: 4px 0 0; color: var(--muted); }
.n { border: 0; background: var(--accent-soft); color: var(--accent); font: 600 .75rem var(--sans); border-radius: 4px; padding: 1px 5px; vertical-align: 2px; }
.n-en { font-size: .75rem; color: var(--accent); }
.old { display: none; }
body.old-print .old { display: inline; } body.old-print .mod { display: none; }
body.no-en .en { display: none; }

/* grammar */
table { border-collapse: collapse; width: 100%; margin: 8px 0; }
th { text-align: left; color: var(--muted); font-weight: 400; font-size: .9rem; border-bottom: 1px solid var(--line); padding: 4px 8px 4px 0; }
td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
td[lang="la"] { font: 1.2rem var(--serif); }
.tip { color: var(--muted); font-size: .95rem; margin-bottom: 0; }

/* quiz */
.q { padding: 6px 0 12px; }
.ask { margin: 0 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ask b { font: 1.3rem var(--serif); color: var(--accent); }
#quiz .plate { margin-top: 6px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts button { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 8px 14px; }
.opts button.right { border-color: var(--ok); color: var(--ok); }
.opts button.wrong { border-color: var(--bad); color: var(--bad); text-decoration: line-through; }
.score { color: var(--muted); margin: 0; }

footer { max-width: 880px; margin: 0 auto; padding: 0 16px 40px; color: var(--muted); font-size: .85rem; }

/* contents */
.contents { list-style: none; padding: 0; }
.contents a { display: flex; gap: 12px; align-items: baseline; padding: 14px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.contents a span[lang] { font: 1.5rem var(--serif); }
.contents small { color: var(--muted); }

@media (max-width: 560px) { hgroup h1 { font-size: 2.1rem; } .dot { width: 22px; height: 22px; border-width: 1.5px; } .dot span { font-size: .65rem; } .la { font-size: 1.2rem; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* home: the book */
.book { position: relative; margin: 8px 0 24px; }
.book canvas { width: 100%; aspect-ratio: 1.45; display: block; cursor: pointer; }
.book.open canvas { cursor: default; }
.flatspread { display: none; }
.book.flat canvas { display: none; }
.book.flat .flatspread { display: flex; justify-content: center; }
.flatspread img { width: 46%; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.tap { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); border: 1px solid var(--accent); background: var(--card);
  color: var(--accent); border-radius: 999px; padding: 6px 16px; transition: opacity .3s; }
.book.opening .tap, .book.open .tap { opacity: 0; pointer-events: none; }
.after { text-align: center; opacity: 0; transform: translateY(6px); transition: opacity .6s, transform .6s; pointer-events: none; }
.book.open .after { opacity: 1; transform: none; pointer-events: auto; }
.after p { color: var(--muted); font: italic 1.05rem var(--serif); margin: 4px 0 14px; }
.after .btn { display: inline-block; text-decoration: none; margin: 0 6px 8px; }
.btn.primary { background: var(--accent); color: var(--card); }
.btn.primary:hover { opacity: .9; background: var(--accent); }
.home h2#contents { font: 400 1.5rem var(--serif); }

/* the whole book */
#reader canvas { width: 100%; height: min(69vw, 72vh); max-height: 760px; display: block; touch-action: pan-y; cursor: grab; user-select: none; }
#reader canvas:active { cursor: grabbing; }
.bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.bar .btn { margin: 0; padding: 4px 14px; font-size: 1.1rem; }
.bar input { flex: 1; accent-color: var(--accent); }
.where { text-align: center; color: var(--muted); margin: 8px 0 0; min-height: 1.6em; }
.where a { color: var(--accent); margin-left: 10px; }
body.reading main { max-width: 1100px; }
.inbook { margin-left: 8px; font-size: .95rem; color: var(--accent); }
#reader canvas.zoomed { cursor: move; }
