:root {
  color-scheme: light;
  --ink: #0f0f0f;
  --muted: #606060;
  --line: #e5e5e5;
  --surface: #f9f9f9;
  --panel: #ffffff;
  --panel-soft: #f2f2f2;
  --accent: #ff0033;
  --accent-dark: #cc0029;
  --accent-soft: #ffe8ed;
  --ok: #16833a;
  --warn: #c62828;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

.file-warning {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 18px;
  background: #fff5f5;
  color: #9f1239;
  border-bottom: 1px solid #fecdd3;
  font-size: 14px;
  text-align: center;
}

.shell {
  display: grid;
  grid-template-columns: minmax(390px, 0.94fr) minmax(440px, 1.06fr);
  gap: 1px;
  min-height: 100vh;
  background: var(--line);
}

.workspace,
.output {
  background: var(--surface);
  padding: 32px;
}

.intro {
  max-width: 720px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  color: var(--ink);
}

h1 {
  font-size: 40px;
  line-height: 1.08;
  font-weight: 800;
}

h2 {
  font-size: 26px;
  font-weight: 750;
}

.control-surface {
  display: grid;
  gap: 16px;
  max-width: 790px;
}

.mode-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.mode-panel legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.mode-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: start;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.mode-card:hover {
  background: #f5f5f5;
}

.mode-card input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.mode-card strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.mode-card span {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.mode-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mode-help {
  margin: -2px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: #3f3f3f;
  line-height: 1.55;
  font-size: 14px;
  font-weight: 600;
}

.field {
  display: grid;
  gap: 8px;
}

.control-surface > .field:not(.file-field) {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.style-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.style-preset {
  display: grid;
  gap: 3px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.style-preset:hover {
  background: #eaeaea;
}

.style-preset.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.style-preset strong {
  font-size: 13px;
  font-weight: 750;
}

.style-preset span {
  color: inherit;
  opacity: 0.7;
  font-size: 12px;
  font-weight: 600;
}

.style-preset.active span {
  opacity: 1;
  color: #ffffff;
}

.field span,
legend {
  color: #3f3f3f;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
input:not([type]),
textarea {
  width: 100%;
  border: 1px solid #d0d0d0;
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #909090;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 0, 51, 0.12);
}

.settings {
  display: grid;
  grid-template-columns: 120px;
  gap: 16px;
  align-items: stretch;
}

fieldset {
  margin: 0;
}

.compact input {
  height: 48px;
}

.file-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  border: 1px dashed #c7c7c7;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--panel);
}

.file-picker input {
  display: none;
}

.file-action,
.clear-file {
  height: 32px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  border: 1px solid #d0d0d0;
  padding: 0 12px;
  font-weight: 700;
}

.file-action:hover,
.clear-file:hover {
  background: #eaeaea;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clear-file {
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

button {
  height: 52px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  transition: background 140ms ease, opacity 140ms ease;
}

button:hover {
  background: var(--accent-dark);
}

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

.status-line {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.badge {
  min-width: 96px;
  text-align: center;
  border-radius: 999px;
  background: #eeeeee;
  color: #3f3f3f;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 750;
}

.badge.ok {
  background: #e7f7ec;
  color: var(--ok);
}

.badge.error {
  background: #fdecec;
  color: var(--warn);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.gallery.empty {
  min-height: 420px;
  border: 1px dashed #d0d0d0;
  border-radius: 12px;
  background: var(--panel);
}

.result {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.result-frame {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  width: 100%;
  aspect-ratio: 1024 / 1792;
  background: #f2f2f2;
  color: var(--muted);
  text-align: center;
}

.result-frame strong {
  color: var(--ink);
  font-size: 15px;
}

.result.pending {
  border-style: dashed;
}

.result.generating .result-frame {
  background: #f7f7f7;
}

.error-frame {
  background: #fff1f1;
}

.result img {
  display: block;
  width: 100%;
  aspect-ratio: 1024 / 1792;
  object-fit: cover;
  background: #eeeeee;
}

.result footer {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.result a {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  padding: 8px 13px;
}

.result a:hover {
  background: #eaeaea;
}

.usage {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

  .workspace,
  .output {
    padding: 24px;
  }

  h1 {
    font-size: 36px;
  }

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