/* Material Design (paper era) — elevation, Roboto, ink & paper palette */

:root {
  --bg: #fafafa;
  --surface: #fff;
  --navbar: #1976d2;
  --navbar-text: #fff;
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --primary-light: #e3f2fd;
  --primary-ripple: rgba(25, 118, 210, 0.12);
  --text-primary: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.54);
  --text-hint: rgba(0, 0, 0, 0.38);
  --divider: rgba(0, 0, 0, 0.12);
  --border: #e0e0e0;
  --code-bg: #f5f5f5;
  --warn-bg: #fff3e0;
  --warn-text: #e65100;
  --info-bg: #e3f2fd;
  --info-text: #1565c0;
  --error-bg: #ffebee;
  --error-text: #c62828;
  --reminder-bg: #e8f5e9;
  --reminder-text: #2e7d32;
  --reminder-border: #a5d6a7;
  --elevation-1: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  --elevation-2: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  --elevation-3: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
  --elevation-4: 0 4px 8px rgba(0, 0, 0, 0.22), 0 2px 4px rgba(0, 0, 0, 0.18);
  --radius: 2px;
  --font: Roboto, system-ui, -apple-system, sans-serif;
}

[data-theme='dark'] {
  --bg: #0d0d0d;
  --surface: #161616;
  --navbar: #0d47a1;
  --navbar-text: #fff;
  --primary: #64b5f6;
  --primary-dark: #42a5f5;
  --primary-light: #0d2137;
  --primary-ripple: rgba(100, 181, 246, 0.14);
  --text-primary: rgba(255, 255, 255, 0.87);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-hint: rgba(255, 255, 255, 0.38);
  --divider: rgba(255, 255, 255, 0.08);
  --border: #2a2a2a;
  --code-bg: #1f1f1f;
  --warn-bg: #2d1f14;
  --warn-text: #ffb74d;
  --info-bg: #0d1b2a;
  --info-text: #90caf9;
  --error-bg: #2a1212;
  --error-text: #ef9a9a;
  --reminder-bg: #0f1f12;
  --reminder-text: #81c784;
  --reminder-border: #2e5c32;
  --elevation-1: 0 1px 3px rgba(0, 0, 0, 0.6);
  --elevation-2: 0 2px 8px rgba(0, 0, 0, 0.7);
  --elevation-3: 0 6px 16px rgba(0, 0, 0, 0.75);
  --elevation-4: 0 4px 12px rgba(0, 0, 0, 0.8);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
}

/* App bar (MD toolbar) */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--navbar);
  color: var(--navbar-text);
  box-shadow: var(--elevation-4);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1.15rem;
  transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme='dark'] .icon-sun { display: inline; }
[data-theme='dark'] .icon-moon { display: none; }
.icon-sun { display: none; }
.icon-moon { display: inline; }

/* Layout */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.page-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

@media (min-width: 900px) {
  .page-grid {
    display: grid;
    grid-template-columns: minmax(300px, 380px) 1fr;
    gap: 24px;
    align-items: start;
  }

  #results-section .track-list {
    max-height: min(480px, calc(100vh - 280px));
  }
}

/* Paper cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--elevation-2);
  padding: 24px;
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  box-shadow: var(--elevation-3);
}

.card-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.body-text {
  margin: 0 0 16px;
  color: var(--text-secondary);
}

.auth-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

.auth-avatar-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 500;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.auth-avatar-placeholder.loading {
  color: transparent;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--primary) 10%, transparent) 0%,
    color-mix(in srgb, var(--primary) 22%, transparent) 50%,
    color-mix(in srgb, var(--primary) 10%, transparent) 100%
  );
  background-size: 200% 100%;
  animation: auth-avatar-shimmer 1.2s ease-in-out infinite;
}

@keyframes auth-avatar-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.auth-avatar {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.auth-playcount {
  color: var(--text-secondary);
  font-weight: 400;
}

.caption {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.tz-hint {
  margin: -8px 0 16px 34px;
}

.card-placeholder .caption {
  line-height: 1.6;
}

.card-placeholder[hidden] {
  display: none !important;
}

/* Buttons — raised & flat (MD1) */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 16px;
  min-height: 36px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none !important;
}

.btn-raised {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--elevation-2);
  padding: 0 20px;
}

.btn-raised:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: var(--elevation-3);
}

.btn-raised:active:not(:disabled) {
  box-shadow: var(--elevation-1);
}

[data-theme='dark'] .btn-raised {
  color: rgba(0, 0, 0, 0.87);
}

.btn-flat {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
}

.btn-flat:hover:not(:disabled) {
  background: var(--primary-ripple);
}

.btn-large {
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
}

/* Checkbox */
.md-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  cursor: pointer;
  margin: 0 0 20px;
  user-select: none;
}

