:root {
  --pi-ink: #251f2b;
  --pi-muted: #6f6674;
  --pi-violet: #5d3d83;
  --pi-indigo: #2d4777;
  --pi-saffron: #a84a16;
  --pi-gold: #d4a34a;
  --pi-line: rgba(74, 55, 92, 0.17);
  --pi-display: "Noto Serif Devanagari", Fraunces, Georgia, serif;
  --pi-body: "Noto Sans Devanagari", Outfit, system-ui, sans-serif;
}

.pi-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 10%, rgba(119, 81, 153, 0.12), transparent 28rem),
    radial-gradient(circle at 92% 22%, rgba(222, 167, 71, 0.13), transparent 30rem),
    linear-gradient(180deg, #faf7f1, #f4f0ea);
  color: var(--pi-ink);
  font-family: var(--pi-body);
}

.pi-wrap {
  width: min(1160px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.2rem 0 4rem;
}

.pi-crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--pi-muted);
  font-size: 0.78rem;
}

.pi-crumb a {
  color: var(--pi-violet);
  text-decoration: none;
}

.pi-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(2.2rem, 6vw, 4.8rem);
  border: 1px solid var(--pi-line);
  border-radius: 1.8rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(245, 237, 255, 0.88)),
    #fff;
  box-shadow: 0 26px 70px rgba(49, 36, 61, 0.09);
  text-align: center;
}

