﻿/* Shared touch and viewport behavior; desktop layout is unchanged. */
@media(max-width:1250px){
 html{scroll-padding-top:88px;scroll-padding-bottom:calc(var(--mobile-nav-height,64px) + 24px + env(safe-area-inset-bottom));}
 .catalog-site :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea){font-size:16px;max-width:100%;min-width:0;}
 .catalog-site :is(main,form,fieldset,.writer-content,.wallet-workspace,.detail-copy){min-width:0;}
 .catalog-site main :is(h1,h2,h3,p,.form-error,.notice){overflow-wrap:anywhere;}
 .catalog-site main :is(button,.primary,.secondary),.catalog-site #drawer>a{min-height:44px;touch-action:manipulation;}
 .catalog-site :is(button,a,input,select,textarea){-webkit-tap-highlight-color:transparent;}
 .catalog-site :is(input,select,textarea,[contenteditable=true]){scroll-margin-block:100px;}
 .catalog-site .bottomnav{box-sizing:border-box;max-width:calc(100% - 24px);padding-inline:4px;gap:2px;}
 .catalog-site .bottomnav a{flex:1 1 0;min-width:0;min-height:44px;display:flex;align-items:center;justify-content:center;flex-direction:column;}
 .catalog-site .bottomnav small{white-space:nowrap;font-size:11px;}
 .catalog-site .bottomnav a.active,.catalog-site.pastel .bottomnav a.active{background:var(--ui-action,#7040b6);color:#fff;}
 .catalog-site .bottomnav a.active :is(svg,small){color:inherit;}
 .catalog-site dialog:not(#drawer):not(.mobile-welcome){box-sizing:border-box;max-width:calc(100vw - 24px);max-height:calc(var(--mobile-visible-height,100dvh) - 24px);overflow-y:auto;overscroll-behavior:contain;}
 .catalog-site #drawer{box-sizing:border-box;height:100dvh;max-height:var(--mobile-visible-height,100dvh);padding-bottom:calc(24px + env(safe-area-inset-bottom));overflow-y:auto;overscroll-behavior:contain;}
 .catalog-site #drawer .drawer-head{flex-shrink:0;}
 .catalog-site .category-options{max-height:min(440px,65dvh);overflow-y:auto;overscroll-behavior:contain;}
 .catalog-site .category-checks label{min-height:44px;}
 .catalog-site .category-checks input{flex-shrink:0;}
 #floating-audio[data-mode=mini]{bottom:calc(var(--mobile-nav-height,64px) + 16px + env(safe-area-inset-bottom));}
 .catalog-site #toast{bottom:calc(var(--mobile-nav-height,64px) + 20px + env(safe-area-inset-bottom));max-width:calc(100vw - 32px);}
 .catalog-site.keyboard-open .bottomnav,.catalog-site.keyboard-open #floating-audio[data-mode=mini]{visibility:hidden;pointer-events:none;}
 .catalog-site.keyboard-open #toast{bottom:16px;}
 .catalog-site .batch-table-wrap{overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;}
 .catalog-site .writer-content :is(.actions,.form-actions){flex-wrap:wrap;gap:8px;}
 .catalog-site .writer-content :is(textarea,input,select){max-width:100%;}
 .catalog-site .wallet-redesign .amount-options button{touch-action:manipulation;}
 .catalog-site .auth-brand,.catalog-site .google-login-host{max-width:100%;}
}
@media(max-width:600px){
 .catalog-site :is(.studio-dialog,.pwa-guide,.membership-modal){width:calc(100vw - 24px);padding:18px;}
 .catalog-site .writer-content .actions>*{flex-shrink:1;white-space:normal;}
 #audio-modal{width:calc(100vw - 24px);}
 #audio-modal #floating-audio{padding:16px;}
}
@media(max-width:1250px) and (max-height:500px){
 .catalog-site .bottomnav{max-width:500px;}
 #floating-audio[data-mode=mini]{width:320px;}
 .catalog-site dialog:not(#drawer):not(.mobile-welcome){margin-block:auto;}
 #audio-modal .audio-modal-label{padding:12px 18px;}
 #audio-modal #floating-audio{padding:14px 18px;}
}
@media(prefers-reduced-motion:reduce){
 .catalog-site{scroll-behavior:auto;}
 .catalog-site :is(.hero-inner,.book,.bottomnav,.writer-sidebar){transition:none;animation:none;}
}
@media(max-width:1250px){.catalog-site .bottomnav{width:calc(100% - 24px);max-width:560px;left:0;right:0;margin-inline:auto;justify-content:space-around}.catalog-site .bottomnav a{flex:0 1 64px;padding-inline:6px}}
/* Inline player is a full-width section of the mobile novel grid. */
@media(max-width:760px){
 .catalog-site .novel-detail #floating-audio[data-mode=inline]{grid-column:1/-1;grid-row:auto;order:2;width:100%;min-width:0;max-width:100%;box-sizing:border-box;margin:8px 0;padding:16px;}
 .catalog-site .novel-detail #floating-audio[data-mode=inline] .floating-audio-body{min-width:0;grid-template-columns:76px minmax(0,1fr);}
 .catalog-site .novel-detail #floating-audio[data-mode=inline] .audio-title{min-width:0;}
 .catalog-site .novel-detail #floating-audio[data-mode=inline] .audio-title strong{overflow-wrap:anywhere;}
 .catalog-site .novel-detail #floating-audio[data-mode=inline] .audio-chapter-nav{min-width:0;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);}
 .catalog-site .novel-detail #floating-audio[data-mode=inline] .audio-chapter-nav button{white-space:nowrap;}
}

/* Compact header actions on desktop, tablet and phone. */
body.catalog-site .site-header .header-inner{column-gap:4px}
body.catalog-site .site-header .header-inner>:is(.header-publish,.theme-toggle,.notification-link,.coin,.account,.mobile-search,.menu-button){margin-right:0}
body.catalog-site .site-header :is(.header-publish + .theme-toggle,.theme-toggle + .notification-link,.notification-link + .coin){margin-left:0}
@media(min-width:761px){body.catalog-site .site-header .header-inner>.brand{margin-right:14px}body.catalog-site .site-header #search-form{margin-right:8px}body.catalog-site .site-header .coin{padding-inline:6px}body.catalog-site .site-header .account{margin-left:2px}}
@media(max-width:760px){body.catalog-site .site-header .header-inner{column-gap:0}body.catalog-site .site-header :is(.theme-toggle,.notification-link,.mobile-search,.menu-button){margin-left:0;margin-right:0}body.catalog-site .site-header .account{margin-left:2px}}

/* Mobile visitors choose categories from the dedicated category page. */
@media (max-width:760px){.catalog-site .catalog-home>.mobile-categories{display:none}}

/* A separate navigation row keeps tablet header actions comfortably spaced. */
.tablet-header-nav{display:none}
@media (min-width:761px) and (max-width:1250px), (min-width:761px) and (max-width:1366px) and (pointer:coarse){
 body.catalog-site .site-header{height:auto}
 body.catalog-site .site-header .header-inner{height:72px}
 body.catalog-site .site-header .topnav{display:none}
 body.catalog-site .tablet-header-nav{display:flex;align-items:center;justify-content:center;gap:12px;padding:0 20px 8px;border-top:1px solid var(--line);background:var(--paper);color:var(--ink)}
 body.catalog-site .tablet-header-nav a{display:flex;align-items:center;justify-content:center;min-height:44px;padding:0 24px;font-size:15px;font-weight:600;color:var(--ink);text-decoration:none;border-radius:8px}
 body.catalog-site .tablet-header-nav a:hover{background:var(--soft)}
 html{scroll-padding-top:132px}
}

.shelf-following-shortcut{margin:0 0 20px}

/* Narrow screens: keep period labels intact and distribute evenly. */
@media(max-width:760px){.catalog-site .rank-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;width:100%;min-width:0}.catalog-site .rank-tabs button{white-space:nowrap;min-width:0;padding:10px 4px;font-size:13px;line-height:1.5}}

/* Channel actions beside the identity on phones only. */
@media(max-width:600px){
.catalog-site .channel-page .channel-identity:has(.follow-author){display:grid;grid-template-columns:52px minmax(0,1fr) 104px;align-items:start;gap:10px}
.catalog-site .channel-page .channel-identity:has(.follow-author) .channel-avatar{width:52px;height:52px;min-width:0}
.catalog-site .channel-page .channel-identity:has(.follow-author) .channel-name h1{font-size:18px;margin-top:0}
.catalog-site .channel-page .channel-identity:has(.follow-author) .channel-name p{overflow-wrap:anywhere}
.catalog-site .channel-page .channel-identity:has(.follow-author) .channel-actions{display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:8px;width:104px;min-width:0;margin:0;flex-basis:auto}
.catalog-site .channel-page .channel-identity:has(.follow-author) .channel-actions :is([data-follow-author],[data-membership-author]){width:104px;min-width:0;flex:0 0 auto;padding:0 6px;font-size:12px}
.catalog-site .channel-page .channel-identity:has(.follow-author) .channel-actions [data-follow-author]{order:0}
.catalog-site .channel-page .channel-identity:has(.follow-author) .channel-actions [data-membership-author]{order:1}
}

/* The welcome screen fills the viewport; it is not an inset popup. */
.catalog-site dialog.mobile-welcome{inset:0;margin:0;padding:0;width:100%;max-width:none;height:100dvh;max-height:none;overflow:hidden;border:0;border-radius:0;box-sizing:border-box}
.catalog-site .mobile-welcome .welcome-enter{box-sizing:border-box;margin:0;min-height:0;border-radius:40px;line-height:1.4}
.catalog-site .mobile-welcome .welcome-search{box-sizing:border-box;margin:0;border-radius:50%}

/* Quiet, theme-aware section links and breathing room below the phone hero. */
.catalog-site .section-title>a{display:inline-flex;align-items:center;justify-content:center;gap:7px;color:var(--ink);font-weight:500;white-space:nowrap;text-decoration:none;transition:opacity .15s ease}
.catalog-site .section-title>a:hover{color:var(--ink);opacity:.72}
.catalog-site .section-title>a .icon{width:18px;height:18px;flex:0 0 18px;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;color:inherit}
@media(max-width:600px){.catalog-site .catalog-home .latest-section{margin-top:24px}.catalog-site .section-title>a{font-size:12px;min-height:36px}}

/* Center phone hero pagination in the space below its action buttons. */
@media(max-width:760px){
.catalog-site #catalog-hero .hero-inner{padding-bottom:64px}
.catalog-site #catalog-hero>.slider-dots{bottom:18px;margin:0;height:28px;align-items:center}
}

.catalog-site:is(.light,.pastel,.dark) .section-title>a,.catalog-site .section-title>a{color:var(--ink)!important}
.catalog-site .spotlight>.section-title>a{color:inherit!important}
