:root {
  --bg: #f5f1e8;
  --bg-accent: #e7eef0;
  --panel: rgba(255, 253, 247, 0.9);
  --panel-strong: rgba(255, 253, 247, 0.98);
  --line: rgba(40, 67, 70, 0.14);
  --text: #1d2829;
  --muted: #5d6c68;
  --accent: #b13d32;
  --accent-strong: #863026;
  --secondary: #1e6f78;
  --shadow: 0 18px 48px rgba(36, 58, 63, 0.12);
  --radius-lg: 16px;
  --radius-md: 8px;
  --radius-sm: 8px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-body: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  background:
    linear-gradient(135deg, rgba(30, 111, 120, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(177, 61, 50, 0.11), transparent 32%),
    linear-gradient(180deg, var(--bg), #faf8f2 45%, var(--bg-accent));
}

a {
  color: inherit;
  text-decoration: none;
}

.landing-shell,
.reader-shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}

.landing-shell {
  display: grid;
  gap: 1.5rem;
}

.hero-panel,
.chapter-sidebar,
.reader-panel,
.chapter-card {
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 2rem;
  border-radius: var(--radius-lg);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.05;
}

.hero-panel h1 {
  font-size: clamp(2.8rem, 6vw, 5rem);
}

.hero-copy,
.sidebar-copy,
.chapter-card p,
.reader-status,
.search-shell span {
  color: var(--muted);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.chapter-card {
  padding: 1.2rem;
  border-radius: var(--radius-md);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.chapter-card:hover,
.chapter-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(163, 74, 31, 0.35);
  background: var(--panel-strong);
}

.chapter-card__eyebrow {
  display: inline-block;
  margin-bottom: 0.65rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chapter-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.reader-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.chapter-sidebar,
.reader-panel {
  border-radius: var(--radius-lg);
}

.chapter-sidebar {
  position: sticky;
  top: 1rem;
  padding: 1.25rem;
}

.brand-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.chapter-links {
  display: grid;
  gap: 0.5rem;
}

.chapter-link {
  padding: 0.8rem 0.95rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.chapter-link:hover,
.chapter-link:focus-visible,
.chapter-link--active {
  color: var(--accent-strong);
  background: rgba(163, 74, 31, 0.08);
  border-color: rgba(163, 74, 31, 0.18);
}

.reader-panel {
  padding: 1.2rem;
  padding-bottom: 0;
}

.reader-header {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 1rem;
}

.reader-header h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.search-shell {
  display: grid;
  gap: 0.45rem;
  min-width: min(320px, 100%);
}

.search-shell input {
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(30, 111, 120, 0.22);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font: inherit;
}

.search-shell input:focus {
  outline: 2px solid rgba(30, 111, 120, 0.18);
  border-color: rgba(30, 111, 120, 0.4);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  width: min(360px, 100%);
  padding: 0.35rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.52);
}

.mode-button {
  appearance: none;
  min-height: 2.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.mode-button--active {
  color: #ffffff;
  background: linear-gradient(180deg, var(--secondary), #15525a);
  box-shadow: 0 8px 22px rgba(30, 111, 120, 0.18);
}

.reader-status {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.sutra-card {
  min-height: 56vh;
  padding: 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.sutra-card--memory {
  display: grid;
  align-content: center;
  min-height: calc(100svh - 17rem);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.card-number {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(163, 74, 31, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
}

.card-heading {
  color: var(--muted);
}

.card-title {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

.card-body {
  font-size: 1.03rem;
  line-height: 1.72;
}

.memory-card-body {
  display: grid;
  gap: 1rem;
}

.memory-section {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(245, 241, 232, 0.62);
  border: 1px solid rgba(40, 67, 70, 0.1);
}

.memory-section h3 {
  margin: 0 0 0.65rem;
  color: var(--secondary);
  font: 800 0.76rem / 1 var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.memory-section p {
  margin: 0;
  overflow-wrap: anywhere;
}

.memory-section--devanagari p {
  font-size: 1.6rem;
  line-height: 1.75;
}

.memory-section--iast p {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.65;
}

.memory-section--translation p {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.card-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.96rem;
}

.card-body th,
.card-body td {
  padding: 0.65rem 0.7rem;
  text-align: left;
  border: 1px solid rgba(90, 63, 31, 0.13);
}

.card-body pre {
  overflow: auto;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: rgba(109, 87, 54, 0.08);
}

.card-body blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid rgba(163, 74, 31, 0.28);
}

.reader-controls {
  position: sticky;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem -1.2rem 0;
  padding: 0.75rem 1.2rem max(0.75rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(250, 248, 242, 0.9);
  backdrop-filter: blur(12px);
}

.nav-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1.35rem;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff7f1;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

.nav-button:hover:not(:disabled),
.nav-button:focus-visible:not(:disabled) {
  transform: translateY(-1px);
}

.nav-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 40vh;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 920px) {
  .reader-shell {
    grid-template-columns: 1fr;
  }

  .chapter-sidebar {
    position: static;
  }
}

@media (max-width: 680px) {
  .landing-shell,
  .reader-shell {
    width: min(100vw - 1rem, 1180px);
    padding-top: 0.75rem;
  }

  .hero-panel,
  .chapter-sidebar,
  .reader-panel {
    padding: 1rem;
  }

  .reader-panel {
    padding-bottom: 0;
  }

  .reader-header,
  .reader-status {
    flex-direction: column;
    align-items: stretch;
  }

  .reader-header {
    gap: 0.65rem;
    margin-bottom: 0.7rem;
  }

  .reader-header .eyebrow {
    display: none;
  }

  .reader-header h1 {
    font-size: 1.65rem;
  }

  .search-shell {
    min-width: 0;
    gap: 0.3rem;
  }

  .search-shell span {
    display: none;
  }

  .search-shell input {
    padding: 0.78rem 0.9rem;
  }

  .mode-switch {
    margin-bottom: 0.7rem;
  }

  .reader-status {
    margin-bottom: 0.7rem;
    font-size: 0.86rem;
  }

  .chapter-sidebar {
    padding: 0.85rem;
    overflow: auto;
  }

  .brand-link {
    margin-bottom: 0.6rem;
    font-size: 1.12rem;
  }

  .sidebar-copy {
    display: none;
  }

  .chapter-links {
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
  }

  .chapter-links::-webkit-scrollbar {
    display: none;
  }

  .chapter-link {
    flex: 0 0 auto;
    padding: 0.65rem 0.8rem;
    white-space: nowrap;
  }

  .sutra-card {
    min-height: calc(100svh - 19rem);
    padding: 1rem;
    margin-bottom: 5.5rem;
  }

  .memory-section {
    padding: 0.9rem;
  }

  .memory-section--devanagari p {
    font-size: 1.35rem;
  }

  .memory-section--iast p {
    font-size: 1.16rem;
  }

  .reader-controls {
    margin-right: -1rem;
    margin-left: -1rem;
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .nav-button {
    flex: 1;
    min-height: 3.15rem;
  }
}
