:root {
  color-scheme: light;
  --background: #efede5;
  --surface: #f9f8f3;
  --text: #1c1c19;
  --muted: #716e66;
  --line: #c9c6bc;
  --line-dark: #8e8a80;
  --rule-strong: #1c1c19;
  --book: #5c6d60;
  --movie: #7a5149;
  --music: #526574;
  --success: #5c6d60;
  --danger: #7a5149;
  --review-text: #4f4d47;
  --empty-star: #c7c3b9;
  --placeholder: #827f76;
  --paper-rule: rgb(28 28 25 / 2%);
  --card-background: rgb(249 248 243 / 72%);
  --card-hover-background: rgb(249 248 243 / 55%);
  --empty-background: rgb(249 248 243 / 50%);
  --panel-background: rgb(249 248 243 / 48%);
  --control-background: transparent;
  --control-focus-background: rgb(255 255 255 / 35%);
  --autofill-background: #f3f0e6;
  --tmdb-background: rgb(122 81 73 / 5%);
  --overlay: rgb(28 28 25 / 42%);
  --menu-shadow: rgb(28 28 25 / 10%);
  --button-filled-background: var(--text);
  --button-filled-text: var(--surface);
  --logo-filter: none;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --serif: Georgia, "Songti SC", "STSong", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #181816;
    --surface: #22221f;
    --text: #e8e3d7;
    --muted: #aaa59a;
    --line: #353530;
    --line-dark: #56544d;
    --rule-strong: #77736a;
    --book: #98ae9d;
    --movie: #c69286;
    --music: #8da9bd;
    --success: #9bb59f;
    --danger: #d18f83;
    --review-text: #cbc6ba;
    --empty-star: #5e5b54;
    --placeholder: #7f7b72;
    --paper-rule: rgb(232 227 215 / 3.5%);
    --card-background: transparent;
    --card-hover-background: rgb(46 45 41 / 72%);
    --empty-background: rgb(34 34 31 / 60%);
    --panel-background: rgb(34 34 31 / 58%);
    --control-background: transparent;
    --control-focus-background: rgb(232 227 215 / 7%);
    --autofill-background: #2b2a26;
    --tmdb-background: rgb(198 146 134 / 8%);
    --overlay: rgb(8 8 7 / 68%);
    --menu-shadow: rgb(8 8 7 / 24%);
    --button-filled-background: var(--text);
    --button-filled-text: var(--surface);
    --logo-filter: brightness(0) saturate(100%) invert(91%) sepia(10%) saturate(245%) hue-rotate(354deg) brightness(100%) contrast(85%);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background-color: var(--background);
  background-image: linear-gradient(var(--paper-rule) 1px, transparent 1px);
  background-size: 100% 6px;
  font-family: var(--sans);
}

button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  padding: 28px 0 38px;
  border-top: 2px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
}

.eyebrow, .section-kicker, .archive-mark, .empty-code,
.page-footer, .archive-number, .card-label, .record-date {
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow, .section-kicker {
  margin: 0 0 12px;
  font-size: 0.69rem;
  font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 13px;
  font-family: var(--serif);
  font-size: clamp(3rem, 8vw, 6.4rem);
  font-weight: 400;
  letter-spacing: -0.065em;
  line-height: 0.95;
}

.site-title-logo {
  display: none;
  width: clamp(360px, 46vw, 600px);
  max-width: 100%;
  height: auto;
  filter: var(--logo-filter);
}

.site-title-logo-ready .site-title-logo { display: block; }

.site-title-logo-ready .site-title-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.is-subpage .site-title-logo {
  width: clamp(170px, 20vw, 260px);
}

.intro {
  margin: 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.03rem;
}

.archive-mark {
  display: grid;
  flex: 0 0 112px;
  width: 112px;
  min-width: 112px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  padding: 14px;
  place-content: center;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  text-align: center;
  font-size: 0.55rem;
  line-height: 1.5;
  transform: rotate(4deg);
}

.archive-mark strong { font-size: 1rem; letter-spacing: 0.04em; }
.records-section { padding: 58px 0 64px; }

.records-header, .section-heading, .form-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.records-header { margin-bottom: 28px; }

.collection-tools {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.search-form {
  display: flex;
  width: min(390px, 100%);
  border-bottom: 1px solid var(--text);
}

.search-form input {
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 0.78rem;
}

.search-form button {
  border: 0;
  padding: 0 7px;
  color: var(--text);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
}

.search-form button:hover { color: var(--muted); }

h2 {
  margin-bottom: 0;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  font-weight: 400;
  letter-spacing: -0.035em;
}

.collection-count {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 0.75rem;
  vertical-align: 8px;
}

.collection-count::before { content: "("; }
.collection-count::after { content: ")"; }

.collection-root-link,
.category-root-link {
  color: inherit;
  text-decoration: none;
}

.collection-root-link:hover,
.category-root-link[href]:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.category-scope {
  display: flex;
  align-items: baseline;
  gap: 15px;
  margin-top: 2px;
}

.category-name {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.61rem;
  letter-spacing: 0.08em;
}

.category-root-link {
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.category-root-link .collection-count {
  font-size: 0.62rem;
  vertical-align: 4px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--line-dark);
}

.filter-button {
  min-width: 68px;
  border: 0;
  border-right: 1px solid var(--line-dark);
  padding: 9px 15px;
  color: var(--muted);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.72rem;
  transition: color 140ms ease, background 140ms ease;
}

.filter-button:last-child { border-right: 0; }

.filter-button:hover, .filter-button.active {
  color: var(--button-filled-text);
  background: var(--button-filled-background);
}

.records-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--text);
  border-left: 1px solid var(--text);
}

.record-card {
  position: relative;
  display: flex;
  min-height: 370px;
  padding: 24px 24px 20px;
  flex-direction: column;
  border-right: 1px solid var(--text);
  border-bottom: 1px solid var(--text);
  background: var(--card-background);
  transition: background 160ms ease;
}

.record-cover-link {
  display: block;
  color: inherit;
}

.record-title-link {
  color: inherit;
  text-decoration: none;
}

.record-title-link:hover { text-decoration: underline; text-underline-offset: 4px; }

.record-card .record-cover { margin-top: 0; }

.record-card .card-main {
  padding: 20px 0 4px;
}