.md-checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.md-checkbox-box {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 2px solid var(--text-secondary);
  border-radius: 2px;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.md-checkbox input:checked + .md-checkbox-box {
  background: var(--primary);
  border-color: var(--primary);
}

.md-checkbox input:checked + .md-checkbox-box::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

[data-theme='dark'] .md-checkbox input:checked + .md-checkbox-box::after {
  border-color: rgba(0, 0, 0, 0.87);
}

.md-checkbox input:focus-visible + .md-checkbox-box {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.md-checkbox-label {
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
}

/* Select — underline field style */
.field {
  margin: 0;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.md-input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 8px 0;
  margin-bottom: 4px;
  border: none;
  border-bottom: 1px solid var(--text-hint);
  border-radius: 0;
  background: transparent;
  color: var(--text-primary);
}

.md-input:focus {
  outline: none;
  border-bottom-width: 2px;
  border-bottom-color: var(--primary);
  padding-bottom: 7px;
}

.md-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.md-select {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 4px 0;
  margin-top: 4px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
}

.md-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.md-select[size] {
  height: auto;
  max-height: 11rem;
  overflow-y: auto;
}

.md-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Compact upload control */
.card-upload {
  padding: 16px 24px;
}

.upload-target {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 16px;
  margin: 0;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  transition:
    background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.2s,
    box-shadow 0.2s;
}

.upload-target:hover,
.upload-target.drag-over {
  background: var(--primary-ripple);
  box-shadow: var(--elevation-1);
}

.upload-target.has-file {
  border-style: solid;
  background: var(--primary-ripple);
}

.upload-target.has-file .upload-label {
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}

.upload-target.has-file .upload-hint {
  font-size: 12px;
}

.upload-target:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.upload-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
}

.upload-hint {
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-secondary);
}

.upload-hint::before {
  content: '·';
  margin-right: 8px;
  color: var(--text-hint);
}

code {
  font-size: 0.9em;
  font-family: 'Roboto Mono', Consolas, monospace;
  background: var(--code-bg);
  padding: 2px 4px;
  border-radius: 2px;
  color: var(--text-primary);
}

/* Preview stats */
.preview-stats {
  display: block;
  margin: 0 0 8px;
  color: var(--text-primary);
}

.preview-stats ul {
  margin: 12px 0;
  padding-left: 20px;
  color: var(--text-secondary);
}

.preview-stats .meta {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
}

#notices {
  display: block;
  margin: 0 0 16px;
}

#notices:empty {
  display: none;
}

.notice {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
  box-shadow: var(--elevation-1);
}

.notice-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.notice-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.notice-error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* Linear progress (MD) */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 20px;
}

.progress-track {
  flex: 1;
  display: block;
  height: 4px;
  background: var(--primary-light);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#progress-text {
  min-width: 4.5em;
  text-align: right;
}

/* Track picker */
.track-picker {
  margin: 16px 0;
}

.track-picker-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  flex-wrap: wrap;
}

.track-picker-actions {
  display: flex;
  gap: 4px;
}

.track-picker-actions .btn {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
}

/* Lists */
.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
}

.track-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--divider);
}

.track-row-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: default;
}

.track-select {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.track-select:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.track-select-spacer {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.track-list li.is-excluded {
  opacity: 0.55;
}

.track-list li:last-child {
  border-bottom: none;
}

.track-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.track-ts {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-pending {
  background: var(--code-bg);
  color: var(--text-secondary);
}
.badge-sending {
  background: var(--primary-light);
  color: var(--primary);
}
.badge-ok {
  background: #e8f5e9;
  color: #2e7d32;
}
[data-theme='dark'] .badge-ok {
  background: #1b3320;
  color: #81c784;
}
.badge-ignored {
  background: var(--warn-bg);
  color: var(--warn-text);
}
.badge-failed {
  background: var(--error-bg);
  color: var(--error-text);
}
.badge-too_old,
.badge-too_new {
  background: #fce4ec;
  color: #ad1457;
}
[data-theme='dark'] .badge-too_old,
[data-theme='dark'] .badge-too_new {
  background: #3b1c2a;
  color: #f48fb1;
}
.badge-skipped {
  background: var(--code-bg);
  color: var(--text-hint);
}
.badge-dry_run {
  background: var(--info-bg);
  color: var(--info-text);
}
.badge-excluded {
  background: var(--code-bg);
  color: var(--text-hint);
}

.scrobbled-list {
  margin: 12px 0 0;
  padding-left: 20px;
  max-height: 240px;
  overflow-y: auto;
  color: var(--text-primary);
}

.scrobbled-list li {
  margin-bottom: 6px;
}

.scrobbled-list .ts {
  color: var(--text-secondary);
  font-size: 12px;
}

/* Reminder snackbar-style */
.reminder {
  display: block;
  background: var(--reminder-bg);
  color: var(--reminder-text);
  border-left: 4px solid var(--reminder-border);
  border-radius: var(--radius);
  box-shadow: var(--elevation-2);
  padding: 16px 20px;
  text-align: left;
  margin: 0;
  font-size: 14px;
}

.results-summary {
  display: block;
  margin: 0 0 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
  color: var(--text-primary);
}

.results-summary[hidden] {
  display: none !important;
}

#results-section.is-complete .progress-wrap {
  margin-bottom: 12px;
}

.summary-line {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.summary-line.error {
  color: var(--error-text);
}

.summary-heading {
  display: block;
  margin: 16px 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
}

.notice-info-inline {
  display: block;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--info-bg);
  color: var(--info-text);
  border-radius: var(--radius);
  font-size: 13px;
}
