:root {
  color-scheme: dark;
  --background: #030303;
  --panel: #0c0c0d;
  --panel-strong: #141414;
  --field: #050505;
  --text: #f4f0e4;
  --muted: #938f86;
  --line: rgba(245, 238, 216, 0.11);
  --line-strong: rgba(245, 238, 216, 0.18);
  --accent: #e2b84b;
  --accent-strong: #f2ca63;
  --danger: #e86d6d;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.62);
  --radius: 2px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background: linear-gradient(90deg, rgba(226, 184, 75, 0.08), transparent 38rem);
  opacity: 0.48;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 28px 0;
}

.app-layout {
  display: block;
}

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

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

.usage-total {
  min-width: 108px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080808;
  opacity: 0.82;
}

.usage-total span,
.usage-total strong {
  display: block;
}

.usage-total span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.usage-total strong {
  margin-top: 2px;
}

.usage-total.is-exceeded {
  border-color: rgba(232, 109, 109, 0.62);
  color: #ffd0d0;
  opacity: 1;
}

.app-header h1,
h2 {
  margin: 0;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.app-header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
}

.app-header p,
.section-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.panel {
  margin-top: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-heading,
.progress-header,
.actions,
.result-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 20px;
}

.playlist-controls {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.playlist-current {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080808;
}

.playlist-manage-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.playlist-current strong,
.playlist-current span {
  display: block;
}

.playlist-current span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  color: var(--text);
  background-color: var(--field);
  outline: none;
}

select {
  appearance: none;
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 54%,
    calc(100% - 14px) 54%;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
}

input:focus,
select:focus {
  border-color: rgba(226, 184, 75, 0.72);
  box-shadow: 0 0 0 4px rgba(226, 184, 75, 0.11);
}

.drop-zone {
  display: grid;
  position: relative;
  align-content: center;
  justify-items: center;
  gap: 0;
  place-items: center;
  min-height: 210px;
  padding: 30px;
  border: 1.5px dashed rgba(226, 184, 75, 0.24);
  border-radius: var(--radius);
  background: var(--field);
  text-align: center;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-zone.is-disabled {
  border-color: var(--line);
  color: var(--muted);
}

.drop-zone:not(.is-disabled):hover,
.drop-zone:not(.is-disabled):focus-within {
  border-color: rgba(242, 202, 99, 0.82);
  background: rgba(226, 184, 75, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(242, 202, 99, 0.24),
    0 0 0 4px rgba(226, 184, 75, 0.1);
  transform: translateY(-1px);
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(226, 184, 75, 0.08);
  transform: translateY(-2px);
}

.drop-zone.has-files {
  align-content: start;
  padding: 18px;
}

.drop-zone.has-files .upload-icon {
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
  font-size: 1.65rem;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  color: #12100a;
  background: var(--accent-strong);
  box-shadow: 0 12px 34px rgba(226, 184, 75, 0.16);
  font-size: 2.2rem;
  font-weight: 700;
}

.drop-title {
  font-size: 1.25rem;
  font-weight: 900;
}

.drop-copy {
  margin-top: 8px;
  color: var(--muted);
}

.file-list {
  display: grid;
  width: 100%;
  max-height: 144px;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 8px;
  margin-top: 14px;
  overflow: auto;
}

.file-list:empty {
  display: none;
}

.file-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 8, 8, 0.9);
  text-align: left;
}

.file-card > div {
  min-width: 0;
}

.file-card img {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--panel-strong);
}

.file-card strong,
.file-card span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.actions {
  justify-content: flex-end;
  margin-top: 22px;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: var(--radius);
  min-height: 46px;
  padding: 12px 18px;
  font-weight: 900;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.primary-button {
  color: #14110a;
  background: var(--accent-strong);
  box-shadow: 0 12px 32px rgba(226, 184, 75, 0.14);
}

.primary-button:hover:not(:disabled) {
  background: #f6d06f;
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: #090909;
}

.ghost-button:hover:not(:disabled) {
  border-color: rgba(226, 184, 75, 0.28);
  background: rgba(226, 184, 75, 0.08);
}

.danger-button {
  color: #ffc9c9;
}

.danger-button:hover:not(:disabled) {
  border-color: rgba(232, 109, 109, 0.38);
  background: rgba(232, 109, 109, 0.1);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #090909;
}

.summary-card strong {
  display: block;
  font-size: 1.8rem;
}

.summary-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.integration-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080808;
}

.integration-toolbar > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.integration-toggle {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.integration-toggle-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  color: var(--muted);
  background: #050505;
  font-size: 0.78rem;
  font-weight: 900;
}

.integration-toggle-button:hover {
  border-color: rgba(226, 184, 75, 0.32);
  color: var(--text);
}

.integration-toggle-button.is-active {
  border-color: rgba(226, 184, 75, 0.42);
  color: #14110a;
  background: var(--accent-strong);
}

.result-note {
  margin: 8px 0 0;
  color: var(--muted);
}

.result-note.is-warning {
  color: var(--accent-strong);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

tbody tr:hover {
  background: rgba(226, 184, 75, 0.045);
}

tbody tr.integration-row-bought td,
tbody tr.bandcamp-row-bought td {
  background: rgba(90, 176, 118, 0.12);
}

tbody tr.integration-row-bought:hover td,
tbody tr.bandcamp-row-bought:hover td {
  background: rgba(90, 176, 118, 0.18);
}

tbody tr.integration-row-not_available td,
tbody tr.bandcamp-row-not_available td {
  background: rgba(232, 109, 109, 0.11);
}

tbody tr.integration-row-not_available:hover td,
tbody tr.bandcamp-row-not_available:hover td {
  background: rgba(232, 109, 109, 0.17);
}

tbody tr.integration-row-bought td:first-child,
tbody tr.bandcamp-row-bought td:first-child {
  border-left: 3px solid rgba(90, 176, 118, 0.72);
}

tbody tr.integration-row-not_available td:first-child,
tbody tr.bandcamp-row-not_available td:first-child {
  border-left: 3px solid rgba(232, 109, 109, 0.7);
}

.track-title-cell {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-width: 250px;
}

.track-artwork {
  display: block;
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(226, 184, 75, 0.14), transparent),
    var(--panel-strong);
  object-fit: cover;
}