.record-card .record-title {
  margin-bottom: 7px;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.record-card .record-creator { font-size: 0.8rem; }

.result-context {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 17px;
  border-top: 1px solid var(--line);
}

.result-context[hidden] { display: none; }
.result-context .section-kicker { margin-bottom: 7px; }

.result-heading h3 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.result-summary {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.active-tag-actions button {
  border: 0;
  min-height: 36px;
  padding: 7px 2px;
  color: var(--muted);
  background: transparent;
  font-size: 0.68rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.detail-view {
  padding: 48px 0 72px;
}

.detail-view[hidden] { display: none; }

.detail-back {
  display: inline-block;
  margin-bottom: 30px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.05em;
  text-decoration: none;
}

.detail-back:hover { color: var(--text); }

.detail-layout {
  display: grid;
  grid-template-columns: minmax(240px, 390px) minmax(0, 1fr);
  gap: clamp(38px, 7vw, 92px);
  align-items: start;
}

.detail-cover-column { min-width: 0; }

.detail-cover {
  width: 100%;
  margin: 0;
}

.detail-content {
  min-width: 0;
  padding-top: 8px;
}

.detail-type {
  margin: 0 0 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}

.detail-title {
  margin-bottom: 13px;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 6vw, 5.6rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.detail-creator {
  margin-bottom: 42px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.detail-secondary {
  display: grid;
  gap: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--rule-strong);
}

.detail-meta-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.detail-meta-block { min-width: 0; }

.detail-label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.59rem;
  letter-spacing: 0.07em;
}

.detail-value {
  margin: 0;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.7;
}

.detail-stars { font-size: 0.8rem; letter-spacing: 0.16em; }

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.detail-tag {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.67rem;
  text-decoration: none;
}

.detail-tag::before { content: "#"; }
.detail-tag:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.detail-review {
  max-width: 700px;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.9;
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.detail-action {
  border: 1px solid var(--text);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--text);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

a[href],
#account-email,
.upload-button {
  cursor: pointer;
}

.active-tag-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.45;
}

.detail-action:hover { color: var(--button-filled-text); background: var(--button-filled-background); }
.detail-action.delete { border-color: var(--danger); color: var(--danger); }
.detail-action.delete:hover { color: var(--button-filled-text); background: var(--danger); }

.detail-missing {
  padding: 80px 20px;
  border: 1px solid var(--rule-strong);
  text-align: center;
}

.record-card:hover { background: var(--card-hover-background); }

.record-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: var(--card-accent);
  content: "";
}

.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.archive-number, .card-label, .record-date {
  color: var(--muted);
  font-size: 0.63rem;
  line-height: 1.5;
}

.archive-number { color: var(--text); font-weight: 700; }

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}

.type-badge::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--card-accent);
  content: "";
}

.card-main { padding: 30px 0 24px; }

.record-cover,
.cover-preview,
.candidate-image-wrap {
  position: relative;
  display: grid;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--line-dark);
  background:
    linear-gradient(135deg, transparent 49.5%, var(--line) 49.7%, var(--line) 50.3%, transparent 50.5%),
    linear-gradient(45deg, transparent 49.5%, var(--line) 49.7%, var(--line) 50.3%, transparent 50.5%),
    var(--background);
}

.record-cover {
  width: 100%;
  margin-top: 22px;
}

.ratio-poster { aspect-ratio: 2 / 3; }
.ratio-square { aspect-ratio: 1; }

.record-cover img,
.cover-preview img,
.candidate-image-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.cover-placeholder-code {
  position: relative;
  padding: 5px 7px;
  color: var(--muted);
  background: var(--background);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

.record-title {
  margin-bottom: 9px;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 2.4vw, 2.05rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.22;
}

.record-creator { margin-bottom: 0; color: var(--muted); font-size: 0.85rem; }

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin: 14px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.03em;
}

.record-tag::before { content: "#"; }

.rating-row {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.stars { color: var(--text); font-size: 0.7rem; letter-spacing: 0.15em; }
.empty-star { color: var(--empty-star); }

.record-review {
  margin: auto 0 0;
  color: var(--review-text);
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.card-menu {
  position: absolute;
  z-index: 3;
  top: 15px;
  right: 13px;
}

.card-menu summary::-webkit-details-marker { display: none; }

.card-menu-trigger {
  display: grid;
  width: 34px;
  height: 28px;
  place-items: center;
  list-style: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  user-select: none;
}

.card-menu-trigger:hover,
.card-menu[open] .card-menu-trigger { color: var(--text); }

.card-menu-panel {
  position: absolute;
  top: 30px;
  right: 0;
  display: grid;
  width: 132px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  box-shadow: 5px 5px 0 var(--menu-shadow);
}

.card-menu-item {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 13px;
  color: var(--text);
  background: transparent;
  font-size: 0.75rem;
  text-align: left;
}

.card-menu-item:last-child { border-bottom: 0; }
.card-menu-item:hover { background: var(--background); }
.card-menu-item.delete:hover { color: var(--danger); }

.card-topline { padding-right: 48px; }

.empty-state {
  padding: 84px 24px;
  border: 1px solid var(--rule-strong);
  text-align: center;
  background: var(--empty-background);
}

.empty-state[hidden] { display: none; }

.empty-code {
  display: block;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.65rem;
}

.empty-state h3 {
  margin-bottom: 10px;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 400;
}

.empty-state p { margin-bottom: 0; color: var(--muted); font-size: 0.88rem; }

.entry-panel {
  margin-top: 12px;
  border-top: 2px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  background: var(--panel-background);
}

.entry-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  padding: 0 4px;
  list-style: none;
}

.entry-panel summary::-webkit-details-marker { display: none; }
.summary-label { font-family: var(--serif); font-size: 1.5rem; }

.summary-action {
  font-family: var(--mono);
  font-size: 1.5rem;
  transition: transform 180ms ease;
}

.entry-panel[open] .summary-action { transform: rotate(45deg); }

.form-panel {
  padding: 42px 4px 48px;
  border-top: 1px solid var(--line-dark);
}

.required-note, .form-message {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.04em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 25px 30px;
  margin-top: 36px;
}

.field { display: flex; flex-direction: column; gap: 9px; }
.field-wide, .field-full { grid-column: 1 / -1; }

.field span {
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cover-field {
  min-width: 0;
  margin: 8px 0 4px;
  padding: 24px 0 0;
  border: 0;
  border-top: 1px solid var(--line-dark);
}

.cover-field legend,
.tmdb-settings label {
  padding: 0;
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cover-picker {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  margin-top: 18px;
}

.cover-preview { width: 150px; }

.cover-controls {
  padding-top: 4px;
}

.cover-help,
.tmdb-settings p,
.cover-status {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.65;
}

.cover-help { max-width: 520px; margin-bottom: 18px; }
.music-artist-search-field { max-width: 420px; margin-bottom: 18px; }
.cover-status { min-height: 1.4em; margin: 13px 0 0; }
.cover-status.error { color: var(--danger); }
.cover-status.success { color: var(--success); }

.cover-actions,
.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.secondary-button,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  border: 1px solid var(--text);
  padding: 8px 14px;
  color: var(--text);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: color 140ms ease, background 140ms ease;
}

.secondary-button:hover,
.upload-button:hover {
  color: var(--button-filled-text);
  background: var(--button-filled-background);
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.text-button {
  border: 0;
  padding: 7px 2px;
  color: var(--muted);
  background: transparent;
  font-size: 0.75rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:hover { color: var(--text); }

.tmdb-settings {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--movie);
  background: var(--tmdb-background);
}

.token-row { margin-top: 12px; }
.token-row input { flex: 1 1 320px; }
.tmdb-settings p { margin: 10px 0 0; }

.cover-results-panel {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line-dark);
}

.cover-results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.cover-results-heading h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 400;
}

.cover-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--rule-strong);
  border-left: 1px solid var(--rule-strong);
}

