:root {
  --bg: #fafafa;
  --fg: #343c3c;
  --dim: #737b7b;
  --muted: #999;
  --faint: #e0e0e0;
  --border: #e4e4e7;

  color-scheme: light;
  --chart-bg: #fff;
  --chart-fg: #293238;
  --chart-dim: #68737c;
  --chart-border: #edf0f2;
  --chart-toolbar: #f5f7f8;
  --chart-hover: #f1f4f6;
  --chart-badge: #edf0f2;
  --chart-label-rgb: 255,255,255;
  --chart-scrollbar: #c5cdd2;
}

[data-theme="dark"] {
  color-scheme: dark;
  --chart-bg: #141414;
  --chart-fg: #e0e0e0;
  --chart-dim: #888;
  --chart-border: rgba(255,255,255,0.08);
  --chart-toolbar: #1a1a1a;
  --chart-hover: rgba(255,255,255,0.04);
  --chart-badge: rgba(255,255,255,0.1);
  --chart-label-rgb: 20,20,20;
  --chart-scrollbar: #424242;
  --bg: #161616;
  --fg: #e0e0e0;
  --dim: #888;
  --muted: #666;
  --faint: #333;
  --border: #333;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--faint);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

h1 {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  margin-bottom: 0;
  color: var(--fg);
}

.subtitle {
  color: var(--dim);
  font-size: 12px;
  font-weight: 400;
}

.sort-toggle {
  display: none;
  align-items: center;
  gap: 6px;
}

.sort-toggle.visible {
  display: flex;
}

.sort-label {
  font-size: 11px;
  color: var(--chart-dim);
  font-weight: 500;
}

.sort-btn {
  background: transparent;
  border: none;
  color: var(--chart-dim);
  padding: 4px 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease;
}

.sort-btn:hover {
  color: var(--chart-fg);
}

.sort-btn.active {
  background: var(--chart-badge);
  color: var(--chart-fg);
}

/* Play count */
.play-count {
  font-size: 10px;
  color: var(--chart-dim);
  white-space: nowrap;
}

[data-theme="dark"] .tooltip {
  background: #1e1e1e;
  border-color: var(--faint);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.theme-toggle{cursor:pointer;color:var(--dim);font-size:13px;background:none;border:none;font-family:var(--font-sans);padding:0}
.theme-toggle:hover{color:var(--fg)}

.chart-wrapper {
  position: relative;
  background: var(--chart-bg);
  border: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  corner-shape: squircle;
  padding: 0;
  overflow: hidden;
  margin: 0 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  min-height: 600px;
}
[data-theme="dark"] .chart-wrapper {
  border: 1px solid rgba(255,255,255,0.1);
}

.chart-wrapper.loading {
  display: none;
}

/* Loading state */
.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--dim);
  font-size: 12px;
}

.loading-indicator.hidden {
  display: none;
}

/* Integrated table toolbar - navigation lives here */

.breadcrumb-link {
  color: var(--chart-fg);
  cursor: pointer;
  transition: color 0.15s ease;
  padding: 4px 0;
}

.breadcrumb-link:hover {
  color: var(--chart-fg);
  text-decoration: underline;
}

.breadcrumb-sep {
  margin: 0 6px;
  color: var(--chart-dim);
  font-size: 11px;
}

.breadcrumb-current {
  color: var(--chart-fg);
  font-weight: 600;
}

/* Column headers */
.column-headers {
  display: flex;
  align-items: center;
  padding: 8px 24px;
  background: var(--chart-bg);
  border-bottom: 1px solid var(--chart-border);
}

.col-header {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--chart-dim);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.col-header-icon {
  font-size: 12px;
  opacity: 0.7;
}

.col-name { width: 160px; padding-right: 16px; flex-shrink: 0; }
.col-timeline { flex: 1; text-align: center; }
.col-hours { width: 60px; text-align: right; padding-left: 12px; flex-shrink: 0; }

/* Song view specific columns */
.col-track { width: 32px; text-align: center; flex-shrink: 0; }
.col-plays { width: 60px; text-align: left; }
.col-link { width: 24px; }

/* Album view extras */
.col-year { width: 50px; text-align: center; }
.col-tracks { width: 50px; text-align: center; }

.time-axis {
  display: flex;
  align-items: center;
  padding: 6px 24px;
  border-bottom: 1px solid var(--chart-border);
}

.time-axis-spacer {
  flex-shrink: 0;
}

.time-axis-spacer.artists,
.time-axis-spacer.albums,
.time-axis-spacer.songs { width: 196px; }

