
:root { --max: 42rem; }
* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body {
  margin: 0;
  font-family: "Source Serif 4", "Iowan Old Style", Palatino, serif;
  font-size: 1.125rem;
  line-height: 1.65;
  min-height: 100dvh;
  position: relative;
  z-index: 0;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 12% 58% at -6% 48%, var(--glow-a), transparent 72%),
    radial-gradient(ellipse 7% 32% at 108% 64%, var(--glow-b), transparent 70%);
}
a { color: inherit; caret-color: var(--ink); }
button, input { font: inherit; color: inherit; }
.skip {
  position: absolute; left: 1rem; top: -4rem;
  background: var(--ink); color: var(--paper); padding: 0.4rem 0.7rem;
}
.skip:focus { top: 0.5rem; z-index: 5; }
.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 0.75rem 1rem;
  flex-wrap: wrap;
  padding: 0.7rem 1.1rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.mark {
  font-family: "Noto Serif Tamil", serif;
  font-weight: 600;
  font-size: 1.15rem;
  text-decoration: none;
  margin-right: auto;
}
.count { margin: 0; color: var(--muted); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.lang, .rom-btn { display: flex; gap: 0.15rem; }
.lang button, .rom-btn {
  background: transparent;
  border: 0;
  padding: 0.45rem 0.55rem;
  min-height: 44px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.lang button[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--mark);
}
.rom-btn[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--mark); }
.wrap { max-width: var(--max); margin: 0 auto; padding: 1.75rem 1.15rem 6.5rem; }
.kicker {
  margin: 0 0 0.8rem;
  color: var(--mark);
  font-family: "Noto Serif Tamil", serif;
  font-size: 1.05rem;
}
.kicker .num {
  font-family: "Source Serif 4", serif;
  color: var(--muted);
  margin-right: 0.45rem;
}
.song, .rom { list-style: none; margin: 0; padding: 0; }
.song li, .rom li {
  display: grid;
  grid-template-columns: 1fr;
  margin: 0 0 0.35rem;
}
.song { font-family: "Noto Serif Tamil", serif; font-weight: 500; font-size: clamp(1.35rem, 2.6vw, 1.7rem); line-height: 1.85; }
.rom { margin-top: 1rem; color: var(--muted); font-size: 1.02rem; line-height: 1.55; }
html:not([data-rom="on"]) .rom { display: none; }
.note {
  margin: 1.1rem 0 0;
  font-family: "Noto Serif Tamil", serif;
  color: var(--muted);
  font-size: 1rem;
}
.context { margin: 1.4rem 0 0; }
.layer { margin-top: 0.4rem; border-top: 1px solid var(--line); }
.layer summary {
  cursor: pointer;
  padding: 0.85rem 0;
  min-height: 48px;
  color: var(--mark);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.layer summary::after {
  content: "Show";
  font-family: "Source Serif 4", serif;
  font-size: 0.95rem;
  color: var(--muted);
}
.layer[open] summary::after { content: "Hide"; }
.layer summary::-webkit-details-marker { display: none; }
.layer summary:focus-visible, .lang button:focus-visible, .rom-btn:focus-visible, .pager a:focus-visible, .jump input:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}
.layer .body { padding: 0 0 1rem; }
.layer .body p { margin: 0 0 0.9rem; }
.ta-body { font-family: "Noto Serif Tamil", serif; font-size: 1.12rem; line-height: 1.85; }
.line-block { padding: 0.4rem 0 1rem; border-bottom: 1px solid var(--line); }
.line-block h3 { margin: 0.6rem 0 0.25rem; font-size: 0.95rem; font-weight: 600; color: var(--muted); }
.src { font-family: "Noto Serif Tamil", serif; margin: 0 0 0.6rem; font-size: 1.15rem; line-height: 1.7; }
.gloss { margin: 0 0 0.7rem; }
.gloss dt { font-family: "Noto Serif Tamil", serif; font-size: 1.05rem; }
.gloss dd { margin: 0 0 0.45rem; color: var(--muted); }
.why { margin: 0; }
html[data-lang="ta"] .en { display: none; }
html[data-lang="en"] .ta { display: none; }
.wrap.reader { display: flex; flex-direction: column; }
.cols, .col-ta, .col-en { display: contents; }
.kicker { order: 0; }
.song { order: 1; }
.note { order: 2; }
.rom { order: 3; }
.context { order: 4; }
.teach.ta { order: 5; }
.teach.en { order: 6; }
.lines { order: 7; }
.pager { order: 8; }
.pager {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem; align-items: center;
  padding: 0.55rem 0.8rem calc(0.55rem + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.pager a, .pager .dead {
  min-height: 48px;
  display: flex; align-items: center;
  text-decoration: none;
  padding: 0 0.4rem;
}
.pager a:last-child, .pager .dead:last-child { justify-content: flex-end; }
.pager .dead { color: var(--dead); }
.jump { display: flex; align-items: center; gap: 0.35rem; }
.jump input {
  width: 4.5rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: center;
  padding: 0.35rem 0;
  border-radius: 0;
}
.books-link { margin: 0.6rem 0 0; font-family: "Noto Serif Tamil", serif; font-weight: 500; font-size: 0.95rem; }
.books-link a { color: var(--mark); text-decoration: none; display: inline-block; padding: 0.7rem 0.6rem 0.7rem 0; margin: -0.7rem 0; }
.books-link a:hover, .books-link a:focus-visible { text-decoration: underline; text-underline-offset: 0.2em; }
.home h1 {
  font-family: "Noto Serif Tamil", serif;
  font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 3.4rem);
  line-height: 1.25;
  margin: 0.4rem 0 0.2rem;
}
.lede { font-size: 1.2rem; margin-top: 0.2rem; }
.quiet { color: var(--muted); }
.start {
  display: inline-flex; align-items: center; min-height: 48px;
  margin: 1.2rem 0 0.4rem;
  padding: 0.55rem 1rem;
  background: var(--ink); color: var(--paper);
  text-decoration: none;
}
.continue { margin: 0.6rem 0 0; }
.continue a { color: var(--mark); }
.jump-home { margin: 1.4rem 0 2rem; display: flex; gap: 0.6rem; align-items: center; }
.jump-home input {
  width: 5rem; background: transparent; border: 0; border-bottom: 1px solid var(--ink);
  padding: 0.4rem 0; text-align: center;
}
.marked { list-style: none; padding: 0; margin: 0.4rem 0 2rem; }
.marked li { border-top: 1px solid var(--line); }
.marked a {
  display: flex; gap: 0.8rem; align-items: baseline;
  text-decoration: none; min-height: 48px; padding: 0.7rem 0;
}
.marked .vn { font-variant-numeric: tabular-nums; color: var(--muted); width: 2.2rem; }
.marked .sn { font-family: "Noto Serif Tamil", serif; font-size: 1.15rem; }

.spread { display: none; }
.verse-block { margin-top: 2.25rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.verse-block .kicker a { color: inherit; text-decoration: none; }
.verse-block .kicker a:hover { color: var(--mark); }

@media (min-width: 960px) {
  body::before {
    background:
      radial-gradient(ellipse 26% 72% at -4% 46%, var(--glow-a-wide), transparent 70%),
      radial-gradient(ellipse 14% 46% at 106% 58%, var(--glow-b-wide), transparent 72%);
  }
  .wrap.reader { display: block; }
  .cols { display: block; }
  .col-ta, .col-en { display: block; }
  html[data-lang="both"] .wrap.reader { max-width: 68rem; }
  html[data-lang="both"] .cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 3.5rem;
    align-items: start;
  }
  html[data-lang="both"] .col-ta,
  html[data-lang="both"] .col-en { display: block; }
  html[data-lang="both"] .context { margin-top: 0; }
  html[data-lang="ta"] .wrap.reader,
  html[data-lang="en"] .wrap.reader { max-width: 54rem; }
  html[data-lang="ta"] .song,
  html[data-lang="en"] .song { font-size: 1.5rem; line-height: 1.65; }
  .spread { display: block; }
  .pager { position: static; border: 0; padding: 1.5rem 0 0; max-width: 42rem; margin: 1rem auto 0; background: transparent; }
  html[data-lang="both"] .pager { max-width: none; }
  .wrap { padding-bottom: 3rem; }
}

.contents { list-style: none; padding: 0; margin: 0.4rem 0 2rem; }
.contents li { border-top: 1px solid var(--line); }
.contents a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  text-decoration: none; min-height: 48px; padding: 0.75rem 0;
}
.contents .range { font-variant-numeric: tabular-nums; font-size: 1.15rem; }

