:root {
  --ink: #1f2328;
  --muted: #68717d;
  --line: #d8dee8;
  --panel: #ffffff;
  --card: #ffffff;
  --soft: #f2f5f8;
  --wash: #e9eef3;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-contrast: #ffffff;
  --pill-bg: #d8f1ed;
  --gold: #c98b25;
  --berry: #9f3a5b;
  --blue: #4267ac;
  --shadow: 0 18px 50px rgba(31, 35, 40, 0.12);
  --page-bg: linear-gradient(135deg, #eef3f7 0%, #fafafa 55%, #e7edf1 100%);
  --page-bg-size: auto;
  --sidebar-bg: rgba(255, 255, 255, 0.78);
  --tab-bg: rgba(255, 255, 255, 0.68);
  --panel-bg: #ffffff;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --toast-bg: #1f2328;
}

body[data-theme="deepwater"] {
  --ink: #edf2f7;
  --muted: #aab5c3;
  --line: #313947;
  --panel: #151b24;
  --card: #1b2330;
  --soft: #202a36;
  --wash: #2d3745;
  --accent: #5dd6c7;
  --accent-dark: #37b6a7;
  --accent-contrast: #081314;
  --pill-bg: #123b3a;
  --gold: #e3b357;
  --berry: #d85f8a;
  --blue: #81a7ff;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  --page-bg: linear-gradient(135deg, #0f141b 0%, #171f29 54%, #101720 100%);
  --page-bg-size: auto;
  --sidebar-bg: rgba(17, 23, 32, 0.88);
  --tab-bg: rgba(27, 35, 48, 0.88);
  --panel-bg: #151b24;
  --card-bg: #1b2330;
  --input-bg: #101720;
  --toast-bg: #edf2f7;
}

body[data-theme="dark"] {
  --ink: #f4ead3;
  --muted: #b9aa8c;
  --line: rgba(184, 134, 45, 0.34);
  --panel: #0b0a08;
  --card: #11100d;
  --soft: #19160f;
  --wash: #2b2416;
  --accent: #b8862d;
  --accent-dark: #d0a64a;
  --accent-contrast: #080704;
  --pill-bg: rgba(184, 134, 45, 0.18);
  --gold: #b8862d;
  --berry: #9c655a;
  --blue: #6f8c9f;
  --shadow: 0 26px 76px rgba(0, 0, 0, 0.68);
  --page-bg:
    radial-gradient(circle at 80% 8%, rgba(184, 134, 45, 0.16), transparent 28%),
    linear-gradient(135deg, #030303 0%, #0b0a08 46%, #151107 100%);
  --page-bg-size: auto;
  --sidebar-bg: rgba(8, 7, 5, 0.92);
  --tab-bg: rgba(25, 22, 15, 0.92);
  --panel-bg: rgba(11, 10, 8, 0.96);
  --card-bg: rgba(17, 16, 13, 0.96);
  --input-bg: #050504;
  --toast-bg: #f4ead3;
}

body[data-theme="night"] {
  --ink: #f2eefe;
  --muted: #c7bde7;
  --line: #3d315f;
  --panel: #1a1230;
  --card: #24183f;
  --soft: #2b1f49;
  --wash: #443466;
  --accent: #f0e7b6;
  --accent-dark: #d8c979;
  --accent-contrast: #1a1230;
  --pill-bg: #3a2a60;
  --gold: #f0c879;
  --berry: #d987c7;
  --blue: #9fa8ff;
  --shadow: 0 24px 70px rgba(8, 3, 22, 0.56);
  --page-bg:
    radial-gradient(circle at 76% 8%, rgba(240, 231, 182, 0.18), transparent 28%),
    linear-gradient(135deg, #10091f 0%, #1a1230 48%, #241640 100%);
  --page-bg-size: auto;
  --sidebar-bg: rgba(18, 10, 34, 0.9);
  --tab-bg: rgba(36, 24, 63, 0.9);
  --panel-bg: #1a1230;
  --card-bg: #24183f;
  --input-bg: #120a22;
  --toast-bg: #f2eefe;
}

body[data-theme="bookstore"] {
  --ink: #f7ecd8;
  --muted: #cdbb9e;
  --line: rgba(225, 184, 120, 0.28);
  --panel: #25170f;
  --card: #342013;
  --soft: #49301d;
  --wash: #6a482c;
  --accent: #d9ad67;
  --accent-dark: #b9823a;
  --accent-contrast: #24170f;
  --pill-bg: rgba(217, 173, 103, 0.18);
  --gold: #e0b75d;
  --berry: #c36f5c;
  --blue: #86a9b7;
  --shadow: 0 28px 70px rgba(20, 10, 4, 0.58);
  --page-bg:
    radial-gradient(ellipse at 22% 18%, rgba(255, 232, 178, 0.12), transparent 32%),
    repeating-radial-gradient(ellipse at 12% 38%, rgba(255, 221, 158, 0.05) 0 1px, transparent 2px 13px),
    repeating-linear-gradient(84deg, rgba(255, 218, 148, 0.055) 0 2px, rgba(80, 40, 16, 0.08) 3px 7px, transparent 8px 18px),
    linear-gradient(135deg, #1b0f08 0%, #342014 42%, #5a371d 100%);
  --page-bg-size: auto, 220px 150px, 160px 100%, auto;
  --sidebar-bg: rgba(37, 23, 15, 0.9);
  --tab-bg: rgba(61, 38, 22, 0.92);
  --panel-bg: rgba(37, 23, 15, 0.94);
  --card-bg: rgba(52, 32, 19, 0.95);
  --input-bg: rgba(25, 14, 8, 0.86);
  --toast-bg: #f7ecd8;
}

body[data-theme="vaporwave"] {
  --ink: #fff2ff;
  --muted: #d8bbff;
  --line: rgba(90, 238, 255, 0.32);
  --panel: #18082f;
  --card: #23104a;
  --soft: #35175f;
  --wash: #5b2c88;
  --accent: #ff71ce;
  --accent-dark: #05d9e8;
  --accent-contrast: #160425;
  --pill-bg: rgba(5, 217, 232, 0.16);
  --gold: #f9f871;
  --berry: #ff71ce;
  --blue: #05d9e8;
  --shadow: 0 26px 76px rgba(10, 2, 30, 0.66);
  --page-bg:
    linear-gradient(rgba(5, 217, 232, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 113, 206, 0.12) 1px, transparent 1px),
    radial-gradient(circle at 22% 10%, rgba(255, 113, 206, 0.42), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(5, 217, 232, 0.32), transparent 28%),
    linear-gradient(135deg, #12051f 0%, #25085b 50%, #061c3f 100%);
  --page-bg-size: 42px 42px, 42px 42px, auto, auto, auto;
  --sidebar-bg: rgba(20, 5, 42, 0.9);
  --tab-bg: rgba(35, 16, 74, 0.92);
  --panel-bg: rgba(24, 8, 47, 0.94);
  --card-bg: rgba(35, 16, 74, 0.94);
  --input-bg: rgba(14, 4, 33, 0.88);
  --toast-bg: #fff2ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page-bg);
  background-size: var(--page-bg-size);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.phone-preview {
  display: grid;
  place-items: center;
  height: 100dvh;
  overflow: hidden;
  padding: 12px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
  padding-bottom: 94px;
}

body.phone-preview .app-shell {
  position: relative;
  overflow: hidden;
  width: min(100%, 390px);
  height: calc(100dvh - 24px);
  min-height: 0;
  max-height: 844px;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  padding-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  scrollbar-width: none;
}

body.phone-preview .bottom-nav {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  width: auto;
  max-width: none;
  margin: 0;
  transform: none;
}

body.phone-preview .app-shell::-webkit-scrollbar {
  display: none;
}

body.phone-preview .sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 14px;
  padding: 14px;
}

body.phone-preview .storage-panel {
  display: none;
}

body.phone-preview .workspace {
  overflow: hidden auto;
  min-height: 0;
  padding: 18px 18px 112px;
  min-width: 0;
  scrollbar-width: none;
}

body.phone-preview .workspace::-webkit-scrollbar {
  display: none;
}

body.phone-preview .topbar,
body.phone-preview .section-heading,
body.phone-preview .audio-dock {
  align-items: stretch;
  flex-direction: column;
}

body.phone-preview .topbar-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

body.phone-preview.profile-active .topbar-actions {
  display: flex;
  justify-content: flex-end;
}

body.phone-preview.library-active .topbar {
  align-items: center;
  flex-direction: row;
}

body.phone-preview.library-active .topbar-actions {
  display: flex;
  justify-content: flex-end;
}

body.phone-preview.library-section .topbar,
body.phone-preview.visual-section .topbar {
  align-items: center;
  flex-direction: row;
}

body.phone-preview.library-section .topbar > div:first-child,
body.phone-preview.visual-section .topbar > div:first-child {
  min-width: 0;
}

body.phone-preview.library-section .topbar-actions,
body.phone-preview.visual-section .topbar-actions {
  flex: 0 0 auto;
}

body.phone-preview .search {
  grid-column: 1 / -1;
  min-width: 0;
}

body.phone-preview .theme-switcher {
  grid-column: 1 / -1;
}

body.phone-preview .theme-option {
  flex: 1;
}

body.phone-preview .content-layout {
  grid-template-columns: 1fr;
}

body.phone-preview .analytics-grid,
body.phone-preview .favourites-grid {
  grid-template-columns: 1fr;
}

body.phone-preview .profile-view,
body.phone-preview .settings-view,
body.phone-preview .profile-panel,
body.phone-preview .settings-panel,
body.phone-preview .metric-card,
body.phone-preview .profile-intro {
  min-width: 0;
}

body.phone-preview .profile-hero,
body.phone-preview .settings-row {
  grid-template-columns: 1fr;
}

body.phone-preview .profile-avatar {
  width: 86px;
  border-radius: 14px;
}

body.phone-preview .profile-intro h2 {
  font-size: 2.45rem;
}

body.phone-preview .rail {
  grid-auto-columns: 156px;
}

body.phone-preview .resume-rail {
  grid-auto-columns: minmax(246px, calc(100% - 10px));
}

body.phone-preview .collection-rail {
  grid-auto-columns: minmax(284px, calc(100% - 10px));
}

body.phone-preview .home-hero,
body.phone-preview .home-view,
body.phone-preview .home-rails,
body.phone-preview .rail-section,
body.phone-preview .rail,
body.phone-preview .title-card {
  min-width: 0;
}

body.phone-preview .detail-panel {
  position: static;
}

body.phone-preview.audio-section .detail-panel {
  gap: 12px;
}

body.phone-preview .title-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

body.phone-preview.audio-section .title-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.phone-preview .title-grid .title-card {
  gap: 6px;
  padding: 6px;
}

body.phone-preview .title-grid .title-card strong {
  min-height: 0;
  font-size: 0.76rem;
  line-height: 1.12;
}

body.phone-preview .title-grid .title-card small,
body.phone-preview .title-grid .mini-progress {
  display: none;
}

body.phone-preview .title-grid .cover span {
  max-width: 56px;
  font-size: 0.68rem;
}

body.phone-preview .title-grid .cover {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

body.phone-preview .title-grid .cover::after {
  right: 6px;
  bottom: 4px;
  font-size: 1.35rem;
}

body.phone-preview .reader-pages {
  grid-template-columns: 1fr;
}

body.phone-preview .reader-stage,
body.phone-preview .audio-dock {
  left: calc(50% - 179px);
  right: auto;
  bottom: 36px;
  width: 358px;
}

body.phone-preview .reader-pages {
  height: 54vh;
}

body.phone-preview .reader-page {
  min-height: 220px;
}

body.phone-preview .audio-progress {
  width: 100%;
  max-width: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(24px);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 8px;
  font-weight: 800;
  border: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  color: var(--ink);
  font-size: 1.04rem;
  font-weight: 580;
  letter-spacing: 0;
  line-height: 1.05;
}

.brand span {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 520;
  line-height: 1.15;
}

.mode-tabs,
.section-tabs,
.rail {
  scrollbar-width: none;
}

.mode-tabs::-webkit-scrollbar,
.section-tabs::-webkit-scrollbar,
.rail::-webkit-scrollbar {
  display: none;
}

.tab,
.section-tab,
.ghost-button,
.primary-button,
.icon-button,
.play-button {
  border: 0;
  border-radius: 8px;
}

.storage-panel {
  margin-top: auto;
  padding: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.storage-panel h2 {
  margin: 0 0 14px;
  font-size: 0.92rem;
}

.storage-meter,
.progress-track {
  overflow: hidden;
  height: 8px;
  background: var(--wash);
  border-radius: 999px;
}

.storage-meter span,
.progress-track span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.storage-stats,
.progress-label,
.audio-progress {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.workspace {
  position: relative;
  overflow: hidden;
  padding: 28px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(0px, env(safe-area-inset-bottom));
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: min(520px, calc(100vw - 32px));
  padding: 10px;
  background: color-mix(in srgb, var(--panel-bg) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.bottom-nav-item {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.bottom-nav-item > span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: inherit;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 1.08rem;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.bottom-nav-item small {
  max-width: 58px;
  overflow: hidden;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-item.active > span {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}

body.audio-open .workspace {
  padding-bottom: 170px;
}

body.reader-open .workspace {
  padding-bottom: 120px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 560;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.95;
}

.topbar-actions,
body.phone-preview .topbar-actions {
  display: none;
}

body.profile-active .topbar-actions {
  min-width: 0;
}

body.library-active .topbar-actions,
body.add-title-active .topbar-actions {
  min-width: 0;
}

body.profile-active .topbar {
  justify-content: flex-end;
  margin-bottom: 10px;
}

body.library-active .topbar {
  align-items: flex-start;
}

body.library-section .topbar,
body.visual-section .topbar {
  align-items: center;
  gap: 12px;
}

body.library-section .eyebrow,
body.visual-section .eyebrow,
body.books-section .eyebrow,
body.audio-section .eyebrow {
  display: none;
}

body.library-section h1,
body.visual-section h1,
body.books-section h1,
body.audio-section h1 {
  font-size: clamp(1.34rem, 2.4vw, 2.35rem);
  line-height: 1;
  white-space: nowrap;
}

body.library-section .topbar-actions,
body.phone-preview.library-section .topbar-actions,
body.visual-section .topbar-actions,
body.phone-preview.visual-section .topbar-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

body.profile-active .topbar > div:first-child {
  display: none;
}

body.add-title-active .topbar-actions,
.topbar-actions .hidden-control {
  display: none;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 220px;
  padding: 0 12px;
  height: 42px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search input::placeholder {
  color: var(--muted);
}

.theme-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.theme-option {
  min-width: 0;
  flex: 1 1 auto;
  height: 32px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 560;
  letter-spacing: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-option.active {
  color: var(--accent-contrast);
  background: var(--accent);
}

.primary-button {
  padding: 11px 16px;
  color: var(--accent-contrast);
  background: var(--accent);
  font-weight: 580;
  letter-spacing: 0;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  padding: 10px 14px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
}

.icon-button,
.play-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
}

.play-button {
  width: 54px;
  height: 54px;
  color: #fff;
  background: var(--berry);
  border: 0;
}

.mode-tabs,
.section-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
}

.topbar .section-tabs {
  padding-bottom: 0;
}

.topbar .mode-tabs {
  max-width: min(62vw, 332px);
  padding-bottom: 0;
}

.topbar .mode-tabs,
.topbar .section-tabs {
  min-width: 0;
}

body.phone-preview.library-section .topbar .mode-tabs {
  max-width: 226px;
}

.tab,
.section-tab {
  flex: 0 0 auto;
  padding: 9px 14px;
  color: var(--muted);
  background: var(--tab-bg);
  border: 1px solid var(--line);
}

.topbar .section-tab {
  min-height: 30px;
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 560;
}

.topbar .tab {
  min-height: 30px;
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 560;
}

.tab.active,
.section-tab.active {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}

.content-layout {
  display: grid;
  grid-template-columns: 344px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.home-view {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.profile-view,
.settings-view {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.home-hero,
.profile-hero,
.profile-panel,
.settings-panel,
.library-panel,
.detail-panel,
.reader-stage,
.audio-dock {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.library-panel {
  padding: 18px;
}

.home-hero {
  padding: 18px;
  min-width: 0;
}

.profile-hero {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 18px;
  text-align: center;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 112px;
  aspect-ratio: 1;
  color: var(--accent-contrast);
  background:
    radial-gradient(circle at 68% 22%, rgba(255, 255, 255, 0.34), transparent 24%),
    var(--accent);
  border-radius: 18px;
  font-size: 3rem;
  font-weight: 660;
}

.profile-intro h2 {
  margin: 10px 0 4px;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 0.95;
}

.profile-intro p {
  max-width: 720px;
  color: var(--muted);
}

.profile-intro .pill {
  margin-inline: auto;
  font-weight: 560;
  text-transform: none;
}

.profile-details {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-symbol {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  color: var(--accent);
  font-size: 1.05rem;
}

.ireland-flag {
  display: inline-block;
  width: 24px;
  height: 16px;
  background: linear-gradient(90deg, #169b62 0 33.33%, #ffffff 33.33% 66.66%, #ff883e 66.66%);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.intro-genres {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 14px;
}

.intro-genres span {
  padding: 7px 10px;
  color: var(--accent);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 560;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.profile-panel,
.settings-panel {
  padding: 16px;
}

.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card span,
.metric-card p,
.settings-row small,
.favourites-grid span {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--accent);
  font-size: 2rem;
  line-height: 1;
}

.year-bars {
  display: grid;
  gap: 12px;
}

.year-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 12px;
}

.bar-track {
  overflow: hidden;
  height: 12px;
  background: var(--wash);
  border-radius: 999px;
}

.bar-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--berry));
}

.genre-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.genre-cloud span {
  padding: 10px calc(12px + var(--genre-size) / 10);
  color: var(--accent-contrast);
  background: color-mix(in srgb, var(--accent) var(--genre-size), var(--soft));
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 580;
}

.profile-rail {
  grid-auto-columns: 150px;
}

.favourites-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.favourites-grid article {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-list,
.toggle-list {
  display: grid;
  gap: 12px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 280px);
  gap: 14px;
  align-items: center;
}

.settings-row span {
  display: grid;
  gap: 4px;
}

.settings-row input[type="email"],
.settings-row input[type="text"],
.settings-row select {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-row select {
  appearance: none;
}

.add-title-view {
  display: grid;
  gap: 16px;
}

.flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.add-actions {
  margin-top: 18px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: start center;
  padding: 24px;
  background: rgba(8, 3, 22, 0.64);
  backdrop-filter: blur(14px);
}

body.phone-preview .overlay {
  position: fixed;
  inset: auto;
  top: max(12px, calc((100dvh - 844px) / 2));
  left: 50%;
  width: min(calc(100vw - 24px), 390px);
  height: min(calc(100dvh - 24px), 844px);
  place-items: end center;
  padding: 12px;
  border-radius: 28px;
  overflow: hidden;
  transform: translateX(-50%);
}

.search-modal,
.utilities-menu {
  width: min(100%, 440px);
  margin-top: 72px;
  padding: 16px;
  color: var(--ink);
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

body.phone-preview .search-modal,
body.phone-preview .utilities-menu {
  width: 100%;
  max-height: calc(100% - 24px);
  margin-top: 0;
  overflow: hidden auto;
  border-radius: 18px;
}

.search-modal h2,
.utilities-menu h2 {
  margin: 14px 0;
}

.overlay-search {
  width: 100%;
  min-width: 0;
}

.search-modal p {
  margin: 12px 0 0;
  color: var(--muted);
}

.utility-list {
  display: grid;
  gap: 10px;
}

.utility-list button,
.utility-select {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 2px 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.utility-list button > span,
.utility-select > span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--accent);
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.utility-list strong,
.utility-list small,
.utility-select strong,
.utility-select small {
  min-width: 0;
}

.utility-list small,
.utility-select small {
  color: var(--muted);
}

.utility-select select {
  width: 100%;
  margin-top: 4px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.settings-theme {
  width: min(100%, 420px);
}

.settings-theme .theme-option {
  flex: 1 1 96px;
}

body.phone-preview .settings-theme .theme-option {
  flex-basis: calc(50% - 4px);
}

.toggle-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.home-rails {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.rail-section {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.rail-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.rail-heading h2 {
  margin-bottom: 0;
}

.rail-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.rail {
  display: grid;
  grid-auto-columns: 172px;
  grid-auto-flow: column;
  gap: 14px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 2px 2px 12px;
  scroll-snap-type: inline proximity;
  min-width: 0;
  max-width: 100%;
}

.resume-rail {
  grid-auto-columns: minmax(260px, 320px);
}

.rail .title-card {
  scroll-snap-align: start;
}

.resume-rail .title-card {
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
}

.resume-rail .cover {
  width: 92px;
}

.resume-rail .title-card strong {
  min-height: 0;
  font-size: 1.04rem;
}

.resume-copy {
  display: grid;
  gap: 6px;
}

.resume-copy small {
  margin-bottom: -2px;
}

.collection-rail {
  grid-auto-columns: minmax(310px, 380px);
}

.collection-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  color: var(--ink);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  scroll-snap-align: start;
}

.collection-cover {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 8px;
  color: var(--accent-contrast);
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.22), transparent 42%),
    var(--accent);
  border-radius: 8px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 680;
}

.collection-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.collection-copy h3,
.collection-copy p {
  margin: 0;
}

.collection-copy p,
.collection-copy li {
  color: var(--muted);
}

.collection-formats,
.collection-order {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.collection-formats span,
.order-toggle {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
}

.collection-formats span {
  color: var(--accent);
  background: var(--soft);
}

.order-toggle {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

.order-toggle.active {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}

.collection-copy ol {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
  font-size: 0.82rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin-bottom: 2px;
}

.section-heading p,
.detail-copy p,
.audio-dock p {
  color: var(--muted);
}

.title-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.title-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  color: var(--ink);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  min-width: 0;
}

.title-card.active,
.title-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.14);
}

.cover,
.detail-cover,
.reader-page {
  position: relative;
  overflow: hidden;
  background:
    var(--cover-image, none),
    linear-gradient(140deg, rgba(255, 255, 255, 0.18), transparent 38%),
    var(--cover-color, var(--accent));
  background-position: center;
  background-size: cover, auto, auto;
  border-radius: 6px;
}

.cover {
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  color: #fff;
  isolation: isolate;
}

.audio-cover {
  aspect-ratio: 1;
}

.real-cover::before,
.real-cover::after,
.real-cover span {
  display: none;
}

.cover::before,
.detail-cover::before,
.reader-page::before {
  content: "";
  position: absolute;
  inset: 14%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
}

.cover::after,
.detail-cover::after {
  content: attr(data-mark);
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 2.3rem;
  font-weight: 900;
}

.cover span {
  z-index: 1;
  max-width: 92px;
  font-size: 0.95rem;
  font-weight: 900;
  text-align: center;
  overflow-wrap: anywhere;
}

.title-card strong {
  min-height: 42px;
}

.title-card small {
  color: var(--muted);
}

.mini-progress {
  overflow: hidden;
  height: 5px;
  background: var(--wash);
  border-radius: 999px;
}

.mini-progress span {
  display: block;
  height: 100%;
  background: var(--gold);
}

.detail-panel {
  position: sticky;
  top: 28px;
  display: grid;
  gap: 16px;
  padding: 16px;
}

.continue-heading {
  margin-bottom: -2px;
}

.continue-heading p:empty {
  display: none;
}

.detail-cover {
  aspect-ratio: 16 / 10;
}

body.audio-section .detail-cover {
  aspect-ratio: 1;
}

body.visual-section .detail-cover {
  width: min(100%, 220px);
  aspect-ratio: 2 / 3;
  justify-self: center;
}

body.phone-preview.visual-section .detail-cover {
  width: min(62%, 188px);
}

body.audio-section .detail-copy {
  display: grid;
  gap: 6px;
}

body.visual-section .detail-copy {
  display: grid;
  gap: 6px;
}

body.audio-section .detail-copy h2 {
  margin: 4px 0 0;
}

body.visual-section .detail-copy h2 {
  margin: 2px 0 0;
}

body.audio-section .detail-copy p,
body.visual-section .detail-copy p {
  margin: 0;
}

body.audio-section .detail-actions #queueButton,
body.visual-section .detail-actions #queueButton {
  display: none;
}

body.audio-section .pill,
body.visual-section .pill {
  display: none;
}

.meta-stack {
  display: grid;
  gap: 3px;
}

.meta-stack span:first-child {
  color: var(--ink);
  font-weight: 620;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 9px;
  color: var(--accent-dark);
  background: var(--pill-bg);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 620;
  text-transform: uppercase;
}

.detail-copy h2 {
  margin: 10px 0 6px;
  font-size: 1.5rem;
}

.progress-label strong {
  color: var(--ink);
}

.detail-actions {
  display: flex;
  gap: 10px;
}

.detail-actions > * {
  flex: 1;
}

.reader-stage,
.audio-dock {
  position: fixed;
  z-index: 20;
  right: 28px;
  bottom: 28px;
}

.reader-stage {
  left: 300px;
  padding: 14px;
}

.reader-toolbar,
.audio-dock,
.audio-controls,
.reader-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reader-toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.reader-pages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  height: min(62vh, 560px);
}

.reader-page {
  min-height: 320px;
}

.reader-page::after {
  content: attr(data-page);
  position: absolute;
  left: 18px;
  bottom: 14px;
  color: rgba(255, 255, 255, 0.84);
  font-weight: 900;
}

.audio-dock {
  left: 300px;
  justify-content: space-between;
  padding: 18px;
}

.audio-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
}

.audio-progress {
  align-items: center;
  flex: 1;
  max-width: 460px;
  margin: 0;
}

.audio-progress .progress-track {
  flex: 1;
  min-width: 140px;
}

.hidden {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  max-width: calc(100vw - 40px);
  padding: 12px 16px;
  color: var(--panel-bg);
  background: var(--toast-bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .storage-panel {
    display: none;
  }

  .content-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

  .analytics-grid,
  .favourites-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reader-stage,
  .audio-dock {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .audio-dock {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    min-width: 0;
  }

  .search {
    min-width: 0;
  }

  .reader-pages {
    grid-template-columns: 1fr;
  }

  .profile-hero,
  .settings-row,
  .analytics-grid,
  .favourites-grid {
    grid-template-columns: 1fr;
  }

  .profile-avatar {
    width: 86px;
    border-radius: 14px;
  }

  .reader-pages {
    height: 54vh;
  }

  .reader-page {
    min-height: 220px;
  }

  .audio-progress {
    width: 100%;
    max-width: none;
  }
}

.topbar-actions {
  display: none;
}

/* The app runs inside a real mobile viewport supplied by the preview shell. */
body.phone-preview { display: block; padding: 0; background: var(--panel-bg); }
body.phone-preview .app-shell { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; box-shadow: none; background: var(--panel-bg); }
body.phone-preview .sidebar { position: relative; width: 100%; border-right: 0; }
body.phone-preview .bottom-nav { bottom: 8px; }
body.phone-preview .overlay { inset: 0; width: 100%; height: 100dvh; border-radius: 0; transform: none; padding: 14px; }
body.phone-preview .reader-stage,
body.phone-preview .audio-dock { left: 12px; right: 12px; bottom: 92px; width: auto; max-height: calc(100dvh - 110px); overflow-y: auto; }
body.phone-preview .reader-pages { height: 42dvh; }
body.phone-preview .toast { bottom: 100px; max-width: calc(100% - 32px); }
#phonePreviewButton { display: none; }

/* Compact greeting replaces the former brand and duplicate Home heading. */
.brand .welcome-label { color: var(--muted); font-size: 12px; line-height: 1.5; }
.brand .welcome-name { font-size: 22px; line-height: 1.2; font-weight: 650; letter-spacing: -.5px; }
body.home-active .topbar { display: none; }
body.phone-preview.home-active .workspace { padding-top: 10px; }

.collection-cover.has-art { padding: 0; aspect-ratio: 2 / 3; align-self: start; overflow: hidden; background: var(--soft); }
.collection-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
body.phone-preview .rail { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--muted) transparent; cursor: grab; touch-action: pan-x pan-y; }
body.phone-preview .rail::-webkit-scrollbar { display: block; height: 4px; }
body.phone-preview .rail::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 4px; }
body.phone-preview .rail.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.rail:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Prevent the browser from carrying an old content anchor into another tab. */
body.phone-preview .workspace { overflow-anchor: none; scroll-behavior: auto; }
