:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #20201d;
  --muted: #6f6a5f;
  --line: #ded7ca;
  --accent: #176b5f;
  --accent-dark: #0f4d45;
  --danger: #9c2f2f;
}

* {
  box-sizing: border-box;
}

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

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(50, 40, 25, 0.08);
}

.controls {
  padding: 20px;
}

.title h1,
.resultsHeader h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.title p {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

label {
  display: block;
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 650;
}

.checkLine {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 600;
}

.checkLine input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.uploadLabel span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 11px 12px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 95, 0.14);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
}

button {
  width: 100%;
  min-height: 44px;
  margin-top: 18px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

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

.secondary {
  background: #364d7a;
}

.secondary:hover {
  background: #293b5f;
}

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

.ghost {
  width: auto;
  min-height: 36px;
  margin: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: #f1ece2;
}

.status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.status.error {
  color: var(--danger);
}

.uploadBox {
  margin-top: 14px;
}

.directorBox {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f1;
}

.directorBox summary {
  cursor: pointer;
  font-weight: 800;
}

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

.templateButtons button {
  margin-top: 14px;
}

.uploadBox input[type="file"] {
  padding: 9px 10px;
}

.previewWrap {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
}

.previewWrap.hidden {
  display: none;
}

.previewWrap img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eee8dd;
}

.previewWrap .ghost {
  justify-self: start;
}

.results {
  min-height: calc(100vh - 48px);
  padding: 18px;
}

.resultsHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.gallery {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.gallery.empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eee8dd;
}

.card a {
  display: block;
  padding: 10px 12px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.savedPath {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 14px;
  background: #221f1a;
  color: #fff8ea;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

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

  .results {
    min-height: 360px;
  }
}
