/* Final layout layer. Keep screen-size decisions together so the base and
   Sandalwood theme cannot disagree about navigation or reading controls. */
:root{--header-height:88px;--compact-nav-height:76px}
html{scroll-padding-top:calc(var(--header-height) + 20px)}
body{min-width:0}
#header{height:var(--header-height)}
.header-inner{min-height:0;height:100%;gap:24px}
.brand{min-width:0;flex-shrink:0}
.desktop-nav{gap:20px;flex-shrink:0}
.desktop-nav a{white-space:nowrap;min-height:44px;display:flex;align-items:center}
.header-actions{gap:10px;flex-shrink:0}
.language-button,.header-actions>.saved-shortcut{min-height:44px}
#main{width:100%;min-width:0}
#main :where(h1,h2,h3,h4,p,li,.badge,.breadcrumb,.notice,.card-meta,.reader-progress){overflow-wrap:anywhere}
#main :where(.card-grid,.explore-grid,.article-grid,.temple-grid,.book-grid,.home-deities,.daily-invitation,.reader-layout)>*{min-width:0}
.card-grid{grid-template-columns:repeat(3,minmax(0,1fr));align-items:stretch}
.explore-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
.platform-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
.article-grid,.temple-grid,.checklist,.book-filters{min-width:0}
.article-grid,.temple-grid,.checklist{grid-template-columns:repeat(2,minmax(0,1fr))}
.section-head{flex-wrap:wrap;align-items:center}
.section-head>a{min-height:44px;white-space:normal}
.hero-actions .button.secondary{display:inline-flex}
.home-deities>a{display:flex;flex-direction:column}
.home-deities img{height:auto;aspect-ratio:1 / 1.05}
.home-deities span{margin-top:auto;padding-top:4px}
.three-paths>a>div{min-width:0}
.daily-invitation>div{min-width:0}
.breadcrumb{flex-wrap:wrap;row-gap:4px}
.reader-heading>div{min-width:0}
.reader-heading>.icon-button{flex-shrink:0}
.reader-toolbar{top:var(--header-height);gap:12px}
.reader-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));min-width:0;flex:1 1 320px;gap:4px}
.reader-tab{min-width:0;min-height:44px;white-space:normal;line-height:1.4;padding:10px 12px;font-size:14px}
.reading-settings{flex-shrink:0}
.reading-settings button{min-width:44px;min-height:44px}
.reader-source-button{white-space:normal;text-align:left;min-height:44px;margin-left:0}
.reader-sidebar{top:calc(var(--header-height) + 20px);max-height:calc(100dvh - var(--header-height) - 40px)}
.verse-actions button{min-width:44px;min-height:44px}
.verse-label{flex-wrap:wrap}
.verse{scroll-margin-top:calc(var(--header-height) + 170px)}
.reader-end .button{margin:6px 3px;white-space:normal}
.button{white-space:normal;text-align:center}
.chip{min-height:44px;display:inline-flex;align-items:center;justify-content:center;white-space:normal;text-align:center}
.badge{display:inline-block;max-width:100%;line-height:1.6}
.filters>*{min-width:0;max-width:100%}
.filters input,.filters select,.calendar-filters select,.book-filters input,.book-filters select,.feedback-form input,.feedback-form textarea,.feedback-form select{font-size:16px}
.book-filters{grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1.4fr)}
.feedback-form label,.calendar-filters label,.book-filters label{min-width:0}
.grantha-pending{padding:22px;display:flex;flex-direction:column;align-items:flex-start}
.grantha-pending>.badge,.grantha-pending>p{margin:0}
.grantha-pending h4{font-size:22px}
.grantha-pending ul{margin-bottom:0;width:100%}
.grantha-pending .badge{border-radius:5px}
.grantha-shelf>h3{margin-bottom:16px}
.grantha-card>.badge{border-radius:5px}
.continue-reading>span{min-width:0}
.continue-reading>.icon{flex-shrink:0}
.mobile-contents summary{min-height:44px;align-content:center}
dialog{max-height:calc(100dvh - 32px);overflow:auto}
#footer a{display:inline-block;min-height:44px;padding-block:8px}
#update-banner{max-height:calc(100dvh - 120px);overflow:auto}