.time-axis-labels {
  flex: 1;
  display: flex;
  position: relative;
  height: 16px;
}

/* Year axis ticks */
.year-mark::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 6px;
  background: var(--muted);
}

.time-axis-end {
  flex-shrink: 0;
}

.time-axis-end.artists,
.time-axis-end.albums,
.time-axis-end.songs { width: 90px; }

.year-mark {
  position: absolute;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--chart-dim);
  font-weight: 500;
  text-transform: uppercase;
}

.chart-content {
  padding: 8px 16px 16px;
}

.horizon-row {
  display: flex;
  align-items: center;
  height: 48px;
  margin-bottom: 0;
  cursor: pointer;
  transition: background 0.1s ease;
  padding: 0 8px;
}

.horizon-row + .horizon-row {
  border-top: 1px solid var(--chart-border);
}
.horizon-row:hover {
  background: var(--chart-hover);
}

.horizon-row.clickable::after {
  content: '';
  display: none;
}

.item-label {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-x: visible;
  overflow-y: clip;
  position: relative;
  z-index: 1;
}

.item-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--chart-fg);
  white-space: nowrap;
  background: linear-gradient(90deg, rgba(var(--chart-label-rgb), 0.7) 0%, rgba(var(--chart-label-rgb), 0.4) 80%, transparent 100%);
  padding: 1px 16px 1px 4px;
  width: fit-content;
}

.item-secondary {
  font-size: 11px;
  color: var(--chart-dim);
  white-space: nowrap;
  background: linear-gradient(90deg, rgba(var(--chart-label-rgb), 0.5) 0%, rgba(var(--chart-label-rgb), 0.3) 80%, transparent 100%);
  padding: 1px 16px 1px 4px;
  width: fit-content;
}

.horizon-chart {
  flex: 1;
  height: 20px;
  position: relative;
  overflow: hidden;
}

.horizon-chart canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.item-hours {
  width: 60px;
  text-align: right;
  font-size: 11px;
  color: var(--chart-dim);
  padding-left: 12px;
  flex-shrink: 0;
  font-weight: 500;
}

/* Album art thumbnails */
.album-art {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-right: 12px;
  background: var(--chart-badge);
  object-fit: cover;
}

.album-art-placeholder {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-right: 12px;
  background: var(--chart-badge);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chart-dim);
  font-size: 14px;
}

/* Album type badge */
.album-type-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 2px 5px;
  background: var(--chart-badge);
  color: var(--chart-dim);
  margin-left: 8px;
  font-weight: 600;
}

.album-type-badge.single {
  background: var(--chart-badge);
  color: var(--chart-dim);
}

.album-type-badge.compilation {
  background: var(--chart-badge);
  color: var(--chart-dim);
}

/* Album metadata row */
.album-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-left: 12px;
}

.album-year {
  font-size: 11px;
  color: var(--chart-dim);
}

.album-tracks {
  font-size: 10px;
  color: var(--chart-dim);
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: #fff;
  color: var(--fg);
  padding: 10px 14px;
  border: 1px solid var(--faint);
  border-radius: 12px;
  corner-shape: squircle;
  font-size: 11px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.1s ease;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.tooltip.visible { opacity: 1; }
.tooltip-title { font-weight: 600; margin-bottom: 2px; font-size: 12px; }
.tooltip-subtitle { color: var(--dim); margin-bottom: 6px; }
.tooltip-week { color: var(--dim); font-size: 11px; }
.tooltip-hours { color: var(--fg); font-weight: 600; }

/* Song-specific styles */
.track-number {
  width: 32px;
  text-align: center;
  font-size: 11px;
  color: var(--chart-dim);
  flex-shrink: 0;
}

.song-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  padding-left: 12px;
}

.spotify-link {
  color: var(--chart-dim);
  text-decoration: none;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.1s ease, color 0.1s ease;
}

.horizon-row:hover .spotify-link {
  opacity: 1;
}

.spotify-link:hover {
  color: var(--chart-fg);
}

.explicit-badge {
  background: var(--chart-badge);
  color: var(--chart-dim);
  font-size: 9px;
  padding: 1px 4px;
  margin-left: 6px;
  text-transform: uppercase;
  font-weight: 600;
}

.horizon-row {
  position: relative;
}

.horizon-row.album-row {
  height: 48px;
  margin-bottom: 0;
}

.horizon-row.album-row .horizon-chart {
  height: 28px;
}

