:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text-primary: #111318;
  --text-secondary: #737780;
  --text-tertiary: #a4a7ad;
  --line: #e8e7e4;
  --line-strong: #d9d8d4;
  --hover: #f3f2ef;
  --active: #ecebe8;
  --shadow: 0 14px 45px rgba(17, 19, 24, .09);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text-primary); font-family: var(--sans); font-size: 15px; }
button, input { color: inherit; font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 3px; }
a { color: inherit; }
[hidden] { display: none !important; }

.app-shell { max-width: 1440px; margin: 0 auto; padding: 0 36px 72px; }
.app-header { min-height: 72px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.wordmark { font-size: 20px; font-weight: 500; letter-spacing: .23em; text-decoration: none; white-space: nowrap; }
.header-tools { display: flex; align-items: center; justify-content: flex-end; gap: 14px; min-width: 0; }
.header-control, .density-control { min-height: 44px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.42); display: inline-flex; align-items: center; }
.header-control { gap: 12px; padding: 0 14px; color: var(--text-secondary); min-width: 290px; text-align: left; }
.import-control { position: relative; cursor: pointer; min-width: 205px; }
.import-control input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.import-status { max-width: 150px; overflow: hidden; color: var(--text-secondary); font: 11px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.import-status.is-error { color: #9a4e45; }
.header-control svg, .search-field svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: 0 0 auto; }
.header-control span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.header-control:hover, .density-control:hover { background: var(--surface); border-color: var(--line-strong); }
.density-control { border-radius: 24px; padding: 3px; gap: 0; }
.density-control button { min-height: 36px; border: 0; border-radius: 19px; padding: 0 15px; background: transparent; color: var(--text-secondary); font-size: 13px; }
.density-control button.is-active { color: var(--surface); background: #292b2d; }
.primary-nav { height: 64px; display: flex; align-items: center; gap: 38px; border-bottom: 1px solid var(--line); }
.primary-nav a { height: 64px; display: inline-flex; align-items: center; position: relative; color: var(--text-secondary); font-size: 14px; text-decoration: none; }
.primary-nav a.is-active { color: var(--text-primary); font-weight: 600; }
.primary-nav a.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text-primary); }