.cover-candidate {
  display: flex;
  min-width: 0;
  padding: 13px;
  flex-direction: column;
  border: 0;
  border-right: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  color: var(--text);
  background: var(--surface);
  text-align: left;
}

.cover-candidate:hover,
.cover-candidate.selected {
  outline: 3px solid var(--text);
  outline-offset: -3px;
}

.candidate-image-wrap { width: 100%; margin-bottom: 12px; }
.candidate-title { margin-bottom: 5px; font-family: var(--serif); font-size: 0.92rem; line-height: 1.3; }
.candidate-meta { margin-top: auto; color: var(--muted); font-size: 0.68rem; line-height: 1.45; }
.candidate-source { margin-top: 9px; font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.05em; }

input, select, textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-dark);
  border-radius: 0;
  outline: none;
  color: var(--text);
  background: var(--control-background);
  caret-color: var(--text);
  transition: border-color 140ms ease, background 140ms ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

select option {
  color: var(--text);
  background: var(--surface);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--autofill-background) inset;
}

input, select { min-height: 48px; padding: 0 8px; }
textarea { min-height: 105px; padding: 12px 8px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--text);
  background: var(--control-focus-background);
}

.form-actions { margin-top: 30px; }
.submit-actions { display: flex; align-items: center; gap: 18px; }
.form-message { min-height: 1.2em; margin-bottom: 0; }
.form-message.success { color: var(--success); }
.form-message.error { color: var(--danger); }

.primary-button {
  flex: 0 0 auto;
  min-width: 145px;
  border: 1px solid var(--text);
  border-radius: 0;
  padding: 13px 22px;
  color: var(--button-filled-text);
  background: var(--button-filled-background);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: color 140ms ease, background 140ms ease;
}

.primary-button:hover { color: var(--text); background: transparent; }

.page-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 70px;
  padding: 18px 0;
  border-top: 1px solid var(--rule-strong);
  color: var(--muted);
  font-size: 0.57rem;
}

.api-credit {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.5;
  text-align: right;
}

@media (max-width: 860px) {
  .records-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cover-results { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: minmax(210px, 34vw) minmax(0, 1fr); gap: 38px; }
  .detail-title { font-size: clamp(2.4rem, 7vw, 4.2rem); }
}

@media (max-width: 640px) {
  .page-shell { width: min(100% - 24px, 1180px); padding-top: 24px; }
  .page-header { padding-top: 20px; }
  .archive-mark { display: none; }
  .records-header, .section-heading, .form-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .collection-tools { width: 100%; justify-items: stretch; }
  .search-form { width: 100%; }
  .filters { display: grid; grid-template-columns: repeat(4, 1fr); }
  .filter-button { min-width: 0; padding-inline: 8px; }
  .records-grid, .form-grid { grid-template-columns: 1fr; }
  .record-card { min-height: 340px; }
  .primary-button { width: 100%; }
  .cover-picker { grid-template-columns: 110px minmax(0, 1fr); gap: 18px; }
  .cover-preview { width: 110px; }
  .cover-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-view { padding-top: 30px; }
  .detail-layout { grid-template-columns: 1fr; gap: 30px; }
  .detail-cover-column { width: min(82vw, 360px); margin: 0 auto; }
  .detail-content { padding-top: 0; }
  .detail-title { font-size: clamp(2.45rem, 13vw, 4rem); }
  .detail-creator { margin-bottom: 30px; }
  .detail-meta-row { grid-template-columns: 1fr; gap: 22px; }
}

/* Compact library and detail proportions */
h1,
h2,
.intro,
.summary-label,
.record-title,
.detail-title,
.detail-creator,
.detail-value,
.detail-review {
  font-family: var(--sans);
}

.records-grid {
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px;
  align-items: start;
  border: 0;
}

.record-card {
  min-height: 0;
  padding: 11px 11px 14px;
  border: 1px solid var(--line-dark);
  background: transparent;
}

.record-card:hover { background: var(--card-hover-background); }
.record-card::before { display: none; }

.record-card .card-main {
  padding: 13px 2px 1px;
}