.horizon-row:hover .spotify-link {
  opacity: 1;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
.nav-home{display:inline}
  .container{display:flex;flex-direction:column}
.tooltip {
    display: none !important;
  }

  .container {
    padding: 16px 1px;
  }

header {
    padding: 0 16px;
    margin-bottom: 16px;
  }

  h1 {
    font-size: 13px;
  }

  .chart-wrapper {
    margin: 12px 0;
    border-radius: 12px;
    corner-shape: squircle;
  }

  .column-headers {
    display: none;
  }

  .time-axis {
    display: flex;
    padding: 8px 10px;
    background: transparent;
  }

  .time-axis-spacer {
    width: 70px !important;
    flex-shrink: 0;
  }

  .time-axis-labels {
    flex: 1;
    margin-right: 60px;
  }

  .time-axis-end {
    display: none;
  }

  .year-mark {
    font-size: 10px;
  }

  .chart-content {
    padding: 0;
    background: transparent;
  }

  /* List rows with chart as background */
  .horizon-row {
    flex-direction: row;
    align-items: center;
    height: 64px;
    padding: 0 10px;
    margin-bottom: 2px;
    background: transparent;
    position: relative;
    overflow: hidden;
  }

  .horizon-row:active {
    background: var(--chart-hover);
  }

  .horizon-row.album-row {
    height: 72px;
  }

  /* Chart as full background */
  .horizon-chart {
    position: absolute !important;
    top: 4px;
    left: 70px;
    right: 60px;
    bottom: 4px;
    width: calc(100% - 130px) !important;
    height: calc(100% - 8px) !important;
    z-index: 0;
    opacity: 0.7;
  }

  .horizon-row.album-row .horizon-chart {
    height: calc(100% - 8px);
  }

  .item-label {
    position: relative;
    z-index: 1;
    width: auto;
    flex: 1;
    padding: 0;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow: hidden;
  }

  .item-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--chart-fg);
    margin-bottom: 2px;
    background: linear-gradient(90deg, rgba(var(--chart-label-rgb), 0.7) 0%, rgba(var(--chart-label-rgb), 0.4) 80%, transparent 100%);
    padding: 2px 16px 2px 6px;
    max-width: calc(100% - 70px);
    width: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .item-secondary {
    font-size: 11px;
    color: var(--chart-dim);
    background: linear-gradient(90deg, rgba(var(--chart-label-rgb), 0.7) 0%, rgba(var(--chart-label-rgb), 0.4) 80%, transparent 100%);
    padding: 2px 16px 2px 6px;
    max-width: calc(100% - 70px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .item-hours {
    position: relative;
    z-index: 1;
    width: auto;
    padding: 3px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--chart-fg);
    text-align: right;
    background: rgba(var(--chart-label-rgb), 0.5);
  }

  /* Show small album art on mobile */
  .album-art,
  .album-art-placeholder {
    display: flex;
    position: relative;
    z-index: 1;
    width: 40px;
    height: 40px;
    margin-right: 12px;
    flex-shrink: 0;
  }

  .horizon-row.album-row .item-label {
    width: auto;
    flex: 1;
  }

  /* Album meta on mobile */
  .album-meta {
    position: absolute;
    top: 12px;
    right: 16px;
    padding: 0;
    gap: 8px;
  }

  .album-year,
  .album-tracks {
    display: none;
  }

  /* Song meta on mobile */
  .song-meta {
    position: absolute;
    top: 12px;
    right: 16px;
    padding: 0;
    gap: 8px;
  }

  .spotify-link {
    display: none;
  }

  .track-number {
    display: block;
    position: relative;
    z-index: 1;
    width: 24px;
    margin-right: 8px;
    font-size: 11px;
    color: var(--chart-dim);
  }

}

/* Even smaller screens */
@media (max-width: 480px) {

  .breadcrumb-sep {
    margin: 0 4px;
  }

  .horizon-row {
    height: 56px;
    padding: 0 10px;
  }

  .horizon-row.album-row {
    height: 64px;
  }

  .item-name {
    font-size: 11px;
  }

  .item-secondary {
    font-size: 10px;
  }

  .item-hours {
    font-size: 10px;
    padding: 2px 5px;
  }

  .album-art,
  .album-art-placeholder {
    width: 36px;
    height: 36px;
  }
}

/* --- Static-site additions (generated pages use real links + SVG charts) --- */
a.horizon-row { color: inherit; text-decoration: none; }
a.breadcrumb-link { text-decoration: none; }

