/* Panel Reading Room: presentation layer over the established application components.
   Layout follows available width, not device detection. Safe areas and dynamic
   viewport units cover phones, folding displays, tablets and browser chrome. */
:root {
  --paper:#f6f4ef; --surface:#fffefa; --surface-subtle:#eeeee6;
  --ink:#203c35; --muted:#65736b; --line:#dce1d7;
  --accent:#b84a2d; --accent-hover:#963b25; --accent-soft:#e8eee2;
  --success:#356645; --rail:208px; --page-pad:clamp(22px,3vw,48px);
  --nav-bottom:0px; --radius:16px;
  font-family:Inter,'Segoe UI Variable','Segoe UI',system-ui,-apple-system,sans-serif;
  font-size:15px;
}
html { scroll-padding-top:80px; -webkit-text-size-adjust:100%; }
body { min-width:280px; }
button,input,select,summary,a { touch-action:manipulation; }
button { transition:background .18s,color .18s,box-shadow .18s,transform .18s; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible { outline:3px solid #bf643c; outline-offset:3px; }
h1 { font-size:34px; letter-spacing:-1.3px; line-height:1.15; font-weight:730; }
h2 { font-size:21px; letter-spacing:-.55px; }
h3 { font-size:15px; }
.heading-dot,.mobile-brand>span { color:var(--accent); }
.sidebar { width:var(--rail); padding:32px 14px 22px; background:#173d37; color:#edf1df; border-right:1px solid #ffffff0a; }
.sidebar .brand { color:#faf7e9; font-size:29px; gap:9px; padding:0 13px; }
.sidebar .brand-symbol { color:#e79a71; width:32px; height:38px; }
.workspace-label { color:#a8b9a7; font-size:9px; letter-spacing:1.8px; margin:42px 14px 17px; }
.sidebar nav { gap:7px; }
.nav { min-height:48px; padding:12px 14px; color:#bed0c1; font-size:13px; border-radius:10px; font-weight:550; }
.nav .icon { opacity:.85; }
.nav:hover { background:#ffffff0d; color:#fff9e8; }
.nav.active { background:#e7eddb; color:#183c32; box-shadow:0 4px 12px #0c27271a; }
.nav.active .icon { opacity:1; }
.nav b { background:#ffffff12; font-size:10px; }
.nav.active b { background:#173d3714; }
.nav b:empty { display:none; }
.sidebar-note { padding:18px 12px 0; border-color:#ffffff19; gap:12px; }
.sidebar-help { color:#dce4d4; font-size:12px; min-height:44px; }
.sidebar-help:hover { color:white; }
.sidebar .connection-state { color:#c1d2b5; }
.sidebar .connection-state::before { background:#a8c887; }
.sidebar .connection-state.offline { color:#f7b39a; }
.sidebar .local-caption { color:#9cb2a6; font-size:10px; line-height:1.7; }
main { margin-left:var(--rail); padding:0 var(--page-pad) 48px; min-height:100dvh; }
main>header { height:52px; margin-inline:calc(-1 * var(--page-pad)); padding-inline:var(--page-pad); background:#f6f4eff5; border-color:#dce1d780; }
.header-context { font-size:11px; letter-spacing:.15px; }
.header-actions { gap:8px; }
.header-connection { box-shadow:0 0 0 4px #4674540a; }
.icon-button { width:40px; min-width:40px; height:40px; border-color:transparent; background:transparent; border-radius:50%; }
.icon-button:hover { background:#e7eadf; }
.logout-form .secondary { min-height:36px; font-size:11px; padding:7px 12px; background:transparent; }
.view { max-width:1500px; }
.page-heading { padding:25px 0 24px; }
.page-heading p { font-size:14px; margin-top:9px; line-height:1.6; }
#discover .page-heading { padding:18px 0 20px; }
#discover .page-heading>div { gap:20px; align-items:baseline; }
#discover .page-heading h1 { font-size:34px; }
#discover .page-heading p { font-size:13px; color:#6d7c6e; }
.primary,.secondary,.subtle { min-height:44px; padding:10px 16px; border-radius:10px; font-size:13px; font-weight:600; }
.primary { box-shadow:0 3px 8px #9d422010; }
.secondary { background:var(--surface); color:var(--ink); }
.secondary:hover:not(:disabled) { background:#edf1e7; border-color:#becdba; }
.subtle { font-weight:550; }
input:not([type=checkbox]),select { min-height:44px; padding:10px 12px; font-size:14px; border-radius:9px; border-color:var(--line); }
select { padding-right:28px; }
input[type=checkbox] { width:20px; height:20px; }
.footnote { font-size:12px; }
/* A compact search station; feeds and genres remain one tap away. */
.discovery-workspace { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px 16px; padding:0; border:0; background:transparent; box-shadow:none; border-radius:0; }
.discovery-workspace>.source-switch { grid-column:1; grid-row:1; display:inline-flex; width:fit-content; border:1px solid #dde2d5; border-radius:12px; background:#e9ecdf; padding:4px; gap:3px; }
.source-switch button,.discovery-workspace>.source-switch button { top:0; padding:9px 22px; min-height:40px; border:0; border-radius:8px; gap:0; }
.source-switch button>span { font-size:14px; font-weight:650; }
.source-switch small { display:none; }
.source-switch button.active { background:var(--surface); color:var(--ink); box-shadow:0 2px 5px #243c2512; }
.discovery-workspace>.manga-source-options { grid-row:1; grid-column:2; }
.manga-source-options label { gap:9px; font-size:12px; }
.manga-source-options select { min-width:155px; max-width:230px; background:transparent; border-color:transparent; font-size:13px; }
.search-box { gap:12px; padding:7px 7px 7px 18px; border:1px solid #cfd9ca; border-radius:14px; background:#fffefa; box-shadow:0 4px 12px #203c3504; }
.search-box input { font-size:16px; min-height:42px; padding:8px 0; }
.search-box .primary { min-height:44px; padding-inline:24px; }
.search-box:focus-within { border-color:#8caa82; box-shadow:0 0 0 3px #3b6c4110; }
.discovery-workspace>.search-box { grid-row:2; }
.discovery-workspace>.discovery-controls { grid-row:3; gap:8px; min-width:0; }
.discovery-workspace>.shared-genres { grid-row:3; }
.discovery-shortcuts { flex:0 1 auto; gap:6px; }
.feed-chip { border-radius:8px; min-height:44px; background:transparent; color:var(--muted); padding:9px 12px; font-size:12px; }
.feed-chip.active,.feed-chip[aria-pressed=true] { background:#e4ebdc; color:#2f573c; border-color:#d7e1ce; box-shadow:none; }
.feed-chip small { font-size:10px; }
#browse-feed { background:transparent; border-color:transparent; color:var(--muted); font-size:12px; padding-inline:8px; }
#surprise-title { margin-left:0; background:transparent; border-color:transparent; font-size:12px; padding-inline:10px; }
.shared-genres>summary { display:flex; align-items:center; min-height:44px; gap:6px; padding:10px 12px; color:var(--ink); font-size:12px; border-radius:9px; background:var(--surface); }
.shared-genres>summary::before { content:'+'; font-size:18px; font-weight:400; color:var(--muted); }
.shared-genres[open]>summary::before { content:'−'; }
.shared-genres>summary::-webkit-details-marker { display:none; }
#shared-genre-count { font-size:10px; margin-left:5px; }
.discovery-workspace>.shared-genres[open] { grid-row:auto; background:var(--surface); padding:16px; border:1px solid var(--line); border-radius:14px; }
.shared-genre-heading { font-size:12px; }
.shared-genre-list { max-height:240px; grid-template-columns:repeat(auto-fit,minmax(165px,1fr)); gap:8px; }
.shared-genre-option { min-height:52px; border-radius:9px; }
.shared-genre-option input { width:18px; height:18px; }
.advanced-discovery { background:var(--surface); padding:12px 16px !important; border:1px solid var(--line); border-radius:10px; }
.advanced-discovery summary { min-height:24px; }
.genre-chip,.filter-chip { min-height:40px; }
/* Results options tuck away so artwork, not form controls, owns the page. */
.catalog-toolbar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin:26px 0 16px; position:relative; z-index:9; }
.results-toolbar { padding:0; min-width:0; flex:1; }
.results-toolbar h2 { font-size:21px; line-height:1.3; }
#results-meta { margin-top:5px; font-size:11px; }
.display-options { flex:0 0 auto; }
.display-options>summary { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; padding:10px 13px; background:var(--surface); border:1px solid var(--line); border-radius:10px; list-style:none; font-size:12px; color:var(--ink); font-weight:600; }
.display-options>summary::-webkit-details-marker { display:none; }
.display-options>summary .icon { width:17px; height:17px; flex-basis:17px; }
.display-options[open]>summary { border-color:#809c74; background:#edf2e6; }
.display-options>.results-options { position:absolute; right:0; top:calc(100% + 8px); width:min(640px,100%); max-height:min(560px,70dvh); overflow-y:auto; margin:0; padding:20px; display:flex; gap:16px; border:1px solid #ced9c7; border-radius:14px; background:var(--surface); box-shadow:0 18px 50px #203c3526; }
.browse-controls { gap:12px; flex-wrap:wrap; }
.browse-controls label { font-size:12px; gap:7px; }
.browse-controls select { max-width:100%; }
.page-size-control select { width:78px; }
.result-filters { width:100%; padding:0; border:0; border-top:1px solid var(--line); border-radius:0; }
.result-filters>summary { padding:14px 0 0; min-height:44px; }
.result-filters[open] { padding:0; }
.filters,.extended-filters { display:flex; margin:14px 0 0; gap:12px; }
.filters label,.extended-filters label { flex:1 1 130px; min-width:0; font-size:12px; }
.filters select,.extended-filters select,.extended-filters input { width:100%; }
.view-help { display:none; }
.selection-hint { margin:0 0 14px; font-size:11px; color:#718070; }
.touch-hint { display:none; }
/* Covers are the centerpiece. Quiet, consistent actions sit underneath. */
.grid,#results.grid { grid-template-columns:repeat(auto-fill,minmax(235px,1fr)); gap:30px 22px; }
.card { padding:0; border:0; border-radius:12px; background:transparent; box-shadow:none; }
.card:hover { border:0; box-shadow:none; }
.cover,#results .cover { border-radius:12px; background:#e1e8d9; box-shadow:0 6px 14px #233d3015,0 1px 2px #233d301f; }
.cover::before { font-family:Georgia,serif; font-size:70px; font-style:italic; font-weight:400; color:#a7b69b; }
.cover img { object-fit:cover; }
.card:hover .cover img { transform:none; }
@media(hover:hover) and (prefers-reduced-motion:no-preference) { .card:hover .cover { box-shadow:0 10px 24px #233d3026; } }
.card-category { margin:16px 0 6px; font-size:10px; font-weight:650; letter-spacing:.8px; color:#63765c; }
.card h3,#results .card h3 { font-size:15px; line-height:1.45; min-height:44px; margin:0 0 10px; font-weight:650; letter-spacing:-.2px; }
#library-grid .card h3 { display:-webkit-box; -webkit-line-clamp:3; overflow:hidden; }
.card-meta { gap:7px; font-size:11px; }
.card-meta>span { margin:0 0 3px; color:#6c7b68; }
.card-meta>button { min-height:44px; padding:9px 10px; font-size:12px; color:#4c624c; background:#e9eee3; border-radius:8px; font-weight:550; }
.card-meta>button:first-of-type { min-height:44px; background:#244e3e; color:#fffdf3; border:1px solid #244e3e; font-size:12px; letter-spacing:.1px; }
.card-meta>button:first-of-type:hover:not(:disabled) { background:#173d30; color:white; }
.card-meta>button:hover:not(:disabled) { background:#dce7d3; }
.card-meta>button:disabled { background:#e9ece5; color:#6a7868; border-color:#dce1d7; }
.card.selected { outline:3px solid var(--accent); outline-offset:6px; box-shadow:none; }
.check { top:9px; left:9px; width:44px; height:44px; border-radius:10px; background:#fffef9f0; }
.check input { width:21px; height:21px; }
.cover-quick-look { top:9px; right:9px; min-height:44px; max-width:calc(100% - 65px); padding:9px 11px; border-radius:9px; font-size:12px; }
.availability-badge.available { bottom:10px; left:10px; max-width:calc(100% - 20px); padding:7px 10px; border-radius:6px; font-size:11px; background:#173d37ef; }
.availability-badge.unavailable { font-size:11px; line-height:1.5; }
.recommendation-reason { margin:9px 0 0; font-size:11px; }
.skeleton-card { padding:0; background:none; border:0; }
.skeleton-cover { border-radius:12px; }
.empty { padding:48px 24px; border:1px solid var(--line); border-radius:16px; background:#fffefa; }
.empty b { font-size:22px; font-weight:650; letter-spacing:-.5px; }
.empty p { max-width:420px; margin:9px auto 0; font-size:14px; line-height:1.7; }
.status:not(:empty) { padding:18px 20px; border-radius:12px; font-size:14px; }
.selection-bar { bottom:24px; border-radius:14px; background:#173d37; padding:12px 16px; max-width:720px; box-shadow:0 8px 28px #173d3733; font-size:13px; }
.selection-bar .subtle { color:#ecf2e4; }
.results-navigation { margin:32px 0 10px; }
.pagination { font-size:12px; }
.shelf-track { gap:20px; padding-top:14px; }
.shelf-card { flex-basis:180px; }
.shelf-card h3 { font-size:14px; min-height:40px; }
.shelf-card>.secondary { min-height:44px; font-size:12px; }
/* Every workspace shares the same hierarchy and spacing. */
.library-controls { padding:12px; border-radius:14px; gap:10px; box-shadow:0 3px 12px #173d3703; }
.library-controls>input { min-width:180px; }
.library-controls label { min-height:44px; font-size:12px; }
.library-controls>button { font-size:12px; }
#saved-status,#library-status { font-size:13px; margin:20px 0; }
.download-summary { border-radius:14px; padding:18px 22px; background:#e7edde; border-color:#d5dfcc; }
#history-count { font-size:15px; color:#35533a; }
.download-tabs { gap:8px; padding:5px; border:1px solid var(--line); border-radius:12px; background:#e9ecdf; width:fit-content; max-width:100%; }
.download-tabs button { padding:10px 16px; border:0; border-radius:8px; min-height:44px; font-size:13px; }
.download-tabs button.active { background:var(--surface); color:var(--ink); box-shadow:0 2px 6px #183d3710; }
.download-controls { margin:18px 0; }
.download-controls>button { font-size:12px; }
.download-row { border-radius:14px; padding:22px; grid-template-columns:44px minmax(0,1fr) auto; gap:16px; }
.download-icon { width:44px; height:44px; border-radius:12px; }
.download-row h3 { font-size:15px; }
.download-row p { font-size:12px; }
.download-status { font-size:10px; font-weight:650; }
.download-row-actions { min-width:130px; }
.download-row-actions button { font-size:12px; min-height:44px; }
.download-row-actions .device-download { background:var(--accent); color:white; padding-inline:18px; }
.device-download-note { background:#eaf0e4; border:1px solid #d9e3d2; border-radius:16px; padding:20px 24px; margin:0 0 24px; max-width:900px; }
.device-download-note strong { display:block; font-size:17px; color:#173d37; margin-bottom:6px; }
.device-download-note p { font-size:14px; line-height:1.65; margin:5px 0; }
.device-download-note span { display:block; color:#526953; font-size:12px; margin-top:12px; }
.device-download-note summary { font-size:12px; padding-block:12px 2px; cursor:pointer; }
.device-delivery-status { color:#315d47; font-weight:600; }
.temporary-expiry { width:100%; font-size:12px; color:var(--muted); }
.settings-grid { gap:20px; }
.settings-card { padding:26px; border-radius:16px; }
.settings-card h2 { font-size:20px; }
.settings-card p { font-size:13px; line-height:1.8; }
.settings-card label { font-size:12px; }
/* Dialogs become full-height sheets on small screens, with reachable actions. */
dialog { border-radius:20px; width:min(960px,calc(100vw - 48px)); max-height:min(900px,90dvh); }
dialog[open] { margin:auto; }
body:has(dialog[open]) { overflow:hidden; }
.dialog-heading { padding:22px 26px; gap:16px; }
.dialog-heading h2 { font-size:24px; letter-spacing:-.7px; }
.dialog-body { padding:22px 26px; }
.dialog-heading>button { min-height:44px; min-width:44px; }
.chapter-controls { gap:12px; padding:16px; border-radius:12px; }
.chapter-controls label { font-size:12px; }
.chapter-filters { border:1px solid var(--line); border-radius:12px; background:#f3f5ec; }
.chapter-filters>summary { min-height:44px; padding:12px 14px; font-size:12px; font-weight:600; color:#34523b; }
.chapter-filters>summary span { color:var(--muted); font-weight:400; margin-left:8px; }
.chapter-filters .chapter-state-controls,.chapter-filters>.footnote { margin:10px 14px; }
.chapter-state-controls { gap:12px; margin:16px 0; }
.chapter-state-controls label { min-height:44px; }
.chapter-row { min-height:64px; padding:12px; gap:14px; }
.chapter-row strong { font-size:14px; }
.chapter-row small { font-size:12px; }
.chapter-source button { min-height:44px; font-size:12px; }
.chapter-actions,#details-actions { padding:16px 26px; background:#f1f3ea; }
.details-synopsis { font-size:14px; line-height:1.85; }
.details-cover { width:190px; }
.details-facts { font-size:13px; }
.flat-series { border-radius:14px; padding:14px; margin:14px 0; }
.flat-heading { grid-template-columns:46px minmax(0,1fr) auto; }
.flat-heading .cover { width:46px; height:69px; border-radius:7px; }
.flat-info h3 { font-size:15px; }
.flat-heading-actions>button,.flat-series .flat-chapter>button,.flat-pagination>button { min-height:44px; font-size:12px; }
.flat-series .card.flat-chapter { min-height:55px; padding:6px 9px; }
.flat-series .card.flat-chapter.selected { outline:0; }
.flat-chapter-text>strong { font-size:13px; }
#preview-dialog { border-radius:16px; width:min(1200px,calc(100vw - 32px)); max-height:94dvh; height:94dvh; }
#preview-dialog>.dialog-heading { padding:12px 18px; }
#preview-dialog>.dialog-body { grid-template-rows:auto auto auto minmax(0,1fr); background:#e9ede4; padding:12px; }
.preview-controls { background:#fffefa; border-radius:12px; gap:10px; }
#preview-content { background:#dce3d6; border-radius:10px; }
#preview-page-label { min-width:76px; text-align:center; }
#toast { background:#173d37; border-radius:12px; font-size:13px; }
.guide-step p { font-size:13px; }
/* A considered entrance, with no decorative images competing with the library. */
.login-page { background:#f1f3e8; }
.login-page .login-shell { background:radial-gradient(ellipse at 0 0,#dce6d4 0,transparent 60%),radial-gradient(ellipse at 100% 100%,#efddcb 0,transparent 50%); gap:24px; padding:36px 24px; }
.login-page .brand { display:flex; color:#234a39; font-size:30px; gap:10px; }
.login-card { padding:38px; width:min(100%,450px); border-radius:22px; border-color:#dce2d4; box-shadow:0 22px 60px #234a3910; }
.login-card h1 { font-size:38px; line-height:1.12; letter-spacing:-1.2px; }
.login-eyebrow { font-size:9px; letter-spacing:1.6px; }
.login-intro { font-size:14px; line-height:1.7; margin-top:15px; }
.login-card label { font-size:13px; }
.login-card input:not([type=hidden]) { min-height:50px; border-radius:10px; background:#fafbf6; }
.password-field { position:relative; margin-bottom:20px; }
.login-card .password-field input { width:100%; padding-right:68px; margin-bottom:0; }
.password-field>button { position:absolute; top:3px; right:3px; min-height:44px; min-width:58px; background:transparent; color:#355a42; font-size:12px; border-radius:8px; }
.password-field>button:hover { background:#e6eddf; }
.login-card .primary { min-height:50px; border-radius:10px; background:#244e3e; border-color:#244e3e; font-size:14px; }
.login-card .primary:hover { background:#173d30; }
.login-caption { font-size:11px; }
/* Compact laptops, tablets and unfolded phones get a rail and fluid columns. */
@media(min-width:1650px) { .grid,#results.grid { grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); } }
@media(min-width:761px) and (max-width:1100px) {
  :root { --rail:76px; --page-pad:26px; }
  .sidebar { padding:26px 10px 16px; }
  .sidebar .brand { padding:0 10px; }
  .sidebar nav { margin-top:32px; }
  .nav { padding:13px; }
  .nav b { font-size:9px; background:#b84a2d; }
  .grid,#results.grid { grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:28px 18px; }
  #discover .page-heading p { font-size:12px; }
}
/* Phone / narrow window: fixed five-item navigation, two generous cover columns. */
@media(max-width:760px) {
  :root { --rail:0px; --page-pad:20px; --nav-bottom:calc(72px + env(safe-area-inset-bottom,0px)); }
  body { padding-bottom:var(--nav-bottom); }
  main { margin-left:0; padding:0 max(var(--page-pad),env(safe-area-inset-right,0px)) 30px max(var(--page-pad),env(safe-area-inset-left,0px)); }
  main>header { height:calc(54px + env(safe-area-inset-top,0px)); padding-top:env(safe-area-inset-top,0px); margin-inline:calc(-1 * var(--page-pad)); padding-inline:var(--page-pad); }
  .sidebar { width:0; height:0; padding:0; border:0; }
  .sidebar>.brand,.workspace-label,.sidebar-note { display:none; }
  .sidebar nav { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:2px; min-height:var(--nav-bottom); padding:8px max(8px,env(safe-area-inset-right,0px)) calc(8px + env(safe-area-inset-bottom,0px)) max(8px,env(safe-area-inset-left,0px)); background:#fffefbf5; border-top:1px solid #dce1d7; box-shadow:0 -6px 24px #173d3706; }
  .nav { min-height:54px; min-width:0; padding:7px 2px; font-size:10px; gap:4px; color:#6c7d6b; border-radius:10px; }
  .nav.active { background:#e6eddd; color:#234c36; box-shadow:none; }
  .nav:hover { background:#eef1e8; color:#234c36; }
  .nav .icon { width:21px; height:21px; flex-basis:21px; }
  .nav b { right:12%; top:1px; background:#b84a2d; color:white; }
  .nav.active b { background:#b84a2d; }
  .mobile-brand { display:flex; font-size:25px; color:#254735; font-weight:750; letter-spacing:-1px; text-decoration:none; min-height:44px; align-items:center; }
  .header-actions { gap:2px; }
  .header-actions .icon-button { min-height:44px; min-width:44px; }
  .logout-form .secondary { min-height:44px; border-color:transparent; }
  .page-heading,#discover .page-heading { padding:18px 0; }
  h1,#discover .page-heading h1 { font-size:30px; }
  #discover .page-heading p { display:none; }
  .page-heading p { font-size:13px; }
  input:not([type=checkbox]),select,.search-box input { font-size:16px; } /* Avoid iOS focus zoom. */
  .discovery-workspace { grid-template-columns:minmax(0,1fr) auto; gap:10px 8px; padding:0; }
  .discovery-workspace>.source-switch { grid-column:1; grid-row:1; }
  .source-switch button,.discovery-workspace>.source-switch button { min-height:40px; padding:8px 14px; }
  .source-switch button>span { font-size:13px; }
  .discovery-workspace>.manga-source-options { grid-column:2; grid-row:1; }
  .manga-source-options label { font-size:0; gap:0; }
  .manga-source-options select { font-size:16px; min-width:0; width:160px; max-width:100%; padding:10px 22px 10px 6px; }
  .discovery-workspace>.search-box { grid-column:1/-1; grid-row:2; }
  .search-box { padding:5px 5px 5px 12px; gap:8px; flex-wrap:nowrap; border-radius:12px; }
  .search-box>.icon,.search-box>span { display:none; }
  .search-box input { width:0; padding:9px 0; }
  .search-box .primary { flex:0 0 auto; padding:10px 12px; font-size:12px; min-height:44px; }
  .discovery-workspace>.discovery-controls { grid-column:1; grid-row:3; flex-wrap:nowrap; gap:6px; }
  .discovery-shortcuts { flex:1 1 auto; flex-wrap:nowrap; margin:0; padding:0; overflow-x:auto; scrollbar-width:none; }
  .feed-chip { flex-shrink:0; min-height:44px; }
  #browse-feed { display:none; } /* Feed chips already perform this exact action. */
  #surprise-title { min-height:44px; min-width:44px; flex:0 0 44px; padding-inline:8px; font-size:12px; }
  .surprise-label { display:none; }
  .discovery-workspace>.shared-genres { grid-column:2; grid-row:3; justify-self:end; }
  #shared-genre-count { display:none; }
  .shared-genres>summary { width:fit-content; min-height:44px; font-size:12px; }
  .discovery-workspace>.shared-genres[open] { grid-column:1/-1; grid-row:4; padding:14px; }
  .shared-genre-heading { display:grid; gap:12px; }
  .shared-genre-heading input { width:100%; }
  .shared-genre-list { grid-template-columns:repeat(2,minmax(0,1fr)); max-height:250px; }
  .shared-genre-option { grid-template-columns:18px minmax(0,1fr); padding:8px; font-size:12px; overflow-wrap:anywhere; }
  .catalog-toolbar { margin:22px 0 14px; gap:10px; }
  .results-toolbar h2 { font-size:19px; }
  #results-meta { font-size:10px; line-height:1.6; }
  .display-options>summary { font-size:11px; gap:8px; padding-inline:10px; }
  .display-options>.results-options { width:100%; padding:16px; max-height:65dvh; }
  .browse-controls { display:grid; grid-template-columns:minmax(0,1fr) auto; width:100%; }
  .browse-controls label { font-size:12px; min-width:0; }
  .browse-controls label:first-child { grid-column:1; }
  .browse-controls .page-size-control { grid-column:2; grid-row:1; }
  #browse-language-label { grid-column:1/-1; }
  .browse-controls select { width:100%; }
  .grid,#results.grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:26px 16px; }
  .card { padding:0; border-radius:10px; }
  .cover,#results .cover { border-radius:10px; }
  .card-category { font-size:9px; margin:12px 0 5px; letter-spacing:.4px; }
  .card h3,#results .card h3 { font-size:14px; min-height:41px; line-height:1.45; }
  .card-meta { gap:6px; }
  .card-meta>button,.card-meta>button:first-of-type { min-height:44px; font-size:11px; padding:8px 5px; white-space:normal; }
  .card-meta>span { font-size:10px; }
  .cover-quick-look { width:44px; min-width:44px; min-height:44px; padding:0; font-size:0; opacity:1; transform:none; pointer-events:auto; background:#fffef9f0; color:#244e3e; }
  .cover-quick-look::after { content:'↗'; font-size:22px; line-height:1; }
  .check { top:7px; left:7px; width:44px; height:44px; }
  .availability-badge.available { bottom:8px; left:8px; font-size:10px; padding:6px 8px; }
  .selection-hint { display:none; }
  .desktop-hint { display:none; } .touch-hint { display:inline; }
  .selection-bar { bottom:calc(var(--nav-bottom) + 12px); padding:10px 12px; gap:6px; border-radius:12px; }
  .selection-bar>span { margin-right:auto; }
  .selection-bar .primary { flex:1 1 100%; }
  .selection-bar .subtle { padding:8px 9px; }
  .library-controls { gap:10px; padding:12px; }
  .library-controls>input { min-width:0; flex-basis:100%; }
  .library-controls>select { flex:1 1 auto; min-width:0; }
  .library-controls>button { flex:1 1 auto; font-size:12px; }
  .library-controls label { font-size:12px; }
  .download-summary { padding:16px; align-items:start; }
  .download-tabs { width:100%; gap:3px; overflow-x:auto; }
  .download-tabs button { flex:1 0 auto; padding:10px; font-size:12px; }
  .download-row { padding:16px; grid-template-columns:36px minmax(0,1fr); gap:12px; }
  .download-icon { width:36px; height:36px; }
  .download-row h3 { font-size:14px; }
  .download-row-actions { grid-column:2; flex-direction:row; flex-wrap:wrap; min-width:0; }
  .download-row-actions button { flex:1; }
  .settings-grid { grid-template-columns:1fr; }
  .settings-card { padding:22px; }
  dialog,#series-details,#preview-dialog { width:100%; max-width:100%; max-height:100dvh; height:100dvh; margin:0; border:0; border-radius:0; }
  .dialog-heading { padding:calc(14px + env(safe-area-inset-top,0px)) max(18px,env(safe-area-inset-right,0px)) 14px max(18px,env(safe-area-inset-left,0px)); }
  .dialog-heading h2 { font-size:21px; }
  .dialog-body { padding:18px; flex:1; min-height:0; }
  .chapter-controls { padding:12px; gap:10px; }
  .chapter-controls label { min-width:calc(50% - 10px); }
  .chapter-filters>summary span { display:none; }
  .chapter-row { flex-wrap:nowrap; gap:10px; padding:12px 6px; }
  .chapter-row strong { font-size:13px; }
  .chapter-row small { font-size:11px; }
  .chapter-row>.chapter-source { flex:0 0 auto; max-width:105px; display:grid; }
  .chapter-source button { padding:8px; font-size:11px; }
  .chapter-actions,#details-actions { padding:12px 18px calc(12px + env(safe-area-inset-bottom,0px)); gap:6px; }
  .chapter-actions>.primary { flex-basis:100%; }
  .chapter-actions>.secondary,.chapter-actions>.subtle { flex:1; font-size:12px; padding-inline:9px; }
  .details-cover { width:130px; margin:0 18px 16px 0; }
  .details-facts { grid-template-columns:90px minmax(0,1fr); gap:12px; font-size:12px; }
  .flat-heading { grid-template-columns:40px minmax(0,1fr); }
  .flat-heading .cover { width:40px; height:60px; }
  .flat-heading-actions { grid-column:1/-1; }
  .flat-series .card.flat-chapter { grid-template-columns:20px minmax(0,1fr) auto; gap:7px; padding:7px 2px; }
  .flat-chapter-text>strong { font-size:12px; }
  .flat-series .flat-chapter>button { font-size:11px; padding-inline:8px; }
  #preview-dialog>.dialog-heading { padding:calc(10px + env(safe-area-inset-top,0px)) 14px 10px; }
  #preview-dialog>.dialog-body { grid-template-rows:auto auto minmax(0,1fr); padding:8px 8px max(8px,env(safe-area-inset-bottom,0px)); gap:6px; }
  #preview-dialog .preview-help { display:none; }
  .preview-controls { padding:6px; gap:6px; }
  .preview-controls button { min-height:44px; padding:8px 9px; font-size:12px; }
  #preview-page-label { order:0; flex-basis:auto; min-width:56px; font-size:11px; }
  #preview-download { flex:1 1 100%; }
  #help-dialog { width:100%; max-width:100%; }
  #toast { bottom:calc(var(--nav-bottom) + 14px); right:16px; }
  .login-page { padding-bottom:0; }
  .login-page .login-shell { padding:calc(28px + env(safe-area-inset-top,0px)) 20px calc(28px + env(safe-area-inset-bottom,0px)); gap:24px; }
  .login-page .brand { display:flex; }
  .login-card { padding:30px; }
  .login-card h1 { font-size:34px; }
}
/* Wider phone windows and portrait foldables use three covers, not giant cards. */
@media(min-width:600px) and (max-width:760px) { .grid,#results.grid { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media(max-width:380px) {
  :root { --page-pad:14px; }
  .discovery-workspace { grid-template-columns:1fr auto; gap:10px 5px; }
  .source-switch button,.discovery-workspace>.source-switch button { padding-inline:10px; }
  .manga-source-options select { width:132px; }
  .grid,#results.grid { gap:22px 12px; }
  .card h3,#results .card h3 { font-size:13px; }
  .cover-quick-look { top:7px; right:7px; }
  .results-toolbar h2 { font-size:17px; }
  .display-options>summary { padding-inline:9px; font-size:11px; }
  .display-options>summary .icon { display:none; }
  .shared-genre-list { grid-template-columns:1fr; }
  .login-card { padding:24px; }
}
/* Landscape phones and keyboards: keep dialogs usable without fixed-height waste. */
@media(max-height:520px) {
  .login-page .login-shell { justify-content:flex-start; padding-block:20px; }
  .login-page .login-caption { display:none; }
  .dialog-heading,#preview-dialog>.dialog-heading { padding-block:8px; }
  .dialog-heading h2 { font-size:18px; }
  .chapter-actions,#details-actions { padding-block:8px; }
  #preview-dialog .preview-help { display:none; }
  #preview-dialog>.dialog-body { grid-template-rows:auto auto minmax(0,1fr); padding:6px; }
  #preview-download { flex:0 1 auto; }
}
@media(min-width:560px) and (max-width:760px) and (max-height:520px) {
  :root { --rail:calc(64px + env(safe-area-inset-left,0px)); --page-pad:16px; --nav-bottom:0px; }
  body { padding-bottom:0; }
  main { margin-left:var(--rail); padding-left:16px; }
  main>header { height:44px; padding-top:0; }
  .page-heading,#discover .page-heading { padding-block:12px; }
  h1,#discover .page-heading h1 { font-size:26px; }
  .sidebar { width:var(--rail); height:100dvh; background:#173d37; }
  .sidebar nav { inset:0 auto 0 0; width:var(--rail); min-height:100dvh; grid-template-columns:1fr; align-content:center; gap:6px; padding:8px 8px 8px max(8px,env(safe-area-inset-left,0px)); background:#173d37; border-top:0; border-right:1px solid #ffffff12; }
  .nav { min-height:44px; color:#c3d4c2; }
  .nav-label { display:none; }
  .nav.active { background:#e6eddd; color:#234c36; }
  .catalog-toolbar { margin-top:16px; }
}
@media(hover:none),(pointer:coarse) {
  .primary,.secondary,.subtle,.feed-chip,.genre-chip,.filter-chip,.quick-search button,.suggestion-link { min-height:44px; }
  .cover-quick-look { opacity:1; transform:none; pointer-events:auto; min-height:44px; }
  .desktop-hint { display:none; } .touch-hint { display:inline; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { transition:none !important; animation:none !important; scroll-behavior:auto !important; } }
