:root {
  --ink: #20231f;
  --muted: #6f756c;
  --paper: #fff;
  --canvas: #f2efe6;
  --line: #c8c9bf;
  --accent: #dbff49;
  --accent-dark: #c8ed35;
  --panel: #faf9f4;
  --sheet-ratio: 1.4142857;
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  background: var(--canvas);
  font-family: "Manrope", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 6px);
  gap: 2px;
}

.brand-mark i {
  width: 6px;
  height: 6px;
  background: var(--ink);
  border-radius: 1px;
}

.sheet-spec {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sheet-format {
  margin-right: 10px;
  padding: 5px 8px;
  color: var(--ink);
  background: var(--accent);
  border-radius: 3px;
  font-weight: 500;
}

main {
  width: min(1440px, 92vw);
  margin: 0 auto;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, .65fr);
  gap: 8vw;
  align-items: end;
  padding: clamp(54px, 8vw, 110px) 0 clamp(46px, 6vw, 78px);
}

.eyebrow,
.step {
  margin: 0 0 15px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(48px, 7.5vw, 112px);
  font-weight: 500;
  letter-spacing: -.075em;
  line-height: .88;
}

.intro-copy {
  max-width: 420px;
  margin: 0 0 8px;
  color: #52574f;
  font-size: clamp(16px, 1.5vw, 20px);
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, .67fr) minmax(540px, 1.33fr);
  min-height: 780px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.editor-panel,
.preview-panel {
  padding: clamp(26px, 3vw, 48px);
}

.editor-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.preview-panel {
  overflow: hidden;
  background: #e7e4da;
}

.panel-heading,
.preview-heading,
.input-meta,
.control-group,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.panel-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-end;
}

h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.04em;
}

.text-button {
  padding: 4px;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.text-button:hover {
  border-bottom-color: transparent;
}

.input-label {
  margin: 42px 0 10px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  padding: 18px;
  color: var(--ink);
  border: 1px solid #aaa;
  border-radius: 0;
  outline: none;
  background: var(--paper);
  font-family: "DM Mono", monospace;
  font-size: 14px;
  line-height: 1.8;
}

textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

textarea::placeholder {
  color: #aaaea5;
}

.input-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.input-meta code {
  color: var(--ink);
  font-family: "DM Mono", monospace;
}

#parse-status.has-error {
  color: #a43a25;
}

.divider {
  margin: 34px 0;
  border-top: 1px solid var(--line);
}

.control-group label {
  font-size: 13px;
  font-weight: 600;
}

.range-wrap {
  display: flex;
  gap: 12px;
  align-items: center;
}

.layout-control,
.font-control {
  margin-top: 22px;
}

.layout-control {
  margin-top: 0;
  margin-bottom: 22px;
}

.orientation-control,
.fold-control,
.fold-line-control {
  margin-bottom: 22px;
}

.fold-line-control[hidden] {
  display: none;
}

input[type="range"] {
  width: 118px;
  accent-color: var(--ink);
}

select {
  min-width: 164px;
  padding: 8px 30px 8px 10px;
  color: var(--ink);
  border: 1px solid #aaa;
  border-radius: 0;
  outline: none;
  background: var(--paper);
  font-size: 12px;
  cursor: pointer;
}

select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