.horizon-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.horizon-chart rect {
  stroke: rgba(100,100,100,0.2);
  stroke-width: 0.5;
  vector-effect: non-scaling-stroke;
}

/* App shell: persistent controls above an independently scrolling chart. */
body { -webkit-text-size-adjust: 100%; }
.container { width: 100%; max-width: none; height: 100vh; height: 100dvh; min-height: 0; margin: 0; padding: 0; overflow: hidden; }
.app-header { width: 100%; max-width: 850px; display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; gap: 24px; margin: 0; padding: 24px 24px 16px; border: 0; }
.app-controls { display: flex; align-items: center; gap: 20px; min-width: 0; flex-shrink: 0; margin-block: 0; }
.site-nav { display: flex; align-items: center; gap: 8px 16px; min-height: 24px; font-size: 13px; line-height: 1.5; letter-spacing: -.011em; }
.site-nav a { color: var(--dim); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--fg); }
h1 { font-size: 16px; line-height: 22px; font-weight: 500; margin: 0; }
.subtitle { font-size: 11px; line-height: 18px; }

.theme-toggle { width: 24px; min-height: 24px; display: grid; place-items: center; }
.chart-wrapper, [data-theme="dark"] .chart-wrapper { display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.column-headers, .time-axis { flex-shrink: 0; }
.chart-content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-color: var(--chart-scrollbar) var(--chart-bg); scrollbar-width: thin; }
.chart-content:focus-visible { outline: 1px solid var(--chart-dim); outline-offset: -2px; }
.col-header { font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.chart-wrapper { font-family: ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Code', monospace; letter-spacing: 0; }
.item-name { font-size: 11px; line-height: 18px; font-weight: 400; }
.sort-toggle { gap: 2px; padding: 2px; border: 1px solid var(--chart-border); border-radius: 6px; }
.sort-label { padding: 0 6px; }
.sort-btn { border-radius: 4px; min-height: 28px; }
@media (max-width: 768px) {
  .app-header { gap: 12px; }
  .app-controls { gap: 6px; margin-block: 0; }
  h1 { font-size: 14px; line-height: 20px; }
  .subtitle { font-size: 10px; line-height: 16px; }

  .theme-toggle { width: 24px; min-height: 24px; }

  .chart-content { padding: 0; }
}
@media (max-width: 480px) {
  .app-header { padding: 20px 20px 12px; }
}

/* Opaque gradients around each artist's hue keep low-volume bands legible on white.
   Dark mode uses translucent SVG fills with a brighter first band. */
.horizon-chart rect.band-0 { --band-gradient: var(--band-gradient-0); }
.horizon-chart rect.band-1 { --band-gradient: var(--band-gradient-1); }
.horizon-chart rect.band-2 { --band-gradient: var(--band-gradient-2); }
.horizon-chart rect.band-3 { --band-gradient: var(--band-gradient-3); }
/* Hairline gaps in the surface colour keep each week a distinct mark (as in light mode) */
[data-theme="dark"] .horizon-chart rect {
  stroke: var(--chart-bg);
  stroke-width: .75;
}

[data-theme="dark"] .horizon-chart rect.band-0 {
  fill: hsl(var(--chart-hue) 70% 60% / 0.55);
}

[data-theme="dark"] .horizon-chart rect.band-1 {
  fill: hsl(var(--chart-hue) 70% 62% / 0.65);
}

[data-theme="dark"] .horizon-chart rect.band-2 {
  fill: hsl(var(--chart-hue) 70% 68% / 0.8);
}

[data-theme="dark"] .horizon-chart rect.band-3 {
  fill: hsl(var(--chart-hue) 70% 76% / 1);
}

/* Chroma rises with intensity so peaks read as more vivid, not just darker;
   hairline gaps in the surface colour keep each week a distinct mark. */
:root:not([data-theme="dark"]) .horizon-chart linearGradient {
  --band-lightness: .70;
  --band-chroma: .115;
}
:root:not([data-theme="dark"]) .horizon-chart stop {
  stop-color: oklch(from hsl(var(--gradient-hue) 70% 50%) var(--band-lightness) var(--band-chroma) h);
}
:root:not([data-theme="dark"]) .horizon-chart rect {
  fill: var(--band-gradient);
  stroke: var(--chart-bg);
  stroke-width: .75;
}
:root:not([data-theme="dark"]) .horizon-chart .band-1 { --band-lightness: .61; --band-chroma: .15; }
:root:not([data-theme="dark"]) .horizon-chart .band-2 { --band-lightness: .52; --band-chroma: .18; }
:root:not([data-theme="dark"]) .horizon-chart .band-3 { --band-lightness: .44; --band-chroma: .20; }
:root:not([data-theme="dark"]) .item-name,
:root:not([data-theme="dark"]) .item-secondary {
  background: #ffffff8c;
  padding: 0;
  text-shadow: none;
  color: #202c34;
  font-weight: 500;
}
:root:not([data-theme="dark"]) .item-name { font-weight: 600; }
@media(max-width:768px) {
  :root:not([data-theme="dark"]) .horizon-chart { opacity: 1; }
  :root:not([data-theme="dark"]) .item-hours {
    background: none;
    text-shadow: none;
  }
}

/* Keep labels, week markers, and bars on exactly the same columns. */
.app-footer { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; padding: 8px 24px; border-top: 1px solid var(--chart-border); background: var(--bg); color: var(--dim); font-size: 11px; }
.chart-help { position: relative; }
.chart-help summary { cursor: pointer; list-style: none; }
.chart-help summary::-webkit-details-marker { display: none; }
.chart-help summary:hover { color: var(--fg); }
.chart-help-body { position: absolute; right: 0; bottom: calc(100% + 16px); z-index: 5; width: min(340px, calc(100vw - 40px)); padding: 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--fg); font-size: 12px; line-height: 1.6; box-shadow: 0 8px 32px #0002; }
.chart-help-body p { margin-top: 12px; }
a.horizon-row:focus-visible { outline: 2px solid var(--chart-dim); outline-offset: -2px; }
.spotify-link:focus-visible, .horizon-row:focus-within .spotify-link { opacity: 1; }
@media (min-width: 769px) {
  .chart-wrapper { --label-width: 100px; --leading: 100px; --trailing: 84px; --columns: var(--label-width) minmax(0,1fr) 84px; }
  .chart-wrapper[data-view="albums"] { --label-width: 56px; --columns: 44px var(--label-width) minmax(0,1fr) 84px; }
  .chart-wrapper[data-view="songs"] { --label-width: 68px; --columns: 32px var(--label-width) minmax(0,1fr) 84px; }
  .column-headers, .horizon-row { display: grid; grid-template-columns: var(--columns); }
  .chart-content { padding: 8px 24px 16px; }
  .horizon-row { padding: 0; }
  .column-headers { padding: 8px 24px; }
  .col-name, .col-track, .col-hours { width: auto; }
  .col-hours { justify-content: flex-end; }
  [data-view="songs"] > .column-headers .col-hours { padding-right: 28px; }
  .item-label { width: auto; min-width: 0; padding-right: 16px; }
  .item-name, .item-secondary { max-width: 100%; padding-left: 0; background: none; overflow: hidden; text-overflow: ellipsis; }
  .item-label { overflow: visible; }
  .item-name, .item-secondary { max-width: min(420px, 45vw); width: max-content; }
  .horizon-chart { width: 100%; min-width: 0; }
  .album-meta, .song-meta { width: var(--trailing); margin: 0; padding-left: 12px; gap: 12px; }
  .item-hours { width: 60px; padding-left: 0; }
  .time-axis { padding: 6px 24px; }
  .time-axis .time-axis-spacer { width: var(--leading); }
  .time-axis .time-axis-end { width: var(--trailing); }
  .spotify-link { width: 16px; flex-shrink: 0; }
}
@media(max-width:768px) {
  .time-axis { padding: 8px 0; }
  .time-axis-spacer { width: 55px !important; }
  .horizon-chart { left: 55px; width: calc(100% - 115px) !important; }
  [data-view="artists"] .item-name,
  [data-view="artists"] .item-secondary { max-width: 100%; }
  .time-axis-labels { margin-right: 0; }
  .time-axis .time-axis-end { display: block; width: 60px; }
  .app-footer { display: none; }
}

/* Page context: a readable trail and quiet controls, without a toolbar panel. */
.listening-context {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px 32px;
  flex-shrink: 0;
  padding: 18px 24px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--chart-border);
  font-family: var(--font-sans);
  letter-spacing: -.011em;
}
.context-heading { min-width: 0; }
.listening-breadcrumb { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; line-height: 22px; }
.listening-breadcrumb .breadcrumb-link { padding: 0; color: var(--dim); overflow-wrap: anywhere; }
.listening-breadcrumb .breadcrumb-link:hover { color: var(--fg); }
.listening-breadcrumb .breadcrumb-sep { margin: 0; color: var(--muted); font-size: 11px; }
.listening-breadcrumb .breadcrumb-current { min-width: 0; color: var(--fg); font-weight: 500; overflow-wrap: anywhere; }
.context-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px 24px; }