.record-card .record-title {
  margin-bottom: 5px;
  font-size: clamp(1rem, 1.5vw, 1.18rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.record-card .record-creator {
  font-size: 0.72rem;
  line-height: 1.4;
}

.detail-view {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 26px 0 54px;
}

.detail-back {
  margin: 0 0 24px -7px;
  padding: 10px 7px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
}

.detail-layout {
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
  gap: clamp(38px, 6vw, 68px);
}

.detail-content { padding-top: 2px; }

.detail-type {
  margin-bottom: 13px;
  font-size: 0.61rem;
}

.detail-title {
  margin-bottom: 9px;
  font-size: clamp(2.25rem, 4.3vw, 3.45rem);
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1.02;
}

.detail-creator {
  margin-bottom: 30px;
  font-size: clamp(0.95rem, 1.7vw, 1.16rem);
  font-weight: 400;
}

.detail-secondary {
  gap: 21px;
  padding-top: 20px;
}

.detail-meta-row { gap: 18px; }
.detail-label { margin-bottom: 7px; }

.detail-value {
  font-size: 0.9rem;
  line-height: 1.6;
}

.detail-review {
  font-size: 0.94rem;
  line-height: 1.75;
}

.detail-actions {
  margin-top: 30px;
  padding-top: 17px;
}

body:has(#detail-view:not([hidden])) .page-shell {
  padding-top: 22px;
}

body:has(#detail-view:not([hidden])) .page-header {
  padding: 16px 0 19px;
}

body:has(#detail-view:not([hidden])) .page-header h1 {
  margin-bottom: 7px;
  font-size: clamp(2rem, 4vw, 2.7rem);
  letter-spacing: -0.045em;
  line-height: 1;
}

body:has(#detail-view:not([hidden])) .page-header .eyebrow {
  margin-bottom: 7px;
  font-size: 0.59rem;
}

body:has(#detail-view:not([hidden])) .page-header .intro {
  font-family: var(--sans);
  font-size: 0.82rem;
}

body:has(#detail-view:not([hidden])) .archive-mark {
  display: none;
}

@media (min-width: 641px) and (max-width: 960px) {
  body.is-subpage .site-title-logo { width: min(30vw, 240px); }

  .records-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 13px;
  }

  .detail-view { width: min(760px, 100%); }

  .detail-layout {
    grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
    gap: 34px;
  }

  .detail-title { font-size: clamp(2.15rem, 5.4vw, 3.15rem); }
}

@media (max-width: 640px) {
  .records-grid {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 12px;
  }

  .record-card {
    padding: 9px 9px 12px;
  }

  .record-card .card-main { padding-top: 12px; }

  .record-card .record-title {
    font-size: 1rem;
    line-height: 1.3;
  }

  .record-card .record-creator { font-size: 0.72rem; }

  .detail-view { padding: 14px 0 42px; }

  .detail-back {
    margin-bottom: 17px;
    padding-block: 11px;
  }

  .detail-layout {
    grid-template-columns: 1fr;
    gap: 25px;
  }

  .detail-cover-column {
    width: min(78vw, 310px);
  }

  .detail-title {
    font-size: clamp(2.05rem, 10.5vw, 3rem);
  }

  .detail-creator { margin-bottom: 25px; }
  .detail-secondary { gap: 19px; }

  body:has(#detail-view:not([hidden])) .page-header {
    padding: 12px 0 15px;
  }

  body:has(#detail-view:not([hidden])) .page-header h1 {
    font-size: 1.85rem;
  }
}

/* Primary collection action and shared entry dialog */
.records-header {
  display: grid;
  align-items: initial;
  justify-content: stretch;
  gap: 20px;
}

.collection-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.collection-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 20px;
}

.collection-tools .filters { flex: 0 0 auto; }

.collection-tools .filter-button {
  min-width: 62px;
  padding: 8px 13px;
  font-size: 0.68rem;
}

.collection-tools .search-form {
  display: flex;
  width: 230px;
  min-height: 38px;
  align-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line-dark);
  transition: border-color 140ms ease;
}

.collection-tools .search-form:focus-within { border-color: var(--text); }

.search-icon {
  width: 15px;
  height: 15px;
  margin-left: 11px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 1.4;
}

.collection-tools .search-form input {
  min-height: 36px;
  padding: 0 10px 0 8px;
  border: 0;
  background: transparent;
  font-size: 0.75rem;
}

.new-record-button {
  min-height: 44px;
  border: 1px solid var(--text);
  padding: 10px 17px;
  color: var(--button-filled-text);
  background: var(--button-filled-background);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color 140ms ease, background 140ms ease;
}

.new-record-button:hover,
.new-record-button:focus-visible {
  color: var(--text);
  background: transparent;
}

body:has(#detail-view:not([hidden])) .new-record-button { display: none; }
body:has(.entry-dialog[open]) { overflow: hidden; }

.entry-dialog {
  width: min(820px, calc(100vw - 48px));
  max-width: none;
  max-height: min(88dvh, 900px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  color: var(--text);
  background: var(--surface);
}

.entry-dialog::backdrop { background: var(--overlay); }

.dialog-surface {
  display: flex;
  max-height: min(88dvh, 900px);
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding: 24px 28px 20px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line-dark);
  background: var(--surface);
}

.dialog-header .section-kicker { margin-bottom: 7px; font-size: 0.61rem; }
.dialog-header h2 { font-size: clamp(1.65rem, 3vw, 2.1rem); line-height: 1.05; }

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

.dialog-close-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-dark);
  padding: 0 0 3px;
  color: var(--text);
  background: transparent;
  font-family: var(--sans);
  font-size: 1.4rem;
  font-weight: 300;
  line-height: 1;
}

.dialog-close-button:hover,
.dialog-close-button:focus-visible { border-color: var(--text); background: var(--background); }

.entry-dialog .form-panel {
  padding: 0 28px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
}

.entry-dialog .form-grid { margin-top: 28px; }

.entry-dialog .form-actions {
  margin: 30px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
}

@media (min-width: 641px) and (max-width: 960px) {
  .archive-mark {
    width: 96px;
    min-width: 96px;
    flex-basis: 96px;
  }
  .entry-dialog { width: min(760px, calc(100vw - 40px)); }
}

