:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --line: #e8e8f2;
  --text: #171724;
  --muted: #76778c;
  --accent: #7c3aed;
  --cyan: #06b6d4;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 18px 55px rgba(26, 22, 61, 0.08);
  --card-gap: 16px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101219;
  --panel: #191c26;
  --line: #2b3040;
  --text: #f4f5fb;
  --muted: #a2a7ba;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
  --night-primary-a: #6732c8;
  --night-primary-b: #4638d4;
  --night-primary-shadow: 0 0 0 1px rgba(172, 148, 255, .14), 0 8px 18px rgba(52, 41, 120, .26);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 144px;
  overflow-y: scroll;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text);
  background: var(--bg);
  transition: background .18s ease, color .18s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
.primary-btn,
.icon-btn,
.action-link {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

button:hover,
.primary-btn:hover,
.icon-btn:hover,
.action-link:hover {
  transform: translateY(-1px);
}

.topbar {
  height: 74px;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 42px 54px 122px;
  gap: 16px;
  align-items: center;
  padding: 0 max(24px, calc((100% - 1060px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

:root[data-theme="dark"] .topbar {
  background: rgba(17, 19, 28, .86);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 18px;
}

.brand strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: visible;
  padding: 0;
}

.mark img {
  display: block;
  height: 42px;
  object-fit: contain;
  width: 42px;
}

.status-pill {
  min-width: 0;
  height: 44px;
  border-radius: 18px;
  background: #f0f1f6;
  color: #7a7b90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  overflow: hidden;
  white-space: nowrap;
}

:root[data-theme="dark"] .status-pill {
  background: #242838;
  color: var(--muted);
}

.status-pill span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-pill strong {
  color: #343447;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-theme="dark"] .brand strong,
:root[data-theme="dark"] .status-pill strong {
  color: var(--text);
}

.file-pill strong {
  direction: rtl;
  text-align: left;
}

.topbar form {
  flex: 0 0 auto;
  margin: 0;
  min-width: 0;
}

.topbar-spacer {
  width: 42px;
  height: 42px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: #f0f1f6;
  color: #4b4b5e;
  font-size: 20px;
}

:root[data-theme="dark"] .icon-btn {
  background: #242838;
  color: #d6d9e8;
}

.notify-btn {
  width: 54px;
}

.notify-btn svg {
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 20px;
}

.notify-btn.active {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: white;
}

:root[data-theme="dark"] .notify-btn.active {
  background: linear-gradient(135deg, var(--night-primary-a), var(--night-primary-b));
  color: #ffffff;
  box-shadow: var(--night-primary-shadow);
}

.primary-btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  min-height: 42px;
  padding: 0 18px;
  white-space: nowrap;
  color: white;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  box-shadow: none;
}

.topbar .primary-btn {
  min-width: 0;
  width: 122px;
}

.theme-toggle {
  align-items: center;
  background: #f0f1f6;
  border-radius: 16px;
  color: #343447;
  display: inline-flex;
  gap: 9px;
  height: 42px;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  width: 122px;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.theme-icon {
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 20px;
}

.theme-divider {
  background: #d7d9e3;
  height: 22px;
  width: 1px;
}

.moon-icon {
  color: #9aa0b5;
  transform: translateY(1px);
}

:root[data-theme="dark"] .theme-toggle {
  background: #242838;
  color: #8f96aa;
}

:root[data-theme="dark"] .theme-divider {
  background: #3a4054;
}

:root[data-theme="dark"] .sun-icon {
  color: #8f96aa;
}

:root[data-theme="dark"] .moon-icon {
  color: #f5f6fb;
}

button.secondary,
.secondary {
  background: #f0f1f6;
  color: #4b4b5e;
  box-shadow: none;
}

button.disabled {
  background: #eef0f6;
  box-shadow: none;
  color: #9a9bad;
  cursor: not-allowed;
}

button.disabled:hover {
  transform: none;
}

button:disabled {
  background: #eef0f6;
  box-shadow: none;
  color: #9a9bad;
  cursor: not-allowed;
}

button:disabled:hover {
  transform: none;
}

.nav {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 max(24px, calc((100% - 1060px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 74px;
  z-index: 9;
}

:root[data-theme="dark"] .nav {
  background: rgba(17, 19, 28, .9);
}

.nav a {
  padding: 10px 16px;
  border-radius: 18px;
  color: #606175;
  font-weight: 800;
}

:root[data-theme="dark"] .nav a {
  color: #a9aec0;
}

.nav a.active {
  color: #5b21b6;
  background: #eee8ff;
}

:root[data-theme="dark"] .nav a.active {
  background: #30264b;
  color: #d8c8ff;
}

main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 18px 0 60px;
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

section[id] {
  scroll-margin-top: 144px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.25fr) minmax(240px, .9fr);
  gap: var(--card-gap);
}

.hero-card,
.section-card,
.side-stack {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero-card {
  min-height: 260px;
  padding: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 28px;
  align-items: center;
  color: white;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(36,31,57,.9), rgba(124,58,237,.58)),
    radial-gradient(circle at 30% 28%, rgba(6,182,212,.42), transparent 20rem);
}

.hero-card.status-hero {
  grid-template-columns: minmax(0, 1fr) 260px;
}

.status-metrics strong {
  font-size: 18px;
  word-break: keep-all;
}

.hero-copy h1 {
  margin: 8px 0 14px;
  font-size: 34px;
  line-height: 1.22;
  letter-spacing: 0;
  word-break: keep-all;
}

.hero-copy p:not(.eyebrow) {
  margin: 0;
  color: rgba(255,255,255,.78);
  line-height: 1.7;
  max-width: 520px;
}

.hero-metrics {
  display: grid;
  gap: 12px;
}

.hero-metrics article {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.22);
}

.hero-metrics span,
.side-stack span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.hero-metrics span {
  color: rgba(255,255,255,.72);
}

.hero-metrics strong,
.side-stack strong {
  display: block;
  font-size: 24px;
  line-height: 1.12;
}

.side-stack {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.side-stack article {
  padding: 22px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}

.toggle-stack article {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(78px, 1fr) 126px;
  align-items: center;
  justify-content: normal;
}

.side-stack article:last-child {
  border-bottom: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
}

.hero-card .eyebrow {
  color: #d8ccff;
}

.section-card {
  background: var(--panel);
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 6px;
}

.section-actions form {
  margin: 0;
}

.section-actions button {
  border-radius: 12px;
  font-size: 13px;
  min-height: 36px;
  min-width: 98px;
  padding: 0 12px;
  white-space: nowrap;
}

.section-card button,
.section-card .action-link {
  box-shadow: none;
}

.progress-button {
  overflow: hidden;
  position: relative;
  --progress: 0%;
}

.progress-button::before {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  bottom: 0;
  content: "";
  left: 0;
  position: absolute;
  top: 0;
  width: var(--progress);
  transition: width .25s ease;
}

.progress-button span {
  position: relative;
  z-index: 1;
}

.progress-button.is-running {
  color: white;
}

.command-status {
  margin: 0;
  padding: 14px 18px;
  border: 1px solid #ddd6fe;
  border-radius: 18px;
  background: #f3efff;
  color: #5b21b6;
  font-weight: 900;
}

.page-popup {
  align-items: center;
  background: rgba(17, 24, 39, .92);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 16px;
  box-shadow: 0 18px 46px rgba(17, 24, 39, .2);
  color: white;
  display: flex;
  font-size: 14px;
  font-weight: 800;
  gap: 14px;
  justify-content: space-between;
  left: 50%;
  max-width: min(520px, calc(100vw - 32px));
  min-width: min(360px, calc(100vw - 32px));
  opacity: 0;
  padding: 14px 16px;
  position: fixed;
  top: 22px;
  transform: translate(-50%, -12px);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 80;
}

.page-popup.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.page-popup-close {
  align-items: center;
  background: rgba(255, 255, 255, .13);
  border: 0;
  border-radius: 12px;
  color: white;
  display: inline-flex;
  flex: 0 0 auto;
  height: 36px;
  justify-content: center;
  padding: 0;
  position: relative;
  transition: background .16s ease, transform .16s ease;
  width: 36px;
}

.page-popup-close::before,
.page-popup-close::after {
  background: currentColor;
  border-radius: 999px;
  content: "";
  height: 2px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform-origin: center;
  width: 13px;
}

.page-popup-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.page-popup-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.page-popup-close:hover {
  background: rgba(255, 255, 255, .2);
}

.page-popup-close:active {
  transform: translateY(1px);
}

.history-tabs {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
  margin: 0 0 14px;
}

.history-tabs a {
  align-items: center;
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #606175;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  gap: 4px;
  justify-content: center;
  min-height: 34px;
  min-width: 0;
  padding: 0 6px;
  white-space: nowrap;
}

.history-tabs a.active {
  background: #eee8ff;
  border-color: #ddd6fe;
  color: #5b21b6;
}

.history-tabs small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.history-tabs a.active small {
  color: #6d28d9;
}

.history-tabs.is-loading a {
  opacity: .72;
  pointer-events: none;
}

.history-table tbody {
  transition: opacity .12s ease;
}

.history-table tbody.is-loading {
  opacity: .48;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 24px;
  letter-spacing: 0;
}

.muted,
.status {
  color: var(--muted);
  line-height: 1.7;
}

.table-wrap {
  background: var(--panel);
  border-radius: 0 0 18px 18px;
  overflow-x: hidden;
  overflow-y: hidden;
}

table {
  background: var(--panel);
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid #f0f0f6;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #73748a;
  font-size: 12px;
  font-weight: 900;
  background: #f7f7fb;
}

td {
  background: var(--panel);
  font-weight: 700;
  height: 68px;
  max-height: 68px;
  overflow: hidden;
}

th:nth-child(1),
td:nth-child(1) { width: 60px; }
th:nth-child(2),
td:nth-child(2) { width: 100px; }
th:nth-child(3),
td:nth-child(3) { width: 170px; }
th:nth-child(4),
td:nth-child(4) { width: 310px; }
th:nth-child(5),
td:nth-child(5) { width: 105px; }
th:nth-child(6),
td:nth-child(6) { width: 90px; }
th:nth-child(7),
td:nth-child(7) {
  padding-right: 12px;
  width: 175px;
}

.history-col-status { width: 60px; }
.history-col-thumb { width: 100px; }
.history-col-file { width: 170px; }
.history-col-recognition { width: 260px; }
.history-col-score { width: 195px; }
.history-col-api { width: 62px; }
.history-col-actions { width: 163px; }

th:nth-child(7) {
  padding-left: 34px;
}

.path {
  color: #55566a;
  font-family: Consolas, "D2Coding", monospace;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-cell {
  min-width: 0;
}

.file-cell .path {
  display: block;
  max-width: 100%;
}

.file-cell .compact-result {
  margin-top: 4px;
}

.thumb,
.review-image {
  aspect-ratio: 16 / 9;
  background: #f4f5fa;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: block;
  object-fit: cover;
}

.thumb {
  width: 86px;
  border-radius: 10px;
}

.review-image {
  width: 100%;
  margin-bottom: 18px;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 86px;
  overflow: hidden;
  padding: 0 12px;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 950;
  background: #eef0f6;
  color: #55566a;
  white-space: nowrap;
}

.uploaded { background: #dcfce7; color: #15803d; }
.skipped { background: #fef3c7; color: #b45309; }
.parsed { background: #dbeafe; color: #1d4ed8; }
.needs_review { background: #ffedd5; color: #c2410c; }
.failed { background: #fee2e2; color: #dc2626; }
.checked { background: #dbeafe; color: #1d4ed8; }
.unchecked { background: #ffedd5; color: #c2410c; }

.actions {
  align-items: center;
  display: flex;
  gap: 5px;
  justify-content: flex-end;
  min-height: 36px;
  white-space: nowrap;
}

.recognition-cell {
  align-items: center;
  display: flex;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.jacket-thumb {
  aspect-ratio: 1 / 1;
  background: #f4f5fa;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(18, 18, 30, .08);
  display: block;
  flex: 0 0 44px;
  height: 44px;
  object-fit: cover;
  overflow: hidden;
  width: 44px;
}

.recognition-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.badge-stack {
  display: grid;
  flex: 0 0 38px;
  gap: 4px;
  justify-items: stretch;
  width: 38px;
}

.song-title {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.song-title.is-overflowing {
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 82%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 82%, transparent 100%);
}

.composer-line {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-badge {
  align-items: center;
  border-radius: 9px;
  color: #fff;
  display: inline-flex;
  font-size: 10px;
  font-weight: 950;
  height: 22px;
  justify-content: center;
  min-width: 38px;
  padding: 0 6px;
  text-shadow: 0 1px 2px rgba(0,0,0,.22);
  width: 100%;
}

.button-b4 { background: #079a5e; }
.button-b5 { background: #2b9db7; }
.button-b6 { background: #c87810; }
.button-b8 { background: #5556ad; }
.button-bunknown { background: #8b8ca0; }

.pattern-nm { background: #475569; }
.pattern-hd { background: #f59e0b; }
.pattern-mx { background: #2563eb; }
.pattern-sc { background: #db00b6; }
.pattern-unknown { background: #8b8ca0; }

.button-metrics {
  display: grid;
  gap: 12px 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.button-metrics div {
  align-items: center;
  background: transparent;
  border: 0;
  display: flex;
  gap: 13px;
  min-height: 34px;
  padding: 0;
}

.button-metrics b {
  color: #171724;
  font-size: 18px;
  font-weight: 950;
  line-height: 1;
}

.metric-button-badge {
  border-radius: 10px;
  color: #fff !important;
  display: inline-grid !important;
  font-size: 12px !important;
  font-weight: 950;
  height: 28px;
  line-height: 28px;
  margin: 0 !important;
  min-width: 48px;
  padding: 0 10px;
  place-items: center;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,.22);
}

.score-pill {
  align-items: center;
  border-radius: 12px;
  color: #06111f;
  display: inline-flex;
  font-size: 15px;
  font-weight: 650;
  justify-content: center;
  line-height: 1;
  min-height: 36px;
  min-width: 80px;
  padding: 1px 8px 0;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}

.score-cell {
  padding-left: 4px;
  padding-right: 4px;
  overflow: visible;
}

.score-compare {
  align-items: center;
  display: grid;
  gap: 5px;
  grid-template-columns: 72px 16px 86px;
  justify-content: start;
  min-width: 0;
  white-space: nowrap;
}

.score-pill-previous {
  border-radius: 12px;
  font-size: 14px;
  min-height: 32px;
  min-width: 0;
  padding: 1px 8px 0;
}

.score-new-label {
  align-items: center;
  color: #ff2558;
  display: inline-flex;
  font-size: 13px;
  font-weight: 950;
  justify-content: center;
  letter-spacing: 0;
  min-width: 0;
}

.score-arrow {
  color: #b9bcc8;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.score-mc {
  background: #4be4a3;
  color: #fff;
  text-shadow:
    -1px -1px 1px rgba(0,0,0,.95),
    1px -1px 1px rgba(0,0,0,.95),
    -1px 1px 1px rgba(0,0,0,.95),
    1px 1px 1px rgba(0,0,0,.95),
    0 0 3px rgba(0,0,0,.78);
}

.score-clear {
  background: #8be2f4;
}

.score-perfect {
  background: #ef3434;
  color: #fff;
  text-shadow:
    -1px -1px 1px rgba(0,0,0,.85),
    1px -1px 1px rgba(0,0,0,.85),
    -1px 1px 1px rgba(0,0,0,.85),
    1px 1px 1px rgba(0,0,0,.85),
    0 0 3px rgba(0,0,0,.7);
}

.score-empty {
  background: #eef0f6;
  color: #8b8ca0;
  text-shadow: none;
}

.api-pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 950;
  min-height: 28px;
  padding: 0 10px;
  white-space: nowrap;
}

.api-empty {
  color: var(--muted);
}

.api-updated {
  background: #dcfce7;
  color: #15803d;
}

.api-kept {
  background: #fef3c7;
  color: #b45309;
}

.api-failed {
  background: #fee2e2;
  color: #dc2626;
}

.actions form {
  margin: 0;
}

.actions button {
  border-radius: 12px;
  font-size: 14px;
  min-height: 36px;
  min-width: 56px;
  padding: 0 9px;
}

.actions .upload-action {
  min-width: 68px;
}

.action-link {
  align-items: center;
  background: #f0f1f6;
  border-radius: 12px;
  color: #4b4b5e;
  display: inline-flex;
  font-size: 14px;
  min-height: 36px;
  justify-content: center;
  min-width: 56px;
  padding: 0 9px;
}

.error {
  color: #dc2626;
  font-size: 12px;
  margin-top: 6px;
  max-width: 420px;
  overflow-wrap: anywhere;
}

.issues {
  color: #b45309;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 4px;
  max-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-result {
  font-size: 12px;
  line-height: 1.25;
  margin-top: 5px;
  max-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.issues.block {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 16px;
  padding: 12px;
}

.empty {
  color: var(--muted);
  padding: 32px;
  text-align: center;
}

.review-grid {
  display: grid;
  gap: var(--card-gap);
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: stretch;
}

.review-side {
  display: grid;
  gap: var(--card-gap);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-width: 0;
}

.status-grid {
  display: grid;
  gap: var(--card-gap);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-head.compact {
  margin-bottom: 12px;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-list div {
  align-items: center;
  border-bottom: 1px solid #f0f0f6;
  display: grid;
  gap: 14px;
  grid-template-columns: 122px minmax(0, 1fr);
  min-height: 42px;
  padding: 0;
}

.status-list div:last-child {
  border-bottom: 0;
}

.status-list dt {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.status-list dd {
  color: #343447;
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.demo-switch {
  align-items: center;
  background: #e5e7ee;
  border: 1px solid #d6dae8;
  border-radius: 999px;
  box-shadow: inset 0 2px 5px rgba(26,22,61,.12);
  cursor: pointer;
  display: inline-flex;
  height: 40px;
  justify-content: space-between;
  justify-self: end;
  min-width: 0;
  width: 126px;
  overflow: hidden;
  padding: 0;
  position: relative;
  transition: background .22s ease, box-shadow .22s ease;
}

.demo-switch:hover {
  transform: none;
}

.demo-switch.is-saving {
  cursor: wait;
  opacity: .72;
}

.demo-switch.is-on {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-color: transparent;
  box-shadow: inset 0 2px 5px rgba(26,22,61,.18), 0 10px 24px rgba(79,70,229,.18);
}

.demo-switch.is-off {
  background: #e7e7ea;
  box-shadow: inset 0 2px 5px rgba(0,0,0,.07);
}

.switch-text {
  font-size: 15px;
  font-weight: 950;
  line-height: 1;
  position: absolute;
  text-shadow: none;
  top: 50%;
  transform: translateY(-50%);
  transition: color .2s ease, opacity .2s ease;
  z-index: 3;
}

.switch-text.on {
  color: rgba(255,255,255,.92);
  left: 20px;
  text-shadow: 0 2px 3px rgba(36,31,57,.22);
}

.switch-text.off {
  color: #9ca1ad;
  right: 20px;
  text-shadow: 0 1px 0 rgba(255,255,255,.7);
}

.demo-switch.is-on .switch-text.on,
.demo-switch.is-off .switch-text.off {
  opacity: 1;
}

.demo-switch.is-on .switch-text.off,
.demo-switch.is-off .switch-text.on {
  opacity: 0;
}

.toggle-label {
  white-space: nowrap;
  margin-bottom: 0 !important;
}

.toggle-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.settings-icon-btn {
  align-items: center;
  background: #f0f1f6;
  border-radius: 12px;
  color: #6d6e82;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.settings-icon-btn svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  width: 18px;
}

.debug-grid {
  display: grid;
  gap: var(--card-gap);
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.policy-form {
  display: grid;
  gap: 14px;
  min-height: 364px;
}

.policy-form label {
  color: #44465d;
  display: grid;
  font-size: 14px;
  font-weight: 850;
  gap: 8px;
}

.policy-form input[type="number"] {
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  min-height: 40px;
  padding: 0 12px;
}

.policy-form .check {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.policy-group {
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 10px;
  padding: 12px 14px;
}

.policy-group-title {
  color: #7c3aed;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.policy-screens {
  display: grid;
  column-gap: 14px;
  grid-template-columns: repeat(4, max-content);
  row-gap: 8px;
}

.policy-form > button[type="submit"] {
  align-self: end;
  margin-top: auto;
}

.backup-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 330px;
}

.backup-list {
  align-content: start;
  display: grid;
  gap: 10px;
  max-height: 340px;
  min-height: 278px;
  overflow-y: auto;
  padding-right: 4px;
}

.backup-list::-webkit-scrollbar {
  width: 8px;
}

.backup-list::-webkit-scrollbar-thumb {
  background: #d8d2e8;
  border-radius: 999px;
}

.backup-list::-webkit-scrollbar-track {
  background: transparent;
}

.backup-list-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.backup-list-head a {
  background: #f2eaff;
  border-radius: 999px;
  color: #6d28d9;
  font-size: 12px;
  font-weight: 850;
  min-height: 30px;
  padding: 7px 12px;
}

.backup-item {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  min-height: 62px;
  padding: 12px 14px;
}

.backup-item strong,
.backup-item span {
  display: block;
}

.backup-item span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.danger-soft {
  background: #fee2e2;
  color: #dc2626;
  min-height: 36px;
}

.exclude-btn {
  background: #fef3c7;
  color: #b45309;
  min-height: 36px;
}

.restore-btn {
  background: #e0f2fe;
  color: #0369a1;
  min-height: 36px;
}

.random-refresh {
  min-width: 88px;
}

.sample-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.sample-tabs {
  align-items: center;
  background: #f6f7fb;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
}

.sample-tabs a {
  border-radius: 999px;
  color: #5f637d;
  font-size: 13px;
  font-weight: 850;
  min-height: 34px;
  padding: 8px 14px;
}

.sample-tabs a.active {
  background: #efe7ff;
  color: #6d28d9;
}

.calendar-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.backup-calendar-panel {
  margin-top: 0;
}

.calendar-head a {
  align-items: center;
  background: #f6f7fb;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.backup-calendar {
  display: grid;
  column-gap: 8px;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto repeat(6, 42px);
  row-gap: 10px;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.calendar-day {
  align-items: center;
  color: #111827;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: inline-flex;
  font-weight: 850;
  height: 42px;
  justify-content: center;
  position: relative;
}

.calendar-day.muted-day {
  color: #c4c6d0;
  background: #fbfbfe;
}

.calendar-day.has-backup {
  background: #f2eaff;
  border-color: #ddd6fe;
  color: #6d28d9;
}

.calendar-day.selected {
  background: #5b21b6;
  border-color: transparent;
  box-shadow:
    0 0 0 1px rgba(17, 24, 39, .12),
    0 10px 20px rgba(17, 24, 39, .18),
    0 0 18px rgba(17, 24, 39, .10);
  color: #fff !important;
}

.calendar-day.has-backup::after {
  background: #7c3aed;
  border-radius: 999px;
  bottom: 5px;
  content: "";
  height: 5px;
  position: absolute;
  width: 5px;
}

.calendar-day.selected::after {
  background: #fff;
}

.debug-reasons {
  color: #b45309;
  font-size: 13px;
  font-weight: 750;
  max-width: 360px;
  overflow-wrap: anywhere;
}

.empty.slim {
  padding: 18px;
}

.switch-knob {
  background: linear-gradient(135deg, #ffffff, #f5f6fb);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(24,24,43,.22), inset 0 1px 0 rgba(255,255,255,.95);
  height: 34px;
  position: absolute;
  top: 3px;
  transition: left .24s ease, width .24s ease;
  width: 34px;
  z-index: 2;
}

.demo-switch.is-on .switch-knob {
  left: calc(100% - 37px);
}

.demo-switch.is-off .switch-knob {
  left: 3px;
}

.file-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.file-card {
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 16px;
}

.file-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.file-card strong {
  color: #232339;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card small {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
}

.file-card.ok {
  border-color: #d7d9e3;
}

.file-card.missing {
  border-color: #fee2e2;
}

.status-table-wrap {
  overflow: hidden;
}

.status-table {
  min-width: 0;
}

.status-table td {
  height: 48px;
  max-height: 48px;
}

.status-table th:nth-child(1),
.status-table td:nth-child(1) { width: 220px; }
.status-table th:nth-child(2),
.status-table td:nth-child(2) { width: auto; }
.status-table th:nth-child(3),
.status-table td:nth-child(3) { width: 190px; }
.status-table th:nth-child(4),
.status-table td:nth-child(4) { width: 90px; }

.samples-table-wrap {
  overflow: hidden;
}

.samples-table {
  min-width: 0;
}

.samples-table th,
.samples-table td {
  padding-left: 5px;
  padding-right: 5px;
}

.samples-table th:nth-child(1),
.samples-table td:nth-child(1) { width: 58px; }
.samples-table th:nth-child(2),
.samples-table td:nth-child(2) { width: 96px; }
.samples-table th:nth-child(3),
.samples-table td:nth-child(3) { width: 132px; }
.samples-table th:nth-child(4),
.samples-table td:nth-child(4) { width: 230px; }
.samples-table th:nth-child(5),
.samples-table td:nth-child(5) { width: 104px; }
.samples-table th:nth-child(6),
.samples-table td:nth-child(6) { width: 108px; }
.samples-table th:nth-child(7),
.samples-table td:nth-child(7) {
  padding-left: 5px;
  padding-right: 5px;
  width: 116px;
}
.samples-table th:nth-child(8),
.samples-table td:nth-child(8) {
  overflow: visible;
  padding-left: 5px;
  padding-right: 5px;
  width: 140px;
}

.samples-table th:nth-child(8) {
  padding-left: 22px;
  padding-right: 0;
  text-align: left;
}

.samples-table td:nth-child(7) .debug-reasons {
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.samples-table .actions {
  gap: 5px;
  justify-content: flex-end;
}

.samples-table .action-link,
.samples-table .actions button {
  min-width: 54px;
  padding-left: 8px;
  padding-right: 8px;
}

.review-main {
  min-width: 0;
}

.review-main .section-head {
  margin-bottom: 18px;
}

.review-main .review-image {
  border-radius: 18px;
  margin-bottom: 22px;
}

.wide {
  grid-column: 1 / -1;
}

.inline-form {
  margin: 0;
}

.edit-form {
  display: grid;
  gap: 12px;
}

label {
  color: #55566a;
  display: block;
  font-size: 13px;
  font-weight: 900;
}

input,
select {
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  display: block;
  font: inherit;
  font-weight: 800;
  margin-top: 7px;
  min-height: 44px;
  padding: 0 13px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: #ddd6fe;
  box-shadow: 0 0 0 4px rgba(124,58,237,.12);
  outline: 0;
}

.check {
  align-items: center;
  display: flex;
  gap: 10px;
}

.check input {
  margin: 0;
  min-height: 0;
  width: auto;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

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

.candidates li {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbfe;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 64px;
  padding: 9px 16px;
  margin-bottom: 8px;
}

.candidates li.recognized-candidate,
.candidates li.upload-candidate {
  background: #eee8ff;
  border-color: #ddd6fe;
  color: #5b21b6;
}

.candidates li.recognized-candidate span,
.candidates li.upload-candidate span {
  color: #6d28d9;
}

.candidates span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.ocr-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ocr-text,
pre {
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: #343447;
  font-family: "D2Coding", Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  flex: 1;
  max-height: none;
  min-height: 230px;
  overflow: auto;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

:root[data-theme="dark"] .hero-card,
:root[data-theme="dark"] .section-card,
:root[data-theme="dark"] .side-stack {
  background: var(--panel);
  border-color: var(--line);
}

:root[data-theme="dark"] .hero-card {
  background:
    linear-gradient(135deg, rgba(19, 22, 34, .96), rgba(95, 57, 168, .48)),
    radial-gradient(circle at 30% 28%, rgba(6, 182, 212, .18), transparent 20rem);
}

:root[data-theme="dark"] .hero-copy p:not(.eyebrow) {
  color: rgba(244, 245, 251, .76);
}

:root[data-theme="dark"] .hero-metrics article,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .file-card,
:root[data-theme="dark"] .candidates li,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] .ocr-text,
:root[data-theme="dark"] pre {
  background: #202433;
  border-color: #34394b;
  color: var(--text);
}

:root[data-theme="dark"] .candidates li.recognized-candidate,
:root[data-theme="dark"] .candidates li.upload-candidate {
  background: #322554;
  border-color: #4c3a7b;
  color: #d8c8ff;
}

:root[data-theme="dark"] .candidates li.recognized-candidate span,
:root[data-theme="dark"] .candidates li.upload-candidate span {
  color: #c9b7ff;
}

:root[data-theme="dark"] .candidates span,
:root[data-theme="dark"] .file-card span,
:root[data-theme="dark"] .file-card small,
:root[data-theme="dark"] .muted,
:root[data-theme="dark"] label {
  color: var(--muted);
}

:root[data-theme="dark"] .file-card strong,
:root[data-theme="dark"] .song-title,
:root[data-theme="dark"] .section-card h2 {
  color: var(--text);
}

:root[data-theme="dark"] .history-table th,
:root[data-theme="dark"] .status-table th,
:root[data-theme="dark"] .samples-table th {
  background: #202433;
  color: #b9bed1;
}

:root[data-theme="dark"] .history-table td,
:root[data-theme="dark"] .status-table td,
:root[data-theme="dark"] .samples-table td,
:root[data-theme="dark"] .status-list div {
  border-color: #2b3040;
}

:root[data-theme="dark"] button.secondary,
:root[data-theme="dark"] .secondary,
:root[data-theme="dark"] .action-link {
  background: #242838;
  color: #e2e5f2;
}

:root[data-theme="dark"] .primary-btn,
:root[data-theme="dark"] .section-card button[type="submit"]:not(.secondary):not(.danger-soft),
:root[data-theme="dark"] .progress-button::before {
  background: linear-gradient(135deg, var(--night-primary-a), var(--night-primary-b));
  box-shadow: var(--night-primary-shadow);
}

:root[data-theme="dark"] .section-card button[type="submit"]:not(.secondary):not(.danger-soft) {
  color: #ffffff;
}

:root[data-theme="dark"] button:disabled {
  background: #252938;
  color: #858ba0;
}

:root[data-theme="dark"] .history-tabs a {
  background: #242838;
  border-color: #34394b;
  color: #d8dced;
}

:root[data-theme="dark"] .history-tabs small {
  color: #a9aec0;
}

:root[data-theme="dark"] .history-tabs a.active {
  background: #30264b;
  border-color: #514078;
  color: #eee8ff;
}

:root[data-theme="dark"] .history-tabs a.active small {
  color: #d8c8ff;
}

:root[data-theme="dark"] table,
:root[data-theme="dark"] td,
:root[data-theme="dark"] .table-wrap {
  background: var(--panel);
}

:root[data-theme="dark"] th {
  background: #222637;
  color: #c4c9dc;
}

:root[data-theme="dark"] td {
  color: #eef1fb;
}

:root[data-theme="dark"] .path,
:root[data-theme="dark"] .status-list dd,
:root[data-theme="dark"] .status-list dt {
  color: #b8bed2;
}

:root[data-theme="dark"] .status-list dd,
:root[data-theme="dark"] .button-metrics b {
  color: #f3f5fb;
}

:root[data-theme="dark"] .badge {
  background: #2a2f40;
  color: #dce2f5;
}

:root[data-theme="dark"] .uploaded,
:root[data-theme="dark"] .checked {
  background: #173927;
  color: #8ee6ad;
}

:root[data-theme="dark"] .skipped,
:root[data-theme="dark"] .unchecked,
:root[data-theme="dark"] .needs_review {
  background: #3b2b13;
  color: #f5c36b;
}

:root[data-theme="dark"] .parsed {
  background: #1c3357;
  color: #a9cfff;
}

:root[data-theme="dark"] .failed {
  background: #431c22;
  color: #ffb4be;
}

:root[data-theme="dark"] .mini-badge,
:root[data-theme="dark"] .metric-button-badge {
  filter: saturate(.72) brightness(.82);
}

:root[data-theme="dark"] .score-pill {
  color: #08111f;
  font-weight: 850;
  filter: saturate(.78) brightness(.9);
  text-shadow: none;
}

:root[data-theme="dark"] .score-mc {
  background: #39b982;
  color: #07161f;
  text-shadow: none;
}

:root[data-theme="dark"] .score-perfect {
  background: #a83338;
  color: #fff3f4;
  text-shadow: none;
}

:root[data-theme="dark"] .score-clear {
  background: #68c5d8;
  color: #07111f;
  text-shadow: none;
}

:root[data-theme="dark"] .score-new-label {
  color: #ff5d83;
}

:root[data-theme="dark"] .score-arrow {
  color: #74798a;
}

:root[data-theme="dark"] .api-updated {
  background: #1d4b33;
  color: #a9f2c5;
}

:root[data-theme="dark"] .api-kept {
  background: #4a3512;
  color: #ffd88a;
}

:root[data-theme="dark"] .api-failed {
  background: #4b1e24;
  color: #ffb7c0;
}

:root[data-theme="dark"] .api-empty {
  color: #9fa6bc;
}

:root[data-theme="dark"] .policy-group,
:root[data-theme="dark"] .policy-form input[type="number"],
:root[data-theme="dark"] .sample-tabs,
:root[data-theme="dark"] .backup-item,
:root[data-theme="dark"] .calendar-head a,
:root[data-theme="dark"] .calendar-day {
  background: #202433;
  border-color: #34394b;
  color: #eef1fb;
}

:root[data-theme="dark"] .policy-group-title,
:root[data-theme="dark"] .backup-list-head a {
  color: #d8c8ff;
}

:root[data-theme="dark"] .backup-list-head a {
  background: #30264b;
  border: 1px solid #514078;
  color: #eee8ff;
}

:root[data-theme="dark"] .policy-group input[type="checkbox"],
:root[data-theme="dark"] .policy-screens input[type="checkbox"] {
  accent-color: #8b5cf6;
}

:root[data-theme="dark"] .calendar-day.muted-day {
  background: #191d29;
  color: #545b70;
}

:root[data-theme="dark"] .calendar-day.has-backup {
  background: #332657;
  border-color: #4c3a7b;
  color: #d8c8ff;
}

:root[data-theme="dark"] .calendar-day.selected {
  background: #7c3aed;
  color: #ffffff !important;
}

:root[data-theme="dark"] .danger-soft {
  background: #4b1e24;
  color: #ffb7c0;
}

:root[data-theme="dark"] .demo-switch.is-on {
  background: linear-gradient(135deg, var(--night-primary-a), var(--night-primary-b));
  box-shadow: var(--night-primary-shadow), inset 0 2px 5px rgba(8, 10, 18, .22);
}

:root[data-theme="dark"] .demo-switch.is-off {
  background: #2a2f40;
  border-color: #3a4054;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .18);
}

:root[data-theme="dark"] .switch-knob {
  background: #f0f2f7;
  box-shadow: 0 5px 12px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .88);
}

:root[data-theme="dark"] .switch-text.off {
  color: #b5bbca;
  text-shadow: none;
}

:root[data-theme="dark"] .switch-text.on {
  color: #f5f3ff;
  text-shadow: none;
}

@media (max-width: 900px) {
  :root { --card-gap: 14px; }
  html { scroll-padding-top: 250px; }
  section[id] { scroll-margin-top: 250px; }

  .topbar {
    grid-template-columns: 48px minmax(0, 1fr);
    height: auto;
    gap: 14px;
    padding: 18px 18px 16px;
  }

  .brand,
  .status-pill,
  .topbar-spacer {
    grid-column: 1 / -1;
  }

  .topbar-spacer {
    display: none;
  }

  .mark {
    width: 40px;
    height: 40px;
  }

  .mark img {
    height: 38px;
    width: 38px;
  }

  .icon-btn {
    grid-column: 1 / 2;
    width: 48px;
    height: 48px;
    border-radius: 18px;
  }

  .primary-btn,
  .topbar form:last-child {
    width: 100%;
  }

  .topbar form:last-child {
    grid-column: 2 / -1;
  }

  .nav {
    height: 54px;
    overflow-x: auto;
    gap: 8px;
    padding: 0 14px;
    top: 0;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar { display: none; }

  .nav a {
    flex: 0 0 auto;
  }

  main {
    padding: 14px 14px 48px;
  }

  .hero-grid,
  .hero-card,
  .review-grid,
  .status-grid,
  .debug-grid,
  .backup-layout,
  .file-grid {
    grid-template-columns: 1fr;
  }

  .hero-card {
    min-height: 0;
    padding: 26px;
  }

  .hero-copy h1 {
    font-size: 28px;
  }

  .section-card {
    padding: 18px;
    border-radius: 20px;
  }

  .section-head,
  .section-actions,
  .actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .thumb {
    width: 150px;
  }
}

@media (max-width: 640px) {
  html {
    scroll-padding-top: 190px;
  }

  body {
    overflow-x: hidden;
  }

  .topbar {
    gap: 10px;
    grid-template-columns: 44px 44px minmax(0, 1fr);
    padding: 14px 12px 12px;
  }

  .brand {
    font-size: 17px;
  }

  .icon-btn {
    border-radius: 16px;
    grid-column: auto;
    height: 44px;
    width: 44px;
  }

  .theme-toggle {
    grid-column: 3 / -1;
    height: 44px;
    min-height: 44px;
    width: 100%;
  }

  .topbar form:last-child {
    grid-column: 3 / -1;
  }

  .topbar .primary-btn {
    min-height: 44px;
    padding: 0 18px;
    width: 100%;
  }

  .status-pill {
    min-height: 48px;
    padding: 0 16px;
  }

  .nav {
    justify-content: flex-start;
    padding: 0 12px;
  }

  .nav a {
    min-width: 104px;
    padding: 0 18px;
  }

  main {
    padding: 12px 10px max(92px, calc(42px + env(safe-area-inset-bottom)));
  }

  .hero-card {
    gap: 20px;
    padding: 24px 20px;
  }

  .hero-copy h1 {
    font-size: 30px;
    line-height: 1.12;
  }

  .hero-copy p:not(.eyebrow) {
    font-size: 15px;
  }

  .hero-metrics {
    gap: 10px;
  }

  .hero-metrics article,
  .side-stack article {
    padding: 18px;
  }

  .section-card {
    padding: 16px 12px;
  }

  .section-head {
    gap: 14px;
  }

  .section-head h2 {
    font-size: 26px;
  }

  .status-list div {
    gap: 10px;
    grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
  }

  .status-list dt {
    font-size: 13px;
  }

  .status-list dd {
    font-size: 15px;
  }

  .toggle-stack article {
    grid-template-columns: minmax(0, 1fr) 118px;
  }

  .demo-switch {
    width: 118px;
  }

  .policy-screens {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .policy-form .check {
    min-width: 0;
  }

  .policy-form .check input {
    flex: 0 0 auto;
  }

  .policy-form > button[type="submit"] {
    width: 100%;
  }

  .backup-layout {
    gap: 18px;
  }

  .backup-list {
    max-height: none;
    min-height: 0;
    overflow: visible;
    padding-right: 0;
  }

  .backup-list-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .backup-item {
    gap: 12px;
  }

  .backup-calendar-panel {
    min-width: 0;
    overflow: hidden;
  }

  .backup-calendar {
    column-gap: 6px;
    grid-template-rows: auto repeat(6, 40px);
    row-gap: 8px;
  }

  .calendar-day {
    border-radius: 11px;
    font-size: 14px;
    height: 40px;
    min-width: 0;
  }

  .calendar-head a {
    flex: 0 0 34px;
  }

  .status-table-wrap {
    overflow: visible;
  }

  .status-table {
    table-layout: fixed;
    width: 100%;
  }

  .status-table th,
  .status-table td {
    height: auto;
    max-height: none;
    padding: 12px 8px;
    white-space: nowrap;
  }

  .status-table th {
    font-size: 11px;
  }

  .status-table td {
    font-size: 14px;
  }

  .status-table th:nth-child(2),
  .status-table td:nth-child(2),
  .status-table th:nth-child(4),
  .status-table td:nth-child(4) {
    display: none;
  }

  .status-table th:nth-child(1),
  .status-table td:nth-child(1) {
    width: 54%;
  }

  .status-table th:nth-child(3),
  .status-table td:nth-child(3) {
    width: 46%;
  }

  .history-tabs {
    grid-template-columns: repeat(9, minmax(112px, 1fr));
    gap: 8px;
    margin: 16px -2px 14px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .history-tabs::-webkit-scrollbar {
    display: none;
  }

  .history-tabs a {
    min-height: 42px;
    padding: 0 14px;
  }

  #history .table-wrap {
    background: transparent;
    border-radius: 0;
    overflow: visible;
  }

  #history table,
  #history tbody,
  #history tr,
  #history td {
    display: block;
  }

  #history table {
    background: transparent;
  }

  #history thead {
    display: none;
  }

  #history tbody {
    display: grid;
    gap: 12px;
  }

  #history tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(26, 22, 61, .07);
    display: grid;
    gap: 10px 12px;
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-areas:
      "status actions"
      "thumb recognition"
      "thumb file"
      "score api";
    padding: 12px;
  }

  #history td {
    background: transparent;
    border: 0;
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 0;
    width: auto !important;
  }

  #history td:nth-child(1) {
    grid-area: status;
  }

  #history td:nth-child(2) {
    grid-area: thumb;
  }

  #history td:nth-child(3) {
    grid-area: file;
    min-width: 0;
  }

  #history td:nth-child(4) {
    grid-area: recognition;
    min-width: 0;
  }

  #history td:nth-child(5) {
    grid-area: score;
  }

  #history td:nth-child(6) {
    align-self: center;
    grid-area: api;
    justify-self: start;
  }

  #history td:nth-child(7) {
    grid-area: actions;
    justify-self: end;
    padding-right: 0;
  }

  #history .badge {
    min-height: 30px;
    padding: 0 11px;
  }

  #history .thumb {
    border-radius: 12px;
    width: 72px;
  }

  #history .file-cell .path {
    font-size: 12px;
    max-width: 100%;
  }

  #history .file-cell .compact-result {
    font-size: 12px;
    margin-top: 2px;
  }

  #history .recognition-cell {
    gap: 8px;
  }

  #history .jacket-thumb {
    border-radius: 10px;
    flex-basis: 46px;
    height: 46px;
    width: 46px;
  }

  #history .badge-stack {
    flex-basis: 40px;
    width: 40px;
  }

  #history .mini-badge {
    min-width: 40px;
  }

  #history .song-title {
    font-size: 14px;
  }

  #history .composer-line {
    font-size: 12px;
  }

  #history .score-pill {
    min-height: 34px;
    min-width: 72px;
    font-size: 15px;
  }

  #history .score-compare {
    gap: 6px;
    grid-template-columns: 72px 16px minmax(78px, 1fr);
  }

  #history .score-pill-previous,
  #history .score-new-label {
    min-width: 0;
  }

  #history .score-pill-previous {
    border-radius: 12px;
    min-height: 32px;
    font-size: 14px;
  }

  #history .api-pill {
    min-height: 30px;
    padding: 0 12px;
  }

  #history .actions {
    flex-direction: row;
    gap: 6px;
    justify-content: flex-end;
    min-height: 0;
  }

  #history .action-link,
  #history .upload-action,
  #history .actions button {
    min-height: 34px;
    min-width: 58px;
    padding: 0 12px;
  }

  #history .empty {
    display: block;
    padding: 24px 12px;
  }
}
