:root {
  --bg: #090d14;
  --bg-2: #0d1420;
  --panel: rgba(17, 24, 37, 0.88);
  --panel-solid: #111825;
  --panel-muted: #182233;
  --panel-soft: #101725;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e7edf7;
  --muted: #91a0b7;
  --muted-strong: #b8c2d4;
  --accent: #3dd6c6;
  --accent-dark: #16a394;
  --accent-soft: rgba(61, 214, 198, 0.13);
  --danger: #ff8f86;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --success: #78e0a3;
  --success-soft: rgba(74, 222, 128, 0.13);
  --warning: #ffd27a;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  --glow: 0 0 0 1px rgba(61, 214, 198, 0.12), 0 18px 44px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -8%, rgba(61, 214, 198, 0.12), transparent 26%),
    radial-gradient(circle at 85% 8%, rgba(104, 117, 245, 0.1), transparent 28%),
    linear-gradient(145deg, var(--bg), var(--bg-2) 58%, #070a10);
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 18px;
}

.app-header h1,
.panel h2,
.playlist-card h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
}

.app-header h1 {
  color: #f6f8fc;
  font-size: clamp(1.35rem, 1rem + 1vw, 2rem);
}

.app-summary {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.app-footer {
  margin-top: 22px;
  padding: 18px 0 0;
  border-top: 1px solid var(--border);
}

.app-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.app-footer form {
  margin: 0;
}

.app-footer a,
.legal-copy a,
.policy-consent a {
  color: #9af4eb;
  text-decoration: none;
}

.app-footer a:hover,
.legal-copy a:hover,
.policy-consent a:hover {
  text-decoration: underline;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.auth-layout {
  display: grid;
  min-height: 46vh;
  align-items: center;
}

.auth-panel,
.finish-panel {
  width: min(520px, 100%);
  margin: 0 auto;
}

.finish-layout {
  display: grid;
  min-height: 50vh;
  align-items: center;
}

.finish-panel {
  text-align: center;
}

.finish-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border: 1px solid rgba(61, 214, 198, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(61, 214, 198, 0.2), rgba(61, 214, 198, 0.06) 58%, transparent 62%);
  box-shadow: 0 0 34px rgba(61, 214, 198, 0.22);
  animation: finish-pop 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.finish-mark::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(61, 214, 198, 0.22);
  border-radius: inherit;
  animation: finish-ring 900ms ease-out 120ms both;
}

.finish-mark span {
  width: 32px;
  height: 18px;
  border-bottom: 4px solid var(--accent);
  border-left: 4px solid var(--accent);
  transform: rotate(-45deg) translate(2px, -2px);
  animation: finish-check 460ms ease-out 220ms both;
}

.finish-actions {
  display: flex;
  justify-content: center;
  margin: 18px 0 8px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 16px 0 10px;
}

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

.policy-consent {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  max-width: 430px;
  color: var(--muted-strong);
  font-size: 0.86rem;
}

.policy-consent span {
  margin: 0;
  color: inherit;
  font-size: inherit;
  font-weight: 600;
}

.workspace-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 6px 0 16px;
}

.workspace-heading h2 {
  margin: 0;
  color: #f6f8fc;
  font-size: 1.08rem;
}

.workspace-heading p {
  max-width: 660px;
  margin: 4px 0 0;
  color: var(--muted);
}

.dashboard-grid,
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(340px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(20, 29, 44, 0.94), rgba(13, 20, 32, 0.94));
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(16px);
}

.primary-panel {
  border-color: rgba(61, 214, 198, 0.34);
  box-shadow: var(--glow);
}

.alert-panel {
  border-color: rgba(255, 143, 134, 0.34);
  background: linear-gradient(180deg, rgba(45, 22, 27, 0.92), rgba(25, 16, 22, 0.94));
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading h2 {
  color: #f4f7fb;
  font-size: 1rem;
}

.section-heading p,
.hint,
.subtle,
.status,
.run-meta,
.playlist-card p,
.empty-state p {
  margin: 3px 0 0;
  color: var(--muted);
}

.legal-panel {
  max-width: 860px;
  margin: 0 auto 16px;
}

.legal-copy {
  display: grid;
  gap: 12px;
}

.legal-copy h3 {
  margin: 6px 0 0;
  color: #f6f8fc;
  font-size: 0.98rem;
}

.legal-copy p {
  margin: 0;
  color: var(--muted-strong);
}

.inline-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stack {
  display: grid;
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 650;
}

input:not([type="checkbox"]):not([type="radio"]),
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: rgba(7, 12, 20, 0.82);
  color: var(--text);
}

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

