:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --ink: #17211d;
  --muted: #63716b;
  --line: #d8e0dc;
  --line-strong: #a9b7b0;
  --green: #28745c;
  --green-dark: #1f5948;
  --green-soft: #dff1ea;
  --berry: #9b2f53;
  --berry-soft: #f7e5ec;
  --gold: #a97622;
  --gold-soft: #f5ead8;
  --danger: #b42318;
  --danger-soft: #f9e5e3;
  --shadow: 0 18px 55px rgba(28, 42, 35, 0.12);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(40, 116, 92, 0.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(244, 246, 245, 0.94) 34%, #f4f6f5 100%);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.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;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 20px;
}

.topbar h1,
.panel h2,
.preview-tools h2,
.notice h2 {
  margin: 0;
  font-weight: 720;
  line-height: 1.08;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 4.2rem);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.topbar__actions,
.button-row,
.panel__footer,
.status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 15px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 720;
  box-shadow: none;
}

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

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

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

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

.button--soft {
  background: var(--green-soft);
  border-color: #bfdfd2;
  color: var(--green-dark);
}

.button--danger {
  background: var(--danger-soft);
  border-color: #efc0bc;
  color: var(--danger);
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(420px, 0.94fr);
  gap: 24px;
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto 42px;
  align-items: start;
}

.workspace,
.preview-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.preview-column {
  position: sticky;
  top: 16px;
}

.panel,
.preview-tools,
.notice {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(23, 33, 29, 0.04);
}

.panel {
  padding: 20px;
  min-width: 0;
}

.panel--compact {
  padding: 17px;
}

.panel__header,
.preview-tools {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel__header {
  margin-bottom: 16px;
}

.panel h2,
.preview-tools h2,
.notice h2 {
  font-size: 1.15rem;
}

.panel__badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.82rem;
  font-weight: 720;
  white-space: nowrap;
}

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

.field-grid--three {
  grid-template-columns: minmax(0, 1fr) 130px minmax(180px, 0.8fr);
  align-items: end;
}

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

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

.field span,
.toggle span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 720;
}

.field input,
.field select,
.field textarea,
.table-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
}