.context-tools .sort-toggle { padding: 0; gap: 10px; border: 0; background: none; }
.context-tools .sort-label { padding: 0; font-size: 10px; color: var(--dim); }
.context-tools .sort-btn { padding: 0; min-height: 18px; border-radius: 0; background: none; color: var(--dim); font-size: 10px; line-height: 18px; }
.context-tools .sort-btn.active { background: none; box-shadow: none; color: var(--fg); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--dim); }
@media (min-width: 769px) {
  /* Match the Books and Links content inset from the viewport's left edge. */
  .listening-context, .time-axis, .chart-content { padding-left: 64px; }
  .listening-context {
    padding-top: 16px;
    padding-right: calc(24px + var(--trailing));
  }
  .context-tools { flex-wrap: nowrap; gap: 24px; }
}
@media (max-width: 768px) {
  .listening-context { gap: 12px 16px; padding: 14px 24px 16px; }
  .context-tools { flex-direction: column; align-items: flex-end; gap: 6px; }

  .context-tools .sort-toggle { gap: 8px; }
  .context-tools .sort-label { display: none; }
}
@media (max-width: 480px) {
  .listening-context { padding-inline: 20px; }
  .listening-breadcrumb { gap: 2px 8px; font-size: 12px; line-height: 20px; }

}

