:root {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #263248;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-active: #1d4ed8;
  --accent: #0d9488;
  --accent-active: #0f766e;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

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

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

.brand-icon {
  border-radius: 9px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.15;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.hidden {
  display: none !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.9rem;
  font-weight: 600;
  color: #cbd5e1;
}

input[type="text"],
input[type="password"],
input[type="url"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; /* Prevents iOS Safari auto-zoom */
}

input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}

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

.btn-primary {
  background: var(--primary);
}

.btn-primary:active:not(:disabled) {
  background: var(--primary-active);
}

.btn-accent {
  background: var(--accent);
}

.btn-accent:active:not(:disabled) {
  background: var(--accent-active);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.btn-danger {
  background: transparent;
  border-color: rgba(220, 38, 38, 0.55);
  color: #fca5a5;
  min-height: 42px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

.btn-block {
  width: 100%;
}

.btn-small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-icon {
  flex: 0 0 auto;
  padding: 0 14px;
  font-size: 0.9rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.btn-tall {
  min-height: 68px;
  padding: 12px 14px;
  text-align: center;
}

.btn-title {
  font-size: 1.02rem;
  font-weight: 700;
}

.btn-sub {
  margin-top: 3px;
  font-size: 0.78rem;
  font-weight: 400;
  opacity: 0.9;
}

.alert {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
}

.alert-error {
  background: rgba(220, 38, 38, 0.16);
  border: 1px solid rgba(220, 38, 38, 0.45);
  color: #fecaca;
}

.alert-ok {
  background: rgba(22, 163, 74, 0.16);
  border: 1px solid rgba(22, 163, 74, 0.45);
  color: #bbf7d0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.section-head h2 {
  margin: 0;
}

.empty-state {
  text-align: center;
  padding: 20px 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.job-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.job-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.job-title {
  font-weight: 600;
  font-size: 0.98rem;
  word-break: break-word;
}

.job-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.badge {
  flex: 0 0 auto;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-queued { background: #334155; color: #e2e8f0; }
.badge-downloading { background: #1d4ed8; color: #dbeafe; }
.badge-processing { background: #b45309; color: #fef3c7; }
.badge-complete { background: #15803d; color: #dcfce7; }
.badge-failed { background: #991b1b; color: #fee2e2; }
.badge-canceled { background: #475569; color: #cbd5e1; }

.progress-bar {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border: none;
  border-radius: 999px;
  background: #0f172a;
  overflow: hidden;
  margin: 8px 0 6px;
}

.progress-bar::-webkit-progress-bar {
  background: #0f172a;
  border-radius: 999px;
}

.progress-bar::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

.progress-bar::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}

.progress-bar.progress-indeterminate {
  opacity: 0.85;
}

.job-detail {
  font-size: 0.86rem;
  color: #cbd5e1;
  margin-bottom: 8px;
}

.job-note {
  font-size: 0.84rem;
  color: #fde68a;
  background: rgba(217, 119, 6, 0.14);
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.job-error {
  font-size: 0.85rem;
  color: #fecaca;
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

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

.help-card summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.help-body {
  margin-top: 12px;
  font-size: 0.92rem;
}

.help-body h3 {
  margin: 12px 0 6px;
  font-size: 0.96rem;
}

.help-body ol, .help-body ul {
  margin: 0 0 10px;
  padding-left: 20px;
}

.help-body li {
  margin-bottom: 5px;
}
