/* 0. Color scheme tokens (warm antique-white / charcoal scale) */
:root {
  color-scheme: light dark;

  --bg: #f6efe1;
  --bg-elevated: #fffcf5;
  --bg-elevated-hover: #efe3cc;
  --bg-elevated-active: #e3d3ae;

  --text: #2b241c;
  --text-muted: #79694f;

  --border: #e1d1ac;
  --border-strong: #b8a074;

  --accent: #c2601f;
  --accent-hover: #a34f18;
  --accent-contrast: #fffcf5;
  --accent-contrast-emboss: rgba(0, 0, 0, 0.45);

  --danger: #b3261e;
  --shadow: rgba(43, 36, 28, 0.16);

  --photo-frame: #2e7d32;
  --post-frame: #7b1fa2;
  --video-frame: #1565c0;
  --chat-frame: #00796b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262320;
    --bg-elevated: #34302a;
    --bg-elevated-hover: #423c34;
    --bg-elevated-active: #504a40;

    --text: #f1e9d8;
    --text-muted: #bcac8c;

    --border: #4a4338;
    --border-strong: #6e6350;

    --accent: #e58a41;
    --accent-hover: #f2a15f;
    --accent-contrast: #211a10;
    --accent-contrast-emboss: rgba(255, 255, 255, 0.5);

    --danger: #f2867e;
    --shadow: rgba(0, 0, 0, 0.5);

    --photo-frame: #66bb6a;
    --video-frame: #64b5f6;
    --post-frame: #ce93d8;
    --chat-frame: #4db6ac;
  }
}

/* Explicit override via the theme toggle, regardless of OS preference */
:root[data-theme="dark"] {
  --bg: #262320;
  --bg-elevated: #34302a;
  --bg-elevated-hover: #423c34;
  --bg-elevated-active: #504a40;

  --text: #f1e9d8;
  --text-muted: #bcac8c;

  --border: #4a4338;
  --border-strong: #6e6350;

  --accent: #e58a41;
  --accent-hover: #f2a15f;
  --accent-contrast: #211a10;
  --accent-contrast-emboss: rgba(255, 255, 255, 0.5);

  --danger: #f2867e;
  --shadow: rgba(0, 0, 0, 0.5);

  --photo-frame: #66bb6a;
  --video-frame: #64b5f6;
  --post-frame: #ce93d8;
  --chat-frame: #4db6ac;
}


/* Skins (Settings > Appearance; data-skin on <html>, set by the head script and app.js).
   Each skin sets every colour above in light and dark; "barrow" is the default above.
   Keep in sync with backend/appearance.go (names, preview swatches). */