span.track-artwork::after {
  display: block;
  color: rgba(245, 238, 216, 0.3);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 56px;
  text-align: center;
  text-transform: uppercase;
  content: "art";
}

.track-title-text {
  min-width: 0;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions-cell {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.compact-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.add-track-row td {
  background: rgba(226, 184, 75, 0.035);
}

.add-track-row.is-editing td {
  background: rgba(226, 184, 75, 0.075);
}

.add-track-row input {
  min-height: 38px;
  padding: 8px 10px;
}

.table-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.inline-add-button {
  border: 1px dashed rgba(226, 184, 75, 0.42);
  border-radius: var(--radius);
  min-height: 38px;
  padding: 8px 12px;
  color: var(--accent-strong);
  background: rgba(226, 184, 75, 0.07);
  font-weight: 900;
}

.inline-add-button:hover {
  border-color: rgba(242, 202, 99, 0.78);
  background: rgba(226, 184, 75, 0.12);
}

.sort-button {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: 900;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
}

.primary-button.is-loading {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.primary-button.is-loading::before {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(20, 17, 10, 0.32);
  border-top-color: #14110a;
  border-radius: 50%;
  content: "";
  animation: spin 800ms linear infinite;
}

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

.is-hidden {
  display: none !important;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.auth-panel {
  width: min(560px, 100%);
}

.auth-panel h1 {
  font-size: clamp(2.4rem, 7vw, 4.2rem);
}

.hero-copy {
  max-width: 720px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.auth-error {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(226, 184, 75, 0.35);
  border-radius: var(--radius);
  color: var(--accent-strong);
  background: rgba(226, 184, 75, 0.08);
}

.auth-success {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(90, 176, 118, 0.44);
  border-radius: var(--radius);
  color: #bdf0cc;
  background: rgba(90, 176, 118, 0.1);
}

.result-actions {
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.import-button {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 18px;
  color: var(--text);
  background: #090909;
  font-weight: 900;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
}

.import-button:hover {
  border-color: rgba(226, 184, 75, 0.28);
  background: rgba(226, 184, 75, 0.08);
}

.import-button:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.48;
}

.import-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.integration-cell,
.bandcamp-cell {
  display: grid;
  gap: 8px;
  min-width: 130px;
}

.integration-cell a,
.bandcamp-cell a {
  color: var(--accent);
  font-weight: 900;
  text-decoration: none;
}

.integration-cell a:hover,
.bandcamp-cell a:hover {
  text-decoration: underline;
}

.integration-mark-actions,
.bandcamp-mark-actions {
  display: flex;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  color: var(--muted);
  background: #050505;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
}

.icon-button:hover {
  border-color: rgba(226, 184, 75, 0.32);
  color: var(--text);
}

.icon-button.is-active {
  border-color: rgba(226, 184, 75, 0.42);
  color: #14110a;
  background: var(--accent-strong);
}

@media (min-width: 1120px) {
  body {
    overflow: hidden;
  }

  .shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(1840px, calc(100% - 20px));
    height: 100dvh;
    min-height: 0;
    padding: 14px 0;
  }

  .app-header h1 {
    font-size: clamp(1.9rem, 2.3vw, 2.6rem);
  }

  .app-header {
    margin-bottom: 12px;
  }

  .app-layout {
    display: grid;
    grid-template-columns: clamp(340px, 21vw, 400px) minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
  }

  .left-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
    padding: 0;
  }

  .left-stack .panel,
  .results-panel {
    margin-top: 0;
  }

  .left-stack .panel {
    padding: 16px;
    box-shadow: none;
  }

  .left-stack .panel-heading {
    margin-bottom: 12px;
  }

  .left-stack h2 {
    font-size: 1.45rem;
  }

  .left-stack .section-copy {
    margin-top: 6px;
    font-size: 0.86rem;
    line-height: 1.4;
  }

  .left-stack .playlist-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
  }

  .left-stack .playlist-controls .primary-button {
    grid-column: 1 / -1;
  }

  .left-stack input,
  .left-stack select {
    padding: 11px 12px;
  }

  .left-stack .playlist-current {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
    padding: 12px;
  }

  .left-stack .playlist-manage-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .upload-panel {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
  }

  .upload-panel .drop-zone {
    flex: 1;
    min-height: 0;
    padding: 18px;
  }

  .upload-panel .drop-zone.has-files {
    grid-template-rows: auto auto auto minmax(0, 1fr);
    align-content: stretch;
    align-items: start;
    padding: 14px;
  }

  .upload-panel .actions {
    gap: 8px;
    margin-top: 12px;
  }

  .upload-panel .actions .primary-button {
    flex: 1;
  }

  .upload-panel .actions .ghost-button {
    padding-inline: 14px;
  }

  .upload-panel .file-list {
    align-self: stretch;
    height: 100%;
    min-height: 0;
    max-height: none;
    grid-template-columns: 1fr;
  }

  .results-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
  }

  .table-wrap {
    flex: 1;
    min-height: 0;
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding: 24px 0;
  }

  .app-header,
  .header-actions,
  .playlist-current,
  .panel-heading,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .playlist-controls,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }

  .integration-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