.field textarea {
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.table-input:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.table-input:focus {
  border-color: var(--green);
}

.toggle {
  grid-template-columns: 20px 1fr;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.toggle--wide {
  margin-top: 14px;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.split-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.radio-card {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 720;
}

.radio-card:has(input:checked) {
  border-color: #92c8b2;
  background: var(--green-soft);
}

.radio-card input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.ingredient-shell {
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ingredient-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: #ffffff;
}

.ingredient-table th {
  padding: 10px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.82rem;
  text-align: left;
  text-transform: uppercase;
}

.ingredient-table td {
  padding: 8px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.ingredient-table th:nth-child(2),
.ingredient-table td:nth-child(2) {
  width: 110px;
}

.ingredient-table th:nth-child(3),
.ingredient-table td:nth-child(3) {
  width: 132px;
}

.ingredient-table th:nth-child(4),
.ingredient-table td:nth-child(4) {
  width: 52px;
  text-align: right;
}

.table-input {
  min-height: 39px;
  padding: 8px 9px;
}

.row-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  min-width: 82px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #edf0ef;
  font-size: 0.76rem;
  font-weight: 760;
  white-space: nowrap;
}

.row-flag--allergen {
  color: var(--berry);
  background: var(--berry-soft);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--danger);
  background: #ffffff;
  font-size: 0.9rem;
  font-weight: 800;
}

.icon-button:hover {
  background: var(--danger-soft);
  border-color: #efc0bc;
}

.panel__footer {
  justify-content: space-between;
  margin-top: 14px;
}

.project-save {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.status-row {
  align-items: center;
  margin-top: 12px;
}

.inline-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #ffffff;
  font-size: 0.82rem;
  font-weight: 720;
}

.inline-status:empty {
  display: none;
}

.inline-status--ok {
  color: var(--green-dark);
  background: var(--green-soft);
  border-color: #bfdfd2;
}

.inline-status--warn {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #efc0bc;
}

.saved-projects {
  display: grid;
  gap: 8px;
  margin-top: 13px;
}

.project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.project-item__name {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 760;
}

.project-item__meta {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.project-item__actions {
  display: flex;
  gap: 7px;
}

.helper-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.preview-tools {
  padding: 17px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 820;
  white-space: nowrap;
}

.status-pill--ready {
  color: var(--green-dark);
  background: var(--green-soft);
}

.status-pill--warn {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-pill--attention {
  transform: scale(1.04);
}

.label-sheet {
  padding: 28px;
  background:
    linear-gradient(135deg, #f7f8f7 0%, #ffffff 45%, #f0f5f2 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.label-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: clamp(12px, 3.2%, 28px);
  aspect-ratio: var(--label-aspect, 10 / 7);
  min-height: 0;
  padding: clamp(18px, 5%, 34px);
  overflow: hidden;
  color: #151a17;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.98)),
    linear-gradient(90deg, #ffffff, #f1f6f3);
  border: 1px solid #cfd8d2;
  border-radius: var(--radius);
}

.label-preview__top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  border-bottom: 1px solid #dfe6e2;
  padding-bottom: clamp(12px, 3%, 22px);
}

.label-preview__function {
  margin: 0 0 9px;
  color: var(--green-dark);
  font-size: 0.9rem;
  font-weight: 760;
  text-transform: uppercase;
}

.label-preview h2 {
  max-width: 16ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 4.2vw, 3.45rem);
  line-height: 1.02;
  font-weight: 620;
  overflow-wrap: anywhere;
}

.label-preview__symbols {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  min-width: 120px;
  color: #151a17;
}

.symbol {
  display: inline-block;
  width: 58px;
  height: 48px;
  flex: 0 0 auto;
  color: currentColor;
  overflow: visible;
}

.symbol--pao {
  width: 74px;
  height: 55px;
}

.symbol--estimated {
  width: 30px;
  height: 30px;
}

.symbol--insert {
  width: 62px;
  height: 48px;
}

.symbol__stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 4.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.symbol--estimated .symbol__stroke {
  stroke-width: 5.2;
}

.symbol__text {
  fill: currentColor;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  font-weight: 760;
}

.label-preview__content {
  display: grid;
  align-content: start;
  gap: clamp(8px, 2%, 13px);
  min-height: 0;
  overflow: hidden;
}

.preview-content-line,
.preview-durability-line,
.inci-line,
.label-preview__footer p {
  margin: 0;
}

.preview-content-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  font-size: 1.22rem;
  font-weight: 780;
}

.preview-content-line .symbol--estimated {
  width: 22px;
  height: 22px;
}

.preview-durability-line {
  color: var(--muted);
  font-weight: 690;
}

.inci-line {
  padding-top: 8px;
  border-top: 1px solid #dfe6e2;
  font-size: 0.96rem;
  overflow-wrap: anywhere;
}

.label-preview__footer {
  display: grid;
  gap: 7px;
  padding-top: clamp(10px, 2.6%, 18px);
  border-top: 1px solid #dfe6e2;
  color: #29342f;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.label-preview__barcode {
  min-height: 0;
}

.label-preview__barcode:empty {
  display: none;
}

.barcode-frame {
  display: grid;
  justify-items: end;
}

.barcode-svg {
  width: min(230px, 60%);
  max-width: 100%;
  height: auto;
  color: #111111;
  background: #ffffff;
}

.barcode-svg__background {
  fill: #ffffff;
}

.barcode-svg__bar,
.barcode-svg__text {
  fill: currentColor;
}

.barcode-svg__text {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.barcode-warning {
  margin: 0;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 760;
}

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

.checklist__item {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.checklist__marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 820;
}

.checklist__item--ok .checklist__marker {
  color: var(--green-dark);
  background: var(--green-soft);
}

.checklist__item--bad .checklist__marker {
  color: var(--danger);
  background: var(--danger-soft);
}

.allergen-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.allergen-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--berry);
  background: var(--berry-soft);
  font-size: 0.85rem;
  font-weight: 760;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.test-output {
  display: block;
  min-height: 42px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.test-summary {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 840;
}

.test-summary--pass {
  color: var(--green-dark);
  background: var(--green-soft);
}

.test-summary--fail {
  color: var(--danger);
  background: var(--danger-soft);
}

.test-list {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  padding-left: 22px;
}

.test-list__item {
  padding-left: 2px;
  color: var(--muted);
}

.test-list__item--pass {
  color: var(--green-dark);
}

.test-list__item--fail {
  color: var(--danger);
}

.notice {
  padding: 17px;
  border-color: #e7d4b4;
  background: #fffaf1;
}

.notice h2 {
  color: #6d4b15;
  font-size: 1rem;
}

.notice p {
  margin: 8px 0 0;
  color: #564425;
}

.is-hidden {
  display: none;
}

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

  .preview-column {
    position: static;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 15px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    width: min(100% - 20px, 1540px);
    padding-top: 18px;
  }

  .topbar__actions,
  .topbar__actions .button {
    width: 100%;
  }

  .topbar__actions .button {
    justify-content: center;
  }

  .studio {
    width: min(100% - 20px, 1540px);
    gap: 14px;
  }

  .panel,
  .preview-tools,
  .notice {
    padding: 15px;
  }

  .panel__header,
  .preview-tools,
  .label-preview__top {
    flex-direction: column;
  }

  .field-grid,
  .field-grid--three,
  .field-grid--two,
  .split-fields {
    grid-template-columns: 1fr;
  }

  .label-sheet {
    padding: 12px;
  }

  .label-preview {
    padding: 22px;
  }

  .label-preview h2 {
    max-width: none;
    font-size: 2.3rem;
  }

  .label-preview__symbols {
    justify-content: flex-start;
  }

  .panel__footer {
    align-items: stretch;
    flex-direction: column;
  }

  .project-save,
  .project-item {
    grid-template-columns: 1fr;
  }

  .project-save .button,
  .project-item__actions,
  .project-item__actions .button {
    width: 100%;
  }

  .project-item__actions .button {
    flex: 1;
  }

  .ingredient-table {
    min-width: 0;
    table-layout: fixed;
  }

  .ingredient-table th:nth-child(2),
  .ingredient-table td:nth-child(2) {
    width: 78px;
  }

  .ingredient-table th:nth-child(3),
  .ingredient-table td:nth-child(3) {
    display: none;
  }

  .ingredient-table th:nth-child(4),
  .ingredient-table td:nth-child(4) {
    width: 44px;
  }

  .ingredient-table td {
    padding: 6px;
  }
}