@media(max-width:1024px){
  :root{--header-height:72px}
  body{padding-bottom:calc(var(--compact-nav-height) + env(safe-area-inset-bottom,0px))}
  .header-inner{padding:10px 24px;gap:14px}
  .brand-word.brand-global{font-size:23px;letter-spacing:.6px}
  .brand>.icon{width:32px;height:32px}
  .brand small{display:none}
  .desktop-nav{display:none}
  .header-actions>.saved-shortcut{display:none}
  .language-button{font-size:12px;padding:8px;min-height:44px}
  #mobile-nav{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));position:fixed;inset:auto 0 0;width:100%;z-index:20;padding:6px max(8px,env(safe-area-inset-right,0px)) calc(6px + env(safe-area-inset-bottom,0px)) max(8px,env(safe-area-inset-left,0px));background:var(--panel);border-top:1px solid var(--line);box-shadow:0 -6px 22px #302b2506}
  #mobile-nav a{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-width:0;min-height:64px;padding:6px 2px;color:var(--muted);font-size:11px;line-height:1.4;border-radius:8px;text-align:center}
  #mobile-nav a.active{background:var(--soft);color:var(--accent)}
  #mobile-nav .icon{width:22px;height:22px}
  #toast{bottom:calc(var(--compact-nav-height) + env(safe-area-inset-bottom,0px) + 12px);max-width:calc(100vw - 32px);width:max-content;text-align:center}
  #update-banner{bottom:calc(var(--compact-nav-height) + env(safe-area-inset-bottom,0px) + 12px);left:16px;right:16px;max-width:460px;margin-left:auto;max-height:calc(100dvh - 180px)}
  #main{padding:24px 24px 40px}
  .sandalwood-hero{margin:-24px -24px 0;padding:42px 28px;min-height:460px}
  .heritage-copy{width:64%}
  .heritage-copy h1{font-size:clamp(40px,5.5vw,55px)}
  .heritage-copy>p{font-size:19px}
  .three-paths>a{padding:6px 16px;gap:12px}
  .three-paths h2{font-size:23px}
  .home-deities{gap:14px}
  .home-deities img{height:auto}
  .card-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .explore-grid,.platform-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .reader-layout{display:block}
  .reader-page .reader-heading,.reader-page .reader-badges{margin-left:0}
  .reader-sidebar{display:none}
  .reader-main{max-width:810px;margin-inline:auto}
  .mobile-contents{display:block;border:1px solid var(--line);border-radius:8px;padding:0 14px;margin:18px 0}
  .mobile-contents-links{max-height:280px;overflow:auto;margin:8px 0 14px}
  .reader-toolbar{position:static;top:auto}
  .reader-tabs{min-width:0;flex-basis:100%}
  .reader-source-button{margin-left:auto}
  .verse{scroll-margin-top:calc(var(--header-height) + 20px)}
  #footer{margin:0 24px;padding:28px 0 24px}
  .book-filters{grid-template-columns:repeat(2,minmax(0,1fr))}
  .book-filters label:first-child{grid-column:1/-1}
}