.library-layout { display: grid; grid-template-columns: 126px minmax(0, 820px); gap: 44px; align-items: start; padding-top: 44px; }
.date-rail { position: sticky; top: 22px; max-height: calc(100vh - 44px); overflow: auto; padding: 0 0 14px; scrollbar-width: thin; }
.rail-month { margin: 0 0 14px; color: var(--text-secondary); font: 600 12px var(--mono); letter-spacing: .06em; }
.rail-day { width: 100%; min-height: 36px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 6px; background: transparent; padding: 0 12px; color: var(--text-secondary); text-align: left; font-size: 15px; }
.rail-day:hover:not(:disabled) { background: var(--hover); color: var(--text-primary); }
.rail-day.is-active { background: var(--active); color: var(--text-primary); font-weight: 600; }
.rail-day.is-muted { color: var(--text-tertiary); }
.rail-day i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-primary); margin-left: auto; }
.rail-empty { color: var(--text-tertiary); font-size: 13px; }
.history-column { min-width: 0; }
.inline-message { min-height: 18px; color: var(--text-secondary); font-size: 12px; margin-bottom: 12px; }
.inline-message.is-error { color: #9a4e45; }
.day-section { scroll-margin-top: 24px; padding: 12px 0 48px; border-bottom: 1px solid var(--line); }
.day-section + .day-section { padding-top: 42px; }
.day-header { display: grid; grid-template-columns: 74px 1fr; gap: 18px; align-items: start; margin-bottom: 30px; }
.day-number { font-size: 54px; line-height: .86; letter-spacing: -.06em; font-weight: 500; }
.day-header p { margin: 2px 0 8px; color: var(--text-secondary); font-size: 13px; letter-spacing: .13em; font-weight: 600; }
.day-header span { color: var(--text-secondary); font: 12px var(--mono); letter-spacing: .08em; }
.timeline { position: relative; --time-col: 64px; --axis-col: 24px; }
.timeline::before { content: ""; position: absolute; top: 19px; bottom: 21px; left: calc(var(--time-col) + (var(--axis-col) / 2)); width: 1px; background: var(--line-strong); }
.timeline-item { display: grid; grid-template-columns: var(--time-col) var(--axis-col) minmax(0, 1fr); gap: 0; min-width: 0; position: relative; }
.timeline-time { padding-top: 8px; padding-right: 12px; color: var(--text-secondary); font: 13px var(--mono); text-align: left; white-space: nowrap; }
.timeline-axis { position: relative; display: flex; justify-content: center; padding-top: 13px; z-index: 1; }
.timeline-axis i { display: block; width: 8px; height: 8px; border: 2px solid var(--bg); border-radius: 50%; background: #888b91; box-shadow: 0 0 0 1px #888b91; }
.track-body { min-width: 0; display: flex; align-items: center; gap: 16px; padding: 5px 0 11px; }
.track-copy, .ranking-copy { min-width: 0; }
.track-copy strong, .track-copy span, .track-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-copy strong { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.track-copy span { margin-top: 4px; color: var(--text-secondary); font-size: 14px; }
.track-copy small { margin-top: 5px; color: var(--text-tertiary); font-size: 11px; }
.artwork { width: 56px; height: 56px; flex: 0 0 auto; position: relative; display: inline-grid; place-items: center; overflow: hidden; border-radius: 5px; background: #e5e4e0; color: #8d8e8b; }
.artwork img { display: block; width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
.artwork-small { width: 34px; height: 34px; border-radius: 4px; }
.cluster-body { min-width: 0; display: flex; gap: 24px; padding: 5px 0 21px; }
.artwork-cluster { width: 120px; height: 120px; border-radius: 5px; }
.cluster-copy { min-width: 0; padding-top: 3px; }
.cluster-artist { margin: 0 0 3px; color: var(--text-secondary); font: 600 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.cluster-copy h3 { margin: 0 0 18px; font-size: 21px; font-weight: 500; letter-spacing: -.025em; }
.cluster-copy ol { margin: 0; padding: 0; list-style: none; }
.cluster-copy li { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 4px 0; font-size: 15px; }
.cluster-copy li time { color: var(--text-secondary); font: 13px var(--mono); }
.delete-event { border: 0; padding: 2px 4px; background: transparent; color: var(--text-tertiary); font: 18px/1 var(--sans); }
.delete-event:hover { color: #9a4e45; }
.track-body > .delete-event { margin-left: auto; }
.cluster-count { display: block; margin-top: 14px; color: var(--text-secondary); font: 13px var(--mono); }
.cluster-body.is-compact { align-items: flex-start; padding-bottom: 10px; gap: 13px; }
.cluster-body.is-compact .cluster-copy { padding-top: 0; }
.cluster-body.is-compact .cluster-artist { display: none; }
.cluster-body.is-compact .cluster-copy h3 { margin: 0 0 7px; font-size: 15px; }
.cluster-body.is-compact .cluster-copy li { grid-template-columns: 41px minmax(0, 1fr) auto; padding: 2px 0; font-size: 13px; }
.cluster-body.is-compact .cluster-count { margin-top: 6px; font-size: 11px; }
.track-body.is-compact { gap: 12px; padding: 3px 0 5px; min-height: 42px; }
.track-body.is-compact .track-copy strong { font-size: 14px; }
.track-body.is-compact .track-copy span { margin-top: 2px; font-size: 12px; }
.is-highlighted .track-body, .is-highlighted .cluster-body { background: var(--hover); border-radius: 5px; }

.top-page { padding-top: 54px; }
.top-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 66px; }
.top-heading h1 { margin: 0; font-size: clamp(32px, 4vw, 42px); line-height: 1; letter-spacing: .03em; font-weight: 500; }
.top-heading p { margin: 13px 0 0; color: var(--text-secondary); font-size: 16px; }
.top-heading p span { padding: 0 9px; color: var(--text-tertiary); }
.period-selector { display: flex; min-height: 44px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; flex: 0 0 auto; }
.period-selector button { min-width: 95px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--text-secondary); padding: 0 13px; font-size: 13px; }
.period-selector button:first-child { border-left: 0; }
.period-selector button:hover { background: var(--hover); }
.period-selector button.is-active { background: #292b2d; color: var(--surface); }
.ranking-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.ranking-section { min-width: 0; padding: 0 32px; border-left: 1px solid var(--line); }
.ranking-section:first-child { border-left: 0; padding-left: 0; }
.ranking-section:last-child { padding-right: 0; }
.ranking-header { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.ranking-header h2 { margin: 0; font-size: 14px; letter-spacing: .19em; text-transform: uppercase; font-weight: 600; }
.view-all { border: 0; padding: 0; background: transparent; color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.view-all:hover { color: var(--text-primary); }
.view-all span { margin-left: 4px; font-size: 16px; }
.ranking-list { display: grid; gap: 3px; }
.ranking-row { min-height: 78px; display: grid; grid-template-columns: 20px 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.rank { color: var(--text-secondary); font-size: 14px; }
.ranking-copy strong, .ranking-copy span, .ranking-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-copy strong { font-size: 16px; font-weight: 600; }
.ranking-copy span { margin-top: 4px; color: var(--text-secondary); font-size: 14px; }
.ranking-copy small { margin-top: 4px; color: var(--text-secondary); font-size: 12px; }
.ranking-count { color: var(--text-secondary); font: 13px var(--mono); white-space: nowrap; }
.artwork-artist { border-radius: 50%; }
.empty-inline { color: var(--text-secondary); font-size: 14px; }

.loading-state, .error-state, .empty-state { max-width: 680px; padding: 88px 0; }
.loading-state p, .error-state p, .empty-state p:not(.eyebrow) { color: var(--text-secondary); font-size: 15px; }
.loading-line { display: block; width: 100%; height: 15px; margin: 0 0 16px; border-radius: 4px; background: var(--active); animation: pulse 1.4s ease-in-out infinite alternate; }
.loading-line.short { width: 42%; height: 44px; }.loading-line.compact { width: 62%; height: 12px; }
.eyebrow { margin: 0; color: var(--text-secondary); font: 600 12px var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.empty-state h1, .error-state h1 { margin: 13px 0 8px; font-size: 32px; font-weight: 500; letter-spacing: -.04em; }
.text-button { border: 0; border-bottom: 1px solid currentColor; padding: 0 0 3px; background: transparent; color: var(--text-primary); font-size: 14px; }
@keyframes pulse { to { opacity: .45; } }
.history-sentinel { height: 1px; }

.overlay { position: fixed; z-index: 10; inset: 0; display: grid; place-items: start center; padding: 90px 20px 20px; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(17, 19, 24, .2); backdrop-filter: blur(3px); }
.search-dialog { position: relative; width: min(620px, 100%); max-height: min(720px, calc(100vh - 110px)); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); padding: 25px; }
.search-dialog-head, .jump-popover-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.search-dialog h2 { margin: 8px 0 22px; font-size: 25px; font-weight: 500; letter-spacing: -.03em; }
.icon-button { width: 32px; height: 32px; border: 0; background: transparent; color: var(--text-secondary); font-size: 25px; line-height: 1; }
.search-field { height: 50px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 13px; color: var(--text-secondary); }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text-primary); font-size: 16px; }
kbd { color: var(--text-tertiary); font: 11px var(--mono); }
.search-results { display: grid; margin-top: 16px; }
.search-result { display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 12px; align-items: center; border: 0; border-top: 1px solid var(--line); background: transparent; padding: 12px 0; text-align: left; }
.search-result:hover { background: var(--hover); }
.artwork-search { width: 40px; height: 40px; }
.search-result-copy strong, .search-result-copy span, .search-result-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-copy strong { font-size: 14px; }.search-result-copy span { margin-top: 3px; color: var(--text-secondary); font-size: 12px; }.search-result-copy small { margin-top: 4px; color: var(--text-tertiary); font: 11px var(--mono); }
.search-arrow { color: var(--text-secondary); }
.jump-popover { position: fixed; z-index: 11; top: 68px; right: max(36px, calc((100vw - 1368px) / 2)); width: 260px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); padding: 17px; }
.date-field { display: grid; gap: 7px; margin-top: 17px; color: var(--text-secondary); font-size: 12px; }
.date-field input { width: 100%; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--bg); padding: 9px; font-size: 14px; }
.popover-note { margin: 13px 0 0; color: var(--text-tertiary); font-size: 12px; line-height: 1.45; }

@media (max-width: 1100px) {
  .app-shell { padding-left: 24px; padding-right: 24px; }
  .header-control { min-width: 0; }.header-control:first-child { width: 230px; }.header-control span { font-size: 13px; }
  .library-layout { grid-template-columns: 100px minmax(0, 760px); gap: 28px; }
  .ranking-section { padding-left: 22px; padding-right: 22px; }.ranking-row { grid-template-columns: 18px 50px minmax(0, 1fr); }.ranking-row .ranking-count { grid-column: 3; margin-top: -13px; }
  .period-selector button { min-width: 78px; padding: 0 8px; }
}

@media (max-width: 780px) {
  .app-shell { padding: 0 16px 48px; }.app-header { min-height: 64px; }.wordmark { font-size: 17px; }.header-tools { gap: 7px; }.header-control { min-width: 42px !important; width: 42px !important; justify-content: center; padding: 0; }.header-control span { display: none; }.density-control { display: none; }.import-status { display: none; }
  .primary-nav { height: 52px; gap: 26px; }.primary-nav a { height: 52px; }
  .library-layout { display: block; padding-top: 25px; }.date-rail { display: flex; position: sticky; top: 0; z-index: 2; gap: 5px; max-height: none; overflow-x: auto; overflow-y: hidden; margin: -25px -16px 24px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); }.rail-month { display: none; }.rail-day { width: auto; min-width: 34px; min-height: 32px; justify-content: center; padding: 0 9px; }.rail-day i { display: none; }.rail-day.is-active { min-width: 50px; }
  .day-section { padding-bottom: 34px; }.day-section + .day-section { padding-top: 32px; }.day-header { grid-template-columns: 56px 1fr; gap: 14px; margin-bottom: 22px; }.day-number { font-size: 45px; }.day-header p { font-size: 11px; letter-spacing: .1em; }
  .timeline { --time-col: 52px; --axis-col: 18px; }.track-body { gap: 11px; }.track-copy strong { font-size: 15px; }.track-copy span { font-size: 13px; }.artwork { width: 48px; height: 48px; }.cluster-body { gap: 14px; }.artwork-cluster { width: 88px; height: 88px; }.cluster-copy h3 { font-size: 17px; margin-bottom: 11px; }.cluster-copy li { grid-template-columns: 39px minmax(0,1fr) auto; font-size: 13px; }.cluster-artist { font-size: 10px; }.cluster-count { font-size: 11px; margin-top: 10px; }
  .top-page { padding-top: 32px; }.top-heading { display: block; margin-bottom: 38px; }.top-heading h1 { font-size: 29px; line-height: 1.1; }.top-heading p { font-size: 14px; }.period-selector { width: 100%; margin-top: 24px; overflow-x: auto; }.period-selector button { flex: 1 0 auto; min-width: 0; font-size: 12px; }
  .ranking-grid { display: block; }.ranking-section, .ranking-section:first-child, .ranking-section:last-child { border-left: 0; border-top: 1px solid var(--line); padding: 28px 0; }.ranking-section:first-child { border-top: 0; }.ranking-row { grid-template-columns: 20px 48px minmax(0,1fr) auto; }.ranking-row .ranking-count { grid-column: auto; margin-top: 0; }.ranking-copy strong { font-size: 15px; }
  .jump-popover { top: 60px; right: 16px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
