:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #d9dee7;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --ready: #0f766e;
  --fail: #b91c1c;
  --warn: #b45309;
  --shadow: 0 14px 40px rgba(30, 41, 59, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(246, 247, 249, 0.9)),
    #f6f7f9;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1160px, calc(100% - 32px));
  margin: 40px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.panel-head.compact {
  align-items: center;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
}

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

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

h2 {
  font-size: 18px;
}

.badge {
  flex: 0 0 auto;
  min-width: 84px;
  text-align: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f8fafc;
}

.badge.working {
  color: var(--warn);
  background: #fffbeb;
  border-color: #fcd34d;
}

.badge.ready {
  color: var(--ready);
  background: #ecfdf5;
  border-color: #5eead4;
}

.badge.fail {
  color: var(--fail);
  background: #fef2f2;
  border-color: #fecaca;
}

.form,
.field {
  display: grid;
  gap: 14px;
}

.hidden {
  display: none;
}

.source-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.source-switch legend {
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.source-switch label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

.source-switch label:has(input:checked) {
  color: #fff;
  background: var(--primary);
}

.source-switch input {
  accent-color: var(--primary);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  gap: 7px;
}

.field span {
  font-size: 14px;
  font-weight: 700;
}

.field small,
.muted {
  color: var(--muted);
  font-size: 13px;
}

input[type="file"],
input[type="text"],
input[type="url"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input[type="file"] {
  padding: 12px;
}

input[type="text"],
input[type="url"],
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 320px;
  resize: vertical;
  padding: 14px;
  line-height: 1.7;
}

.file-field {
  padding: 16px;
  border: 1px dashed #b8c2d4;
  border-radius: 8px;
  background: #fbfcfe;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

button[type="submit"] {
  color: #fff;
  background: var(--primary);
}

button[type="submit"]:hover {
  background: var(--primary-hover);
}

#downloadButton {
  color: #fff;
  background: var(--ready);
}

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

.output-panel {
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto;
}

.log {
  min-height: 150px;
  max-height: 260px;
  overflow: auto;
  margin: 0 0 14px;
  padding: 12px 12px 12px 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
    margin: 20px auto;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1160px);
  }

  .panel {
    padding: 18px;
  }

  .panel-head,
  .grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    display: grid;
  }

  .badge {
    width: fit-content;
  }

  .actions button {
    width: 100%;
  }
}
