:root {
  --bg: #f5f7f2;
  --panel: #ffffff;
  --paper: #fffdf8;
  --ink: #17201f;
  --muted: #66736f;
  --line: #d9e1da;
  --line-strong: #aebcb4;
  --teal: #0f766e;
  --teal-dark: #0b4f4a;
  --blue: #1d4ed8;
  --amber: #b45309;
  --red: #be123c;
  --green: #166534;
  --shadow: 0 20px 50px rgba(23, 32, 31, 0.10);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(29, 78, 216, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 22px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-block {
  max-width: 860px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
  line-height: 1.25;
}

.lede {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.header-actions,
.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  color: var(--ink);
  background: var(--panel);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.22);
  outline-offset: 2px;
}

.button.primary {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.20);
}

.button.primary:hover:not(:disabled) {
  background: var(--teal-dark);
}

.button.secondary {
  border-color: var(--line-strong);
}

.button:disabled {
  color: #8a9690;
  background: #eef2ef;
  border-color: #d8e1db;
  box-shadow: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 0.95fr) minmax(500px, 1.2fr);
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}

.form-panel,
.preview-panel {
  min-width: 0;
}

.form-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-heading,
.preview-top {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.status-pill,
#missingCount,
#testSummary {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--amber);
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.ready,
#missingCount.ready,
#testSummary.ready {
  color: var(--green);
  background: #ecfdf3;
  border-color: #bbf7d0;
}

#testSummary.fail {
  color: var(--red);
  background: #fff1f2;
  border-color: #fecdd3;
}

form {
  padding: 18px;
}