input:not([type="checkbox"]):not([type="radio"])::placeholder {
  color: #6f7d91;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus {
  outline: 2px solid rgba(61, 214, 198, 0.18);
  border-color: rgba(61, 214, 198, 0.72);
  box-shadow: 0 0 0 4px rgba(61, 214, 198, 0.06);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin: 0;
  padding: 0;
}

button,
.secondary-button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(61, 214, 198, 0.62);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(61, 214, 198, 0.95), rgba(22, 163, 148, 0.95));
  color: #041111;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 10px 28px rgba(22, 163, 148, 0.18);
}

button:hover,
.secondary-button:hover,
.button-link:hover {
  border-color: rgba(93, 240, 226, 0.82);
  background: linear-gradient(180deg, #5df0e2, #24b6a7);
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.46;
  box-shadow: none;
}

.secondary-button,
.secondary-action,
.footer-button {
  background: rgba(10, 16, 26, 0.74);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: none;
}

.secondary-button:hover,
.secondary-action:hover,
.footer-button:hover {
  color: #f6f8fc;
  background: rgba(24, 34, 51, 0.92);
  border-color: rgba(148, 163, 184, 0.42);
}

.footer-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 0.82rem;
}

.panel-actions {
  margin: 14px 0;
}

.flash {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 16px;
  background: rgba(17, 24, 37, 0.92);
}

.flash-success {
  border-color: rgba(120, 224, 163, 0.32);
  background: var(--success-soft);
  color: var(--success);
}

.flash-error {
  border-color: rgba(255, 143, 134, 0.34);
  background: var(--danger-soft);
  color: var(--danger);
}

.error-list {
  margin: 0;
  padding-left: 18px;
  color: var(--danger);
}

.status-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border);
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  background: rgba(12, 18, 29, 0.92);
}

.status-row span {
  color: var(--muted);
}

.status-row strong,
.ok,
.missing {
  font-size: 0.82rem;
}

.ok {
  color: var(--success);
}

.missing {
  color: var(--warning);
}

.compact-list {
  display: grid;
  gap: 8px;
}

.playlist-picker-panel {
  padding: 0;
  overflow: hidden;
}

.playlist-picker-form {
  display: grid;
}

.picker-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.picker-toolbar .section-heading {
  margin: 0;
}

.playlist-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  padding: 18px;
}

.playlist-select-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(15, 23, 37, 0.9), rgba(9, 15, 25, 0.92));
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.playlist-select-card:hover {
  border-color: rgba(61, 214, 198, 0.34);
  background:
    linear-gradient(180deg, rgba(20, 32, 49, 0.94), rgba(11, 19, 31, 0.96));
  transform: translateY(-1px);
}

.playlist-select-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.playlist-select-card:has(input:checked) {
  border-color: rgba(93, 240, 226, 0.9);
  background:
    radial-gradient(circle at 12% 0%, rgba(61, 214, 198, 0.16), transparent 42%),
    linear-gradient(180deg, rgba(18, 39, 51, 0.98), rgba(10, 22, 32, 0.98));
  box-shadow:
    0 0 0 1px rgba(61, 214, 198, 0.22),
    0 0 28px rgba(61, 214, 198, 0.18),
    0 16px 36px rgba(0, 0, 0, 0.34);
}

.playlist-select-card:has(input:focus-visible) {
  outline: 2px solid rgba(61, 214, 198, 0.26);
  outline-offset: 2px;
}

.playlist-check {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: rgba(5, 10, 17, 0.82);
  box-shadow: inset 0 0 0 3px rgba(5, 10, 17, 0.92);
}

.playlist-select-card:has(input:checked) .playlist-check {
  border-color: var(--accent);
  background: var(--accent);
}

.playlist-card-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.playlist-card-main strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-card-main span {
  color: var(--muted);
  font-size: 0.86rem;
}

.playlist-card-count {
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.picker-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 18px 18px;
}

.playlist-card,
.empty-state {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(10, 16, 26, 0.64);
}

.playlist-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.playlist-card:hover {
  border-color: rgba(61, 214, 198, 0.26);
  background: rgba(18, 27, 42, 0.84);
  transform: translateY(-1px);
}

.playlist-card h3 {
  color: var(--text);
  font-size: 0.95rem;
}

.playlist-card strong {
  color: var(--accent);
  font-size: 0.84rem;
  white-space: nowrap;
}

.empty-state {
  padding: 14px;
}

.empty-state strong {
  color: var(--text);
}

.hidden,
.is-filtered {
  display: none;
}