.go {
  min-height: 44px;
  min-width: 44px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}

/* Theme toggle in the header, same button as the other books. */
.top .theme {
  width: 44px; height: 44px; display: grid; place-items: center;
  padding: 0; border: 0; background: transparent; color: var(--ink);
  cursor: pointer; border-radius: 0.5rem; margin-right: -0.4rem;
}
.top .theme:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; }
html[lang="en"] .mark,
html[lang="en"] .kicker,
html[lang="en"] .song,
html[lang="en"] .note,
html[lang="en"] .layer .body,
html[lang="en"] .ta-body,
html[lang="en"] .src,
html[lang="en"] .gloss dt {
  font-family: "Source Serif 4", "Noto Serif Tamil", Palatino, "Palatino Linotype", serif;
  font-weight: 400;
}
html[lang="en"] .song,
html[lang="en"] .song li,
html[lang="en"] .note,
html[lang="en"] .layer .body,
html[lang="en"] .ta-body {
  line-height: 1.6;
  hyphens: none;
  overflow-wrap: break-word;
}
html[lang="en"] .layer .body,
html[lang="en"] .note,
html[lang="en"] .ta-body {
  font-size: clamp(1.35rem, 2.6vw, 1.7rem);
}
@media (min-width: 1000px) {
  html[lang="en"] .song,
  html[lang="en"] .song li,
  html[lang="en"] .note,
  html[lang="en"] .layer .body {
    line-height: 1.75;
  }
}
@media (max-width: 640px) {
  .top a.lang-toggle { order: 2; }
}
/* Phone: keep the toggle on the first row, beside the count. */
@media (max-width: 640px) {
  .top .mark { order: 0; }
  .top .count { order: 1; }
  .top .theme { order: 2; }
  .top .lang { order: 3; }
  .top .rom-btn { order: 4; }
}
/* Verse pages. The account control stays on the first tool row through 640px,
   and the verse count is hidden at 420px and below. Above that, the language
   link is taken out of the flex line so it cannot add a row. */