output {
  min-width: 42px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.notice {
  display: flex;
  gap: 14px;
  margin-top: 32px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #f1efe6;
}

.notice-icon {
  display: grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #9fa397;
  border-radius: 50%;
  font-size: 12px;
}

.notice p {
  margin: 0;
  color: #5a5f56;
  font-size: 11px;
  line-height: 1.55;
}

.print-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: auto;
  padding: 18px 20px;
  border: 1px solid var(--ink);
  background: var(--accent);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.print-button:hover {
  background: var(--accent-dark);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.print-button:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}

.print-button span:last-child {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 400;
}

.legend {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.legend span {
  width: 11px;
  height: 11px;
  border: 1px solid #9b9f95;
  background: var(--paper);
}

.sheet-stage {
  display: grid;
  min-height: 650px;
  padding: 44px 36px 28px 48px;
  place-items: center;
}

.sheet-wrap {
  position: relative;
  width: min(100%, 500px);
}

.label-sheet {
  display: grid;
  grid-template-columns: repeat(var(--label-columns, 4), 1fr);
  grid-template-rows: repeat(var(--label-rows, 10), 1fr);
  width: 100%;
  aspect-ratio: 210 / 297;
  overflow: hidden;
  border: 1px solid #aeb1a8;
  background: var(--paper);
  box-shadow: 0 18px 45px rgb(39 42 35 / 16%);
}

.label-cell {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 3px;
  place-items: center;
  overflow: hidden;
  border-right: 1px dashed #d1d2cc;
  border-bottom: 1px dashed #d1d2cc;
  outline: none;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--label-font-family, "Manrope", sans-serif);
  font-size: var(--label-font-size-preview, 14px);
  line-height: 1.1;
  writing-mode: var(--label-writing-mode, horizontal-tb);
  text-orientation: mixed;
  cursor: text;
}

.label-sheet.is-folded .label-cell {
  color: transparent;
}

.label-sheet.is-folded .label-cell::before,
.label-sheet.is-folded .label-cell::after {
  position: absolute;
  right: 3px;
  left: 3px;
  display: grid;
  height: calc(50% - 3px);
  place-items: center;
  overflow: hidden;
  color: var(--ink);
  content: attr(data-text);
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.label-sheet.is-folded .label-cell::before {
  top: 3px;
  transform: rotate(180deg);
}

.label-sheet.is-folded .label-cell::after {
  bottom: 3px;
}

.label-sheet.is-folded.is-vertical .label-cell::before,
.label-sheet.is-folded.is-vertical .label-cell::after {
  top: 3px;
  bottom: 3px;
  width: calc(50% - 3px);
  height: auto;
}

.label-sheet.is-folded.is-vertical .label-cell::before {
  right: auto;
  left: 3px;
  transform: none;
}

.label-sheet.is-folded.is-vertical .label-cell::after {
  right: 3px;
  left: auto;
  transform: rotate(180deg);
}

.label-sheet.is-folded.show-fold-line .label-cell {
  background-image: repeating-linear-gradient(
    to right,
    #aeb1a8 0 3px,
    transparent 3px 6px
  );
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 1px;
}

.label-sheet.is-folded.is-vertical.show-fold-line .label-cell {
  background-image: repeating-linear-gradient(
    to bottom,
    #aeb1a8 0 3px,
    transparent 3px 6px
  );
  background-size: 1px 100%;
}

.label-sheet.is-folded .label-cell:focus {
  color: var(--ink);
}

.label-sheet.is-folded .label-cell:focus::before,
.label-sheet.is-folded .label-cell:focus::after {
  display: none;
}

.label-cell.is-last-column {
  border-right: 0;
}

.label-cell.is-last-row {
  border-bottom: 0;
}

.label-cell:focus {
  background: #f4ffd0;
  box-shadow: inset 0 0 0 2px var(--ink);
}

.label-cell:not(:empty) {
  font-weight: 600;
}

.column-guides {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  left: 0;
  display: grid;
  grid-template-columns: repeat(var(--label-columns, 4), 1fr);
}

.row-guides {
  position: absolute;
  top: 0;
  right: calc(100% + 14px);
  bottom: 0;
  display: grid;
  grid-template-rows: repeat(var(--label-rows, 10), 1fr);
}

.column-guides span,
.row-guides span {
  display: grid;
  place-items: center;
  color: #858a80;
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.edit-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

footer {
  padding: 30px 0 50px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

footer p {
  margin: 0;
}

@media (max-width: 900px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    min-height: 680px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sheet-stage {
    min-height: auto;
    padding-top: 54px;
  }
}

@media (max-width: 540px) {
  main {
    width: min(100% - 28px, 1440px);
  }

  .site-header {
    padding: 0 14px;
  }

  .sheet-spec {
    font-size: 0;
  }

  .sheet-format {
    margin: 0;
    font-size: 10px;
  }

  h1 {
    font-size: clamp(48px, 16vw, 70px);
  }

  .editor-panel,
  .preview-panel {
    padding: 24px 20px;
  }

  .preview-heading {
    align-items: flex-start;
  }

  .legend {
    max-width: 90px;
  }

  .sheet-stage {
    padding-right: 5px;
    padding-left: 22px;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    width: 210mm;
    height: 297mm;
    margin: 0;
    padding: 0;
    background: #fff;
  }

  body > * {
    display: none !important;
  }

  body > main {
    display: block !important;
    width: auto;
    margin: 0;
  }

  .intro,
  .editor-panel,
  .preview-heading,
  .column-guides,
  .row-guides,
  .edit-hint,
  footer {
    display: none !important;
  }

  .workspace,
  .preview-panel,
  .sheet-stage,
  .sheet-wrap,
  .label-sheet {
    display: block;
    width: 210mm;
    height: 297mm;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  .label-sheet {
    display: grid;
    grid-template-columns: repeat(var(--label-columns, 4), 1fr);
    grid-template-rows: repeat(var(--label-rows, 10), 1fr);
    overflow: visible;
  }

  .label-cell {
    border: 0 !important;
    box-shadow: none !important;
    color: #000;
    background: #fff !important;
    font-size: var(--label-font-size-print, 14pt);
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .label-sheet.is-folded .label-cell::before,
  .label-sheet.is-folded .label-cell::after {
    color: #000;
  }

  .label-sheet.is-folded.show-fold-line .label-cell {
    background-color: #fff !important;
    background-image: repeating-linear-gradient(
      to right,
      #777 0 3px,
      transparent 3px 6px
    ) !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 100% .2mm !important;
  }

  .label-sheet.is-folded.is-vertical.show-fold-line .label-cell {
    background-image: repeating-linear-gradient(
      to bottom,
      #777 0 3px,
      transparent 3px 6px
    ) !important;
    background-size: .2mm 100% !important;
  }
}