fieldset {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

fieldset:last-child {
  margin-bottom: 0;
}

legend {
  padding: 0 7px;
  font-weight: 900;
}

.fieldset-note {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

.field span {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 18px;
}

.field.required span::after {
  content: "Required";
  padding: 2px 6px;
  color: var(--blue);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 900;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfdfb;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(23, 32, 31, 0.04);
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
}

input.invalid,
textarea.invalid {
  border-color: var(--red);
  background: #fff8f9;
}

small[data-error-for] {
  min-height: 16px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef5f1;
}

.segmented-control label {
  position: relative;
  display: block;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 900;
}

.segmented-control input:checked + span {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

.is-conditional-inactive {
  border-style: dashed;
  background: #f7faf8;
}

.is-conditional-inactive .fieldset-note::after {
  content: " Current selection: not required.";
  color: var(--green);
  font-weight: 800;
}

.toggle-group {
  margin-top: 16px;
}

.toggle-header {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.toggle-header span {
  font-weight: 900;
}

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

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

.picto-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  align-items: center;
  min-height: 46px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
  font-weight: 800;
  cursor: pointer;
}

.picto-toggle input {
  position: absolute;
  opacity: 0;
}

.picto-code {
  display: inline-flex;
  width: 56px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--ink);
  background: #fef3c7;
  border: 1px solid #fcd34d;
  font-size: 0.72rem;
  font-weight: 900;
}

.picto-toggle:has(input:checked) {
  border-color: var(--teal);
  background: #eefcf8;
}

.picto-toggle:has(input:focus-visible) {
  outline: 3px solid rgba(29, 78, 216, 0.22);
  outline-offset: 2px;
}

.preview-panel {
  display: grid;
  gap: 16px;
}

.preview-top,
.notice,
.support-grid > section,
.explainer {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.notice {
  padding: 12px 14px;
  color: var(--amber);
  background: #fffaf2;
  border-color: #fed7aa;
  font-weight: 800;
  line-height: 1.45;
}

.notice.ready {
  color: var(--green);
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.preview-canvas {
  display: grid;
  place-items: start center;
  min-height: 620px;
  padding: 28px;
  overflow: auto;
  background:
    linear-gradient(45deg, #e7eee9 25%, transparent 25%),
    linear-gradient(-45deg, #e7eee9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7eee9 75%),
    linear-gradient(-45deg, transparent 75%, #e7eee9 75%),
    #f8faf7;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.label-block {
  width: 70mm;
  min-height: 105mm;
  padding: 6mm;
  color: #101413;
  background: var(--paper);
  border: 1.5px solid #101413;
  box-shadow: 0 18px 42px rgba(23, 32, 31, 0.16);
  font-family: Arial, sans-serif;
}

.label-block.size-wide {
  width: 100mm;
  min-height: 70mm;
}

.label-block.size-a6 {
  width: 105mm;
  min-height: 148mm;
}

.label-status {
  display: inline-flex;
  margin-bottom: 4mm;
  padding: 1.5mm 2mm;
  border: 1px solid #c9a227;
  color: #6b4507;
  background: #fff8df;
  font-size: 8.5pt;
  font-weight: 700;
  text-transform: uppercase;
}

.label-status.is-ready {
  color: #14532d;
  background: #ecfdf3;
  border-color: #86efac;
}

.label-header {
  padding-bottom: 3mm;
  border-bottom: 1.5px solid #101413;
}

.label-header p {
  margin-bottom: 1mm;
  font-size: 8pt;
  font-weight: 700;
  text-transform: uppercase;
}

.label-header h2 {
  margin: 0;
  font-size: 13pt;
  line-height: 1.08;
  letter-spacing: 0;
}

.label-section {
  padding: 3mm 0;
  border-bottom: 1px solid #101413;
}

.label-section h3 {
  margin: 0 0 2mm;
  font-size: 8.5pt;
  font-weight: 800;
  text-transform: uppercase;
}

.label-section dl {
  display: grid;
  gap: 1.5mm;
  margin: 0;
}

.label-row {
  display: grid;
  grid-template-columns: 27mm minmax(0, 1fr);
  gap: 2mm;
  align-items: start;
  font-size: 8.5pt;
  line-height: 1.25;
}

.label-row dt {
  color: #49524f;
  font-weight: 700;
}

.label-row dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.warning-copy {
  margin-bottom: 2.5mm;
  font-size: 8.5pt;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.label-pictos {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5mm;
}

.label-picto {
  display: inline-grid;
  grid-template-columns: auto 1fr;
  gap: 1.5mm;
  align-items: center;
  max-width: 100%;
  padding: 1.2mm 1.5mm;
  border: 1px solid #101413;
  font-size: 7.5pt;
  line-height: 1.15;
}

.label-picto b {
  display: inline-flex;
  min-width: 10mm;
  min-height: 6mm;
  align-items: center;
  justify-content: center;
  color: #101413;
  background: #fef3c7;
  border: 1px solid #101413;
  font-size: 6.5pt;
}

.label-footer {
  padding-top: 3mm;
  font-size: 8pt;
  line-height: 1.32;
}

.placeholder {
  color: #9a3412;
  font-style: italic;
}

.support-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.support-grid > section,
.explainer {
  padding: 16px;
}

.panel-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-title-row h3 {
  margin: 0;
}

.checklist,
.test-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist li,
.test-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
}

.checklist li span,
.test-list li span {
  overflow-wrap: anywhere;
}

.checklist b,
.test-list b {
  font-size: 0.72rem;
}

.checklist li.pass b,
.test-list li.pass b {
  color: var(--green);
}

.checklist li.missing b,
.test-list li.fail b {
  color: var(--red);
}

.checklist li.skip {
  color: var(--muted);
  background: #f6f8f6;
}

.test-list small {
  grid-column: 1 / -1;
  color: var(--red);
  font-weight: 700;
}

.explainer p {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.explainer p:last-child {
  margin-bottom: 0;
}

.disclaimer {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
}

.noscript {
  max-width: 780px;
  margin: 24px auto;
  padding: 16px;
  color: #ffffff;
  background: var(--red);
  border-radius: var(--radius);
  font-weight: 800;
}

@media (max-width: 1180px) {
  .app-header,
  .workspace {
    grid-template-columns: 1fr;
  }

  .header-actions,
  .preview-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 780px) {
  .app-shell {
    padding: 12px;
  }

  .app-header,
  .section-heading,
  .preview-top {
    padding: 16px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .field-grid.two,
  .support-grid,
  .pictogram-grid {
    grid-template-columns: 1fr;
  }

  .segmented-control {
    grid-template-columns: 1fr;
  }

  .preview-canvas {
    min-height: 460px;
    padding: 12px;
  }

  .label-block,
  .label-block.size-wide,
  .label-block.size-a6 {
    width: min(100%, 70mm);
    min-height: auto;
  }

  .label-row {
    grid-template-columns: 1fr;
    gap: 0.5mm;
  }
}
