/* Offline listening (Save for offline button, notes). Existing tokens only. */
.offline-save { display: flex; flex-direction: column; gap: 0.35rem; }
.offline-save[hidden] { display: none; }
.offline-save-button { min-height: var(--tap); }
.offline-save-button[aria-pressed="true"] { border-color: var(--accent); }
.offline-note { margin: 0; color: var(--muted); font-size: var(--text-small); }
.offline-note:empty { display: none; }

/* The Offline page. */
.offline-root { display: flex; flex-direction: column; gap: 1rem; padding-bottom: calc(var(--dock-h) + 5rem); }
.offline-meter { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 1rem; }
.offline-meter-text { margin: 0 0 0.6rem; font-weight: 700; }
.offline-bar { display: block; width: 100%; height: 8px; border: 0; border-radius: 8px; background: var(--raised); overflow: hidden; appearance: none; }
.offline-bar::-webkit-progress-bar { background: var(--raised); border-radius: 8px; }
.offline-bar::-webkit-progress-value { background: var(--accent); border-radius: 8px; }
.offline-bar::-moz-progress-bar { background: var(--accent); border-radius: 8px; }

.offline-job { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.offline-job[hidden], .offline-selection[hidden] { display: none; }
.offline-job p { margin: 0; }
.offline-failures { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: var(--text-small); }

.offline-lists { display: flex; flex-direction: column; gap: 1rem; }
.offline-row { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.offline-world { border-left: 6px solid var(--tile, var(--accent)); }
.offline-world-icon { flex: 0 0 auto; display: grid; place-items: center; width: 56px; height: 40px; border-radius: var(--radius-sm); background: var(--tile, var(--accent)); color: var(--tile-ink, var(--accent-ink)); }
.offline-world-icon svg { width: 40px; height: 28px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.offline-world-icon:empty { display: none; }
.offline-row-text, .offline-world-toggle { flex: 1 1 10rem; min-width: 0; }
.offline-row-title { margin: 0; font-family: var(--font-display); font-size: 1.35rem; font-weight: 500; }
.offline-row-detail { display: block; margin: 0.15rem 0 0; color: var(--muted); font-size: var(--text-small); }
.offline-row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.offline-row-actions .btn, .offline-job .btn, .offline-selection .btn { min-height: var(--tap); }
.offline-world-toggle { display: flex; flex-direction: column; align-items: flex-start; min-height: var(--tap); padding: 0; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.offline-world-toggle[aria-expanded="true"] .offline-row-title::after { content: " \25BE"; }
.offline-world-toggle[aria-expanded="false"] .offline-row-title::after { content: " \25B8"; }

.offline-stories { flex: 1 1 100%; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.offline-story { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 0.75rem; min-height: var(--tap); padding: 0.4rem 0; border-top: 1px solid var(--line-soft); }
.offline-story input[type="checkbox"] { width: var(--tap); height: var(--tap); margin: 0; accent-color: var(--accent); }
.offline-story-title { overflow-wrap: anywhere; }
.offline-story-size, .offline-story-state { color: var(--muted); font-size: var(--text-small); white-space: nowrap; }
.offline-story-state { grid-column: 2 / 4; }
.offline-story .btn { padding-inline: 0.75rem; }

.offline-selection { position: sticky; bottom: calc(var(--dock-h) + 0.75rem); display: flex; gap: 0.5rem; align-items: center; justify-content: space-between; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; box-shadow: 0 6px 24px rgb(0 0 0 / 0.45); }

/* Library: Saved badge, and rows that are not saved while the tablet is offline.
   No opacity on text (it would drop below 4.5:1): the cue is muted text (--muted
   passes on every surface), a dimmed cover, a plain "Not saved" label and a quiet
   Play button. The tap itself is answered by the .offline-toast notice. */
.badge-saved, .badge-unsaved { display: none; margin-left: 0.5rem; padding: 0 0.55rem; min-height: 1.4rem; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 700; }
.badge-saved { color: var(--text); }
.badge-unsaved { color: var(--muted); }
.row[data-offline="saved"] .badge-saved { display: inline-flex; }
.row[data-offline="unavailable"] .badge-unsaved { display: inline-flex; }
.row[data-offline="unavailable"] .row-title, .row[data-offline="unavailable"] .row-meta { color: var(--muted); }
.row[data-offline="unavailable"] .cover { opacity: 0.45; }
.row[data-offline="unavailable"] .btn-primary { background: var(--raised); color: var(--muted); border-color: var(--line); }
.offline-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h) + 1rem); z-index: 20; margin: 0; max-width: calc(100vw - 2rem); padding: 0.7rem 1.1rem; background: var(--raised); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-pill); font-weight: 700; }
.offline-toast:empty { opacity: 0; padding: 0; border: 0; pointer-events: none; } /* stays rendered so the live region announces its text */
body.has-mini-player .offline-toast { bottom: calc(var(--dock-h) + var(--dock-mini-h) + 1rem); }
.saved-empty { margin: 1rem 0; color: var(--text); }
.saved-empty a { color: var(--accent); }
.saved-empty[hidden] { display: none; }