/* YouTube source share (local --youtube builds) */
:root { --youtube: #e5484d; }
[data-theme="dark"] { --youtube: #ff6369; }
.album-type-badge.youtube { color: var(--youtube); }

/* Chart grid: year rules on every row, so years line up across rows */
.horizon-chart .chart-grid line { stroke: var(--chart-border); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* Mobile rows: a header line (art or track #, name · plays, hours) above a full-width chart,
   so labels never cover the early years and every chart shares the time axis.
   At ~1.2px per week, hairline gaps would erase the bars, and the minimum bar height
   (baked in for 20px desktop charts) is scaled back down to ~2.5px. */
@media (max-width: 768px) {
  :root .horizon-chart rect,
  :root:not([data-theme="dark"]) .horizon-chart rect,
  [data-theme="dark"] .horizon-chart rect { stroke: none; }
  .horizon-chart rect.floor { transform: scaleY(.7); transform-box: fill-box; transform-origin: bottom; }
  :root .horizon-row,
  :root .horizon-row.album-row {
    display: grid !important; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto 30px;
    height: auto !important; padding: 7px 12px 6px !important; margin: 0; column-gap: 0; row-gap: 3px; align-items: center;
  }
  :root .horizon-chart {
    position: static !important; grid-column: 1 / -1; grid-row: 2;
    width: 100% !important; height: 30px !important; opacity: 1;
  }
  :root .album-art,
  :root .album-art-placeholder {
    grid-column: 1; grid-row: 1; width: 18px; height: 18px; margin: 0 8px 0 0; font-size: 10px;
  }
  :root .track-number {
    grid-column: 1; grid-row: 1; width: auto; min-width: 2ch; margin: 0 8px 0 0; text-align: right;
  }
  :root .item-label {
    grid-column: 2; grid-row: 1; flex-direction: row; align-items: baseline; justify-content: flex-start;
    gap: 8px; min-width: 0; overflow: hidden;
  }
  :root .item-label > * {
    max-width: none !important; width: auto !important; padding: 0 !important; margin: 0;
    background: none !important; text-shadow: none !important; flex-shrink: 1; min-width: 0;
  }
  :root .item-name { flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; }
  :root .item-secondary,
  :root .play-count { flex-shrink: 0; }
  :root .album-meta,
  :root .song-meta {
    position: static !important; grid-column: 3; grid-row: 1; padding: 0 0 0 12px; width: auto;
  }
  :root .item-hours { background: none; padding: 0; text-shadow: none; }
  :root .time-axis { padding: 8px 12px; }
  :root .time-axis-spacer { width: 0 !important; }
  :root .time-axis-labels { margin-right: 0; }
  :root .time-axis .time-axis-end { display: none; }
  /* Edge years: anchor the label inside the chart instead of centring it on the edge */
  :root .year-mark:first-child { transform: none; }
  :root .year-mark:first-child::before { left: 0; transform: none; }
  :root .year-mark:last-child { transform: translateX(-100%); }
  :root .year-mark:last-child::before { left: 100%; transform: translateX(-1px); }
}