@media(max-width:720px){
  .header-inner{padding:10px 16px;gap:8px}
  .brand{gap:7px}
  .brand-word.brand-global{font-size:21px}
  .brand>.icon{width:28px;height:28px}
  #main{padding:20px 18px 32px}
  .sandalwood-hero{margin:-20px -18px 0;display:block;padding:218px 20px 28px;min-height:0;background:var(--paper)}
  .heritage-art{height:270px;object-position:75% 43%}
  .sandalwood-hero:after,:root[data-theme=dark] .sandalwood-hero:after{inset:0 0 auto;height:272px;background:linear-gradient(180deg,transparent 45%,var(--paper) 95%)}
  .heritage-copy{width:100%;max-width:none}
  .heritage-copy h1{font-size:clamp(34px,9vw,45px);line-height:1.17;margin:12px 0 16px}
  .heritage-copy>p{font-size:18px;line-height:1.65;max-width:36ch}
  .heritage-copy .search-form{margin:22px 0 14px;padding:8px 10px}
  .search-form input{font-size:16px}
  .search-form .search-submit{min-width:44px;min-height:44px}
  .hero-actions{display:flex;flex-wrap:wrap;gap:10px}
  .hero-actions .button{flex:1 1 145px;font-size:13px;min-height:48px;padding:12px}
  .hero-actions .button.secondary{display:inline-flex}
  .three-paths{grid-template-columns:1fr;padding:8px 0;margin-bottom:28px}
  .three-paths>a,.three-paths>a:first-child{padding:22px 2px;gap:18px;border:0;border-bottom:1px solid var(--line)}
  .three-paths>a:last-child{border:0}
  .three-paths .icon{width:34px;height:34px;margin-top:6px}
  .three-paths h2{font-size:24px}
  .three-paths p{font-size:14px}
  .path-arrow{display:none}
  .section-head{margin:28px 0 18px;gap:4px 16px}
  .section-head h2{font-size:28px;line-height:1.3}
  .section-head>a{font-size:13px}
  .home-deities{gap:12px}
  .home-deities img{height:auto;aspect-ratio:1 / 1.15}
  .home-deities h3{font-size:22px;margin-inline:6px}
  .home-deities span{margin-left:6px;font-size:12px}
  .daily-invitation{grid-template-columns:1fr;padding:26px 22px;gap:12px;margin-top:32px}
  .daily-invitation h2{font-size:30px}
  .page-heading h1{font-size:34px;line-height:1.25}
  .page-heading p{font-size:15px}
  .article-grid,.temple-grid,.checklist{grid-template-columns:1fr}
  .reader-heading h1{font-size:30px;line-height:1.4}
  .reader-tab{font-size:14px;padding:10px 6px}
  .reader-source-button{font-size:12px;flex:1 1 150px;justify-content:flex-end}
  .reader-context{font-size:14px}
  .verse-text{font-size:var(--reading)}
  .verse-actions{margin-left:auto}
  .chapter-pager{gap:12px;font-size:14px;justify-content:center}
  .chapter-pager .button{font-size:13px;flex:1 1 130px;padding:12px 8px}
  .chapter-pager>span{flex-basis:100%;text-align:center}
  .reader-end .button{display:flex;margin:12px 0 0;width:100%}
  .grantha-pending{padding:20px}
  .grantha-pending h4{font-size:23px}
  .grantha-pending li{font-size:14px}
  .calendar-filters{grid-template-columns:repeat(2,minmax(0,1fr))}
  .calendar-filters select{min-width:0}
  .article-body p{font-size:17px}
  .deity-hero:has(.deity-portrait){grid-template-columns:1fr;gap:0}
  .deity-hero:has(.deity-portrait) .hero-copy{padding:24px 20px}
  .deity-portrait{max-height:360px}
  .book-card{gap:14px}
  .book-mark{flex-basis:40px}
  #footer{margin-inline:18px;font-size:12px}
}

@media(max-width:600px){
  .card-grid{grid-template-columns:minmax(0,1fr)}
  .book-grid{grid-template-columns:minmax(0,1fr)}
  .book-card{padding:20px 16px}
  .book-actions{flex-direction:column;align-items:stretch}
}
@media(max-width:380px){
  .brand-word.brand-global{font-size:19px;letter-spacing:.2px}
  .brand>.icon{width:25px;height:25px}
  .language-button{gap:4px;font-size:11px;padding:8px 5px}
  .sandalwood-hero{padding-top:190px}
  .heritage-art,.sandalwood-hero:after,:root[data-theme=dark] .sandalwood-hero:after{height:242px}
  .explore-grid,.platform-grid,.daily-limbs{grid-template-columns:minmax(0,1fr)}
  .book-filters,.calendar-filters{grid-template-columns:minmax(0,1fr)}
  .book-filters label,.calendar-filters label{grid-column:auto}
  .reading-settings{gap:4px}
  .reader-source-button{flex-basis:125px;font-size:11px}
}
@media print{
  body{padding-bottom:0!important}
  #header,#mobile-nav,#footer,.reader-toolbar,.mobile-contents,.verse-actions,#toast,#update-banner{display:none!important}
  #main{max-width:none;padding:0}
}
