:root {
  --paper: #fbf8f1;
  --paper-raised: #fffdf8;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --muted: #78716c;
  --line: #e7e0d3;
  --accent: #9a3412;
  --accent-soft: #fdf1e4;
  --te: "Noto Sans Telugu", "Gautami", "Nirmala UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.4rem 1.25rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--te);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.nav { display: flex; gap: 1.15rem; flex-wrap: wrap; }

.nav a {
  font-family: var(--ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover { color: var(--accent); }

/* Sections that exist in the information architecture but are not built yet. */
.nav .soon {
  font-family: var(--ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.45;
  cursor: default;
}

.page {
  max-width: 52rem;
  margin: 0 auto;
  padding: 2.4rem 1.25rem 5rem;
}

/* ---------- song header ---------- */

.song-head { margin-bottom: 2rem; }

.eyebrow {
  font-family: var(--ui);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.7rem;
}

.song-title {
  font-family: var(--te);
  font-size: clamp(1.9rem, 5.5vw, 2.9rem);
  font-weight: 600;
  line-height: 1.55;
  margin: 0 0 0.15rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.1rem;
}

.chip {
  font-family: var(--ui);
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
}
.chip b { font-weight: 600; color: var(--accent); }

.aka {
  font-family: var(--ui);
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.poet-note {
  font-family: var(--te);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 0.45rem;
}

/* ---------- controls ---------- */

.song-controls {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.1rem;
  padding: 0.7rem 0;
  margin-bottom: 2.2rem;
  background: linear-gradient(var(--paper) 78%, rgba(251, 248, 241, 0));
  border-bottom: 1px solid var(--line);
}

.song-controls__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--ui);
  font-size: 0.78rem;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.song-controls__toggle input { accent-color: var(--accent); }

/* ---------- sections ---------- */

.song-section { margin-bottom: 3.4rem; scroll-margin-top: 4rem; }

.song-section__label {
  font-family: var(--te);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin: 0 0 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.verse { margin: 0 0 1.6rem; }

.verse__line {
  font-family: var(--te);
  font-size: clamp(1.3rem, 3.4vw, 1.62rem);
  line-height: 2.05;
  margin: 0;
  letter-spacing: 0.005em;
}

.verse__line + .verse__line { margin-top: 0.15rem; }

/* corpus text has no word buttons, so it can breathe less */
.verse--plain .verse__line {
  font-size: clamp(1.18rem, 2.9vw, 1.4rem);
  line-height: 1.85;
}

/* a word that has a note */
.word-token {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0 0.04em;
  margin: 0;
  cursor: pointer;
  border-bottom: 2px dotted rgba(154, 52, 18, 0.55);
  border-radius: 2px;
  transition: background 120ms ease;
}
.word-token:hover,
.word-token:focus-visible { background: var(--accent-soft); outline: none; }
.word-token.is-active {
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ---------- word notes ---------- */

.word-notes { margin: 0 0 1.6rem; }

.word-notes__title {
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.7rem;
}

.word-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  padding: 0.9rem 1.05rem;
  margin-bottom: 0.7rem;
  scroll-margin-top: 5rem;
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
.word-card.is-active {
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-color: var(--accent);
}

.word-card__head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}

.word-card__form {
  font-family: var(--te);
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.4;
}

.word-card__equation {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0.65rem;
}

.word-card__segment {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  font-family: var(--te);
  font-size: 1.02rem;
  line-height: 1.5;
}
.word-card__segment em {
  font-family: var(--ui);
  font-style: normal;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
  max-width: 15rem;
}

.word-card__segment-word { font-family: var(--te); }

.word-card__operator {
  font-size: 0.95rem;
  color: var(--muted);
  padding-top: 0.35rem;
}

.word-card__meaning {
  font-family: var(--te);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink-soft);
  border-top: 1px dashed var(--line);
  padding-top: 0.55rem;
  margin-top: 0.15rem;
}
.word-card__meaning .word-card__arrow { color: var(--muted); margin: 0 0.35rem; }
.word-card__meaning .word-card__translation {
  display: block;
  font-family: var(--serif);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
  line-height: 1.5;
}

.word-card__referent {
  display: inline-block;
  font-family: var(--te);
  font-size: 0.92rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.05rem 0.6rem;
}

.word-card__note {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0.6rem 0 0;
}
.word-card__note .word-card__translation {
  display: block;
  font-style: italic;
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.2rem;
}

/* ---------- section meaning ---------- */

.section-meaning {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-bottom: 1.2rem;
}

.section-meaning__label {
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.45rem;
}

.section-meaning__text {
  font-family: var(--te);
  font-size: 1.1rem;
  line-height: 1.95;
  margin: 0;
}
.section-meaning__translation {
  font-size: 0.98rem;
  font-style: italic;
  color: var(--muted);
  margin: 0.35rem 0 0;
  line-height: 1.6;
}

.word-notes__pending {
  font-family: var(--ui);
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--paper-raised);
  border: 1px dashed var(--line);
  border-radius: 3px;
  padding: 0.6rem 0.8rem;
  margin: 0 0 1.2rem;
}

/* ---------- provenance ---------- */

.provenance {
  margin-top: 3.5rem;
  padding: 1.1rem 1.2rem;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.provenance h2 {
  font-family: var(--ui);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6rem;
}
.provenance dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; }
.provenance dt { color: var(--muted); }
.provenance dd { margin: 0; overflow-wrap: anywhere; }

.provenance__status {
  display: inline-block;
  font-family: var(--ui);
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- colophon ---------- */

.colophon {
  max-width: 52rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--line);
  font-family: var(--ui);
  font-size: 0.85rem;
  color: var(--muted);
}
.colophon p { margin: 0; }

/* ---------- home ---------- */

.home-head { margin-bottom: 2rem; }

.home-title {
  font-family: var(--te);
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.35rem;
  letter-spacing: 0.01em;
}

.lede {
  font-family: var(--serif);
  font-size: 1.02rem;
  color: var(--ink-soft);
  margin: 0 0 1.4rem;
  max-width: 34rem;
}

.home-songs {
  margin-bottom: 2.5rem;
  border-top: 1px solid var(--line);
  padding-top: 1.2rem;
}
.home-songs > h2 {
  font-family: var(--ui);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.3rem;
}
.home-songs__note {
  font-family: var(--te);
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1rem;
}
.song-group { margin-bottom: 1.1rem; }
.song-group__title {
  font-family: var(--te);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.25rem;
}
.song-group__list { border-top: 1px solid var(--line); }

.song-note {
  font-family: var(--te);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0.2rem 0 0.7rem;
  padding-left: 0.7rem;
  border-left: 2px solid var(--accent-soft);
}

.song-index__link {
  display: block;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.song-index__link:hover { background: var(--accent-soft); }

.song-index__title {
  display: block;
  font-family: var(--te);
  font-size: 1.12rem;
  font-weight: 500;
  line-height: 1.45;
}

.song-index__meta {
  display: block;
  font-family: var(--te);
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.back {
  display: inline-block;
  font-family: var(--ui);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 1.2rem;
}
.back:hover { color: var(--accent); }

.refrain {
  font-family: var(--te);
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.loading {
  font-family: var(--te);
  color: var(--muted);
}

.song-source {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.song-source h2 {
  font-family: var(--ui);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.song-source dl {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.2rem 1rem;
  margin: 0;
  font-family: var(--te);
  font-size: 0.88rem;
}
.song-source dt { color: var(--muted); }
.song-source dd { margin: 0; }
.song-source a { color: var(--accent); }
.pending-inline { color: var(--muted); }

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  body { font-size: 16px; }
  .page { padding: 1.6rem 1rem 4rem; }
  .masthead { padding: 1rem 1rem 0.8rem; }
  .nav { display: none; }
  .word-card { padding: 0.8rem 0.85rem; }
  .provenance dl { grid-template-columns: 1fr; gap: 0.15rem; }
  .provenance dt { margin-top: 0.55rem; }
  .song-source dl { grid-template-columns: 1fr; }
  .home-title { font-size: 2rem; }
}

/* ---------- print ---------- */

@media print {
  .song-controls, .masthead, .colophon { display: none; }
  body { background: #fff; font-size: 11pt; }
  .page { max-width: none; padding: 0; }
  .word-card { break-inside: avoid; }
  .word-token { border-bottom: none; }
}
