:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #66645f;
  --line: #d8d4cc;
  --paper: #ffffff;
  --panel: #f7f5f0;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --label-width: 1in;
  --label-height: 0.5in;
  --label-columns: 1;
  --label-gap: 0.125in;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(18rem, 22rem) 1fr;
  min-height: 100vh;
}

.controls {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1.5rem;
}

.controls__header {
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
}

.form,
.fieldset {
  display: grid;
  gap: 0.9rem;
}

.fieldset {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.fieldset .field:has(select) {
  grid-column: 1 / -1;
}

.fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.field:has(select) {
  grid-column: 1 / -1;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  padding: 0.62rem 0.7rem;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.actions {
  display: grid;
  gap: 0.75rem;
}

.actions p,
.error,
.hint {
  min-height: 1.25rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.error {
  color: #9f1239;
}

button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

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

button:disabled {
  background: #b8b4ac;
  cursor: not-allowed;
}

.sheet-wrap {
  overflow: auto;
  padding: 1.5rem;
}

.sheet {
  width: min-content;
  min-width: 8.5in;
  min-height: 11in;
  margin: 0 auto;
  padding: 0.35in;
  background: var(--paper);
  box-shadow: 0 18px 42px rgb(23 23 23 / 0.14);
}

.label-grid {
  display: grid;
  grid-template-columns: repeat(var(--label-columns), var(--label-width));
  gap: var(--label-gap);
  align-content: start;
}

.label {
  display: grid;
  grid-template-rows: minmax(0.12in, auto) 1fr minmax(0.1in, auto);
  place-items: center;
  width: var(--label-width);
  height: var(--label-height);
  overflow: hidden;
  border: 1px dashed #b9b3aa;
  border-radius: 2px;
  page-break-inside: avoid;
  break-inside: avoid;
  text-align: center;
}

.sheet[data-print-mode="roll"] {
  min-width: 0;
  min-height: 0;
  padding: 0.35in;
}

.sheet[data-print-mode="roll"] .label-grid {
  grid-template-columns: var(--label-width);
}

.label__part {
  min-height: 0.16in;
  padding-top: 0.03in;
  font-size: clamp(10px, 0.14in, 18px);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.sheet[data-label-size="1x0.5"] .label {
  grid-template-rows: 0.11in 1fr 0.08in;
}

.sheet[data-label-size="1x0.5"] .label__part {
  min-height: 0.12in;
  padding-top: 0.02in;
  font-size: 9px;
}

.sheet[data-label-size="1x0.5"] .label__number {
  font-size: 21px;
}

.label__number {
  font-size: clamp(24px, 0.45in, 72px);
  font-weight: 900;
  line-height: 0.95;
}

.label__marker {
  align-self: end;
  padding-bottom: 0.02in;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.sheet[data-label-size="1x0.5"] .label__marker {
  padding-bottom: 0.01in;
  font-size: 7px;
}

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

  .controls {
    position: static;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sheet-wrap {
    padding: 1rem;
  }
}

@media print {
  body {
    background: white;
  }

  .controls {
    display: none;
  }

  .app {
    display: block;
    min-height: auto;
  }

  .sheet-wrap {
    overflow: visible;
    padding: 0;
  }

  .sheet {
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  .label {
    border-color: transparent;
  }

  .label-grid {
    display: block;
  }
}