:root[data-skin="vinyl"] {
  --bg: #f3efe8;
  --bg-elevated: #fffdf9;
  --bg-elevated-hover: #ebe4d8;
  --bg-elevated-active: #ddd3c3;
  --text: #1d1b19;
  --text-muted: #665f56;
  --border: #ddd5c8;
  --border-strong: #a39a8b;
  --accent: #c8312b;
  --accent-hover: #a82620;
  --accent-contrast: #fffdf9;
  --danger: #9c1c1c;
  --shadow: rgba(29, 27, 25, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root[data-skin="vinyl"]:not([data-theme="light"]) {
    --bg: #141414;
    --bg-elevated: #1f1f1f;
    --bg-elevated-hover: #2a2a2a;
    --bg-elevated-active: #363636;
    --text: #f2ede4;
    --text-muted: #a9a196;
    --border: #333333;
    --border-strong: #555555;
    --accent: #ff5a4f;
    --accent-hover: #ff7a70;
    --accent-contrast: #1a0b0a;
    --danger: #ff8a80;
    --shadow: rgba(0, 0, 0, 0.6);
  }
}
:root[data-skin="vinyl"][data-theme="dark"] {
  --bg: #141414;
  --bg-elevated: #1f1f1f;
  --bg-elevated-hover: #2a2a2a;
  --bg-elevated-active: #363636;
  --text: #f2ede4;
  --text-muted: #a9a196;
  --border: #333333;
  --border-strong: #555555;
  --accent: #ff5a4f;
  --accent-hover: #ff7a70;
  --accent-contrast: #1a0b0a;
  --danger: #ff8a80;
  --shadow: rgba(0, 0, 0, 0.6);
}
:root[data-skin="seventies"] {
  --bg: #f4e6c4;
  --bg-elevated: #fdf5e0;
  --bg-elevated-hover: #ecd9ad;
  --bg-elevated-active: #e0c993;
  --text: #3a2614;
  --text-muted: #75583a;
  --border: #e0c993;
  --border-strong: #b08a55;
  --accent: #a65f00;
  --accent-hover: #8a4e00;
  --accent-contrast: #fff8e7;
  --danger: #a8321e;
  --shadow: rgba(58, 38, 20, 0.18);
}
@media (prefers-color-scheme: dark) {
  :root[data-skin="seventies"]:not([data-theme="light"]) {
    --bg: #2a1f14;
    --bg-elevated: #36291b;
    --bg-elevated-hover: #443423;
    --bg-elevated-active: #52402b;
    --text: #f6e7c8;
    --text-muted: #c9ad80;
    --border: #4d3b27;
    --border-strong: #7a5f3d;
    --accent: #f0a830;
    --accent-hover: #f6bd5a;
    --accent-contrast: #2a1a05;
    --danger: #f2867e;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}
:root[data-skin="seventies"][data-theme="dark"] {
  --bg: #2a1f14;
  --bg-elevated: #36291b;
  --bg-elevated-hover: #443423;
  --bg-elevated-active: #52402b;
  --text: #f6e7c8;
  --text-muted: #c9ad80;
  --border: #4d3b27;
  --border-strong: #7a5f3d;
  --accent: #f0a830;
  --accent-hover: #f6bd5a;
  --accent-contrast: #2a1a05;
  --danger: #f2867e;
  --shadow: rgba(0, 0, 0, 0.5);
}
:root[data-skin="moss"] {
  --bg: #eef1e6;
  --bg-elevated: #fafcf5;
  --bg-elevated-hover: #e1e7d3;
  --bg-elevated-active: #d2dbc0;
  --text: #1f2a1f;
  --text-muted: #5a6954;
  --border: #d3dbc3;
  --border-strong: #98a88a;
  --accent: #3f7d4e;
  --accent-hover: #326640;
  --accent-contrast: #fafcf5;
  --danger: #a8321e;
  --shadow: rgba(31, 42, 31, 0.15);
}
@media (prefers-color-scheme: dark) {
  :root[data-skin="moss"]:not([data-theme="light"]) {
    --bg: #1c221d;
    --bg-elevated: #263027;
    --bg-elevated-hover: #313d32;
    --bg-elevated-active: #3c4a3d;
    --text: #e6eee0;
    --text-muted: #a7b8a0;
    --border: #364237;
    --border-strong: #56685a;
    --accent: #7cc18c;
    --accent-hover: #97d2a5;
    --accent-contrast: #102014;
    --danger: #f2867e;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}
:root[data-skin="moss"][data-theme="dark"] {
  --bg: #1c221d;
  --bg-elevated: #263027;
  --bg-elevated-hover: #313d32;
  --bg-elevated-active: #3c4a3d;
  --text: #e6eee0;
  --text-muted: #a7b8a0;
  --border: #364237;
  --border-strong: #56685a;
  --accent: #7cc18c;
  --accent-hover: #97d2a5;
  --accent-contrast: #102014;
  --danger: #f2867e;
  --shadow: rgba(0, 0, 0, 0.5);
}
:root[data-skin="harbor"] {
  --bg: #eef2f5;
  --bg-elevated: #fbfcfd;
  --bg-elevated-hover: #e0e7ed;
  --bg-elevated-active: #cfdae3;
  --text: #1b2733;
  --text-muted: #566778;
  --border: #d3dde6;
  --border-strong: #94a6b6;
  --accent: #2b6cb0;
  --accent-hover: #22578f;
  --accent-contrast: #fbfcfd;
  --danger: #b3261e;
  --shadow: rgba(27, 39, 51, 0.15);
}
@media (prefers-color-scheme: dark) {
  :root[data-skin="harbor"]:not([data-theme="light"]) {
    --bg: #151b22;
    --bg-elevated: #1e262f;
    --bg-elevated-hover: #28323d;
    --bg-elevated-active: #333f4c;
    --text: #e4ebf2;
    --text-muted: #9fb0c0;
    --border: #2f3a46;
    --border-strong: #4d5d6e;
    --accent: #63a4ec;
    --accent-hover: #85b9f2;
    --accent-contrast: #0b1828;
    --danger: #f2867e;
    --shadow: rgba(0, 0, 0, 0.55);
  }
}
:root[data-skin="harbor"][data-theme="dark"] {
  --bg: #151b22;
  --bg-elevated: #1e262f;
  --bg-elevated-hover: #28323d;
  --bg-elevated-active: #333f4c;
  --text: #e4ebf2;
  --text-muted: #9fb0c0;
  --border: #2f3a46;
  --border-strong: #4d5d6e;
  --accent: #63a4ec;
  --accent-hover: #85b9f2;
  --accent-contrast: #0b1828;
  --danger: #f2867e;
  --shadow: rgba(0, 0, 0, 0.55);
}
:root[data-skin="neon"] {
  --bg: #f6f0fa;
  --bg-elevated: #fdfaff;
  --bg-elevated-hover: #ece1f4;
  --bg-elevated-active: #dfcdec;
  --text: #22172e;
  --text-muted: #675677;
  --border: #e0d1ec;
  --border-strong: #a68fbd;
  --accent: #a1279c;
  --accent-hover: #85207f;
  --accent-contrast: #fdfaff;
  --danger: #b3261e;
  --shadow: rgba(34, 23, 46, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root[data-skin="neon"]:not([data-theme="light"]) {
    --bg: #130f1c;
    --bg-elevated: #1d1729;
    --bg-elevated-hover: #282036;
    --bg-elevated-active: #342a45;
    --text: #f0e8fa;
    --text-muted: #b3a3c8;
    --border: #30264a;
    --border-strong: #54457a;
    --accent: #e040fb;
    --accent-hover: #ea6cfc;
    --accent-contrast: #1a0520;
    --danger: #ff8a9a;
    --shadow: rgba(0, 0, 0, 0.6);
  }
}
:root[data-skin="neon"][data-theme="dark"] {
  --bg: #130f1c;
  --bg-elevated: #1d1729;
  --bg-elevated-hover: #282036;
  --bg-elevated-active: #342a45;
  --text: #f0e8fa;
  --text-muted: #b3a3c8;
  --border: #30264a;
  --border-strong: #54457a;
  --accent: #e040fb;
  --accent-hover: #ea6cfc;
  --accent-contrast: #1a0520;
  --danger: #ff8a9a;
  --shadow: rgba(0, 0, 0, 0.6);
}
:root[data-skin="paper"] {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --bg-elevated-hover: #f0f0f0;
  --bg-elevated-active: #e2e2e2;
  --text: #000000;
  --text-muted: #444444;
  --border: #c8c8c8;
  --border-strong: #6b6b6b;
  --accent: #111111;
  --accent-hover: #333333;
  --accent-contrast: #ffffff;
  --danger: #b00020;
  --shadow: rgba(0, 0, 0, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root[data-skin="paper"]:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elevated: #0d0d0d;
    --bg-elevated-hover: #1f1f1f;
    --bg-elevated-active: #2e2e2e;
    --text: #ffffff;
    --text-muted: #c4c4c4;
    --border: #444444;
    --border-strong: #8a8a8a;
    --accent: #f5f5f5;
    --accent-hover: #ffffff;
    --accent-contrast: #000000;
    --danger: #ff8a80;
    --shadow: rgba(0, 0, 0, 0.7);
  }
}
:root[data-skin="paper"][data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #0d0d0d;
  --bg-elevated-hover: #1f1f1f;
  --bg-elevated-active: #2e2e2e;
  --text: #ffffff;
  --text-muted: #c4c4c4;
  --border: #444444;
  --border-strong: #8a8a8a;
  --accent: #f5f5f5;
  --accent-hover: #ffffff;
  --accent-contrast: #000000;
  --danger: #ff8a80;
  --shadow: rgba(0, 0, 0, 0.7);
}
:root[data-skin="winter"] {
  --bg: #f4f7f8;
  --bg-elevated: #ffffff;
  --bg-elevated-hover: #e6edf0;
  --bg-elevated-active: #d6e1e6;
  --text: #1a2a26;
  --text-muted: #56695f;
  --border: #d5e0e3;
  --border-strong: #95aab0;
  --accent: #b3262e;
  --accent-hover: #931d24;
  --accent-contrast: #ffffff;
  --danger: #b3261e;
  --shadow: rgba(26, 42, 38, 0.15);
}
@media (prefers-color-scheme: dark) {
  :root[data-skin="winter"]:not([data-theme="light"]) {
    --bg: #18212a;
    --bg-elevated: #212c37;
    --bg-elevated-hover: #2b3846;
    --bg-elevated-active: #364455;
    --text: #eef3f5;
    --text-muted: #a8b8c2;
    --border: #33414f;
    --border-strong: #52657a;
    --accent: #ef7a80;
    --accent-hover: #f59a9f;
    --accent-contrast: #1e0709;
    --danger: #ff8a80;
    --shadow: rgba(0, 0, 0, 0.55);
  }
}
:root[data-skin="winter"][data-theme="dark"] {
  --bg: #18212a;
  --bg-elevated: #212c37;
  --bg-elevated-hover: #2b3846;
  --bg-elevated-active: #364455;
  --text: #eef3f5;
  --text-muted: #a8b8c2;
  --border: #33414f;
  --border-strong: #52657a;
  --accent: #ef7a80;
  --accent-hover: #f59a9f;
  --accent-contrast: #1e0709;
  --danger: #ff8a80;
  --shadow: rgba(0, 0, 0, 0.55);
}

/* 1. Base reset */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  accent-color: var(--accent);
}

a {
  color: var(--accent);
}

a:visited {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

/* 2. Header */
.site-header {
  padding: 2rem 1rem;
  text-align: center;
}

.video-site-header,
.media-site-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.45rem 1rem;
}

.video-site-header h1,
.media-site-header h1 {
  margin: 0;
  font-size: 1.3rem;
}

.browse-site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.35rem;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: 0 3px 12px var(--shadow);
}

.global-media-nav,
.header-breadcrumbs {
  width: min(100%, 800px);
  margin: 0 auto;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.global-media-nav {
  display: flex;
  gap: 0.45rem;
}

.standard-media-header .global-media-nav {
  margin-bottom: 0.7rem;
}

.standard-media-header h1 {
  margin: 0;
}

/* Keep the nav's vertical position identical across every page, whether or
   not the header also carries a page title below it. */
.standard-media-header {
  padding-top: 0.85rem;
}

.section-home-header {
  padding: 0.85rem 1rem;
}

.section-home-header .global-media-nav {
  margin-bottom: 0;
}

.context-link {
  display: inline-block;
  margin-top: 0.45rem;
}

.home-page {
  max-width: 1000px;
  padding-top: 0.2rem;
}

.home-hero {
  position: relative;
  margin-bottom: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: 0 5px 20px var(--shadow);
}

/* an uploaded front picture: same 3:2 frame as the built-in one, label kept readable */
.home-hero[data-hero-custom] img {
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.home-hero[data-hero-custom] .home-hero-label {
  padding: 0.15rem 0.6rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

.home-hero img {
  display: block;
  width: 100%;
  height: auto;
}

.home-hero-label {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  color: #262320;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

/* Timeline: which kinds to show (photos, videos, blog, WhatsApp, playlists) */
.timeline-filters,
.home-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.timeline-filter,
.home-more a {
  display: inline-block;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
}

.timeline-filter:hover,
.home-more a:hover {
  background: var(--bg-elevated-hover);
  text-decoration: none;
}

.timeline-filter.is-on {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.timeline-filter.is-on:hover {
  background: var(--accent-hover);
}

.timeline-section-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-left: auto;
}

.global-media-nav a,
.header-breadcrumbs a {
  display: inline-block;
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-weight: 600;
}

.global-media-nav a:hover,
.header-breadcrumbs a:hover {
  background: var(--bg-elevated-hover);
  text-decoration: none;
}

.global-media-nav a.current {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.global-media-nav a.current:hover {
  background: var(--accent-hover);
}

.nav-logo {
  width: 1.6em;
  height: 1.6em;
  vertical-align: -0.45em;
  border-radius: 50%;
}

.nav-logo-sketch,
:root[data-logo="sketch"] .nav-logo-chilla {
  display: none;
}

:root[data-logo="sketch"] .nav-logo-sketch {
  display: inline;
}

.logo-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.logo-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.8rem;
}

.logo-card img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.logo-card[aria-pressed="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-logo-emboss {
  stroke: rgba(0, 0, 0, 0.5);
}

.global-media-nav a.current .nav-logo-emboss {
  stroke: var(--accent-contrast-emboss);
}

.theme-options {
  display: flex;
  gap: 0.6rem;
}

.theme-option-button {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.theme-option-button:hover {
  background: var(--bg-elevated-hover);
}

.theme-option-button.current {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

/* Settings > Appearance */
.appearance-heading {
  margin: 1.4rem 0 0.2rem;
  font-size: 1rem;
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.skin-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.skin-card:hover {
  border-color: var(--border-strong);
}

.skin-card[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.skin-swatch {
  display: block;
  height: 64px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(127, 127, 127, 0.3);
}

.skin-swatch-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 100%;
  padding: 7px 8px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.skin-swatch-line {
  display: block;
  width: 75%;
  height: 4px;
  border-radius: 2px;
  opacity: 0.85;
}

.skin-swatch-line.short {
  width: 45%;
  opacity: 0.5;
}

.skin-swatch-button {
  display: block;
  width: 38%;
  height: 9px;
  margin-top: auto;
  border-radius: 3px;
}

.skin-card-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.skin-card-description {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.hero-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin: 0.5rem 0;
}

.hero-option {
  cursor: pointer;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero-preview {
  display: block;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.appearance-status:empty {
  display: none;
}

.header-breadcrumbs {
  padding: 0.1rem 0 0.2rem 0;
}

.header-nav-sep {
  margin: 0 0.5rem;
}

.photo-browser .photo-viewer {
  top: 6.5rem;
}

/* 3. Main container */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

/* library page: search and genre filter in a sidebar */
.container-wide {
  max-width: 1100px;
}

.library-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.library-sidebar {
  position: sticky;
  top: 1rem;
}

.library-sidebar .library-search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
}

.library-sidebar .library-search-form input[type="search"] {
  flex: 1 1 100%;
  min-width: 0;
}

.sidebar-heading {
  margin: 1.1rem 0 0.5rem;
  padding: 0;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.library-sidebar .genre-filter {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.genre-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.genre-option:hover {
  background-color: var(--bg-elevated-hover);
}

.genre-option input {
  margin: 0;
  accent-color: var(--accent);
}

.genre-option .genre-name {
  flex: 1;
}

.genre-option.is-selected {
  font-weight: 600;
}

.genre-filter-actions {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.genre-filter-actions a {
  color: var(--accent);
}

.sidebar-note {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.folder-crumbs {
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

@media (max-width: 760px) {
  .library-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .library-sidebar {
    position: static;
  }

  /* on a phone the genres become a row of chips above the list */
  .library-sidebar .genre-filter {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .library-sidebar .genre-filter .sidebar-heading {
    flex-basis: 100%;
  }

  .genre-option {
    border: 1px solid var(--border);
    border-radius: 999px;
    background-color: var(--bg-elevated);
  }

  .genre-option.is-selected {
    border-color: var(--accent);
  }
}

/* 4. upload form */
.upload-form {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.admin-upload-form {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 0;
}

.admin-upload-form input[type="file"] {
  padding: 0.8rem;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.admin-upload-form button {
  width: fit-content;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  cursor: pointer;
}

.admin-upload-form button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.form-help,
.upload-progress {
  margin: 0;
  color: var(--text-muted);
}

.upload-success {
  border-color: #38783f;
}

.upload-failure {
  border-color: var(--danger);
}

/* 5. Panels / sections */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.album-cover {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--shadow);
}

.browse-heading-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* 6. Lists */
.media-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.media-list .song {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-radius: 6px;
  transition:
    background-color 0.15s ease,
    transform 0.05s ease,
    box-shadow 0.15s ease;
}

.media-list .song:hover {
  background-color: var(--bg-elevated-hover);
}

.media-list .song:active {
  transform: scale(0.98);
}

.media-list .song.playing {
  background-color: var(--bg-elevated-active);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.artist-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.7;
}

.artist-link:hover {
  opacity: 1;
  background-color: var(--bg-elevated-hover);
}

/* 6b. Directory browsing */
.music-menu {
  max-width: 560px;
}

.music-menu-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.music-menu-options .browse-link {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.music-menu-options .browse-link:hover {
  background: var(--bg-elevated-hover);
}

.browse-link {
  display: block;
  text-align: center;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.browse-link:hover {
  color: var(--accent);
}

@media (max-width: 480px) {
  .music-menu-options {
    grid-template-columns: 1fr;
  }
}

.breadcrumbs {
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.crumb-sep {
  margin: 0 0.35rem;
}

.up-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}

.up-link:hover {
  text-decoration: underline;
}

.dir-list a {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.dir-list a:hover {
  background-color: var(--bg-elevated-hover);
}

.dir-genres {
  margin-left: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.genre-count {
  opacity: 0.7;
  font-size: 0.8em;
}

.genre-filter-note {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-radius: 6px;
}

.song-row .song {
  flex: 1;
  padding: 0.75rem 0;
}

.song-checkbox {
  margin-left: 0.75rem;
}

/* song length, pushed to the end of the row (.song takes the free space) */
.song-duration {
  flex: 0 0 auto;
  margin-left: auto;
  padding-right: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.media-delete-button {
  flex: 0 0 auto;
  padding: 0.45rem 0.7rem;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.song-selection-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.library-delete-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.folder-protection-control {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.8rem;
}

.folder-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 0.8rem;
}

.browse-heading-row .folder-actions {
  margin: 0 0 0 auto;
}

.folder-actions form {
  margin: 0;
}

.folder-normalize-control button {
  border-color: var(--accent);
  color: var(--accent);
}

.folder-normalize-banner {
  margin-bottom: 0.8rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated));
}

.normalize-progress {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in srgb, #000 58%, transparent);
}

/* Author CSS overrides the browser's user-agent [hidden] rule, so restate it
   explicitly for the maintenance dialog. It must appear only after submit. */
.normalize-progress[hidden] {
  display: none;
}

.normalization-failure {
  color: #b42318;
  font-size: 0.82em;
  margin-left: 0.5rem;
}

.normalize-progress-card {
  width: min(100%, 30rem);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: 0 12px 40px var(--shadow);
}

.normalize-progress-card h2 {
  margin-top: 0;
}

.normalize-progress-card progress {
  width: 100%;
}

.normalize-progress-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.folder-protection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid #b18a24;
  border-radius: 7px;
  background: color-mix(in srgb, #d5a72f 14%, var(--bg-elevated));
}

.folder-protection-banner form {
  flex: 0 0 auto;
  margin: 0;
}

.folder-protection-banner code {
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .folder-protection-banner {
    align-items: stretch;
    flex-direction: column;
  }
}

.song-selection-controls button {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.song-selection-controls button:hover {
  background: var(--bg-elevated-hover);
}

.selection-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.playlist-add-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.playlist-add-bar select,
.playlist-add-bar input[type="text"] {
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.playlist-add-bar button {
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  cursor: pointer;
}

.playlist-add-bar button:hover {
  background: var(--accent-hover);
}

.library-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.library-search-form input[type="search"] {
  flex: 1 1 16rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.library-search-form button {
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  cursor: pointer;
}

.library-search-form button:hover {
  background: var(--accent-hover);
}

.search-clear-link {
  color: var(--text-muted);
}

.search-results-heading {
  color: var(--text-muted);
  margin: 0 0 1rem;
}

/* Account and user administration */
.account-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

.account-actions form {
  margin-left: auto;
}

.account-actions button,
.account-form button,
.user-actions button,
.session-row button {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.account-form {
  display: grid;
  gap: 0.65rem;
  max-width: 480px;
}

.form-hint {
  margin: -0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.password-validation-error {
  margin: 0;
  text-align: left;
}

.account-form input,
.password-reset-form input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.video-viewer {
  position: sticky;
  top: 0.25rem;
  z-index: 20;
  padding: 0.35rem 0.5rem;
  box-shadow: 0 8px 30px var(--shadow);
}

.video-viewer-heading,
.video-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.video-viewer-heading h2 {
  margin: 0;
  overflow: hidden;
  font-size: 0.95rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-viewer-heading button,
.video-play-button {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.video-viewer-heading button {
  flex: 0 0 auto;
  padding: 0.2rem 0.5rem;
}

.video-viewer-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.4rem;
}

#video-player {
  display: block;
  width: 100%;
  max-height: calc(100vh - 4.5rem);
  margin-top: 0.3rem;
  background: #000;
}

.video-list {
  margin-top: 0.8rem;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
  padding: 0;
  list-style: none;
}

@media (max-width: 1200px) {
  .video-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.video-card {
  min-width: 0;
}

.video-play-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.video-play-button .video-thumbnail {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 0;
}

.video-date {
  display: block;
  padding: 0.45rem 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.video-row {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.video-name {
  overflow-wrap: anywhere;
}

.video-thumbnail {
  display: block;
  flex: 0 0 120px;
  width: 120px;
  height: 76px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #171512;
}

.media-row-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.45rem;
}

.media-row-actions form,
.photo-delete-form {
  margin: 0;
}

@media (max-width: 640px) {
  .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .video-row {
    align-items: stretch;
    flex-direction: column;
  }

  .video-play-button {
    width: 100%;
  }

  .video-thumbnail {
    flex-basis: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .media-row-actions,
  .media-row-actions form,
  .media-row-actions button {
    width: 100%;
  }
}

.photo-viewer {
  position: sticky;
  top: 0.25rem;
  z-index: 20;
  padding: 0.35rem 0.5rem;
  box-shadow: 0 8px 30px var(--shadow);
}

.photo-viewer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.photo-viewer-heading h2 {
  margin: 0;
  overflow: hidden;
  font-size: 0.95rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-viewer-heading button {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.photo-viewer-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.4rem;
}

.photo-viewer-actions button:disabled {
  cursor: default;
  opacity: 0.45;
}

#photo-image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 4.5rem);
  margin-top: 0.3rem;
  object-fit: contain;
  background: #000;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 1200px) {
  .photo-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.photo-card {
  min-width: 0;
}

.photo-delete-form {
  margin-top: 0.4rem;
  text-align: right;
}

.photo-display-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 2px 8px var(--shadow);
  cursor: pointer;
  text-align: left;
}

.photo-display-button:hover,
.photo-display-button:focus-visible {
  border-color: var(--border-strong);
  background: var(--bg-elevated-hover);
}

.photo-thumbnail {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #171512;
}

.photo-date {
  display: block;
  padding: 0.6rem 0.7rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.2;
  text-align: center;
}

@media (max-width: 640px) {
  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
}

.user-list {
  display: grid;
  gap: 0.8rem;
}

.user-card {
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.user-role,
.user-status {
  margin-left: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.user-status.enabled {
  color: #38783f;
}

.user-status.disabled,
.danger-button {
  color: var(--danger) !important;
}

.user-actions,
.user-actions form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.password-reset-form input {
  min-width: 220px;
}

.session-list {
  margin-top: 0.7rem;
}

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

/* 7. Footer */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

/* ---- Login Page ---- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
}

.login-container {
  width: 100%;
  max-width: 360px;
  padding: 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px var(--shadow);
}

.login-title {
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.login-form input {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-form button {
  margin-top: 0.5rem;
  padding: 0.6rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  cursor: pointer;
}

.login-form button:hover {
  background: var(--accent-hover);
}

.login-error {
  margin-top: 1rem;
  color: var(--danger);
  text-align: center;
}

/* ---- Setup Page ---- */

.setup-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
}

.setup-container {
  width: 100%;
  max-width: 520px;
  padding: 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px var(--shadow);
}

.setup-title {
  margin: 0;
  text-align: center;
  font-size: 1.6rem;
}

.setup-subtitle {
  margin: 0.75rem 0 1.5rem;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.4;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.setup-section {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.setup-section-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: var(--text);
}

.setup-form label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.setup-form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.setup-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.setup-button {
  padding: 0.75rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  cursor: pointer;
}

.setup-button:hover {
  background: var(--accent-hover);
}

.setup-error {
  margin: 0.25rem 0 0;
  color: var(--danger);
  text-align: center;
}

.setup-footnote {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

/* ===== Bottom Music Player ===== */

#player {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 72px;

  display: flex;
  align-items: center;
  gap: 1rem;

  padding: 0 1.25rem;

  background: var(--bg-elevated);
  color: var(--text);

  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px var(--shadow);

  z-index: 1000;
}

/* Hide cleanly using the hidden attribute */
#player[hidden] {
  display: none;
}

/* Now playing text */
#now-playing {
  flex: 1;

  font-size: 0.95rem;
  font-weight: 500;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Audio controls */
#audio {
  width: 320px;
  max-width: 45vw;
  height: 36px;
}

/* Playback buttons and audio controls */
.player-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-control-button {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated-hover);
  color: var(--text);

  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.player-control-button:hover:not(:disabled) {
  background: var(--bg-elevated-active);
}

.player-control-button:disabled {
  cursor: default;
  opacity: 0.4;
}

.shuffle-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  #player {
    height: auto;
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: stretch;
  }

  #audio {
    width: 100%;
    max-width: none;
  }

  .player-controls {
    width: 100%;
  }

  .player-controls #audio {
    min-width: 0;
  }

  #now-playing {
    text-align: center;
  }
}

/* Timeline */
.timeline-page,
.photo-browser,
.video-browser {
  max-width: min(96vw, 1800px);
}

.timeline-jump-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.timeline-jump-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.timeline-jump-form select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text);
}

.timeline-jump-form button {
  padding: 0.45rem 1rem;
}

.timeline-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 1200px) {
  .timeline-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.timeline-card.photo-card .photo-display-button {
  border: 2px solid var(--photo-frame);
}

.timeline-card.video-card .video-play-button {
  border: 2px solid var(--video-frame);
}

.timeline-playlist-card {
  min-width: 0;
}

.timeline-playlist-card a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  height: 100%;
  min-height: 150px;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 2px 8px var(--shadow);
  text-decoration: none;
  text-align: center;
}

.timeline-playlist-card a:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated-hover);
}

.timeline-playlist-icon {
  font-size: 1.8rem;
}

.timeline-playlist-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.timeline-playlist-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.timeline-post-card {
  min-width: 0;
}

.timeline-post-card a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  height: 100%;
  min-height: 150px;
  padding: 1rem;
  border: 2px solid var(--post-frame);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 2px 8px var(--shadow);
  text-decoration: none;
  text-align: center;
}

.timeline-post-card a:hover {
  background: var(--bg-elevated-hover);
}

.timeline-post-icon {
  font-size: 1.8rem;
}

.timeline-post-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.timeline-post-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* WhatsApp day cards: blog-post card layout with their own frame color */
.timeline-chat-card a {
  border-color: var(--chat-frame);
}

.timeline-chat-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .timeline-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
}

/* Blog */
.blog-category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.blog-category-chip {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}

.blog-category-chip:hover {
  background: var(--bg-elevated-hover);
  color: var(--text);
}

.blog-category-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.blog-category-chip.small {
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  pointer-events: none;
}

.blog-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.blog-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.blog-list-item:last-child {
  border-bottom: none;
}

.blog-list-title {
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

.blog-list-title:hover {
  color: var(--accent);
}

.blog-list-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.blog-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
}

.blog-pager a {
  color: var(--accent);
  text-decoration: none;
}

.blog-pager a:hover {
  text-decoration: underline;
}

.blog-pager-disabled {
  color: var(--text-muted);
}

.blog-pager-status {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.blog-post-title {
  margin: 0 0 0.4rem;
}

.blog-post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.blog-post-body {
  line-height: 1.65;
}

.blog-post-body p {
  margin: 0 0 1rem;
}

.blog-post-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.5rem 0;
  border-radius: 6px;
}

.blog-post-body a {
  color: var(--accent);
}

.blog-post-body blockquote {
  margin: 0 0 1rem;
  padding: 0.25rem 1rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.blog-post-body table {
  border-collapse: collapse;
  margin: 0 0 1rem;
}

.blog-post-body th,
.blog-post-body td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
}

@media (max-width: 640px) {
  .blog-list-item {
    flex-direction: column;
    align-items: flex-start;
  }
}

.blog-category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.blog-category-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 400;
}

#blog-body {
  width: 100%;
  font-family: ui-monospace, monospace;
  resize: vertical;
}

.blog-push-form {
  display: flex;
  justify-content: flex-end;
}

.blog-push-output {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
}

/* WhatsApp archive (admin-only, read-only view of wa-archive-import output) */
.whatsapp-group + .whatsapp-group {
  margin-top: 1rem;
}

.whatsapp-year-label {
  margin: 1rem 0 0.4rem;
  font-size: 1rem;
  color: var(--text-muted);
}

.whatsapp-day {
  margin-top: 1.5rem;
}

.whatsapp-day-label {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 1rem;
}

.whatsapp-day-label a {
  color: inherit;
  text-decoration: none;
}

.whatsapp-day-label a:hover {
  color: var(--accent);
}

.whatsapp-message {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.45rem 0;
}

.whatsapp-time {
  padding-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.whatsapp-sender {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
}

.whatsapp-text {
  margin: 0.1rem 0 0;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.whatsapp-notice .whatsapp-text {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

.whatsapp-media {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.whatsapp-media img,
.whatsapp-media video {
  display: block;
  max-width: min(100%, 22rem);
  max-height: 22rem;
  height: auto;
  border-radius: 6px;
  background: var(--bg);
}

.whatsapp-media audio {
  max-width: 100%;
}

.whatsapp-file,
.whatsapp-missing {
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.whatsapp-file {
  color: var(--accent);
}

@media (max-width: 640px) {
  .whatsapp-message {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.1rem;
  }
}

/* Admin: edit a song's title and artist */
.song-edit-button {
  margin-left: auto;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.2;
}

.song-edit-button:hover,
.song-edit-button:focus-visible {
  border-color: var(--border-strong);
  color: var(--text);
}

.song-edit-dialog {
  width: min(32rem, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0;
}

.song-edit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.song-edit-form {
  display: grid;
  gap: 0.45rem;
  padding: 1.1rem 1.2rem;
}

.song-edit-form h2 {
  margin: 0 0 0.2rem;
  font-size: 1.15rem;
}

.song-edit-form input {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.song-edit-file,
.song-edit-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.song-edit-error {
  margin: 0;
  color: var(--danger);
}

.song-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

/* album views: compilations / best-ofs grid, album bar on album folders */

.album-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.album-tabs a {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.album-tabs a:hover {
  background: var(--bg-elevated-hover);
}

.album-tabs a[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.album-count {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.album-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 1.25rem 1rem;
}

@media (max-width: 480px) {
  .album-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 0.75rem;
  }
}

.album-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.album-card-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  color: var(--text);
  text-decoration: none;
}

.album-card-cover {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 2px 10px var(--shadow);
  margin-bottom: 0.35rem;
  transition: transform 0.12s ease;
}

.album-card-link:hover .album-card-cover {
  transform: translateY(-2px);
}

.album-card-nocover {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-muted);
}

.album-card-title {
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.album-card-link:hover .album-card-title {
  color: var(--accent);
}

.album-card-artist {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.album-card-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.album-card-discs,
.album-discs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.album-card-discs a,
.album-discs a,
.album-discs span {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text);
  text-decoration: none;
}

.album-card-discs a:hover,
.album-discs a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.album-discs span[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.album-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.album-bar [data-play-album] {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  cursor: pointer;
}

.album-bar [data-play-album]:hover {
  background: var(--accent-hover);
}

.song-album-link {
  margin-left: 0.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.song-album-link:hover {
  color: var(--accent);
}

/* on a phone the album note may wrap, so the title keeps its room and the
   song length stays on screen */
@media (max-width: 640px) {
  .song-row .song {
    min-width: 0;
  }
  .song-album-link {
    flex: 0 1 7rem;
    white-space: normal;
  }
}

/* Offline downloads (static/offline.js, static/downloads.html) */
.offline-button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.offline-button:hover {
  background: var(--bg-elevated-hover);
}

.offline-status {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.media-list .song.offline-saved::after {
  content: " \2B07";
  color: var(--text-muted);
  font-size: 0.8em;
}

.media-list .song.offline-missing {
  color: var(--text-muted);
}

.offline-net {
  display: block;
  margin-top: 0.4rem;
  color: var(--danger);
  font-weight: 600;
}

.offline-summary p {
  margin: 0.3rem 0 0.8rem;
}

.offline-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.offline-collections {
  list-style: none;
  padding: 0;
  margin: 0;
}

.offline-collection {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.offline-collection:last-child {
  border-bottom: none;
}

.offline-text {
  min-width: 0;
  flex: 1 1 14rem;
}

.offline-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.offline-line {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.offline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.offline-actions button {
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
}

.offline-actions .primary-button {
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

#songs-panel h2 {
  margin: 0;
  flex: 1 1 auto;
}

.offline-open {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.offline-open:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

/* Settings > Add an album */
.album-add-form .album-add-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.album-add-form .album-add-option input {
  width: auto;
}

.album-add-form .album-add-sub {
  margin-left: 1.6rem;
}

.album-add-form button.primary-button,
.album-apply {
  justify-self: start;
  padding: 0.55rem 1.1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  cursor: pointer;
}

.album-add-form button.primary-button:hover:not(:disabled),
.album-apply:hover:not(:disabled) {
  background: var(--accent-hover);
}

.album-add-form button:disabled,
.album-apply:disabled {
  opacity: 0.6;
  cursor: progress;
}

.album-job-status {
  margin: 0 0 0.8rem;
  overflow-wrap: anywhere;
}

.album-found {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.album-found p {
  margin: 0.15rem 0;
}

.album-job-log {
  margin-top: 1rem;
}

.album-job-log pre {
  max-height: 24rem;
  overflow: auto;
  padding: 0.7rem;
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.78rem;
  white-space: pre;
}

.album-history {
  margin: 0;
  padding: 0;
  list-style: none;
}

.album-history li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.album-history li:last-child {
  border-bottom: 0;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link, var(--accent));
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.album-add-form {
  margin-top: 1rem;
}

#album-add-settings .offline-open {
  margin-top: 0.9rem;
}

.album-found-source {
  overflow-wrap: anywhere;
}

.album-add-form .album-add-wild {
  margin: -0.2rem 0 0.3rem;
}

.album-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.album-results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.album-results li:last-child {
  border-bottom: 0;
}

.album-results li.album-picked {
  background: var(--bg);
}

.album-result-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.album-result-text .form-hint {
  display: block;
  margin: 0.1rem 0 0;
}

.album-results .album-pick {
  flex: none;
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
}

.album-results-more {
  margin-top: 0.6rem;
}

/* ===== Playlist editor (admin) ===== */
.playlist-edit-name {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.playlist-edit-name input {
  font-size: 1.1rem;
  max-width: 32rem;
}

.playlist-edit-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.playlist-edit-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.3rem;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.12));
}

.playlist-edit-handle {
  cursor: grab;
  opacity: 0.5;
  letter-spacing: -0.3em;
}

.playlist-edit-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.playlist-edit-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.playlist-move {
  min-width: 2.2rem;
}

.playlist-remove {
  white-space: nowrap;
  font-size: 0.9rem;
}

.playlist-edit-row.is-removed .playlist-edit-title {
  text-decoration: line-through;
  opacity: 0.55;
}

.playlist-edit-row.is-dragging {
  opacity: 0.4;
}

.playlist-edit-buttons {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ===== Groups & access (admin) ===== */
.access-panel {
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.access-panel summary {
  cursor: pointer;
}

.access-panel.access-restricted {
  border-color: var(--accent);
}

.access-panel .form-hint {
  margin: 0.5rem 0 0.3rem;
}

.access-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.3rem 0 0.6rem;
}

.access-groups label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.access-groups input {
  width: auto;
}

.access-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

.access-manage {
  margin-left: auto;
}

.access-lock {
  font-size: 0.85em;
}

.access-notice {
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  background: var(--bg);
}

.admin-groups fieldset {
  margin: 0.4rem 0;
  padding: 0;
  border: 0;
}

.admin-groups legend {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.group-card .form-hint {
  display: block;
}

/* ===== View as (admin) ===== */
.view-as-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 1rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.95rem;
  text-align: center;
}

.view-as-bar .view-as-stop {
  padding: 0.2rem 0.7rem;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.view-as-bar .view-as-stop:hover {
  background: var(--accent-hover);
}

.view-as-form {
  display: inline-block;
  margin-left: 0.6rem;
}

.view-as-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.view-as-picker select {
  width: auto;
}

/* ---- Audiobooks ---- */
.audiobook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audiobook-card a {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--text);
  text-decoration: none;
}

.audiobook-card a:hover .audiobook-card-title {
  color: var(--accent);
}

.audiobook-cover {
  width: 100%;
  aspect-ratio: 2 / 3; /* book covers are upright */
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.audiobook-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.audiobook-card-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.audiobook-card-meta,
.audiobook-hint,
.audiobook-now {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.audiobook-heading {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.audiobook-heading .audiobook-cover {
  width: 120px;
  flex: 0 0 120px;
}

.audiobook-heading h1 {
  margin: 0 0 0.3rem;
  overflow-wrap: anywhere;
}

.audiobook-audio {
  width: 100%;
  margin-top: 1rem;
}

.audiobook-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 0.6rem 0 1rem;
}

.audiobook-part {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.audiobook-part-play {
  flex: 1 1 auto;
  text-align: left;
  overflow-wrap: anywhere;
}

.audiobook-part.playing .audiobook-part-play {
  font-weight: 700;
  color: var(--accent);
}

.audiobook-upload-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-start;
}

.audiobook-upload-form input[type="text"] {
  min-width: min(28rem, 80vw);
}

.audiobook-upload-status {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

.audiobook-upload-status .done {
  color: var(--text-muted);
}

.audiobook-upload-status .failed {
  color: var(--danger);
}

.audiobook-author {
  margin: 1rem 0 0.6rem;
}

.audiobook-by {
  margin: 0;
  color: var(--text-muted);
}

.yt-results {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.yt-results li {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.yt-results li:last-child {
  border-bottom: 0;
}

.yt-results img {
  width: 160px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  flex: 0 0 160px;
  border-radius: 4px;
  background: var(--bg);
}

.yt-result-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.yt-result-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.yt-result-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.3rem;
}

@media (max-width: 640px) {
  .yt-results img {
    width: 110px;
    flex-basis: 110px;
  }
}

#ab-job-progress {
  width: 100%;
}

.audiobook-find-link {
  margin: 0 0 1rem;
}

.audiobook-author,
.audiobook-by {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.audiobook-author-photo {
  width: 3rem;
  height: 3rem;
  flex: 0 0 3rem;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 20%;
  background: var(--border);
}

.audiobook-artwork-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start;
}

.audiobook-author-portrait {
  aspect-ratio: 3 / 4;
  object-position: 50% 20%; /* keep the face */
}

.audiobook-heading .audiobook-author-portrait {
  width: 160px;
  flex: 0 0 160px;
}

.audiobook-by a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
}

/* ---------------------------------------------------------------- e-book reader */

.reader-body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.reader {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.reader-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.reader-foot {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.reader-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.reader-title strong,
.reader-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-title span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.reader-button {
  min-width: 2.4rem;
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  text-decoration: none;
}

.reader-toc {
  max-width: min(18rem, 35vw);
}

.reader-view {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: var(--bg-elevated);
}

.reader-view foliate-view {
  display: block;
  width: 100%;
  height: 100%;
}

.reader-status {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.reader-slider {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--accent);
}

.reader-percent {
  min-width: 3.2rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.audiobook-read {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.6rem 0 0;
}

@media (max-width: 600px) {
  .reader-toc {
    max-width: 30vw;
  }
}