.run-panel {
  display: grid;
  gap: 14px;
}

.run-summary,
.review-toolbar,
.toolbar-actions,
.run-meta {
  display: flex;
  gap: 12px;
  align-items: center;
}

.run-summary,
.review-toolbar {
  justify-content: space-between;
}

.run-summary h2 {
  font-size: 1.12rem;
}

.run-meta {
  flex-wrap: wrap;
  font-size: 0.86rem;
}

.status-pill,
.badge,
.confidence {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(61, 214, 198, 0.2);
  border-radius: 999px;
  background: var(--accent-soft);
  color: #9af4eb;
  font-size: 0.78rem;
  font-weight: 750;
}

.badge.muted {
  margin-top: 7px;
  border-color: var(--border);
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
}

.confidence {
  min-width: 36px;
  justify-content: center;
  border-color: var(--border);
  background: rgba(148, 163, 184, 0.09);
  color: var(--muted-strong);
}

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

.metric {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(8, 13, 22, 0.64);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 2px;
  color: #f8fbff;
  font-size: 1.25rem;
}

.review-panel {
  padding: 0;
  overflow: hidden;
}

.review-toolbar {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.review-toolbar .section-heading {
  margin: 0;
}

.toolbar-actions {
  flex: 1;
  justify-content: flex-end;
}

.toolbar-actions input {
  max-width: 330px;
}

.table-wrap {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.results-table th {
  background: rgba(8, 13, 22, 0.78);
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.results-table tbody tr {
  transition: background 140ms ease;
}

.results-table tbody tr:hover {
  background: rgba(61, 214, 198, 0.045);
}

.results-table tr:last-child td {
  border-bottom: 0;
}

.song-cell {
  min-width: 210px;
}

.reason-cell {
  min-width: 220px;
  color: var(--muted);
}

.mood-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 270px;
}

.mood-option {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.mood-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mood-option span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(8, 13, 22, 0.72);
  color: var(--muted-strong);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.mood-option span:hover {
  border-color: rgba(61, 214, 198, 0.36);
  color: var(--text);
}

.mood-option input:checked + span {
  border-color: rgba(61, 214, 198, 0.66);
  background: var(--accent-soft);
  color: #9af4eb;
  box-shadow: inset 0 0 0 1px rgba(61, 214, 198, 0.08);
}

.mood-option input:focus-visible + span {
  outline: 2px solid rgba(61, 214, 198, 0.2);
  outline-offset: 2px;
}

form.is-submitting {
  pointer-events: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 8, 14, 0.74);
  backdrop-filter: blur(7px);
}

.loading-overlay.is-visible {
  display: flex;
}

.loading-card {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 28px;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(17, 24, 37, 0.96);
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(61, 214, 198, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-title,
.loading-message {
  margin: 0;
}

.loading-title {
  color: #f8fbff;
  font-weight: 800;
}

.loading-message {
  color: var(--muted);
}

.loading-bar {
  grid-column: 1 / -1;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
}

.loading-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: indeterminate 1.1s ease-in-out infinite;
}

.loading-overlay.is-progress .loading-bar span {
  width: 0;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  animation: none;
  transition: width 260ms ease;
}

.loading-progress-text {
  grid-column: 1 / -1;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes indeterminate {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(260%);
  }
}

@keyframes finish-pop {
  0% {
    opacity: 0;
    transform: scale(0.82);
  }
  70% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes finish-ring {
  0% {
    opacity: 0.8;
    transform: scale(0.84);
  }
  100% {
    opacity: 0;
    transform: scale(1.32);
  }
}

@keyframes finish-check {
  0% {
    opacity: 0;
    transform: rotate(-45deg) translate(2px, -2px) scale(0.7);
  }
  100% {
    opacity: 1;
    transform: rotate(-45deg) translate(2px, -2px) scale(1);
  }
}

@media (max-width: 860px) {
  .app-header,
  .dashboard-grid,
  .workspace-grid,
  .workspace-heading,
  .picker-toolbar,
  .review-toolbar,
  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .app-summary {
    max-width: none;
    text-align: left;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions input,
  .toolbar-actions button,
  .toolbar-actions .secondary-button {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 14px;
  }

  .panel {
    padding: 14px;
  }

  .auth-actions {
    display: grid;
  }

  .playlist-select-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .playlist-select-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .playlist-card-count {
    grid-column: 2;
  }

  .picker-actions {
    padding: 0 14px 14px;
  }

  .picker-actions button,
  .picker-toolbar button {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .run-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .playlist-card,
  .status-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}
