:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #1f2520;
  --muted: #697168;
  --line: #d9dfd5;
  --accent: #176b5b;
  --accent-strong: #0d4f43;
  --danger: #a63838;
  --warm: #c8862f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar,
.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.progress-actions,
.file-actions,
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar {
  margin-bottom: 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.tab-panel[hidden] {
  display: none !important;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.25;
}

p,
small,
.current,
.log-box {
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  margin-top: 14px;
  box-shadow: 0 10px 24px rgba(25, 36, 28, 0.06);
}

.upload-grid,
.source-text-grid,
.settings-grid,
.facecam-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.upload-grid,
.source-text-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-grid,
.facecam-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.facecam-grid .drop-zone {
  grid-column: span 2;
}

.drop-zone {
  display: grid;
  min-height: 132px;
  align-content: center;
  gap: 10px;
  border: 1px dashed #b8c3b2;
  border-radius: 8px;
  background: #fbfcfa;
  padding: 16px;
  cursor: pointer;
}

.drop-zone span,
.source-text-grid label,
.settings-grid label,
.facecam-grid label {
  color: var(--text);
  font-weight: 700;
}

.drop-zone input {
  width: 100%;
}

.source-text-grid label,
.settings-grid label,
.facecam-grid label {
  display: grid;
  gap: 8px;
}

select,
input[type="number"],
textarea {
  width: 100%;
  border: 1px solid #cfd6ca;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

select,
input[type="number"] {
  min-height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 150px;
  padding: 11px;
  resize: vertical;
  line-height: 1.35;
}

textarea:disabled {
  background: #f1f4ee;
  color: var(--muted);
  cursor: not-allowed;
}

.text-hooks-field {
  grid-column: 1 / -1;
}

.text-mode-field,
.text-style-field {
  grid-column: 1 / -1;
}

.text-hooks-field.is-disabled,
.text-mode-field.is-disabled,
.text-style-field.is-disabled {
  opacity: 0.7;
}

.text-hooks-field small {
  color: var(--muted);
  font-weight: 600;
}

.form-hint {
  grid-column: span 2;
  align-self: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.upload-hint {
  grid-column: 1 / -1;
}

.checkbox-line {
  grid-column: span 2;
  display: flex !important;
  align-items: center;
  gap: 10px !important;
  min-height: 42px;
}

.checkbox-line input {
  width: 18px;
  height: 18px;
}

.text-toggle {
  grid-column: 1 / -1;
}

button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 15px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  border-color: #c7d0c1;
  background: #fff;
  color: var(--text);
}

.danger {
  border-color: #e5b9b9;
  background: #fff6f6;
  color: var(--danger);
}

.upload-button,
.generate-button {
  align-self: end;
}

.upload-button {
  grid-column: 1 / -1;
}

.generate-button {
  grid-column: span 2;
}

.combo-count {
  min-height: 34px;
  border-radius: 999px;
  background: #fff7e8;
  color: #6a4315;
  padding: 8px 12px;
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
}

.progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebe2;
  margin-top: 16px;
}

.progress div {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  transition: width 180ms ease;
}

.current {
  min-height: 24px;
  margin-top: 12px;
  font-size: 0.95rem;
}

.file-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #e3e7df;
  border-radius: 6px;
  padding: 12px;
}

.history-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-main span,
.empty-state {
  color: var(--muted);
}

.history-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-actions button,
.history-actions a {
  min-height: 34px;
  padding: 0 12px;
}

.empty-state {
  border: 1px dashed #cfd6ca;
  border-radius: 6px;
  padding: 14px;
  background: #fbfcfa;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #e3e7df;
  border-radius: 6px;
  padding: 10px 12px;
}

.file-size {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.file-row a,
.download-button {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #b9d4cb;
  border-radius: 6px;
  background: #ffffff;
  padding: 0 12px;
  white-space: nowrap;
}

.zip-row {
  border-color: #b9d4cb;
  background: #f3fbf7;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-box {
  margin-top: 14px;
}

.log-box pre {
  max-height: 220px;
  overflow: auto;
  border: 1px solid #e3e7df;
  border-radius: 6px;
  background: #fbfcfa;
  padding: 12px;
  white-space: pre-wrap;
}

.hidden {
  display: none;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

@media (max-width: 860px) {
  .topbar,
  .section-title {
    display: grid;
  }

  .progress-actions {
    justify-content: stretch;
  }

  .topbar-actions,
  .progress-actions > * {
    width: 100%;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions > * {
    flex: 1;
  }

  .upload-grid,
  .settings-grid,
  .facecam-grid {
    grid-template-columns: 1fr;
  }

  .facecam-grid .drop-zone {
    grid-column: auto;
  }

  .checkbox-line,
  .generate-button {
    grid-column: auto;
  }

  .combo-count {
    width: max-content;
  }

  .file-row {
    grid-template-columns: 1fr;
  }

  .history-row {
    grid-template-columns: 1fr;
  }

  .history-actions {
    justify-content: stretch;
  }

  .file-actions,
  .history-actions > *,
  .download-button {
    width: 100%;
  }
}
