:root {
  color-scheme: light;
  --background: #ffffff;
  --surface: #f8fafc;
  --surface-strong: #eef6f4;
  --text: #111827;
  --muted: #64748b;
  --border: #dbe5e2;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --progress: #f59e0b;
  --danger: #b91c1c;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 22px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: var(--surface-strong);
  color: var(--primary);
}

.brand-mark svg,
button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 760;
  line-height: 1.1;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.download-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 10px;
}

input {
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.icon-button,
.primary-button,
.text-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  background: #ffffff;
  color: var(--primary);
  border: 1px solid var(--border);
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 0 16px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 760;
}

.primary-button:active,
.icon-button:active,
.text-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.35;
}

.compact-heading {
  align-items: baseline;
  margin-bottom: 8px;
}

.helper-text,
.helper-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.helper-copy code {
  font-size: 12px;
}

.cookies-card {
  margin-top: 14px;
}

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

.cookies-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.cookies-row input[type="file"] {
  height: 44px;
  padding: 10px 12px;
}

.queue-section {
  padding-top: 26px;
}

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

h2 {
  font-size: 18px;
  font-weight: 760;
}

.text-button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--surface-strong);
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 700;
}

.queue-list {
  display: grid;
  gap: 10px;
}

.empty-state,
.queue-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.empty-state {
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.queue-item {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.queue-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.queue-title {
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.queue-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-chip {
  flex: 0 0 auto;
  min-width: 70px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--primary-strong);
  text-align: center;
  font-size: 12px;
  font-weight: 760;
}

.status-chip.error {
  background: #fee2e2;
  color: var(--danger);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-bar {
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--progress);
  transition: width 180ms ease;
}

.download-link {
  justify-self: start;
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
}

.player-card {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.player-card audio {
  width: 100%;
}

.is-hidden {
  display: none;
}

.track-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.track-button .queue-row {
  width: 100%;
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.thumb-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: start;
}

.thumb {
  width: 88px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  background: #e2e8f0;
}

@media (min-width: 760px) {
  body {
    background: #f1f5f9;
  }

  .app-shell {
    min-height: auto;
    margin-top: 42px;
    margin-bottom: 42px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: #ffffff;
  }
}
