:root {
  --bg: #f7fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e5e7eb;
  --accent: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  padding-bottom: 5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
}

header .logo {
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

nav {
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

nav a {
  display: inline-block;
  margin: 0 0.65rem;
  text-decoration: none;
  color: #111827;
  font-weight: 600;
}

nav a[aria-current="page"] {
  text-decoration: underline;
}

nav a:hover {
  color: #2563eb;
}

.controls {
  display: flex;
  gap: 0.5rem;
}

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  background: #f8fafc;
  border-color: #d1d5db;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
}

.menu-toggle span {
  display: block;
  width: 25px;
  height: 3px;
  background: var(--text);
  margin: 5px 0;
  transition: 0.3s;
}

.mobile-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  padding: 1rem 2rem;
}

.mobile-nav a {
  display: block;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  color: #111827;
  font-weight: 600;
}

.mobile-nav a:last-child {
  border-bottom: none;
}

.mobile-nav .controls {
  margin-top: 1rem;
  border-top: 1px solid #f3f4f6;
  padding-top: 1rem;
  justify-content: center;
}

h1 {
  text-align: center;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  margin: 0.75rem 0 0.25rem;
  line-height: 1.2;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 1rem;
  font-size: clamp(0.95rem, 3.5vw, 1.05rem);
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.tab {
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab[aria-selected="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tab:hover {
  background: #f8fafc;
}

section.text {
  margin: 0 auto;
  max-width: 700px;
  padding: 0 1rem 3rem;
  text-align: center;
}

.section-label {
  font-weight: 800;
  margin: 1.2rem 0 0.5rem;
}

.verse {
  margin: 0.7rem auto;
  max-width: 65ch;
  font-size: clamp(1rem, 3.8vw, 1.15rem);
  line-height: 1.75;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.verse .line {
  display: block;
  text-align: center;
}

.dev {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, 'Noto Sans Devanagari', 'Hind', 'Tiro Devanagari Hindi', sans-serif;
  letter-spacing: 0.1px;
}

footer {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 1rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: auto;
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Breadcrumb styles */
.breadcrumb-nav {
  padding: 1rem 2rem;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}

.breadcrumb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 0.9rem;
}

.breadcrumb-list li {
  display: flex;
  align-items: center;
}

.breadcrumb-list li:not(:last-child)::after {
  content: '/';
  margin: 0 0.5rem;
  color: #6b7280;
}

.breadcrumb-list a {
  color: #2563eb;
  text-decoration: none;
}

.breadcrumb-list a:hover {
  text-decoration: underline;
}

/* Related chalisas section */
.related-chalisas {
  background: #f8fafc;
  padding: 3rem 1rem;
  margin: 2rem 0;
}

/* Desktop section spacing */
@media (min-width: 769px) {
  .related-chalisas {
    padding: 4rem 2rem;
    margin: 3rem 0;
  }
}

.related-chalisas h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text);
  font-size: 1.8rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Desktop-specific grid layout */
@media (min-width: 769px) {
  .related-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 1000px;
  }
}

@media (min-width: 1200px) {
  .related-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5rem;
    max-width: 1200px;
  }
}

.related-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.3s ease;
  min-height: 200px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Desktop card optimization */
@media (min-width: 769px) {
  .related-item {
    min-height: 240px;
    padding: 2rem 1.5rem;
  }
}

@media (min-width: 1200px) {
  .related-item {
    min-height: 220px;
    padding: 1.75rem 1.25rem;
  }
}

.related-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: #d1d5db;
}

.related-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Desktop image optimization */
@media (min-width: 769px) {
  .related-item img {
    width: 100px;
    height: 100px;
    margin-bottom: 1.25rem;
  }
}

@media (min-width: 1200px) {
  .related-item img {
    width: 90px;
    height: 90px;
  }
}

.related-item h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.related-item p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
  flex-grow: 1;
}

/* Desktop typography optimization */
@media (min-width: 769px) {
  .related-item h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    min-height: 1.5rem;
  }
  
  .related-item p {
    font-size: 0.95rem;
    line-height: 1.5;
    min-height: 3rem;
  }
}

@media (min-width: 1200px) {
  .related-item h3 {
    font-size: 1.1rem;
    min-height: 1.4rem;
  }
  
  .related-item p {
    font-size: 0.9rem;
    min-height: 2.8rem;
  }
}

.related-chalisa-card img {
  border-radius: 12px;
  overflow: hidden;
}

.related-chalisa-card {
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s;
}

.related-chalisa-card:hover {
  transform: translateY(-2px);
}

img {
  border-radius: 8px;
  overflow: hidden;
}

.related-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s ease;
  text-align: center;
}

.related-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #d1d5db;
}

.related-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.related-card h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text);
  font-size: 1.2rem;
}

.related-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Performance optimizations */
img {
  max-width: 100%;
  height: auto;
}

/* Critical CSS for above-the-fold content */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }
  
  nav,
  .controls {
    display: none;
  }
  
  .mobile-nav.active {
    display: block;
  }
  
  header {
    padding: 1rem;
  }
  
  .breadcrumb-nav {
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 480px) {
  .verse {
    max-width: 92vw;
    font-size: 1rem;
    line-height: 1.65;
  }
  
  .related-chalisas {
    padding: 2rem 1rem;
  }
  
  .related-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  .related-item {
    min-height: 180px !important;
    padding: 1.25rem !important;
  }
  
  .related-item img {
    width: 70px !important;
    height: 70px !important;
  }
  
  .related-item h3 {
    font-size: 1rem !important;
  }
  
  .related-item p {
    font-size: 0.85rem !important;
  }
}

/* Re-apply desktop styles with higher specificity */
@media (min-width: 769px) {
  .related-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 2rem !important;
    max-width: 1000px !important;
  }
  
  .related-item {
    min-height: 240px !important;
    padding: 2rem 1.5rem !important;
  }
  
  .related-item img {
    width: 100px !important;
    height: 100px !important;
    margin-bottom: 1.25rem !important;
  }
  
  .related-item h3 {
    font-size: 1.2rem !important;
    margin-bottom: 0.75rem !important;
    min-height: 1.5rem !important;
  }
  
  .related-item p {
    font-size: 0.95rem !important;
    line-height: 1.5 !important;
    min-height: 3rem !important;
  }
}

@media (min-width: 1200px) {
  .related-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 1.5rem !important;
    max-width: 1200px !important;
  }
  
  .related-item {
    min-height: 220px !important;
    padding: 1.75rem 1.25rem !important;
  }
  
  .related-item img {
    width: 90px !important;
    height: 90px !important;
  }
  
  .related-item h3 {
    font-size: 1.1rem !important;
    min-height: 1.4rem !important;
  }
  
  .related-item p {
    font-size: 0.9rem !important;
    min-height: 2.8rem !important;
  }
}

/* Font loading optimization */
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;600;700&display=swap');
}

/* Reduce layout shifts */
.section-label {
  min-height: 1.5rem;
}

.verse {
  min-height: 2rem;
}

/* Optimize for Core Web Vitals */
header {
  contain: layout style;
}

main {
  contain: layout style;
}

footer {
  contain: layout style;
}

/* Smooth scrolling optimization */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}