:root {
  color-scheme: light dark;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #d9dce5;
  --text: #171a21;
  --muted: #5b6270;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --warn-bg: #fff5e5;
  --warn-border: #f0b64a;
  --error-bg: #fdecec;
  --error-border: #d64545;
  --ok-bg: #eaf6ee;
  --ok-border: #46a06b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --surface: #1b1e26;
    --border: #2e3340;
    --text: #eef0f5;
    --muted: #a3aab8;
    --accent: #7aa2ff;
    --accent-text: #10131a;
    --warn-bg: #3a2f18;
    --warn-border: #a5813a;
    --error-bg: #3a1d1d;
    --error-border: #a34a4a;
    --ok-bg: #16301f;
    --ok-border: #3f7d58;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 2rem;
}

.wrap {
  width: min(760px, 100% - 2rem);
  margin-inline: auto;
}

.app-header {
  padding: 1.5rem 0 1rem;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

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

h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.85rem;
  font-weight: 700;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem 1.25rem;
  margin-bottom: 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

.row > .field {
  flex: 1 1 12rem;
}

.field {
  display: block;
  margin-bottom: 0.75rem;
}

.field > span {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.field em {
  font-weight: 400;
  font-style: normal;
  color: var(--muted);
}

select,
input[type="number"],
textarea {
  width: 100%;
  padding: 0.65rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

textarea {
  resize: vertical;
  min-height: 6rem;
  line-height: 1.5;
}

select:focus-visible,
input:focus-visible,
textarea:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.checkboxes {
  display: grid;
  gap: 0.6rem;
}

.checkbox {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.checkbox input {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

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

.hint.over {
  color: var(--warn-border);
  font-weight: 600;
}

.actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 0;
  background: linear-gradient(to top, var(--bg) 65%, transparent);
}

button {
  font: inherit;
  cursor: pointer;
}

.primary,
.secondary {
  border-radius: 10px;
  padding: 0.8rem 1.3rem;
  border: 1px solid transparent;
  font-weight: 600;
}

.primary {
  background: var(--accent);
  color: var(--accent-text);
  flex: 1 1 14rem;
}

.primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

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

.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
}

.messages {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.message {
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.message.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.message.error {
  background: var(--error-bg);
  border-color: var(--error-border);
}

.message.ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}

.results ul {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: grid;
  gap: 0.6rem;
}

.results li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}

.file-name {
  font-weight: 600;
  word-break: break-word;
}

.file-size {
  color: var(--muted);
  font-size: 0.9rem;
}

.help {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
}

.help summary {
  cursor: pointer;
  font-weight: 600;
}

.help ol {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.help code {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  padding: 0.1rem 0.3rem;
  border-radius: 5px;
}

.app-footer {
  color: var(--muted);
  font-size: 0.85rem;
  padding-bottom: 1rem;
}

@media (max-width: 480px) {
  .app-header {
    padding-top: 1rem;
  }
  .card {
    padding: 1rem;
  }
}