@media (max-width: 640px) {
  .collection-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .collection-tools {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .collection-tools .search-form { width: 100%; }

  .new-record-button {
    width: auto;
    min-height: 46px;
    padding: 11px 16px;
    align-self: flex-start;
  }

  .entry-dialog {
    width: 100%;
    height: min(92dvh, 100%);
    max-height: 92dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
  }

  .dialog-surface { height: 100%; max-height: none; }

  .dialog-header {
    gap: 14px;
    padding: 17px 18px 14px;
  }

  .dialog-header h2 { font-size: 1.55rem; }

  .dialog-header-actions {
    align-items: flex-start;
    gap: 9px;
  }

  .dialog-header .required-note { display: none; }
  .dialog-close-button { width: 44px; height: 44px; }

  .entry-dialog .form-panel { padding: 0 18px 18px; }
  .entry-dialog .form-grid { margin-top: 23px; }

  .entry-dialog .form-actions {
    margin: 26px 0 0;
    padding: 0 0 env(safe-area-inset-bottom);
  }

  .entry-dialog .submit-actions {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(92px, 1fr) minmax(140px, 1.4fr);
    gap: 10px;
  }

  .entry-dialog .primary-button { width: auto; min-width: 0; }
  .entry-dialog .text-button { min-height: 44px; }
}

/* Supabase authentication */
.auth-view {
  display: grid;
  min-height: 100dvh;
  padding: 32px 20px;
  place-items: center;
}

.auth-panel {
  width: min(430px, 100%);
  padding: 34px 4px 30px;
  border-top: 2px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
}

.auth-heading { margin-bottom: 34px; }

.auth-heading h1 {
  margin-bottom: 12px;
  font-size: clamp(2.5rem, 10vw, 4.4rem);
}

.auth-heading > p:last-child,
.auth-note,
.auth-checking > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

.auth-form {
  display: grid;
  gap: 22px;
}

.auth-form .primary-button {
  width: 100%;
  margin-top: 2px;
}

.auth-message {
  min-height: 1.4em;
  margin: -6px 0 -4px;
  color: var(--danger);
  font-size: 0.75rem;
  line-height: 1.5;
}

.auth-note {
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.auth-checking { text-align: center; }

.header-meta {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.account-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.59rem;
  letter-spacing: 0.03em;
}

.account-status span {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status button {
  min-height: 32px;
  border: 1px solid var(--line-dark);
  padding: 5px 10px;
  color: var(--text);
  background: transparent;
  font-size: 0.64rem;
}

.account-status button:hover,
.account-status button:focus-visible { border-color: var(--text); }

@media (max-width: 640px) {
  .auth-view { padding: 20px 16px; }
  .auth-panel { padding-top: 28px; }
  .auth-heading { margin-bottom: 28px; }

  .header-meta {
    width: 100%;
    justify-items: start;
  }

  .account-status {
    width: 100%;
    justify-content: space-between;
  }

  .account-status span { max-width: calc(100vw - 110px); }
}

/* iPhone layout refinements */
@media (max-width: 640px) {
  .page-shell {
    width: calc(100% - 24px);
    padding-top: 16px;
  }

  .page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 16px 0 18px;
  }

  .identity-block {
    width: 100%;
    min-width: 0;
  }

  .page-header .eyebrow {
    margin-bottom: 8px;
    font-size: 0.6rem;
  }

  .page-header h1 {
    margin-bottom: 8px;
    font-size: clamp(2.35rem, 12vw, 3.25rem);
    line-height: 0.98;
    white-space: nowrap;
  }

  body.is-subpage .site-title-logo { width: min(48vw, 190px); }

  .page-header .intro { font-size: 0.82rem; }

  .header-meta {
    width: 100%;
    justify-items: stretch;
    gap: 0;
  }

  .account-status {
    min-height: 44px;
    padding-top: 9px;
    border-top: 1px solid var(--line);
    font-size: 0.55rem;
  }

  .account-status span {
    max-width: calc(100vw - 104px);
  }

  .account-status button {
    min-width: 52px;
    min-height: 36px;
    padding: 6px 9px;
    font-size: 0.61rem;
  }

  .records-section { padding: 32px 0 42px; }

  .records-header {
    gap: 13px;
    margin-bottom: 18px;
  }

  .collection-title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
  }

  .collection-title-row .section-kicker {
    margin-bottom: 7px;
    font-size: 0.59rem;
  }

  .collection-title-row h2 {
    font-size: clamp(1.45rem, 7vw, 1.8rem);
    line-height: 1.05;
  }

  .collection-count {
    margin-left: 4px;
    font-size: 0.62rem;
    vertical-align: 5px;
  }

  .new-record-button {
    min-height: 44px;
    padding: 8px 11px;
    align-self: center;
    font-size: 0.72rem;
  }

  .collection-tools { gap: 9px; }

  .collection-tools .filters {
    width: 100%;
  }

  .collection-tools .filter-button {
    min-height: 44px;
    padding: 7px 5px;
    font-size: 0.65rem;
  }

  .collection-tools .search-form {
    min-height: 44px;
  }

  .collection-tools .search-form input {
    min-height: 42px;
    font-size: 0.73rem;
  }

  .category-scope {
    gap: 11px;
    margin-top: 0;
  }

  .category-root-link { font-size: 0.96rem; }

  .result-context {
    align-items: flex-start;
    gap: 10px;
    padding: 14px 0;
    flex-direction: column;
  }

  .result-heading h3 { font-size: 1.35rem; }

  .active-tag-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .records-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }

  .record-card {
    padding: 6px 6px 9px;
  }

  .record-card .card-main {
    padding: 8px 1px 0;
  }

  .record-card .record-title {
    margin-bottom: 3px;
    font-size: 0.84rem;
    line-height: 1.24;
  }

  .record-card .record-creator {
    font-size: 0.64rem;
    line-height: 1.35;
  }

  body:has(#detail-view:not([hidden])) .page-header {
    gap: 11px;
    padding: 12px 0 14px;
  }

  body:has(#detail-view:not([hidden])) .page-header h1 {
    font-size: 2rem;
  }
}

