:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e2e0da;
  --text: #1b1b19;
  --muted: #6b6a64;
  --accent: #ffd400;
  --ok: #1a7f4b;
  --warn: #9a6400;
  --error: #b3261e;
  --radius: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #17171a;
    --surface: #1f1f23;
    --border: #35343a;
    --text: #ececef;
    --muted: #a3a2ab;
    --ok: #57c98a;
    --warn: #e0b054;
    --error: #ef8a82;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    0.9375rem/1.5 system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
}

.bar {
  padding: 1.5rem 1rem 0.75rem;
  max-width: 68rem;
  margin: 0 auto;
}
.bar h1 {
  margin: 0;
  font-size: 1.25rem;
}
.sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  max-width: 60ch;
}

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  display: grid;
  gap: 1rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.panel-head h2 {
  margin: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.field {
  display: grid;
  gap: 0.25rem;
  min-width: 9rem;
}
.field > span {
  font-size: 0.75rem;
  color: var(--muted);
}
.field.inline {
  min-width: 7rem;
}

input,
select,
button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  padding: 0.375rem 0.5rem;
}
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

button {
  cursor: pointer;
}
button:hover:not(:disabled) {
  border-color: var(--muted);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1b1b19;
  font-weight: 600;
  padding-inline: 1rem;
}
button.link {
  border: 0;
  background: none;
  padding: 0;
  text-decoration: underline;
}
button.remove {
  margin-left: auto;
  color: var(--error);
}

.drop {
  margin-top: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--muted);
  text-align: center;
}
.drop[data-over='true'] {
  border-color: var(--accent);
  border-style: solid;
}
.drop p {
  margin: 0;
}

.pages {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.page {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.page-number {
  font-weight: 600;
  align-self: center;
}

.code-preview {
  /* Two lines, and the newline between them is the point — the extractor reads
     the number as the line above the identity. */
  white-space: pre-line;
  margin: 0.5rem 0 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
}
.code-preview[data-state='ok'] {
  color: var(--ok);
}
.code-preview[data-state='warn'] {
  color: var(--warn);
}
.code-preview[data-state='error'] {
  color: var(--error);
}

/* The sheet is the template's own 16:9, so a slot's box on screen is its box
   in the PDF. */
.slots {
  position: relative;
  aspect-ratio: 960.1 / 540;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    color-mix(in srgb, var(--border) 45%, transparent) 8px,
    color-mix(in srgb, var(--border) 45%, transparent) 16px
  );
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}
.slot {
  position: absolute;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--muted);
  display: grid;
  place-items: center;
}
.slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.status {
  margin: 0;
  font-size: 0.875rem;
}
.status[data-state='ok'] {
  color: var(--ok);
}
.status[data-state='error'] {
  color: var(--error);
}
.error {
  color: var(--error);
  font-size: 0.75rem;
}

.summary {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--muted);
  padding-bottom: 0.4rem;
}
.check input {
  width: 1rem;
  height: 1rem;
}
