:root {
  color-scheme: light;
  --ink: #171812;
  --muted: #65685e;
  --line: #d8dacd;
  --paper: #fbfbf4;
  --panel: #ffffff;
  --forge: #c94f2d;
  --cool: #1b6f7a;
  --sage: #79845a;
  --warn: #9a5b00;
  --shadow: 0 18px 40px rgba(27, 30, 20, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(201, 79, 45, 0.08) 0 1px, transparent 1px 80px),
    linear-gradient(180deg, rgba(27, 111, 122, 0.08) 0 1px, transparent 1px 80px),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.72rem 0.9rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--cool);
  box-shadow: 0 0 0 3px rgba(27, 111, 122, 0.14);
}

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

button[hidden], [hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem clamp(1rem, 3vw, 2.25rem) 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 244, 0.9);
  backdrop-filter: blur(10px);
}

h1, h2, p { margin: 0; }

h1 {
  font-size: clamp(2rem, 4.2vw, 4.1rem);
  line-height: 0.95;
  max-width: 14ch;
}

h2 {
  font-size: 1.15rem;
}

.eyebrow {
  color: var(--cool);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.trust-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  background: #fff;
  font-weight: 700;
  font-size: 0.82rem;
}

.studio-shell {
  display: grid;
  grid-template-columns: minmax(230px, 0.9fr) minmax(260px, 1.1fr) minmax(0, 2.3fr);
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2.25rem) 1.25rem;
  align-items: start;
}

.drop-stage, .recipe-rail, .output-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.drop-stage {
  overflow: hidden;
}

.drop-zone {
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    repeating-linear-gradient(-45deg, rgba(201, 79, 45, 0.07) 0 10px, transparent 10px 20px),
    #fff;
}

.drop-zone.dragover {
  outline: 3px solid rgba(201, 79, 45, 0.35);
  outline-offset: -8px;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.drop-zone label {
  display: grid;
  gap: 0.55rem;
  text-align: center;
  border: 2px dashed var(--forge);
  border-radius: 8px;
  padding: 2rem 1.2rem;
  background: rgba(255, 255, 255, 0.88);
  width: min(100%, 360px);
  cursor: pointer;
}

.drop-zone strong {
  font-size: 1.25rem;
}

.drop-zone span, .feedback p, .empty-state span {
  color: var(--muted);
  line-height: 1.45;
}

.batch-meter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.batch-meter div {
  padding: 0.9rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.batch-meter span {
  display: block;
  font-weight: 900;
  font-size: 1.25rem;
}

.batch-meter small {
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 800;
}

.recipe-rail {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.rail-head, .panel-head, .action-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

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

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

.recipe-rail label {
  display: grid;
  gap: 0.35rem;
  font-weight: 800;
  color: var(--muted);
}

.recipe-rail input, .recipe-rail select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.66rem;
  background: #fff;
  color: var(--ink);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.toggles {
  display: grid;
  gap: 0.45rem;
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-weight: 700;
}

.toggles input {
  width: auto;
}

.primary-action {
  background: var(--forge);
  border-color: var(--forge);
  color: #fff;
  font-weight: 900;
}

.workbench {
  min-width: 0;
  display: grid;
  gap: 1rem;
}

.preview-lane {
  min-height: 230px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.75rem;
  min-width: 0;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 230px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 1rem;
}

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

.tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background:
    linear-gradient(45deg, #eef0e8 25%, transparent 25% 75%, #eef0e8 75%),
    linear-gradient(45deg, #eef0e8 25%, #f8f8f0 25% 75%, #eef0e8 75%);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
}

.tile-body {
  padding: 0.7rem;
  display: grid;
  gap: 0.25rem;
}

.tile strong {
  overflow-wrap: anywhere;
}

.tile small {
  color: var(--muted);
}

.output-panel {
  padding: 1rem;
  min-width: 0;
}

.status-pill {
  border-radius: 999px;
  background: #eef4f0;
  color: var(--cool);
  padding: 0.45rem 0.65rem;
  font-weight: 900;
  font-size: 0.82rem;
}

.table-wrap {
  margin-top: 1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  table-layout: fixed;
}

th, td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.action-bar {
  margin-top: 0.9rem;
}

.feedback {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
  background: #fff8ef;
}

.feedback a {
  display: inline-block;
  margin-top: 0.55rem;
  color: var(--cool);
  font-weight: 900;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0 1rem 1rem;
}

.footer-links a {
  color: var(--cool);
  font-weight: 800;
}

@media (max-width: 1120px) {
  .studio-shell {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.75fr);
  }
  .workbench {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .trust-strip {
    justify-content: flex-start;
  }
  .studio-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .drop-zone {
    min-height: 230px;
  }
  .field-row, .preset-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .preview-lane {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  table {
    min-width: 520px;
  }
}