.pi-hero::before,
.pi-hero::after {
  content: "";
  position: absolute;
  width: 20rem;
  height: 20rem;
  border: 1px solid rgba(93, 61, 131, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.pi-hero::before {
  top: -11rem;
  left: -6rem;
  box-shadow: 0 0 0 3rem rgba(93, 61, 131, 0.025), 0 0 0 6rem rgba(93, 61, 131, 0.018);
}

.pi-hero::after {
  right: -8rem;
  bottom: -12rem;
  box-shadow: 0 0 0 3rem rgba(212, 163, 74, 0.03), 0 0 0 6rem rgba(212, 163, 74, 0.02);
}

.pi-hero__yantra {
  position: relative;
  display: grid;
  width: 5rem;
  height: 5rem;
  place-items: center;
  margin: 0 auto 1rem;
  color: #fff;
  font-family: var(--pi-display);
  font-size: 2rem;
  font-weight: 700;
  isolation: isolate;
}

.pi-hero__yantra::before,
.pi-hero__yantra::after {
  content: "";
  position: absolute;
  inset: 0.35rem;
  z-index: -1;
  background: linear-gradient(145deg, #8060a2, #3f285f);
  clip-path: polygon(50% 0, 100% 88%, 0 88%);
}

.pi-hero__yantra::after {
  transform: rotate(180deg);
  opacity: 0.82;
}

.pi-kicker,
.pi-panel-label {
  margin: 0 0 0.45rem;
  color: var(--pi-violet);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pi-hero h1,
.pi-theme-map h2,
.pi-library h2,
.pi-detail-hero h1,
.pi-lens h2 {
  margin: 0;
  color: #33223f;
  font-family: var(--pi-display);
  line-height: 1.12;
}

.pi-hero h1 {
  max-width: 920px;
  margin-inline: auto;
  font-size: clamp(2rem, 5vw, 3.8rem);
}

.pi-hero > p:not(.pi-kicker) {
  max-width: 760px;
  margin: 1rem auto 0;
  color: var(--pi-muted);
  line-height: 1.65;
}

.pi-lang {
  position: relative;
  z-index: 1;
  display: inline-flex;
  gap: 0.35rem;
  margin-top: 1.25rem;
  padding: 0.3rem;
  border: 1px solid var(--pi-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
}

.pi-lang a {
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  color: var(--pi-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.pi-lang a.is-active {
  background: var(--pi-violet);
  color: #fff;
}

/* Interactive topic mandala */
.pi-theme-map {
  position: relative;
  min-height: 35rem;
  margin: 1.3rem 0;
  overflow: hidden;
  border: 1px solid var(--pi-line);
  border-radius: 1.5rem;
  background:
    repeating-radial-gradient(circle at center, transparent 0 4.5rem, rgba(93, 61, 131, 0.045) 4.55rem 4.62rem),
    radial-gradient(circle at center, rgba(253, 247, 229, 0.9), rgba(247, 242, 252, 0.92));
}

.pi-theme-map::before,
.pi-theme-map::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24rem;
  height: 24rem;
  border: 1px solid rgba(93, 61, 131, 0.1);
  transform: translate(-50%, -50%) rotate(45deg);
  pointer-events: none;
}

.pi-theme-map::after {
  transform: translate(-50%, -50%) rotate(15deg);
}

.pi-theme-map__center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: grid;
  width: 13rem;
  height: 13rem;
  place-content: center;
  padding: 1rem;
  border: 1px solid rgba(168, 74, 22, 0.22);
  border-radius: 50%;
  background: radial-gradient(circle, #fffdf7, #f6e7c7);
  box-shadow: 0 0 0 0.7rem rgba(255, 255, 255, 0.48), 0 14px 32px rgba(68, 39, 25, 0.12);
  text-align: center;
  transform: translate(-50%, -50%);
}

.pi-theme-map__center > span {
  color: var(--pi-saffron);
  font-family: var(--pi-display);
  font-size: 1.7rem;
}

.pi-theme-map__center h2 {
  margin-top: 0.25rem;
  font-size: 1rem;
}

.pi-theme-map__center p {
  margin: 0.4rem 0 0;
  color: var(--pi-muted);
  font-size: 0.75rem;
}

.pi-theme-map__orbit {
  position: absolute;
  inset: 0;
}

.pi-theme {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: grid;
  width: 9.5rem;
  min-height: 5.6rem;
  place-items: center;
  padding: 0.65rem;
  border: 1px solid var(--pi-line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--pi-ink);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transform:
    translate(-50%, -50%)
    rotate(calc(60deg * var(--pi-theme-index)))
    translateY(-13.3rem)
    rotate(calc(-60deg * var(--pi-theme-index)));
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.pi-theme > span {
  color: var(--pi-violet);
  font-family: var(--pi-display);
  font-size: 1.25rem;
}

.pi-theme strong {
  font-family: var(--pi-display);
  font-size: 0.8rem;
  line-height: 1.25;
}

.pi-theme:hover,
.pi-theme:focus-visible,
.pi-theme.is-active {
  border-color: var(--pi-violet);
  box-shadow: 0 0 0 3px rgba(93, 61, 131, 0.13), 0 10px 24px rgba(62, 41, 79, 0.11);
}

.pi-theme.is-active {
  background: linear-gradient(145deg, #fff, #f1e8fa);
}

.pi-library {
  padding-top: 1.5rem;
}

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

.pi-library h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

.pi-library__tools {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.pi-search {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  min-width: min(19rem, 48vw);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--pi-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
}

.pi-search i {
  color: var(--pi-violet);
}

.pi-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--pi-ink);
  font: inherit;
  font-size: 0.82rem;
}

.pi-surprise,
.pi-focus-toggle {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--pi-line);
  border-radius: 999px;
  background: #fff;
  color: var(--pi-violet);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.pi-empty {
  padding: 1rem;
  border-radius: 0.8rem;
  background: #fff7e1;
  color: var(--pi-saffron);
  text-align: center;
}

.pi-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.pi-card {
  display: flex;
  min-height: 18rem;
  flex-direction: column;
  padding: 1rem;
  border: 1px solid var(--pi-line);
  border-radius: 1.1rem;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.96), rgba(247, 240, 252, 0.82)),
    #fff;
  box-shadow: 0 8px 22px rgba(55, 38, 66, 0.05);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.pi-card:hover,
.pi-card:focus-within,
.pi-card.is-highlighted {
  border-color: rgba(93, 61, 131, 0.48);
  box-shadow: 0 17px 38px rgba(55, 38, 66, 0.11);
  transform: translateY(-4px);
}

.pi-card__meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--pi-violet);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pi-card h3 {
  margin: 0.9rem 0 0;
  color: #352540;
  font-family: var(--pi-display);
  font-size: 1.08rem;
  line-height: 1.3;
}

.pi-card p {
  display: -webkit-box;
  margin: 0.7rem 0 1rem;
  overflow: hidden;
  color: var(--pi-muted);
  font-size: 0.84rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.pi-card > a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 0.7rem;
  border-top: 1px solid var(--pi-line);
  color: var(--pi-saffron);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.pi-card[hidden] {
  display: none;
}

.pi-library.is-arriving .pi-card:not([hidden]) {
  animation: pi-card-arrive 0.8s ease 0.45s both;
}

@keyframes pi-card-arrive {
  0% {
    border-color: rgba(93, 61, 131, 0.55);
    box-shadow: 0 0 0 5px rgba(93, 61, 131, 0.08);
    transform: translateY(8px);
  }
  100% {
    border-color: var(--pi-line);
    box-shadow: 0 8px 22px rgba(55, 38, 66, 0.05);
    transform: translateY(0);
  }
}

/* Detail contemplation lens */
.pi-detail-wrap {
  width: min(920px, calc(100% - 2rem));
}

.pi-detail-hero {
  padding: clamp(1.5rem, 5vw, 3.2rem);
  border: 1px solid var(--pi-line);
  border-radius: 1.5rem;
  background:
    radial-gradient(circle at 85% 10%, rgba(212, 163, 74, 0.13), transparent 15rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(241, 234, 248, 0.9));
  box-shadow: 0 20px 50px rgba(55, 38, 66, 0.08);
}

.pi-detail-hero__meta {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  color: var(--pi-violet);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pi-detail-hero__meta span:nth-child(2) {
  font-size: 1.25rem;
}

.pi-detail-hero h1 {
  max-width: 820px;
  margin-top: 0.75rem;
  font-size: clamp(1.8rem, 4.5vw, 3.25rem);
}

.pi-detail-hero__actions {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: end;
  margin-top: 1rem;
}

.pi-detail-hero__actions .pi-focus-toggle:first-of-type {
  margin-left: auto;
}

.pi-pdf-button {
  background: var(--pi-violet);
  color: #fff;
}

.pi-pdf-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.pi-detail-hero .pi-lang {
  margin-top: 0;
}

.pi-lens {
  margin-top: 1.2rem;
  padding: clamp(1rem, 4vw, 1.7rem);
  border: 1px solid var(--pi-line);
  border-radius: 1.5rem;
  background: rgba(255, 253, 249, 0.92);
  box-shadow: 0 20px 50px rgba(55, 38, 66, 0.08);
}

.pi-lens__header {
  max-width: 690px;
  margin: 0 auto;
  text-align: center;
}

.pi-lens__header h2 {
  font-size: clamp(1.4rem, 3vw, 2.1rem);
}

.pi-lens__header > p:last-child {
  color: var(--pi-muted);
  font-size: 0.85rem;
}

.pi-lens__dial {
  position: relative;
  width: min(100%, 35rem);
  height: 18rem;
  margin: 1rem auto;
}

.pi-lens__ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14rem;
  height: 14rem;
  border: 1px solid rgba(93, 61, 131, 0.18);
  border-radius: 50%;
  box-shadow: 0 0 0 1.8rem rgba(93, 61, 131, 0.025), 0 0 0 3.6rem rgba(93, 61, 131, 0.018);
  transform: translate(-50%, -50%);
}

.pi-lens-tab {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 8rem;
  min-height: 4.8rem;
  place-items: center;
  padding: 0.55rem;
  border: 1px solid var(--pi-line);
  border-radius: 1rem;
  background: #fff;
  color: var(--pi-ink);
  font: inherit;
  cursor: pointer;
}

.pi-lens-tab:nth-of-type(1) {
  left: 50%;
  top: 0.4rem;
  transform: translateX(-50%);
}

.pi-lens-tab:nth-of-type(2) {
  right: 1rem;
  bottom: 0.5rem;
}

.pi-lens-tab:nth-of-type(3) {
  left: 1rem;
  bottom: 0.5rem;
}

.pi-lens-tab > span {
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border-radius: 50%;
  background: rgba(93, 61, 131, 0.1);
  color: var(--pi-violet);
  font-weight: 800;
}

.pi-lens-tab strong {
  font-family: var(--pi-display);
  font-size: 0.78rem;
}

.pi-lens-tab:hover,
.pi-lens-tab:focus-visible,
.pi-lens-tab.is-active {
  border-color: var(--pi-violet);
  box-shadow: 0 0 0 3px rgba(93, 61, 131, 0.12);
}

.pi-lens-tab.is-active > span {
  background: var(--pi-violet);
  color: #fff;
}

.pi-lens__center {
  position: absolute;
  left: 50%;
  top: 54%;
  display: grid;
  width: 7.5rem;
  height: 7.5rem;
  place-items: center;
  border: 1px solid rgba(168, 74, 22, 0.2);
  border-radius: 50%;
  background: radial-gradient(circle, #fff8df, #ebcf92);
  color: var(--pi-saffron);
  font-family: var(--pi-display);
  font-size: 2.5rem;
  box-shadow: 0 10px 28px rgba(90, 54, 25, 0.12);
  transform: translate(-50%, -50%);
}

.pi-lens__panels {
  display: grid;
  gap: 1rem;
}

.pi-lens-panel {
  padding: clamp(1rem, 4vw, 1.6rem);
  border: 1px solid var(--pi-line);
  border-radius: 1.1rem;
  background: #fff;
  scroll-margin-top: 5rem;
}

.pi-lens.is-enhanced .pi-lens-panel[hidden] {
  display: none;
}

.pi-question-panel blockquote {
  max-width: 760px;
  margin: 0.5rem auto 1rem;
  color: #392547;
  font-family: var(--pi-display);
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  line-height: 1.45;
  text-align: center;
}

.pi-perspective-grid,
.pi-reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.pi-perspective-grid section {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  padding: 1rem;
  border-radius: 0.9rem;
  background: linear-gradient(145deg, #f7f1fb, #fff);
}

.pi-perspective-grid section > span {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: var(--pi-violet);
  color: #fff;
  font-weight: 800;
}

.pi-perspective-grid p {
  margin: 0;
  color: var(--pi-muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.pi-reference-grid figure {
  position: relative;
  margin: 0;
  padding: 1.2rem;
  overflow: hidden;
  border: 1px solid rgba(168, 74, 22, 0.18);
  border-radius: 0.9rem;
  background:
    linear-gradient(145deg, rgba(255, 251, 237, 0.96), rgba(247, 233, 204, 0.7));
}

.pi-reference-grid__mark {
  position: absolute;
  right: 0.5rem;
  top: -0.3rem;
  color: rgba(168, 74, 22, 0.1);
  font-family: var(--pi-display);
  font-size: 4rem;
}

.pi-reference-grid blockquote {
  position: relative;
  margin: 0;
  color: #493720;
  font-family: var(--pi-display);
  font-size: 0.94rem;
  line-height: 1.62;
}

.pi-reference-grid figcaption {
  position: relative;
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(168, 74, 22, 0.17);
  color: var(--pi-saffron);
  font-size: 0.76rem;
  font-weight: 700;
}

.pi-continue {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem auto 0;
  padding: 0.65rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: var(--pi-violet);
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.pi-contemplation-close {
  margin: 1rem 0 0;
  color: var(--pi-violet);
  font-family: var(--pi-display);
  text-align: center;
}

.pi-lens__status {
  margin: 0.8rem 0 0;
  color: var(--pi-muted);
  font-size: 0.75rem;
  text-align: center;
}

.pi-adjacent {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.7rem;
  align-items: stretch;
  margin-top: 1rem;
}

.pi-adjacent a {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--pi-line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.82);
  color: var(--pi-violet);
  text-decoration: none;
}

.pi-adjacent a > span {
  display: grid;
  min-width: 0;
}

.pi-adjacent small {
  color: var(--pi-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.pi-adjacent strong {
  overflow: hidden;
  font-family: var(--pi-display);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pi-adjacent__next {
  justify-content: flex-end;
  text-align: right;
}

.pi-adjacent__all {
  justify-content: center;
}

body.pi-focus-mode > nav,
body.pi-focus-mode > footer,
body.pi-focus-mode .pi-crumb,
body.pi-focus-mode .pi-adjacent {
  display: none !important;
}

body.pi-focus-mode .pi-detail-wrap {
  padding-top: 1rem;
}

@media (max-width: 850px) {
  .pi-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pi-theme-map {
    min-height: auto;
    padding: 1rem;
    background: linear-gradient(145deg, #fbf7ff, #fff8e8);
  }

  .pi-theme-map::before,
  .pi-theme-map::after {
    display: none;
  }

  .pi-theme-map__center {
    position: static;
    width: auto;
    height: auto;
    border-radius: 1rem;
    transform: none;
  }

  .pi-theme-map__orbit {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin-top: 0.8rem;
  }

  .pi-theme {
    position: static;
    width: auto;
    min-height: 4.3rem;
    transform: none;
  }
}

@media (max-width: 620px) {
  .pi-wrap,
  .pi-detail-wrap {
    width: min(100% - 1rem, 1160px);
  }

  .pi-hero,
  .pi-detail-hero,
  .pi-lens {
    border-radius: 1.1rem;
  }

  .pi-library__head,
  .pi-detail-hero__actions {
    align-items: stretch;
    flex-direction: column;
  }

  .pi-detail-hero__actions .pi-focus-toggle:first-of-type {
    margin-left: 0;
  }

  .pi-library__tools {
    align-items: stretch;
    flex-direction: column;
  }

  .pi-search {
    min-width: 0;
  }

  .pi-surprise {
    justify-content: center;
  }

  .pi-card-grid,
  .pi-theme-map__orbit,
  .pi-perspective-grid,
  .pi-reference-grid {
    grid-template-columns: 1fr;
  }

  .pi-card {
    min-height: 15rem;
  }

  .pi-lens__dial {
    display: grid;
    height: auto;
    gap: 0.55rem;
  }

  .pi-lens__ring,
  .pi-lens__center {
    display: none;
  }

  .pi-lens-tab,
  .pi-lens-tab:nth-of-type(1),
  .pi-lens-tab:nth-of-type(2),
  .pi-lens-tab:nth-of-type(3) {
    position: static;
    display: grid;
    width: 100%;
    min-height: auto;
    grid-template-columns: 2rem minmax(0, 1fr);
    justify-items: start;
    transform: none;
  }

  .pi-adjacent {
    grid-template-columns: 1fr;
  }

  .pi-adjacent__all {
    grid-row: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pi-theme,
  .pi-card {
    transition: none;
  }

  .pi-library.is-arriving .pi-card:not([hidden]) {
    animation: none;
  }
}

@media print {
  .pi-page {
    background: #fff;
  }

  .pi-detail-hero__actions,
  .pi-lens__dial,
  .pi-lens__status,
  .pi-continue,
  .pi-adjacent {
    display: none !important;
  }

  .pi-lens,
  .pi-lens-panel,
  .pi-detail-hero {
    border-color: #bbb;
    box-shadow: none;
  }

  .pi-lens.is-enhanced .pi-lens-panel[hidden] {
    display: block !important;
  }
}
