:root { --ink:#1c2b25; --accent:#1f7a5a; --bg:#f6f4ec; --line:#e4ddcc; --muted:#5a6b62; }
* { box-sizing: border-box; }
body { font-family: system-ui, 'Segoe UI', sans-serif; background: var(--bg); color: var(--ink);
       margin: 0; line-height: 1.7; }
.wrap { max-width: 44rem; margin: 0 auto; padding: 1.5rem; }
a.back { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.6rem; margin: .5rem 0 .2rem; }
.date { color: var(--muted); margin: 0 0 1rem; }
.sub { color: var(--accent); }

/* Site title (multilingual, one line per language) */
.sitetitle { font-size: 1.35rem; line-height: 1.55; margin: .5rem 0 1rem; font-weight: 700; }
.sitetitle span { display: block; }

/* Site hero (index page) */
.hero { display: block; max-width: 420px; width: 100%; height: auto; margin: .8rem auto 1.2rem;
  border-radius: 14px; }

/* Lesson illustration */
.illustration { display: block; max-width: 100%; height: auto; margin: .8rem 0 1.2rem;
  border: 1px solid var(--line); border-radius: 10px; }

/* Lesson audio player */
.lesson-audio { display: block; width: 100%; margin: 0 0 1.2rem; border-radius: 999px; }

/* Summary / song audio sections */
.audio-section { margin: 0 0 .4rem; }
.audio-heading { margin: 0 0 .4rem; font-size: 1.05rem; color: var(--ink); }

/* An author `display` rule above beats the browser's own [hidden] rule at equal
   specificity (author origin always wins over user-agent origin), so the hero,
   illustration, and audio player would otherwise stay visible while hidden. */
.hero[hidden], .illustration[hidden], .lesson-audio[hidden] { display: none; }

/* Index list */
ul.lessons { list-style: none; padding: 0; }
ul.lessons li { margin: .4rem 0; }
ul.lessons a { display: flex; gap: .8rem; align-items: flex-start; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; }
ul.lessons a:hover { border-color: var(--accent); }

/* Completion checkbox: a sibling of the row link, never inside it. */
li.lrow { display: flex; align-items: center; gap: .6rem; }
li.lrow > a { flex: 1 1 auto; min-width: 0; }
.donebox { flex: 0 0 auto; width: 1.4rem; height: 1.4rem; margin: 0; cursor: pointer;
  accent-color: var(--accent); }
.donebox:disabled { cursor: default; opacity: .5; }
/* Finished lessons recede without disappearing. */
li.lrow.done > a { opacity: .6; }
li.lrow.done .d { color: var(--muted); }
/* Lesson number: compact on phones (mobile-first)… */
.d { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; padding-top: .15rem;
     flex: 0 0 auto; }
.titles { display: flex; flex-direction: column; gap: .2rem; flex: 1 1 auto; }
.tline { font-weight: 600; }
/* …large and prominent (about half the row) on wider screens. */
@media (min-width: 640px) {
  ul.lessons a { align-items: center; gap: 1.2rem; }
  .d { flex: 0 0 40%; font-size: 2.2rem; font-weight: 700; color: var(--accent);
       text-align: center; padding-top: 0; }
}

/* Language toggle */
.langtoggle { margin: .5rem 0 1rem; }
.langbtn { border: 1px solid #d9d3c4; background: #fff; padding: .4rem .8rem; border-radius: 999px;
  cursor: pointer; margin: 0 .3rem .3rem 0; font: inherit; }
.langbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.banner { background: #fff4e0; border: 1px solid #e6c37a; color: #7a5a12; padding: .7rem;
  border-radius: 8px; margin: 1rem 0; }

/* Table of contents */
.toc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1.2rem; margin: 1rem 0; }
.toctitle { font-weight: 700; margin: .2rem 0 .5rem; }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin: .3rem 0; }
.toc a { color: var(--accent); text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* Collapsible sections */
details.sec { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin: .8rem 0; padding: 0 1.2rem; }
details.sec > summary { cursor: pointer; font-weight: 700; padding: .9rem 0; list-style: none; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: "\25B8"; display: inline-block; margin-inline-end: .5rem;
  color: var(--accent); transition: transform .15s; }
details.sec[open] > summary::before { transform: rotate(90deg); }
.secbody { padding-bottom: 1rem; }

/* Report error */
.report { margin: 2.5rem 0 1rem; text-align: center; }
#reportlink { display: inline-block; color: #9a2b1f; border: 1px solid #e0b4ad; background: #fff;
  padding: .5rem 1rem; border-radius: 8px; text-decoration: none; }