/* Compact entry dialog for iPhone portrait widths */
@media (max-width: 640px) {
  .entry-dialog {
    width: calc(100% - 20px);
    height: auto;
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: max(10px, env(safe-area-inset-top)) auto max(10px, env(safe-area-inset-bottom));
    border-width: 1px;
  }

  .dialog-surface {
    height: auto;
    max-height: inherit;
  }

  .dialog-header {
    align-items: center;
    gap: 10px;
    padding: 11px 13px 10px;
  }

  .dialog-header .section-kicker {
    display: none;
  }

  .dialog-header h2 {
    font-size: 1.3rem;
    line-height: 1.1;
  }

  .dialog-close-button {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .entry-dialog .form-panel {
    min-height: 0;
    padding: 0 13px calc(13px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .entry-dialog .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin-top: 15px;
  }

  .entry-dialog .field {
    gap: 6px;
  }

  .entry-dialog .field span,
  .entry-dialog .cover-field legend,
  .entry-dialog .tmdb-settings label {
    font-size: 0.62rem;
    letter-spacing: 0.045em;
  }

  .entry-dialog input,
  .entry-dialog select {
    min-height: 42px;
    padding: 0 6px;
    font-size: 16px;
  }

  .entry-dialog textarea {
    min-height: 82px;
    padding: 9px 6px;
    font-size: 16px;
    line-height: 1.45;
  }

  .entry-dialog input::placeholder,
  .entry-dialog textarea::placeholder {
    font-size: 0.8rem;
  }

  .entry-dialog .cover-field {
    margin: 1px 0 0;
    padding-top: 14px;
  }

  .entry-dialog .cover-picker {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 11px;
    flex-direction: column;
  }

  .entry-dialog .cover-preview {
    width: min(34vw, 128px);
  }

  .entry-dialog .cover-controls {
    width: 100%;
    padding-top: 0;
  }

  .entry-dialog .cover-help,
  .entry-dialog .tmdb-settings p,
  .entry-dialog .cover-status {
    font-size: 0.72rem;
    line-height: 1.5;
  }

  .entry-dialog .cover-help {
    margin-bottom: 10px;
  }

  .entry-dialog .cover-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .entry-dialog .cover-actions .secondary-button,
  .entry-dialog .cover-actions .upload-button {
    min-width: 0;
    min-height: 40px;
    padding: 7px 9px;
    font-size: 0.62rem;
  }

  .entry-dialog .cover-actions .text-button {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .entry-dialog .cover-status {
    min-height: 1.2em;
    margin-top: 8px;
  }

  .entry-dialog .tmdb-settings {
    margin-top: 15px;
    padding: 12px;
  }

  .entry-dialog .token-row {
    align-items: stretch;
    gap: 8px;
    flex-direction: column;
  }

  .entry-dialog .token-row input {
    flex-basis: auto;
  }

  .entry-dialog .cover-results-panel {
    margin-top: 18px;
    padding-top: 14px;
  }

  .entry-dialog .cover-results-heading {
    margin-bottom: 12px;
  }

  .entry-dialog .cover-results-heading h3 {
    font-size: 1.05rem;
  }

  .entry-dialog .cover-candidate {
    padding: 8px;
  }

  .entry-dialog .candidate-title {
    font-size: 0.8rem;
  }

  .entry-dialog .form-actions {
    margin: 18px 0 0;
    padding: 0;
  }

  .entry-dialog .form-message {
    font-size: 0.62rem;
  }

  .entry-dialog .submit-actions {
    grid-template-columns: minmax(84px, 0.8fr) minmax(132px, 1.2fr);
    gap: 8px;
  }

  .entry-dialog .submit-actions button {
    min-height: 42px;
    padding: 9px 12px;
    font-size: 0.68rem;
  }
}

/* Compact header for every routed state outside the true #/ home view. */
body.is-subpage .page-shell {
  padding-top: 24px;
}

body.is-subpage .page-header {
  align-items: center;
  gap: 28px;
  padding: 14px 0 15px;
}

body.is-subpage .identity-block,
body.is-subpage .header-meta {
  min-width: 0;
}

body.is-subpage .page-header .eyebrow,
body.is-subpage .page-header .intro,
body.is-subpage .archive-mark {
  display: none;
}

body.is-subpage .site-title {
  margin: 0;
  line-height: 1;
}

body.is-subpage .site-title-logo {
  width: clamp(180px, 18vw, 220px);
}

body.is-subpage .header-meta {
  display: block;
  margin-left: auto;
}

body.is-subpage .account-status {
  min-width: 0;
}

body.is-subpage .records-section {
  padding-top: 34px;
}

body.is-subpage .detail-view {
  padding-top: 28px;
}

@media (min-width: 641px) and (max-width: 960px) {
  body.is-subpage .page-shell {
    padding-top: 20px;
  }

  body.is-subpage .page-header {
    gap: 22px;
    padding: 12px 0 14px;
  }

  body.is-subpage .site-title-logo {
    width: clamp(160px, 24vw, 190px);
  }

  body.is-subpage .records-section {
    padding-top: 30px;
  }

  body.is-subpage .detail-view {
    padding-top: 26px;
  }
}

@media (max-width: 640px) {
  body.is-subpage .page-shell {
    padding-top: 12px;
  }

  body.is-subpage .page-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 10px 0 11px;
  }

  body.is-subpage .identity-block {
    width: auto;
  }

  body.is-subpage .site-title-logo {
    width: min(38vw, 145px);
  }

  body.is-subpage .header-meta {
    width: auto;
    justify-self: end;
  }

  body.is-subpage .account-status {
    width: auto;
    min-height: 40px;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 0;
    border-top: 0;
  }

  body.is-subpage .account-status span {
    max-width: clamp(64px, 24vw, 96px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.is-subpage .account-status button {
    min-width: 48px;
    min-height: 36px;
  }

  body.is-subpage .records-section {
    padding-top: 24px;
  }

  body.is-subpage .detail-view {
    padding-top: 22px;
  }
}

/* Collection view switch and native Cover Flow */
.collection-tools-secondary {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.view-switch {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--line-dark);
}

.view-switch button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line-dark);
  padding: 7px 10px;
  color: var(--muted);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.61rem;
  letter-spacing: 0.03em;
}

.view-switch button:last-child { border-right: 0; }

.view-switch button:hover,
.view-switch button.active,
.view-switch button:focus-visible {
  color: var(--button-filled-text);
  background: var(--button-filled-background);
}

.records-cover-flow {
  --cover-flow-cover-height: clamp(240px, 28vw, 320px);
  --cover-flow-item-width: var(--cover-flow-cover-height);
  position: relative;
  min-width: 0;
}

.records-cover-flow:empty { display: none; }

.cover-flow-track {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: clamp(12px, 2.5vw, 30px);
  padding: 36px 0 11px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-padding-inline: calc(50% - (var(--cover-flow-item-width) / 2));
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  perspective: 1100px;
}

.cover-flow-track::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.cover-flow-track.is-initializing {
  visibility: hidden;
}

.cover-flow-track.is-initializing .cover-flow-item {
  transition: none;
}

.cover-flow-track::before,
.cover-flow-track::after {
  min-width: max(0px, calc(50% - (var(--cover-flow-item-width) / 2)));
  flex: 0 0 max(0px, calc(50% - (var(--cover-flow-item-width) / 2)));
  content: "";
}

.cover-flow-track:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 5px;
}

.cover-flow-item {
  --media-cover-scale: 0.9;
  width: var(--cover-flow-item-width);
  flex: 0 0 var(--cover-flow-item-width);
  opacity: 0.42;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  transform: scale(0.7);
  transform-origin: center;
  transition: opacity 220ms ease, transform 220ms ease;
}

.cover-flow-item.media-type-movie { --media-cover-scale: 1; }
.cover-flow-item.media-type-book { --media-cover-scale: 0.9; }
.cover-flow-item.media-type-music { --media-cover-scale: 0.8; }

.cover-flow-item.is-before { transform: rotateY(5deg) scale(0.7); }
.cover-flow-item.is-after { transform: rotateY(-5deg) scale(0.7); }
.cover-flow-item.is-second-near { opacity: 0.58; }
.cover-flow-item.is-before.is-second-near { transform: rotateY(4deg) scale(0.8); }
.cover-flow-item.is-after.is-second-near { transform: rotateY(-4deg) scale(0.8); }
.cover-flow-item.is-near { opacity: 0.76; }
.cover-flow-item.is-before.is-near { transform: rotateY(3deg) scale(0.9); }
.cover-flow-item.is-after.is-near { transform: rotateY(-3deg) scale(0.9); }
.cover-flow-item.is-active { opacity: 1; transform: none; }

.cover-flow-cover-link {
  display: grid;
  width: 100%;
  min-height: var(--cover-flow-cover-height);
  place-items: center;
  color: inherit;
  text-decoration: none;
}

.cover-flow-item .record-cover {
  margin: 0;
  background-color: var(--background);
}

.cover-flow-item .record-cover.ratio-poster {
  width: calc(var(--cover-flow-cover-height) * var(--media-cover-scale) * 2 / 3);
  height: calc(var(--cover-flow-cover-height) * var(--media-cover-scale));
}

.cover-flow-item .record-cover.ratio-square {
  width: calc(var(--cover-flow-cover-height) * var(--media-cover-scale));
  height: calc(var(--cover-flow-cover-height) * var(--media-cover-scale));
}

.records-cover-flow .cover-flow-item .record-cover:has(> img) {
  width: fit-content;
  height: auto;
  aspect-ratio: auto;
  border: 0;
  background: none;
}

.records-cover-flow .cover-flow-item .record-cover:has(> img) img {
  width: auto;
  height: calc(var(--cover-flow-cover-height) * var(--media-cover-scale));
  object-fit: contain;
}

.cover-flow-caption-host {
  min-height: 96px;
  padding: 18px 16px 0;
  text-align: center;
}

.cover-flow-caption {
  max-width: 560px;
  margin: 0 auto;
}

.cover-flow-title {
  margin-bottom: 6px;
  font-family: var(--sans);
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.2;
}

.cover-flow-creator {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.cover-flow-details {
  margin-bottom: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.025em;
}

.cover-flow-rating {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.83rem;
  letter-spacing: 0.025em;
  line-height: 1.25;
}

.cover-flow-details + .cover-flow-rating {
  margin-top: 5px;
}

@media (min-width: 641px) and (max-width: 960px) {
  body.is-subpage .records-cover-flow {
    --cover-flow-cover-height: clamp(230px, 34vw, 290px);
  }

  body.is-subpage .cover-flow-track {
    padding: 34px 0 10px;
  }

  body.is-subpage .cover-flow-caption-host {
    min-height: 90px;
  }
}

@media (max-width: 640px) {
  .collection-tools-secondary {
    width: 100%;
    gap: 8px;
  }

  .collection-tools-secondary .search-form {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }

  .view-switch button {
    min-height: 44px;
    padding-inline: 8px;
    font-size: 0.57rem;
  }

  body.is-subpage .records-cover-flow {
    --cover-flow-cover-height: clamp(190px, 58vw, 230px);
  }

  body.is-subpage .cover-flow-track {
    gap: 8px;
    padding: 24px 0 6px;
  }

  body.is-subpage .cover-flow-caption-host {
    min-height: 82px;
    padding: 14px 10px 0;
  }

  .cover-flow-title {
    font-size: var(--home-cover-caption-title-size, 1.12rem);
  }

  .cover-flow-creator { font-size: 0.72rem; }
  .cover-flow-details { font-size: 0.61rem; }
  .cover-flow-rating { font-size: 0.76rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cover-flow-item { transition: none; }
  .cover-flow-nav { transition: none; }
  .cover-flow-item.is-before,
  .cover-flow-item.is-after { transform: scale(0.7); }
  .cover-flow-item.is-before.is-second-near,
  .cover-flow-item.is-after.is-second-near { transform: scale(0.8); }
  .cover-flow-item.is-before.is-near,
  .cover-flow-item.is-after.is-near { transform: scale(0.9); }
}

/* Fluid home composition. Structural changes remain in the narrow-screen rules. */
body.is-home-root {
  --home-inline-gutter: clamp(12px, 2vw, 20px);
  --home-shell-padding-top: clamp(
    10px,
    min(calc(8.1vw - 41.8px), calc(14.5svh - 103px)),
    48px
  );
  --home-header-padding-start: clamp(
    10px,
    min(calc(6vw - 28px), calc(8svh - 52px)),
    28px
  );
  --home-header-padding-end: clamp(
    10px,
    min(calc(8.7vw - 45.7px), calc(11svh - 74px)),
    38px
  );
  --home-header-gap: clamp(8px, min(calc(6.7vw - 35px), calc(6.7svh - 35px)), 32px);
  --home-eyebrow-gap: clamp(5px, min(1svh, calc(3.9vw - 20px)), 12px);
  --home-title-gap: clamp(6px, min(1svh, calc(3.3vw - 15px)), 13px);
  --home-logo-height-limit: clamp(260px, calc(156svh - 959px), 600px);
  --home-logo-width: clamp(
    218px,
    min(calc(88vw - 328px), var(--home-logo-height-limit)),
    600px
  );
  --home-intro-height-limit: clamp(0.76rem, calc(2.22svh - 5.72px), 1.03rem);
  --home-intro-size: clamp(
    0.76rem,
    min(calc(0.7rem + 0.28vw), var(--home-intro-height-limit)),
    1.03rem
  );
  --home-stamp-height-limit: clamp(78px, calc(18svh - 70px), 112px);
  --home-stamp-size: clamp(78px, min(12vw, var(--home-stamp-height-limit)), 112px);
  --home-stamp-padding: clamp(10px, 1vw, 14px);
  --home-stamp-size-small: clamp(0.48rem, 0.5vw, 0.55rem);
  --home-stamp-size-strong: clamp(0.85rem, 1.1vw, 1rem);
  --home-section-padding-start: clamp(
    20px,
    min(calc(12vw - 57px), calc(15svh - 101px)),
    58px
  );
  --home-section-padding-end: clamp(24px, calc(1vw + 1.8svh), 34px);
  --home-records-gap: clamp(10px, calc(0.6vw + 0.8svh), 20px);
  --home-records-margin-end: clamp(
    8px,
    min(calc(0.8vw + 1svh), calc(10svh - 74px)),
    28px
  );
  --home-title-row-gap: clamp(12px, 2vw, 24px);
  --home-tools-gap: clamp(9px, 1.5vw, 20px);
  --home-tools-secondary-gap: clamp(8px, 0.8vw, 10px);
  --home-cover-flow-height: clamp(
    230px,
    min(34vw, calc(36svh + 3dvh)),
    320px
  );
  --home-cover-flow-group-offset: clamp(0px, calc(20svh - 168px), 32px);
  --home-cover-track-gap: clamp(8px, 2.2vw, 30px);
  --home-cover-track-padding-start: clamp(
    16px,
    min(calc(10vw - 48px), calc(10svh - 66px)),
    36px
  );
  --home-cover-track-padding-end: clamp(5px, calc(0.3vw + 0.4svh), 11px);
  --home-cover-caption-min-height: clamp(78px, 9svh, 96px);
  --home-cover-caption-padding-start: clamp(12px, calc(0.5vw + 1.2svh), 18px);
  --home-cover-caption-title-size: clamp(1.12rem, calc(0.56rem + 1.4vw), 1.65rem);
  --home-cover-stage-max-width: 2560px;
  --home-cover-stage-inline-gutter: 24px;
  --home-cover-nav-size: clamp(36px, 2.5vw, 40px);
  --home-cover-nav-inset: clamp(20px, 1.6vw, 28px);
  --home-footer-gap: clamp(28px, 3.6svh, 40px);
}

body.is-home-root .page-shell {
  width: min(1180px, calc(100% - (2 * var(--home-inline-gutter))));
  padding-top: var(--home-shell-padding-top);
}

body.is-home-root .page-header {
  gap: var(--home-header-gap);
  padding-block: var(--home-header-padding-start) var(--home-header-padding-end);
}

body.is-home-root .page-header .eyebrow {
  margin-bottom: var(--home-eyebrow-gap);
}

body.is-home-root .site-title {
  margin-bottom: var(--home-title-gap);
}

body.is-home-root .site-title-logo {
  width: var(--home-logo-width);
}

body.is-home-root .page-header .intro {
  font-size: var(--home-intro-size);
}

body.is-home-root .archive-mark {
  width: var(--home-stamp-size);
  min-width: var(--home-stamp-size);
  flex-basis: var(--home-stamp-size);
  padding: var(--home-stamp-padding);
  font-size: var(--home-stamp-size-small);
}

body.is-home-root .archive-mark strong {
  font-size: var(--home-stamp-size-strong);
}

body.is-home-root .records-section {
  padding-block: var(--home-section-padding-start) var(--home-section-padding-end);
}

body.is-home-root .records-header {
  gap: var(--home-records-gap);
  margin-bottom: var(--home-records-margin-end);
}

body.is-home-root .collection-title-row {
  gap: var(--home-title-row-gap);
}

body.is-home-root .collection-tools {
  gap: var(--home-tools-gap);
}

body.is-home-root .collection-tools-secondary {
  gap: var(--home-tools-secondary-gap);
}

body.is-home-root .records-cover-flow {
  --cover-flow-cover-height: var(--home-cover-flow-height);
  padding-top: var(--home-cover-flow-group-offset);
}

body.is-home-root .cover-flow-track {
  gap: var(--home-cover-track-gap);
  padding-block: var(--home-cover-track-padding-start) var(--home-cover-track-padding-end);
}

body.is-home-root .cover-flow-caption-host {
  min-height: var(--home-cover-caption-min-height);
  padding: var(--home-cover-caption-padding-start) 16px 0;
}

body.is-home-root .cover-flow-title {
  font-size: var(--home-cover-caption-title-size);
}

.cover-flow-nav-group {
  display: none;
  position: absolute;
  z-index: 3;
  top: calc(36px + var(--cover-flow-cover-height) + 11px + 18px);
  right: max(0px, calc(50% - 590px));
  align-items: center;
  gap: 6px;
}

body.is-home-root .cover-flow-nav-group {
  top: calc(
    var(--home-cover-flow-group-offset)
    + var(--home-cover-track-padding-start)
    + var(--home-cover-flow-height)
    + var(--home-cover-track-padding-end)
    + var(--home-cover-caption-padding-start)
  );
}

.cover-flow-nav {
  display: grid;
  width: var(--home-cover-nav-size, 40px);
  height: var(--home-cover-nav-size, 40px);
  border: 1px solid var(--line);
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: transparent;
  opacity: 0.62;
  transition: border-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

.cover-flow-nav::before {
  width: 11px;
  height: 11px;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  content: "";
}

.cover-flow-nav-previous::before { transform: rotate(135deg); }
.cover-flow-nav-next::before { transform: rotate(-45deg); }

.cover-flow-nav:not(:disabled):hover,
.cover-flow-nav:not(:disabled):focus-visible,
.cover-flow-nav:not(:disabled):active {
  border-color: var(--line-dark);
  color: var(--text);
  opacity: 1;
}

.cover-flow-nav:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 2px;
}

.cover-flow-nav:disabled {
  color: var(--muted);
  opacity: 0.22;
  cursor: default;
}

/* Let the visual stage grow beyond the text measure on large viewports. */
@media (min-width: 1200px) {
  body.is-home-root .records-cover-flow {
    position: relative;
    left: 50%;
    width: min(
      var(--home-cover-stage-max-width),
      max(100%, calc(100vw - (2 * var(--home-cover-stage-inline-gutter))))
    );
    max-width: none;
    transform: translateX(-50%);
  }

}

@media (min-width: 641px) {
  .cover-flow-nav-group {
    display: flex;
  }
}

@media (min-width: 641px) and (max-width: 960px) {
  body.is-subpage .cover-flow-nav-group {
    top: calc(34px + var(--cover-flow-cover-height) + 10px + 18px);
  }
}

body.is-home-root:has(.records-cover-flow) .page-footer {
  margin-top: var(--home-footer-gap);
}

/* Phone: keep the established one-column structure and touch targets. */
@media (max-width: 640px) {
  body.is-home-root {
    --home-shell-padding-top: clamp(8px, 1.2svh, 10px);
    --home-header-padding-start: clamp(8px, 1.2svh, 10px);
    --home-header-padding-end: clamp(8px, 1.2svh, 10px);
    --home-header-gap: clamp(7px, 1svh, 8px);
    --home-eyebrow-gap: clamp(4px, 0.7svh, 5px);
    --home-title-gap: clamp(5px, 0.8svh, 6px);
    --home-logo-width: clamp(180px, 56vw, 235px);
    --home-intro-size: clamp(0.72rem, calc(0.68rem + 0.2vw), 0.76rem);
    --home-section-padding-start: clamp(18px, 2.4svh, 20px);
    --home-section-padding-end: clamp(28px, 3.8svh, 32px);
    --home-records-gap: clamp(9px, 1.2svh, 10px);
    --home-records-margin-end: clamp(8px, 1.2svh, 10px);
    --home-cover-flow-height: clamp(
      190px,
      min(58vw, calc(29svh + 3dvh)),
      230px
    );
    --home-cover-track-padding-start: clamp(14px, 2svh, 16px);
    --home-cover-track-padding-end: 5px;
    --home-cover-caption-min-height: clamp(76px, 9.2svh, 78px);
    --home-cover-caption-padding-start: clamp(12px, 1.7svh, 14px);
    --home-cover-caption-title-size: clamp(1.06rem, calc(0.98rem + 0.6vw), 1.12rem);
    --home-footer-gap: clamp(28px, 4svh, 34px);
  }

  body.is-home-root .header-meta {
    gap: 0;
  }

  body.is-home-root .account-status {
    min-height: 38px;
    padding-top: 6px;
  }

  body.is-home-root .cover-flow-caption-host {
    padding-inline: 10px;
  }
}

/* Only genuinely short landscape viewports need a content-level fallback. */
@media (orientation: landscape) and (max-height: 700px) {
  body.is-home-root .page-header .intro {
    display: none;
  }
}
