:root {
  color-scheme: dark;
  --bg: #0f1116;
  --panel: #161b24;
  --panel-2: #1d2430;
  --border: #2a3445;
  --text: #edf2fb;
  --muted: #9ca9bc;
  --accent: #66b2ff;
  --accent-2: #2f81f7;
  --danger: #ff6b6b;
  --success: #57d39b;
  --warning: #f4c96b;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #0d1015 0%, #11161f 100%);
  color: var(--text);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 24px auto 36px;
}

.page-header,
.panel,
.page-footer {
  background: rgba(22, 27, 36, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-header {
  padding: 24px 28px;
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 2vw, 2.6rem);
}

.lead {
  margin: 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.panel {
  padding: 22px;
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 1.2rem;
}

.field-group + .field-group,
.drop-zone,
.button-grid,
.status-card {
  margin-top: 18px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.drop-zone {
  border: 1.5px dashed #3c4f6e;
  border-radius: var(--radius-sm);
  padding: 26px 18px;
  text-align: center;
  background: linear-gradient(180deg, rgba(28, 36, 49, 0.9), rgba(18, 24, 33, 0.96));
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.drop-zone p,
.drop-zone small {
  display: block;
  margin: 8px 0 0;
  color: var(--muted);
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(37, 52, 76, 0.95), rgba(20, 27, 38, 0.98));
}

.input-select,
.input-range,
.btn {
  width: 100%;
}

.input-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.quality-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#qualityValue {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.input-range {
  accent-color: var(--accent-2);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #202938;
  color: var(--text);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #45608b;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #327de6, #2a67c0);
  border-color: #438fff;
}

.btn-danger {
  background: linear-gradient(180deg, #7f2732, #6b2029);
  border-color: #a13844;
}

.status-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: #131922;
  border: 1px solid var(--border);
}

.status-card h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.status-card p {
  margin: 0;
  line-height: 1.5;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #202938;
  color: var(--muted);
  border: 1px solid var(--border);
}

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

.result-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: rgba(17, 22, 30, 0.72);
}

.result-table th,
.result-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(59, 74, 99, 0.44);
  text-align: left;
  vertical-align: middle;
  font-size: 0.95rem;
}

.result-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1a2230;
  color: var(--muted);
  font-weight: 600;
}

.result-table tbody tr:hover {
  background: rgba(40, 52, 72, 0.2);
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  border: 1px solid transparent;
}

.status-queued,
.status-reading,
.status-encoding {
  background: rgba(102, 178, 255, 0.12);
  color: #a8d3ff;
  border-color: rgba(102, 178, 255, 0.3);
}

.status-done {
  background: rgba(87, 211, 155, 0.12);
  color: #8be8b9;
  border-color: rgba(87, 211, 155, 0.3);
}

.status-error {
  background: rgba(255, 107, 107, 0.12);
  color: #ffb0b0;
  border-color: rgba(255, 107, 107, 0.28);
}

.status-cancelled {
  background: rgba(244, 201, 107, 0.12);
  color: #f9da93;
  border-color: rgba(244, 201, 107, 0.28);
}

.save-link {
  color: #9bc8ff;
  text-decoration: none;
}

.save-link:hover {
  text-decoration: underline;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.dim {
  color: var(--muted);
}

.page-footer {
  margin-top: 18px;
  padding: 18px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 100%);
    margin: 10px auto 20px;
  }

  .panel,
  .page-header,
  .page-footer {
    padding: 16px;
  }

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