#reportlink:hover { background: #fbe9e7; }
.reportaddr { margin-top: .5rem; font-size: .85rem; color: var(--muted); }
.reportaddr a { color: var(--muted); }

/* Footnote reference markers */
.fnref { font-size: .75em; vertical-align: super; line-height: 0; }

/* Content typography */
.lang-block table { border-collapse: collapse; width: 100%; }
.lang-block th, .lang-block td { border: 1px solid var(--line); padding: .5rem; text-align: start; }
.lang-block blockquote { border-inline-start: 3px solid var(--accent); margin: .6rem 0; padding: .2rem 1rem;
  color: #2c463b; font-weight: 600; }
[dir=rtl] { font-size: 1.1rem; }

.status-msg { color: var(--muted); padding: 2rem 0; }

/* Progress: counter + bar on the index, complete button on a lesson */
.progress { margin: 1rem 0 1.2rem; }
.progress:empty { margin: 0; }
.progress-line { margin: 0; font-weight: 600; font-size: .95rem; }
.progress-line + .progress-line { color: var(--muted); font-weight: 400; font-size: .85rem; }
/* Percentage width, so the fill grows from the start edge in both directions. */
.progressbar { margin-top: .5rem; height: .5rem; background: var(--line); border-radius: 999px;
  overflow: hidden; }
.progressbar > span { display: block; height: 100%; background: var(--accent);
  border-radius: 999px; transition: width .2s; }

.lesson-done { margin: 2rem 0 .5rem; text-align: center; }
.donebtn { border: 1px solid var(--accent); background: #fff; color: var(--accent);
  padding: .6rem 1.2rem; border-radius: 999px; cursor: pointer; font: inherit; }
.donebtn:hover { background: #e6f4ee; }
.donebtn.is-done { background: var(--accent); color: #fff; }
.donebtn:disabled { opacity: .6; cursor: default; }

/* Inline save failure (hidden until progressError() shows it) */
.progress-err { display: none; margin: .6rem 0; padding: .6rem .8rem; border-radius: 8px;
  background: #fbe9e7; color: #9a2b1f; font-size: .9rem; }
.progress-err.show { display: block; }

/* Auth: account bar on gated pages */
.authbar { display: flex; justify-content: flex-end; align-items: center; gap: .6rem;
  min-height: 1.5rem; font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.authuser { color: var(--muted); }
/* Non-prod environment badge — deliberately loud, so staging is never mistaken for live. */
.envbadge { background: #9a2b1f; color: #fff; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; font-size: .7rem; padding: .15rem .5rem; border-radius: 999px;
  margin-inline-end: .2rem; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit;
  padding: 0; text-decoration: underline; }

/* ---------------------------------------------------------------------------
   Admin dashboard (admin.html). Tables need their own rules: the existing
   `.lang-block table` block is scoped to a container app.js toggles `hidden`.
   --------------------------------------------------------------------------- */
.wrap-wide { max-width: 68rem; }

/* Stat tiles */
.stats { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0 1.2rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .9rem; min-width: 7rem; flex: 1 1 auto; }
.statv { display: block; font-size: 1.4rem; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums; line-height: 1.2; }
.statl { display: block; font-size: .75rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; }

/* Tab counts sit inside the reused .langbtn pill */
.tabn { opacity: .65; font-size: .85em; }

/* Table container + filter */
.adminbox { background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: .8rem; overflow-x: auto; }
.adminfilter { width: 100%; max-width: 20rem; padding: .5rem .7rem; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: .8rem; }
.adminbox table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.adminbox th, .adminbox td { border-bottom: 1px solid var(--line); padding: .5rem .6rem;
  text-align: start; vertical-align: middle; white-space: nowrap; }
.adminbox th { cursor: pointer; user-select: none; color: var(--muted); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .03em; border-bottom-width: 2px; }
.adminbox th:hover { color: var(--accent); }
.adminbox th.sorted { color: var(--accent); }
.adminbox tbody tr:hover { background: #fafaf6; }
.adminbox tbody tr:last-child td { border-bottom: 0; }
.nums { font-variant-numeric: tabular-nums; }

/* Inline completion bar inside a cell (smaller sibling of .progressbar) */
.minibar { display: inline-block; width: 4.5rem; height: .4rem; background: var(--line);
  border-radius: 999px; overflow: hidden; vertical-align: middle; margin-inline-start: .3rem; }
.minibar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Attention marker: inactive member, never-activated account, unsubscribed */
.warn { color: #9a2b1f; font-size: .8rem; font-weight: 600; }

.adminmeta { color: var(--muted); font-size: .8rem; margin: .8rem 0 2rem; }

/* Small inline action buttons (resend invite, revoke) */
.minibtn { font: inherit; font-size: .78rem; padding: .2rem .55rem; border-radius: 999px;
  border: 1px solid var(--accent); background: #fff; color: var(--accent); cursor: pointer; }
.minibtn:hover { background: #e6f4ee; }
.minibtn:disabled { opacity: .55; cursor: default; }
.minibtn.danger { border-color: #e0b4ad; color: #9a2b1f; }
.minibtn.danger:hover { background: #fbe9e7; }
.muted-cell { color: var(--muted); font-size: .78rem; }

/* Grant-admin form above the Admins table */
.grantrow { display: flex; gap: .5rem; align-items: center; margin: 0 0 .8rem; flex-wrap: wrap; }
.grantrow input { flex: 1 1 16rem; max-width: 22rem; padding: .45rem .7rem; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; }

/* Raw audit payload (Logins tab escape hatch) */
.rawpayload { background: #f4f2ea; border: 1px solid var(--line); border-radius: 8px;
  padding: .8rem; margin: .8rem 0 0; font-size: .75rem; line-height: 1.45;
  max-height: 22rem; overflow: auto; white-space: pre-wrap; word-break: break-word; }

/* #flash reuses .msg / .msg.ok / .msg.err, which are display:none until classed */

/* Modal popup: lesson Completed/Plays member lists */
.modal-overlay { position: fixed; inset: 0; background: rgba(28,43,37,.45);
  display: flex; align-items: center; justify-content: center; padding: 1.2rem; z-index: 100; }
.modal-box { background: #fff; border: 1px solid var(--line); border-radius: 12px;
  max-width: 32rem; width: 100%; max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 36px rgba(0,0,0,.18); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.05rem; margin: 0; }
.modal-close { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--muted);
  cursor: pointer; padding: 0 .2rem; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: .9rem 1.1rem 1.1rem; overflow: auto; }
.modal-body table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.modal-body th, .modal-body td { border-bottom: 1px solid var(--line); padding: .4rem .5rem;
  text-align: start; white-space: nowrap; }
.modal-body th { color: var(--muted); font-size: .78rem; text-transform: uppercase;
  letter-spacing: .03em; }

/* Auth: login / reset pages */
body.authpage { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.authcard { background: #fff; max-width: 24rem; width: 100%; padding: 2rem;
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.05); }
.authcard h1 { font-size: 1.4rem; margin: 0 0 .2rem; }
.authcard .sub { color: var(--muted); margin: 0 0 1.2rem; }
.authcard label { display: block; font-weight: 600; margin: 1rem 0 .35rem; }
.authcard input { width: 100%; padding: .7rem .8rem; border: 1px solid var(--line);
  border-radius: 8px; font-size: 1rem; }
.authcard button[type=submit] { margin-top: 1.4rem; width: 100%; padding: .8rem; font-size: 1rem;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px; cursor: pointer; }
.forgotrow { margin: 1rem 0 0; font-size: .9rem; }
.forgotrow a { color: var(--accent); }
.msg { margin-top: 1rem; padding: .8rem; border-radius: 8px; display: none; }
.msg.ok  { background: #e6f4ee; color: #14603f; display: block; }
.msg.err { background: #fbe9e7; color: #9a2b1f; display: block; }
