:root {
  --ink: #19201f;
  --muted: #63706c;
  --subtle: #d9ded8;
  --paper: #fbfaf6;
  --surface: #ffffff;
  --wash: #eef4f1;
  --green: #1d6b54;
  --green-strong: #125540;
  --blue: #235b8d;
  --amber: #a65f13;
  --red: #a53f37;
  --line: #d7ddd7;
  --shadow: 0 18px 42px rgba(24, 33, 31, 0.12);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(35, 91, 141, 0.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(238, 244, 241, 0.9), rgba(251, 250, 246, 0) 340px),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
}

.skip-link:focus {
  top: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 28px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid rgba(29, 107, 84, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, #f9fff8 0%, #e6f2ec 54%, #f7ede2 100%);
  color: var(--green-strong);
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.95rem;
}

.header-actions,
.section-heading,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 13px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

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

.button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.button.primary:hover {
  background: var(--green-strong);
}

.button.secondary {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.84);
}

.button.ghost {
  border-color: var(--line);
  background: transparent;
}

.button.danger {
  min-width: 38px;
  padding: 8px 10px;
  color: var(--red);
  border-color: rgba(165, 63, 55, 0.22);
  background: #fff8f7;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.58fr);
  gap: 22px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px 32px;
  align-items: start;
}

.control-column {
  display: grid;
  gap: 16px;
}

.surface,
.preview-column {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.surface {
  padding: 20px;
}

.preview-column {
  position: sticky;
  top: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--green-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.class-result,
.preview-class {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.class-result.true-soap,
.preview-class.true-soap {
  background: #e7f4eb;
  color: #125540;
}

.class-result.cosmetic,
.preview-class.cosmetic {
  background: #eef3fb;
  color: #1e4b78;
}

.question-list {
  display: grid;
  gap: 10px;
}

.question-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-row label {
  display: block;
  font-weight: 800;
  line-height: 1.25;
}

.question-row p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(54px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f6f8f6;
}

.segmented button {
  border: 0;
  border-radius: 0;
  padding: 8px 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.explain-box,
.ingredient-note,
.issue-summary,
.disclaimer {
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.45;
}

.explain-box {
  margin-top: 14px;
  padding: 12px;
  border-left: 3px solid var(--green);
  background: #f5faf7;
  border-radius: 6px;
}

.explain-box.cosmetic {
  border-left-color: var(--blue);
  background: #f4f7fb;
}

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

.required-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--red);
}

.required-item.good .status-dot {
  background: var(--green);
}

.required-item strong {
  display: block;
  font-size: 0.92rem;
}

.required-item span:last-child {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

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

.span-2 {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.net-fieldset legend {
  color: #35413e;
  font-size: 0.85rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c9d2cb;
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #96a09b;
}

.net-fieldset {
  margin: 18px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.net-fieldset legend {
  padding: 0 6px;
}

.net-output {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px dashed #b6c3bc;
  border-radius: 7px;
  background: #f8faf8;
  color: var(--green-strong);
  font-weight: 800;
}

.ingredient-note {
  margin-bottom: 12px;
}

.ingredient-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ingredient-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.ingredient-table th,
.ingredient-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.ingredient-table th {
  background: #f4f7f4;
  color: #33413d;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ingredient-table tr:last-child td {
  border-bottom: 0;
}

.ingredient-table input {
  min-width: 120px;
}

.ingredient-amount {
  max-width: 110px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 160px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff4e6;
  color: #77420e;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
}

.chip.neutral {
  background: #eef2f0;
  color: var(--muted);
}

.warning-field {
  margin-top: 14px;
}

.preview-toolbar {
  margin-bottom: 14px;
}

.label-sheet {
  display: grid;
  place-items: center;
  min-height: 620px;
  padding: 22px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(25, 32, 31, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(25, 32, 31, 0.05) 1px, transparent 1px),
    #edf1ec;
  background-size: 22px 22px;
}

.label-preview {
  display: flex;
  flex-direction: column;
  width: min(100%, 390px);
  min-height: 510px;
  padding: 26px;
  border: 1px solid #202825;
  border-radius: 7px;
  background: #fffdf7;
  box-shadow: 0 20px 40px rgba(25, 32, 31, 0.18);
  color: #161c1a;
}

.label-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 2px solid #202825;
}

.label-maker {
  color: #3f4b47;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.label-path {
  color: #5d6763;
  font-size: 0.7rem;
  font-weight: 800;
  text-align: right;
  text-transform: uppercase;
}

.label-preview h3 {
  margin: 28px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.label-identity {
  color: #4e5a55;
  font-weight: 800;
}

.label-net {
  margin-top: 20px;
  padding: 10px 0;
  border-top: 1px solid #303936;
  border-bottom: 1px solid #303936;
  font-size: 1.02rem;
  font-weight: 900;
}

.label-block {
  margin-top: 18px;
  color: #303936;
  font-size: 0.88rem;
  line-height: 1.45;
}

.label-block strong {
  color: #161c1a;
}

.label-party {
  margin-top: auto;
  padding-top: 22px;
  color: #303936;
  font-size: 0.82rem;
  line-height: 1.45;
}

.allergen-panel {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #f1d2ac;
  border-radius: 7px;
  background: #fff9f0;
  color: #77420e;
  font-size: 0.8rem;
  line-height: 1.35;
}

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

.issue-summary.good {
  border-color: rgba(29, 107, 84, 0.28);
  color: var(--green-strong);
}

.issue-summary.warn {
  border-color: rgba(165, 63, 55, 0.25);
  color: var(--red);
}

.issue-summary ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.disclaimer {
  margin-top: 12px;
}

.test-summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 7px;
  background: #eef2f0;
  color: var(--muted);
  font-weight: 800;
}

.test-summary.pass {
  background: #e7f4eb;
  color: var(--green-strong);
}

.test-summary.fail {
  background: #fff0ee;
  color: var(--red);
}

.test-results {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 20px;
}

.test-results li {
  color: var(--muted);
  font-size: 0.9rem;
}

.test-results li.pass {
  color: var(--green-strong);
}

.test-results li.fail {
  color: var(--red);
}

@media (max-width: 1120px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-column {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-header,
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .surface,
  .preview-column {
    padding: 14px;
  }

  .section-heading,
  .preview-toolbar,
  .question-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .required-list,
  .form-grid,
  .net-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .label-sheet {
    min-height: auto;
    padding: 12px;
  }

  .label-preview {
    min-height: 460px;
    padding: 20px;
  }

  .label-preview h3 {
    font-size: 1.65rem;
  }
}
