:root {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #182536;
    background: #f3f6fa;
    color-scheme: light;
    --navy: #142339;
    --navy-light: #1c344f;
    --blue: #1479ea;
    --line: #dce3ed;
    --cover-radius: 9px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; overflow: hidden; }
body { height: 100vh; height: 100dvh; margin: 0; display: flex; flex-direction: column; overflow: hidden; }
button, input, select { font: inherit; }
button { min-height: 44px; padding: 8px 12px; color: var(--navy); background: white; border: 1px solid #b8c6d6; border-radius: 8px; cursor: pointer; }
button:hover { background: #e9f3ff; }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
    outline: 3px solid #53a5ff;
    outline-offset: 3px;
}
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.topbar { background: var(--navy); color: white; border-bottom: 3px solid #0e67ce; }
.topbar-inner {
    min-height: 70px; padding: 10px 20px;
    display: flex; align-items: center; gap: clamp(18px, 3vw, 48px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 212px; padding: 0; color: white; background: transparent; border: 0; font: inherit; font-size: 1.35rem; font-weight: 750; letter-spacing: -.035em; white-space: nowrap; cursor: pointer; }
.brand:hover { color: white; background: transparent; }
.brand-mark { width: 38px; height: 38px; color: white; }
.top-search {
    width: min(410px, 45vw); min-width: 220px; height: 42px; margin: 0;
    display: flex; align-items: center; gap: 8px; padding: 0 14px;
    background: #314158; border: 1px solid #41536b; border-radius: 999px;
    color: #d7e5f6;
}
.top-search > span[aria-hidden] { font-size: 1.5rem; line-height: 1; }
.top-search input[type="search"] { width: 100%; min-height: 0; height: 38px; margin: 0; padding: 0; color: white; background: transparent; border: 0; border-radius: 0; outline: 0; }
.top-search input::placeholder { color: #d0d9e5; }
.top-search:focus-within { outline: 2px solid #68b0ff; }
.top-stats { display: flex; align-items: center; gap: 14px; margin-left: auto; color: #dce9f8; font-size: .82rem; white-space: nowrap; }
.top-stats span + span { padding-left: 14px; border-left: 1px solid #526781; }
.top-user { position: relative; min-width: 0; color: #dce9f8; font-size: .82rem; white-space: nowrap; }
.top-user strong { color: white; }
.top-user > button { display: flex; align-items: center; gap: 5px; max-width: 230px; min-height: 44px; padding: 8px 10px; color: #dce9f8; background: transparent; border: 1px solid transparent; }
.top-user > button:hover, .top-user > button[aria-expanded="true"] { background: #29405c; border-color: #64758b; }
.top-user > button strong { overflow: hidden; text-overflow: ellipsis; }
.account-arrow { width: 0; height: 0; margin-left: 6px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid currentColor; }
.top-user > button[aria-expanded="true"] .account-arrow { transform: rotate(180deg); }
.account-menu { position: absolute; z-index: 20; top: calc(100% + 5px); right: 0; width: 240px; padding: 8px; color: var(--navy); background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 28px #0004; white-space: normal; }
.account-menu button { width: 100%; text-align: left; }
.account-menu label { margin: 10px 4px 2px; }
.account-menu select { margin-top: 5px; }
#sleepTimerStatus { display: block; margin: 5px 4px; color: #526478; }
#sleepTimerStatus:empty { display: none; }
.menu-toggle { margin-left: auto; padding: 8px 14px; min-height: 44px; color: white; background: transparent; border: 1px solid #64758b; border-radius: 9px; }
.menu-toggle:hover { background: #29405c; }
.menu-toggle { display: none; font-size: 1.25rem; }

main { width: 100%; min-height: 0; flex: 1 1 auto; padding: 0; overflow: hidden; }
main:has(#login:not([hidden])) { overflow-y: auto; }
#login {
    width: min(100%, 430px); margin: min(9vh, 96px) auto 0; padding: 36px;
    background: white; border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 18px 50px #14233910;
}
.login-emblem { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 14px; background: #e3f1ff; color: #005cb9; font-size: 2rem; }
#login h1 { margin: 22px 0 5px; font-size: 1.65rem; letter-spacing: -.025em; }
#login p { margin: 0 0 28px; color: #5b6b7e; }
label { display: block; margin: 12px 0; font-weight: 600; }
input:not([type="range"]), select {
    width: 100%; min-height: 44px; margin-top: 6px; padding: 9px 12px;
    color: #182536; background: white; border: 1px solid #aab8c9; border-radius: 9px;
}
.primary-button {
    min-height: 44px; padding: 10px 18px; color: white; background: #096aca;
    border: 1px solid #096aca; border-radius: 9px; font-weight: 700;
}
.primary-button:hover { background: #005ab4; }
#login .primary-button { width: 100%; margin-top: 16px; }

#app { height: 100%; min-height: 0; display: grid; grid-template-columns: 218px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 0; align-items: stretch; }
#primaryNav {
    grid-column: 1; grid-row: 1;
    display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
    padding: 16px 10px; background: var(--navy); color: white;
    border-radius: 0; box-shadow: none;
}
.nav-caption { margin: 12px 14px 7px; color: #8da8c5; font-size: .7rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
#primaryNav button.admin-caption { border-top: 1px solid #40536b; margin-top: 25px; padding-top: 22px; border-radius: 0; }
#primaryNav button {
    display: flex; align-items: center; gap: 13px; width: 100%; min-height: 48px;
    padding: 9px 14px; text-align: left; color: #eff5fc; background: transparent;
    border: 0; border-radius: 8px; font-weight: 550;
}
#primaryNav button:hover { background: #2b4767; }
#primaryNav button[aria-current="page"] { background: #096aca; color: white; font-weight: 700; }
#connectionProbeToggle { display: none !important; }
.nav-icon { width: 22px; flex: 0 0 22px; text-align: center; font-size: 1.35rem; line-height: 1; font-weight: 400; }
#libraryContent, #adminPanel { grid-column: 2; grid-row: 1; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#libraryContent > :not(#welcome) { margin-left: 26px; margin-right: 26px; }
#libraryContent #breadcrumbs { margin-top: 24px; }
#adminPanel { margin: 24px 26px; }

.welcome-banner {
    min-height: 270px; margin-bottom: 0; padding: clamp(22px, 3vw, 38px);
    display: grid; grid-template-columns: minmax(135px, 210px) minmax(0, 1fr);
    align-items: center; gap: clamp(20px, 4vw, 50px);
    position: relative; isolation: isolate;
    background: #223953; color: white; border-radius: 0; overflow: hidden;
    box-shadow: none;
}
.welcome-backdrop { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.welcome-backdrop img {
    display: block; width: 100%; height: 100%; object-fit: cover;
    transform: scale(1.16); filter: blur(22px) brightness(.78) saturate(.95);
}
.welcome-banner::before {
    content: ""; position: absolute; inset: 0; z-index: 1;
    background: linear-gradient(90deg, #14233933 0%, #14233982 54%, #142339aa 100%);
    pointer-events: none;
}
.welcome-art, .welcome-copy { position: relative; z-index: 2; }
.welcome-art {
    width: 100%; aspect-ratio: 1; max-height: 210px; display: grid; place-items: center;
    border: 1px solid #7aa6d0; border-radius: 10px; background: #dbeaf5;
    box-shadow: 0 12px 20px #0004; color: #1766a8;
}
.welcome-art span { width: 62%; aspect-ratio: .8; display: grid; place-items: center; background: #fff; border: 7px solid #b5d5ed; border-radius: 3px 11px 11px 3px; box-shadow: 10px 8px 0 #8db6d7; font-size: 3.3rem; }
.welcome-art.has-image { border: 0; background: transparent; box-shadow: none; }
.welcome-art img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--cover-radius); }
.welcome-art #welcomeEmptyArt { width: 86%; max-height: 86%; }
.welcome-art img[hidden], .welcome-art span[hidden] { display: none; }
.eyebrow { font-size: .75rem; letter-spacing: .17em; font-weight: 800; color: #a9d5ff; }
.welcome-copy h1 { max-width: 18ch; margin: 12px 0; font-size: clamp(1.55rem, 3vw, 2.65rem); letter-spacing: -.035em; line-height: 1.15; }
.welcome-copy p { max-width: 54ch; margin: 0 0 22px; color: #dfebf6; line-height: 1.55; }

.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-height: 35px; margin: 0 0 5px; color: #64758b; font-size: .9rem; }
.breadcrumbs button { min-height: 40px; padding: 6px 8px; color: #0f64bc; background: transparent; border: 0; border-radius: 6px; }
.breadcrumbs button:hover { background: #e4f0fc; }
.breadcrumbs [aria-current="page"] { font-weight: 700; color: var(--navy); overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 17px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 6px 0 14px; font-size: 1.5rem; letter-spacing: -.025em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(174px, 1fr)); gap: 17px; }
.cards.is-author-grouped { display: block; }
.author-series + .author-series { margin-top: 30px; }
.author-series h3 { margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); color: var(--navy); font-size: 1.13rem; }
.card {
    display: flex; flex-direction: column; align-items: stretch; min-width: 0; min-height: 220px;
    margin: 0; padding: 0; text-align: left; color: var(--navy); background: white;
    border: 1px solid var(--line); border-radius: 11px; overflow: hidden;
    box-shadow: 0 3px 10px #1423390b;
}
.card:hover { border-color: #79b7f6; box-shadow: 0 10px 20px #14233918; transform: translateY(-2px); }
.book-card-shell { position: relative; min-width: 0; }
.book-card-shell > .card { width: 100%; height: 100%; }
.card-favorite {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    width: 40px; height: 40px; min-height: 40px; padding: 0;
    border: 1px solid #b8c6d6; border-radius: 50%;
    color: #17324f; background: #fff; box-shadow: 0 2px 8px #14233955;
    font-size: 1.65rem; line-height: 1;
}
.card-favorite[aria-pressed="true"] { color: #cc315a; border-color: #cc315a; }
.card-favorite:hover { background: #fff0f4; }
.card-completed-corner {
    position: absolute; top: 8px; left: 8px; z-index: 2;
    display: grid; place-items: center; width: 36px; height: 36px;
    border: 1px solid #a8d8bb; border-radius: 50%;
    color: #176844; background: white; box-shadow: 0 2px 8px #14233933;
    font-size: 1.55rem; font-weight: 800; line-height: 1;
    pointer-events: none;
}
.card-completed { display: block; margin: auto 12px 12px; color: #176844; font-size: .8rem; font-weight: 750; }
.card.is-selected { border-color: #1976d2; background: #eaf4ff; box-shadow: 0 0 0 2px #1976d255; }
.selected-book-label { display: block; margin: 0 12px 12px; color: #105aa7; font-size: .78rem; font-weight: 750; }
.card-cover { flex: 0 0 auto; height: 155px; display: grid; place-items: center; overflow: hidden; background: #dceafa; color: #125a9c; }
.card-cover::before { content: ""; width: 68px; height: 86px; border: 5px solid currentColor; border-radius: 3px 11px 11px 3px; box-shadow: 8px 5px 0 #a6c9e9; }
.card-cover.has-image { background: transparent; }
.card-cover.has-image::before { display: none; }
.card-cover img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--cover-radius); }
.folder-card .card-cover { height: 110px; background: #e7f1fa; color: #166eb8; }
.folder-card .card-cover::before { width: 84px; height: 60px; border-radius: 5px; box-shadow: none; background: #c3dffc; }
.folder-card .card-cover.has-image img { object-fit: contain; }
.card-label { padding: 12px 13px 3px; font-weight: 750; line-height: 1.3; overflow-wrap: anywhere; }
.card-kind { padding: 0 13px 14px; color: #637489; font-size: .82rem; }
.empty-state { padding: 20px; background: white; border: 1px dashed #b8c8da; border-radius: 9px; color: #526478; }
.track-list { margin-top: 18px; }
.track {
    display: flex; align-items: center; gap: 9px; padding: 9px 12px;
    background: white; border: 1px solid var(--line); border-bottom: 0;
}
.track:first-child { border-radius: 10px 10px 0 0; }
.track:last-child { border-bottom: 1px solid var(--line); border-radius: 0 0 10px 10px; }
.track:only-child { border-radius: 10px; }
.track button { min-height: 44px; padding: 8px 11px; color: #17324f; background: #fff; border: 1px solid transparent; border-radius: 8px; }
.track button:hover { background: #eaf4ff; }
.track button:first-child { flex: 1; min-width: 0; text-align: left; font-weight: 650; overflow-wrap: anywhere; }
.track-duration { min-width: 52px; color: #607085; font-variant-numeric: tabular-nums; }
.track .chapter-action { display: flex; align-items: center; gap: 8px; }
.chapter-action > span:nth-child(2) { min-width: 0; }
.chapter-action-icon { flex: 0 0 16px; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; }
.chapter-action-icon.pause-icon { gap: 3px; }
.chapter-action-icon.pause-icon::before, .chapter-action-icon.pause-icon::after {
    content: ''; width: 4px; height: 15px; border-radius: 1px; background: currentColor;
}
.track.is-current { background: #2d4c6d; border-color: #517396; }
.track.is-current button { color: #f5f9ff; background: transparent; }
.track.is-current button:hover { background: #335776; }
.track.is-current .track-duration { color: #c7d9ee; }
.chapter-indicator { flex: 0 0 32px; width: 32px; height: 25px; display: block; overflow: hidden; }
.chapter-indicator[hidden] { display: block; visibility: hidden; }
.chapter-indicator img { display: block; width: 32px; height: 25px; object-fit: contain; }

#adminPanel { padding: 24px; background: white; border: 1px solid var(--line); border-radius: 12px; }
#adminPanel h2 { margin-top: 0; }
.user-form { padding: 18px; margin: 14px 0; border: 1px solid var(--line); border-radius: 10px; background: #f8fafd; }
.user-form h3 { margin-top: 0; }
.user-form p { max-width: 72ch; color: #53657b; }
.user-form input[type="checkbox"] { display: inline-block; width: 24px; min-height: 24px; vertical-align: middle; margin-left: 12px; }
.user-form label:has(input[type="checkbox"]) { min-height: 44px; }
.user-list-scroll { overflow-x: auto; margin: 18px 0 24px; }
.user-list-heading, #userList .user-row {
    min-width: 980px; display: grid;
    grid-template-columns: minmax(140px, 1fr) 160px 75px 150px 125px 174px 82px;
    align-items: center; gap: 10px;
}
.user-list-heading { padding: 0 12px 7px; color: #52657c; font-size: .78rem; font-weight: 700; }
#userList { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
#userList .user-row { margin: 0; padding: 8px 12px; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); background: white; }
#userList .user-row:nth-child(even) { background: #f8fafd; }
#userList .user-row:last-child { border-bottom: 0; }
#userList .user-row h3 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: .94rem; }
#userList .user-row label { min-width: 0; margin: 0; font-size: 0; }
#userList .user-row :is(input:not([type="checkbox"]), select) { min-height: 38px; margin: 0; padding: 6px 8px; font-size: .88rem; }
#userList .user-row input[type="checkbox"] { margin: 0 0 0 20px; }
#userList .user-row label:has(input[type="checkbox"]) { min-height: 38px; display: flex; align-items: center; }
#userList .user-row button { min-height: 38px; padding: 5px 8px; font-size: .8rem; line-height: 1.2; }
#userList .user-row .delete-user { color: #a3212a; border-color: #d9a9ae; }
#userList .user-row .delete-user:hover { background: #fff0f1; }
.upload-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cover-upload-preview { display: flex; flex-wrap: wrap; gap: 18px; margin: 12px 0; }
.cover-upload-preview figure { margin: 0; color: #53657b; font-size: .85rem; }
.cover-upload-preview img { display: block; width: 105px; height: 145px; margin-bottom: 5px; object-fit: contain; border-radius: var(--cover-radius); }
.cover-upload-preview img[hidden] { display: none; }
#coverBookSearch, #coverBookSelect, #coverImageFile { display: block; width: min(100%, 550px); margin: 5px 0 14px; }
#uploadProgress { display: block; width: 100%; height: 16px; margin-top: 16px; accent-color: var(--blue); }
#uploadStatus { min-height: 1.5em; }
#uploadReview { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto;
    border: 1px solid var(--line); border-radius: 12px; padding: 22px; color: var(--ink); }
#uploadReview::backdrop { background: #07152abb; }
#uploadReview h2 { margin-top: 0; }
.upload-review-grid { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 20px; }
#uploadReviewCover { width: 150px; max-height: 220px; object-fit: contain; border-radius: var(--cover-radius); }
#uploadReviewImage { display: block; width: min(100%, 500px); margin: 6px 0 4px; }
#uploadReviewImageHint { margin-top: 0; color: #53657b; font-size: .88rem; }
#uploadReviewFiles { max-height: 170px; overflow: auto; overflow-wrap: anywhere; }
#uploadReviewWarnings { color: #704600; }
@media(max-width: 560px) { .upload-review-grid { grid-template-columns: 1fr; } }

#player {
    position: relative; z-index: 8; flex: 0 0 auto; color: white;
    background: var(--navy); border-top: 2px solid #2c77c8; box-shadow: 0 -12px 30px #0c193b2b;
}
.player-main {
    padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: 48px minmax(120px, 1fr) auto minmax(150px, .9fr) 136px auto;
    align-items: center; gap: 14px;
}
.player-art { width: 48px; height: 48px; display: grid; place-items: center; color: #165a95; background: #dceafa; border-radius: 5px; font-size: 1.8rem; }
.player-art.has-image { overflow: hidden; background: transparent; }
.player-art img { width: 100%; height: 100%; object-fit: contain; border-radius: 5px; }
.player-art img[hidden], .player-art span[hidden] { display: none; }
.player-meta { min-width: 0; }
#now { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#syncStatus { min-height: 1.2em; margin: 3px 0 0; color: #bbd0e7; font-size: .78rem; }
#syncStatus.error { color: #ffd191; font-weight: 650; }
.player-transport { display: flex; align-items: center; gap: 5px; }
.player-transport button { flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; padding: 0; display: grid; place-items: center; color: white; background: transparent; border: 0; border-radius: 50%; font-size: 1.6rem; line-height: 1; }
.player-transport button:hover { background: #334e6a; }
.player-transport .skip-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.skip-arrow { display: block; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.player-transport .skip-button small { display: block; font-size: .65rem; line-height: 1; font-weight: 750; }
.player-transport .play-button { flex-basis: 50px; width: 50px; height: 50px; min-height: 50px; background: var(--blue); font-size: 1.25rem; }
.player-transport .play-button:hover { background: #0064cb; }
.player-transport .play-button { position: relative; }
.play-button::before {
    content: ''; position: absolute; top: 50%; left: 50%;
    border-top: 10px solid transparent; border-bottom: 10px solid transparent;
    border-left: 16px solid currentColor; transform: translate(-40%, -50%);
}
.play-button.is-playing::before, .play-button.is-playing::after {
    content: ''; position: absolute; top: 50%; width: 4px; height: 18px;
    border: 0; border-radius: 1px; background: currentColor; transform: translateY(-50%);
}
.play-button.is-playing::before { left: calc(50% - 6px); }
.play-button.is-playing::after { left: calc(50% + 2px); }
.player-timeline { min-width: 0; display: flex; align-items: center; gap: 10px; }
#seekPosition { width: 100%; min-width: 0; margin: 0; accent-color: #258aff; cursor: pointer; }
#playerTime { flex: 0 0 auto; color: #cbd8e6; font-size: .78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.player-volume { display: flex; align-items: center; gap: 5px; min-width: 0; }
#volumeToggle { flex: 0 0 36px; width: 36px; height: 44px; min-height: 44px; padding: 8px; color: white; background: transparent; border: 0; }
#volumeToggle:hover { background: #334e6a; }
#volumeToggle svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#volumeToggle .volume-cross, #volumeToggle.is-muted .volume-waves { display: none; }
#volumeToggle.is-muted .volume-cross { display: block; }
#volumeLevel { width: 100%; min-width: 0; margin: 0; accent-color: #258aff; cursor: pointer; }
#playerDetails { position: relative; }
#playerDetails summary { min-height: 44px; padding: 11px 9px; color: white; cursor: pointer; white-space: nowrap; border-radius: 8px; list-style: none; }
#playerDetails summary::-webkit-details-marker { display: none; }
#playerDetails summary::before { content: "☷ "; font-size: 1.1rem; }
#playerDetails summary:hover { background: #334e6a; }
.player-detail {
    position: absolute; right: 0; bottom: calc(100% + 18px); width: min(650px, calc(100vw - 24px));
    max-height: 60vh; padding: 16px; overflow-y: auto; background: var(--navy-light);
    border: 1px solid #54718f; border-radius: 11px; box-shadow: 0 16px 35px #0006;
}
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.controls button, .controls select { min-height: 44px; padding: 8px 11px; color: white; background: #2d4b6b; border: 1px solid #587696; border-radius: 8px; }
.controls button:hover { background: #3b628b; }
.controls label { display: flex; align-items: center; gap: 7px; margin: 0; white-space: nowrap; }
.controls select { width: auto; margin: 0; }
audio { display: block; width: 100%; height: 44px; margin: 12px 0; }
#chapters { max-height: 190px; overflow-y: auto; padding-left: 27px; }
#chapters button { min-height: 40px; padding: 7px 10px; text-align: left; color: white; background: transparent; border: 0; border-radius: 6px; overflow-wrap: anywhere; }
#chapters button:hover, #chapters [aria-current="true"] { background: #335776; }
#chapters [aria-current="true"] { font-weight: 750; }
#notice { position: fixed; z-index: 15; top: 78px; right: 16px; max-width: min(370px, 90vw); padding: 12px 15px; color: white; background: var(--navy); border: 1px solid #667e98; border-radius: 9px; box-shadow: 0 10px 25px #0003; }
#notice:empty { display: none; }
.book-metadata {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 18px;
    margin: 0 0 20px; padding: 14px 18px; background: white;
    border: 1px solid #d9e3ef; border-radius: 10px;
}
.book-metadata p { margin: 0; overflow-wrap: anywhere; }
.book-detail-cover {
    display: block; flex: 0 0 150px; width: 150px; max-width: 35%; max-height: 220px;
    object-fit: contain; border-radius: var(--cover-radius);
}
#bookMetaSummary { flex: 1 1 240px; min-width: 0; }
#bookFavorite { flex: 0 0 auto; }
#bookFavorite[aria-pressed="true"] { color: #0d5ead; border-color: #71aaf0; background: #eaf4ff; font-weight: 700; }
#bookCompletion { align-self: center; color: #52657b; font-size: .88rem; font-weight: 650; }
#bookCompletion.is-completed { color: #176844; }
#bookMetaEditor { flex: 1 0 100%; min-width: 0; }
.book-metadata summary { min-height: 44px; padding: 10px 0; color: var(--blue); cursor: pointer; font-weight: 700; }
#bookMetaForm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#bookMetaForm label { display: grid; gap: 5px; }
#bookMetaForm input { width: 100%; min-height: 44px; padding: 8px; border: 1px solid #aebfd2; border-radius: 6px; }
#bookMetaForm button { min-height: 44px; }

@media (max-width: 1023px) {
    .topbar-inner { padding: 10px 18px; flex-wrap: wrap; gap: 8px 18px; }
    .top-stats { order: 4; flex-basis: 100%; margin-left: 0; }
    .top-user { margin-left: auto; }
    main { padding: 18px; }
    #app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 16px; }
    #primaryNav { grid-column: 1; grid-row: 1; min-height: 0; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 9px; border-radius: 12px; }
    #primaryNav button { width: auto; }
    .nav-caption { display: none; }
    #libraryContent, #adminPanel { grid-column: 1; grid-row: 2; }
    #libraryContent > :not(#welcome) { margin-left: 0; margin-right: 0; }
    #libraryContent #breadcrumbs { margin-top: 0; }
    #adminPanel { margin: 0; }
    .welcome-banner { margin-bottom: 26px; border-radius: 13px; box-shadow: 0 10px 25px #1423391a; }
    .player-main { padding-left: 18px; padding-right: 18px; grid-template-columns: 42px minmax(130px, 1fr) auto auto; }
    .player-volume { display: none; }
    .player-art { width: 42px; height: 42px; }
    .player-timeline { grid-column: 2 / 5; grid-row: 2; }
}
@media (max-width: 599px) {
    html { height: 100%; overflow: hidden; }
    #bookMetaForm { grid-template-columns: 1fr; }
    body {
        height: 100vh; height: 100dvh; padding-bottom: 0;
        display: flex; flex-direction: column; overflow: hidden;
    }
    .topbar { flex: 0 0 auto; }
    .topbar-inner { min-height: 62px; padding: 9px 14px; gap: 8px; flex-wrap: wrap; }
    .brand { flex: 1; font-size: 1.12rem; }
    .brand-mark { width: 33px; height: 33px; }
    .top-user { order: 2; max-width: 155px; margin-left: 0; font-size: .72rem; }
    .top-user > button { max-width: 155px; padding: 6px; }
    .account-menu { right: 0; width: min(240px, calc(100vw - 28px)); font-size: .9rem; }
    .menu-toggle { display: block; margin-left: 0; padding: 6px 12px; }
    .top-search { order: 4; width: 100%; min-width: 0; }
    .top-stats { order: 5; flex-basis: 100%; justify-content: center; gap: 9px; font-size: .72rem; }
    .top-stats span + span { padding-left: 9px; }
    main { flex: 1 1 auto; min-height: 0; padding: 0 13px; overflow-y: auto; }
    #login { margin-top: 6vh; padding: 25px 20px; }
    #app {
        position: relative; height: 100%; min-height: 0;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr); gap: 0;
    }
    #primaryNav {
        position: static; grid-column: 1; grid-row: 1; width: 100%; height: auto; min-height: 0;
        display: flex; flex-wrap: nowrap; justify-content: space-around; gap: 0; padding: 3px 4px;
        background: var(--navy); border-radius: 0; box-shadow: none;
    }
    #primaryNav button { width: 25%; min-width: 0; min-height: 54px; flex-direction: column; justify-content: center; gap: 2px; padding: 2px; font-size: .67rem; text-align: center; }
    #primaryNav .nav-icon { font-size: 1.35rem; }
    #primaryNav > button:nth-of-type(n+5) { display: none; }
    #primaryNav.menu-open {
        position: absolute; z-index: 9; inset: 0; width: auto; height: auto;
        flex-direction: column; justify-content: flex-start;
        align-items: stretch; gap: 4px; padding: 18px 14px; overflow-y: auto;
    }
    #primaryNav.menu-open > button { display: flex; width: 100%; min-height: 48px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 9px 14px; font-size: 1rem; text-align: left; }
    #primaryNav.menu-open #connectionProbeToggle { display: flex !important; }
    #primaryNav.menu-open .nav-caption { display: block; }
    #libraryContent, #adminPanel {
        grid-column: 1; grid-row: 2; min-height: 0;
        overflow-y: auto; overscroll-behavior: contain;
    }
    #libraryContent { padding: 15px 0; }
    .welcome-banner { min-height: 0; grid-template-columns: 95px minmax(0, 1fr); gap: 13px; padding: 17px; margin-bottom: 20px; }
    .welcome-art { align-self: start; }
    .welcome-art span { font-size: 1.4rem; border-width: 4px; box-shadow: 5px 4px 0 #8db6d7; }
    .welcome-copy h1 { font-size: 1.12rem; margin: 7px 0; }
    .welcome-copy p { display: none; }
    .welcome-copy .primary-button { font-size: .8rem; padding: 7px 9px; }
    .eyebrow { font-size: .59rem; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .card { min-height: 190px; }
    .card-cover { height: 120px; }
    .card-label { padding: 10px 10px 3px; font-size: .91rem; }
    .card-kind { padding: 0 10px 10px; }
    .folder-card { grid-column: 1 / -1; min-height: 78px; flex-direction: row; align-items: center; }
    .folder-card-shell { grid-column: 1 / -1; }
    .folder-card .card-cover { width: 78px; height: 78px; flex: 0 0 78px; }
    .folder-card .card-cover::before { width: 42px; height: 32px; border-width: 3px; }
    .folder-card .card-label { flex: 1; }
    .folder-card .card-kind { display: none; }
    .track { flex-wrap: wrap; }
    .track button:first-child { flex-basis: calc(100% - 70px); }
    .track-duration { order: 2; }
    #adminPanel { padding: 16px; }
    #player {
        position: relative; bottom: auto; flex: 0 0 auto;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .player-main { padding: 8px 10px; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 7px; }
    .player-art { width: 40px; height: 40px; }
    #now { font-size: .85rem; }
    #syncStatus { font-size: .68rem; }
    .player-transport { display: grid; grid-template-columns: 32px 42px 32px; align-items: center; gap: 5px; }
    .player-transport button { flex: none; width: 32px; height: 42px; min-height: 42px; font-size: 1.2rem; }
    .player-transport .play-button { width: 42px; height: 42px; min-height: 42px; aspect-ratio: 1; font-size: 1rem; }
    .player-transport .skip-arrow { width: 18px; height: 18px; }
    .player-transport .skip-button small { font-size: .55rem; }
    #playerDetails summary { width: 34px; overflow: hidden; font-size: 0; }
    #playerDetails summary::before { content: "☷"; font-size: 1.35rem; }
    .player-timeline { grid-column: 1 / 5; grid-row: 2; }
    .player-detail { right: -10px; bottom: calc(100% + 14px); }
    #notice { top: 115px; right: 9px; }
}
@media (max-width: 380px) {
    .welcome-banner { grid-template-columns: 76px minmax(0, 1fr); }
    .player-transport { grid-template-columns: 42px; }
    .player-transport #back, .player-transport #next { display: none; }
}
