:root {
  --navy: #123c7b; --navy-dark: #0d2c5c; --ink: #1c2733; --mut: #5d6b7a;
  --line: #d8e0ea; --bg: #f4f7fb; --card: #ffffff; --good: #1d8a4e;
  --warn: #d9a400; --bad: #cf3d3d; --accent: #eaf1fb;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); }
#topbar { background: var(--navy); color: #fff; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 19px; }
.brand-sub { font-weight: 400; font-size: 13px; opacity: .85; margin-left: 6px; }
#topnav button { background: transparent; border: 1px solid rgba(255,255,255,.45);
  color: #fff; border-radius: 999px; padding: 5px 13px; margin-right: 6px; cursor: pointer; font-size: 14px; }
#topnav button:hover { background: rgba(255,255,255,.15); }
main { max-width: 1180px; margin: 0 auto; padding: 18px 14px 70px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; margin-bottom: 14px; }
h1 { font-size: 24px; margin: 4px 0 10px; }
h2 { font-size: 18px; margin: 2px 0 10px; }
button.primary { background: var(--navy); color: #fff; border: none; border-radius: 8px;
  padding: 11px 20px; font-size: 16px; cursor: pointer; }
button.primary:hover { background: var(--navy-dark); }
button.ghost { background: #fff; color: var(--navy); border: 1px solid var(--navy);
  border-radius: 8px; padding: 10px 16px; font-size: 15px; cursor: pointer; }
button.small { padding: 6px 12px; font-size: 14px; }
input[type=text], input[type=date], input[type=number], select {
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.mut { color: var(--mut); } .err { color: var(--bad); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.big { font-size: 30px; font-weight: 700; }
.loading { color: var(--mut); padding: 30px; text-align: center; }

/* player */
.player-head { display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px;
  background: var(--accent); padding: 4px 12px; border-radius: 999px; }
.player-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 880px) { .player-body { grid-template-columns: 1fr; } }
.passage { background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; font-family: Georgia, "Times New Roman", serif; font-size: 17.5px;
  line-height: 1.65; max-height: 66vh; overflow: auto; white-space: pre-wrap; }
.passage img { max-width: 100%; height: auto; }
.qpanel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.prompt { font-size: 16.5px; line-height: 1.55; margin-bottom: 14px; white-space: pre-wrap; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 12px; margin-bottom: 9px; cursor: pointer; font-size: 16px; line-height: 1.5; }
.choice:hover { border-color: var(--navy); }
.choice.sel { border-color: var(--navy); background: var(--accent); }
.choice .letter { font-weight: 700; border: 1.5px solid var(--ink); border-radius: 50%;
  width: 26px; height: 26px; flex: 0 0 26px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.choice.sel .letter { background: var(--navy); color: #fff; border-color: var(--navy); }
.player-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; flex-wrap: wrap; }
.palette { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.palette button { width: 34px; height: 34px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 13px; position: relative; }
.palette button.cur { border-color: var(--navy); border-width: 2px; font-weight: 700; }
.palette button.done { background: var(--accent); }
.palette button.flagged::after { content: "⚑"; position: absolute; top: -7px; right: -3px;
  color: var(--bad); font-size: 11px; }
span.w { cursor: pointer; border-radius: 3px; }
span.w:hover { background: #fff3bf; }

/* results */
.band { font-size: 34px; font-weight: 800; color: var(--navy); }
.review-item { border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; margin-bottom: 10px; background: #fff; }
.review-item.right { border-left: 5px solid var(--good); }
.review-item.wrong { border-left: 5px solid var(--bad); }
.expl { background: var(--accent); border-radius: 8px; padding: 10px 12px; margin-top: 8px; white-space: pre-wrap; line-height: 1.55; }
.rat { background: #f6f6f0; border-radius: 8px; padding: 10px 12px; margin-top: 8px; white-space: pre-wrap; line-height: 1.55; }
.tag { display: inline-block; font-size: 12px; background: var(--accent); color: var(--navy);
  border-radius: 999px; padding: 2px 9px; margin-right: 5px; }

/* dashboard */
table.skills { width: 100%; border-collapse: collapse; }
table.skills td, table.skills th { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: 15px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; }
.dot.g { background: var(--good); } .dot.y { background: var(--warn); } .dot.r { background: var(--bad); } .dot.n { background: #c3ccd6; }

/* word popup */
#wordpop { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 60;
  width: min(480px, 92vw); background: #fff; border: 1px solid var(--navy); border-radius: 12px;
  box-shadow: 0 10px 34px rgba(0,0,0,.28); padding: 13px 15px; }
.wordpop-head { display: flex; justify-content: space-between; align-items: center; }
#wordpop-word { font-weight: 800; font-size: 19px; }
#wordpop-close { border: none; background: none; font-size: 22px; cursor: pointer; }
.wordpop-actions { margin-top: 9px; text-align: right; }
#wordpop-save { background: var(--navy); color: #fff; border: none; border-radius: 7px; padding: 8px 13px; cursor: pointer; }

/* print */
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { display: block !important; position: absolute; inset: 0; padding: 18px;
    font-family: Georgia, serif; color: #000; background: #fff; }
  #printArea .pq { page-break-inside: avoid; margin-bottom: 22px; }
  #printArea img { max-width: 100%; }
}
.flashcard { text-align: center; padding: 34px 12px; cursor: pointer; }
.rev-tools { position: sticky; top: 0; z-index: 20; background: #fff; padding: 8px 0 6px;
  border-bottom: 1px solid var(--line); }
.rev-jump { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rev-jump button { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 12px; }
.rev-jump button.jr { border-color: var(--good); color: var(--good); }
.rev-jump button.jw { border-color: var(--bad); color: var(--bad); }
.rev-head { cursor: pointer; }
.rev-head .chev { float: right; color: var(--mut); }
.daypick label { margin-right: 10px; font-size: 15px; }
textarea.copybox { width: 100%; min-height: 90px; }
