:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --ink: #17202a;
  --muted: #60707d;
  --line: #d8e0e5;
  --blue: #2563eb;
  --green: #16865a;
  --amber: #b7791f;
  --red: #c2413a;
  --shadow: 0 24px 70px rgba(30, 47, 67, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.08), transparent 40%),
    linear-gradient(300deg, rgba(22, 134, 90, 0.09), transparent 44%),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(216, 224, 229, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 16px;
}

.support-pill {
  flex: 0 0 auto;
  max-width: 320px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.4;
}

.support-pill.ok {
  color: #0f6a45;
  border-color: rgba(22, 134, 90, 0.35);
  background: rgba(22, 134, 90, 0.08);
}

.support-pill.limited {
  color: #87570d;
  border-color: rgba(183, 121, 31, 0.36);
  background: rgba(183, 121, 31, 0.1);
}

.layout {
  display: grid;
  grid-template-columns: minmax(270px, 330px) 1fr;
  min-height: 680px;
}

.controls {
  padding: 22px;
  background: #f8fafb;
  border-right: 1px solid var(--line);
}

.control-group {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.control-group label,
.control-label,
.switch {
  color: #273441;
  font-size: 14px;
  font-weight: 700;
}

.control-label {
  display: block;
}

.format-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e9eff4;
}

.format-toggle label {
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #536372;
  cursor: pointer;
  font-weight: 800;
}

.format-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.format-toggle label:has(input:checked) {
  color: white;
  background: var(--blue);
}

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

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.number-input {
  width: 72px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-align: center;
}

.switch-row {
  display: grid;
  gap: 12px;
  margin: 26px 0;
}

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

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.actions {
  display: grid;
  gap: 10px;
}

.primary,
.secondary {
  min-height: 46px;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  font-weight: 800;
}

.primary {
  color: white;
  background: var(--blue);
}

.secondary {
  color: #1e344f;
  background: #e8edf3;
}

.secondary.subtle {
  color: #91352f;
  background: rgba(194, 65, 58, 0.1);
}

.panel {
  padding: 22px;
  min-width: 0;
}

.drop-zone {
  min-height: 118px;
  border: 1px dashed #aab7c3;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: #fbfcfd;
  transition: border-color 160ms ease, background 160ms ease;
}

.drop-zone strong,
.drop-zone span {
  display: block;
}

.drop-zone strong {
  color: var(--ink);
  margin-bottom: 7px;
  font-size: 18px;
}

.drop-zone span {
  font-size: 14px;
}

.drop-zone.dragging {
  border-color: var(--blue);
  background: rgba(37, 99, 235, 0.06);
}

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

.summary > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric {
  display: block;
  margin-bottom: 4px;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.metric.success {
  color: var(--green);
}

.metric.warning {
  color: var(--amber);
}

.metric.danger {
  color: var(--red);
}

.summary span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.progress-wrap {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce4eb;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #16865a);
  transition: width 180ms ease;
}

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 22px 0 12px;
}

.text-button {
  padding: 6px 0;
  color: var(--blue);
  background: transparent;
  font-weight: 800;
}

.queue {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.queue-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.thumb {
  width: 84px;
  height: 84px;
  overflow: hidden;
  border-radius: 8px;
  background: #dce4eb;
  display: grid;
  place-items: center;
  color: #526271;
  font-size: 12px;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.item-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.item-title-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.status {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #526271;
  font-size: 12px;
  font-weight: 800;
}

.status.done {
  color: var(--green);
  background: rgba(22, 134, 90, 0.09);
}

.status.skip {
  color: var(--amber);
  background: rgba(183, 121, 31, 0.1);
}

.status.fail {
  color: var(--red);
  background: rgba(194, 65, 58, 0.1);
}

.item-meta {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.item-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e9ef;
}

.item-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 160ms ease;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.download-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  color: white;
  background: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .layout,
  .summary {
    display: grid;
    grid-template-columns: 1fr;
  }

  .controls {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .support-pill {
    max-width: none;
  }
}

@media (max-width: 520px) {
  .topbar,
  .controls,
  .panel {
    padding: 16px;
  }

  .queue-item {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .thumb {
    width: 64px;
    height: 64px;
  }

  .item-title-row {
    display: grid;
    justify-content: stretch;
  }

  .status {
    justify-self: start;
  }
}