@media (max-width: 640px) {
  body[data-verse] .top .notes-account-slot { order: 2; }
}
@media (max-width: 420px) {
  body[data-verse] .top .count { display: none; }
}
@media (min-width: 421px) {
  /* Anchor placement has no fallback of its own. Without this support the
     absolute link drops to the start of the header and covers the name.
     Those browsers keep the 44px link in the flex row, before the theme button. */
  @supports (position-area: left center) {
    /* The flex gap before the account icon is 16px. Shift the theme button
       8px left, into the gap on its other side, so 24px opens up without
       moving the account control or the flex line. */
    body[data-verse] header.top > .theme:has(+ .notes-account-slot) {
      margin-left: -8px;
      margin-right: 8px;
    }
    body[data-verse] .top .notes-account-slot { anchor-name: --verse-account; }
    body[data-verse] .top a.lang-toggle {
      position: absolute;
      z-index: 3;
      position-anchor: --verse-account;
      position-area: left center;
      width: 24px;
      height: 44px;
      margin: 0;
      position-try-fallbacks: flip-inline;
    }
  }
}
/* From 700px the header is one row, so the language link can be a full
   44px target again. Anchor positioning opens 44px between the theme
   button and the account icon (the flex gap is 16px, and 28px of right
   margin moves across it). The left margin is -8px, so 8px of that gap
   stays between Sound and the theme button, the same gap as below 700px.
   Sound's right padding is calc(0.55rem - 12px), floored at 0, and its left
   padding gives up 8px, so the row still fits.
   Without position-area the link is already 44px in the flex row,
   before the theme button, so that shift stays inside the support query. */
@media (min-width: 700px) {
  body[data-verse] .top .rom-btn {
    padding-right: calc(0.55rem - 12px);
    padding-left: calc(0.55rem - 8px);
  }
  body[data-verse] .top a.lang-toggle {
    width: 44px;
    height: 44px;
  }
  @supports (position-area: left center) {
    body[data-verse] header.top > .theme:has(+ .notes-account-slot) {
      margin-left: -8px;
      margin-right: 28px;
    }
  }
}
html[lang="en"] body[data-verse] .mark { min-width: 9.2333984375rem; }
html[lang="en"] body[data-verse] .lang { min-width: 13.0009765625rem; }
html[lang="en"] body[data-verse] .top .lang button {
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  line-height: 1;
  padding-top: 0;
  padding-bottom: 0;
}
/* Transliterated commentary has no .ta class, so it would sort before the verse. */
html[lang="en"] .layer.teach { order: 5; }
