:root {
  --ink: #102b3a;
  --ink-2: #294555;
  --paper: #f7fbfc;
  --surface: #ffffff;
  --line: #bfd0d7;
  --line-dark: #78929d;
  --accent: #008f91;
  --accent-dark: #006b6d;
  --signal: #ffb23f;
  --danger: #b63b32;
  --radius: 3px;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: #dfe9ed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button, label, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, .drop-zone:focus-within {
  outline: 3px solid var(--signal);
  outline-offset: 2px;
}

.topbar {
  min-height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--ink);
  color: white;
  border-bottom: 4px solid var(--accent);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.brand-mark {
  width: 28px;
  height: 22px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 2px solid white;
  padding: 3px;
}
.brand-mark span { display: block; height: 2px; background: var(--signal); }
.runtime-status { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 3px rgb(255 178 63 / .2); }
.runtime-status.is-ok .status-dot { background: #52d0b4; box-shadow: 0 0 0 3px rgb(82 208 180 / .2); }
.runtime-status.is-error .status-dot { background: #ff786f; box-shadow: 0 0 0 3px rgb(255 120 111 / .2); }

main { width: min(1680px, 100%); margin: 0 auto; padding: 34px 28px 48px; }
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(420px, .9fr);
  align-items: end;
  gap: 48px;
  margin-bottom: 28px;
}
h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(46px, 5vw, 76px);
  line-height: .94;
  letter-spacing: -.02em;
  text-transform: uppercase;
}
.intro p { max-width: 850px; margin: 0; color: var(--ink-2); font-size: 18px; }
.process-strip { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-dark); }
.process-strip li { position: relative; padding: 12px 10px 0; display: grid; gap: 2px; border-right: 1px solid var(--line-dark); }
.process-strip li:last-child { border-right: 0; }
.process-strip b { color: var(--accent-dark); font-family: var(--font-display); font-size: 22px; }
.process-strip span { font-size: 13px; font-weight: 700; }

.bench { display: grid; grid-template-columns: minmax(250px, .72fr) minmax(420px, 1.5fr) minmax(310px, .9fr); gap: 1px; background: var(--line-dark); border: 1px solid var(--line-dark); box-shadow: 0 10px 35px rgb(16 43 58 / .13); }
.panel { min-width: 0; background: var(--surface); padding: 22px; }
.panel-heading { min-height: 42px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.panel-heading > div:first-child { display: flex; align-items: baseline; gap: 9px; }
.panel-index { color: var(--accent); font-family: var(--font-display); font-size: 18px; font-weight: 800; }
h2 { margin: 0; font-family: var(--font-display); font-size: 30px; line-height: 1; text-transform: uppercase; }
h3 { margin: 0; font-family: var(--font-display); font-size: 20px; text-transform: uppercase; }
.file-badge, .field-count { padding: 3px 7px; border: 1px solid var(--line-dark); font-family: var(--font-display); font-size: 13px; font-weight: 700; text-transform: uppercase; }

.drop-zone {
  min-height: 154px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed var(--line-dark);
  background: var(--paper);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.drop-zone:hover, .drop-zone.is-dragging { background: #e9f7f7; border-color: var(--accent); }
.drop-icon { min-width: 48px; margin-bottom: 10px; padding: 5px 7px; background: var(--ink); color: white; font-family: var(--font-display); font-weight: 800; letter-spacing: .08em; }
.drop-zone strong { font-size: 16px; }
.drop-zone > span:last-child { color: var(--ink-2); font-size: 13px; }
.example-heading { margin: 26px 0 10px; display: flex; align-items: baseline; justify-content: space-between; }
.example-heading span { color: var(--ink-2); font-size: 12px; }
.example-list { display: grid; border-top: 1px solid var(--line); }
.example-button {
  width: 100%; min-height: 58px; padding: 10px 2px;
  display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 10px;
  text-align: left; background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.example-button:hover { color: var(--accent-dark); }
.example-number { font-family: var(--font-display); font-weight: 800; color: var(--accent); }
.example-copy { min-width: 0; display: grid; }
.example-copy strong { font-size: 14px; }
.example-copy span { color: var(--ink-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-facts { margin: 24px 0 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.template-facts div { display: grid; grid-template-columns: 72px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.template-facts dt { color: var(--ink-2); font-size: 12px; }
.template-facts dd { min-width: 0; margin: 0; font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.preview-panel { display: flex; flex-direction: column; }
.preview-actions { display: flex; gap: 12px; }
.text-button { min-height: 32px; padding: 2px 0; color: var(--accent-dark); background: transparent; border: 0; border-bottom: 1px solid currentColor; cursor: pointer; font-size: 13px; font-weight: 700; }
.text-button:disabled { color: #81949c; cursor: not-allowed; }
.preview-stage {
  position: relative;
  min-height: 510px;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 56px 58px 44px;
  background: #203d4c;
}
.preview-stage::after { content: "PREVIEW · 300 DPI BASIS"; position: absolute; right: 14px; bottom: 10px; color: #a9bec7; font-family: var(--font-display); font-size: 11px; letter-spacing: .1em; }
.ruler { position: absolute; opacity: .5; pointer-events: none; }
.ruler-top { left: 56px; right: 16px; top: 20px; height: 11px; border-top: 1px solid #8fa7b1; background: repeating-linear-gradient(90deg, #8fa7b1 0 1px, transparent 1px 18px); }
.ruler-side { top: 54px; bottom: 36px; left: 22px; width: 11px; border-left: 1px solid #8fa7b1; background: repeating-linear-gradient(0deg, #8fa7b1 0 1px, transparent 1px 18px); }
.preview-empty { display: grid; place-items: center; text-align: center; gap: 7px; color: #d8e4e8; }
.preview-empty > span:last-child { max-width: 280px; color: #a9bec7; font-size: 13px; }
.empty-sheet { width: 150px; height: 74px; margin-bottom: 12px; background: transparent; border: 1px dashed #9ab0b9; }
#label-preview { display: block; width: min(76%, 520px); height: auto; max-width: 100%; max-height: 430px; background: white; border: 1px solid #c6d4d9; box-shadow: 0 12px 28px rgb(0 0 0 / .25); }
.diagnostics { min-height: 44px; padding: 11px 12px; display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-top: 0; color: var(--ink-2); font-size: 13px; }
.diagnostic-ok::before, .diagnostic-warn::before, .diagnostic-error::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--accent); }
.diagnostic-warn::before { background: var(--signal); }
.diagnostic-error::before { background: var(--danger); }

.control-panel { display: flex; flex-direction: column; }
.parameter-form { min-height: 160px; max-height: 370px; overflow: auto; padding-right: 5px; }
.parameter-empty { padding: 18px 0; color: var(--ink-2); font-size: 14px; }
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > span:first-child { font-size: 12px; font-weight: 700; }
.field small { color: var(--ink-2); font-size: 11px; }
input, select {
  width: 100%; min-height: 42px; padding: 8px 10px;
  border: 1px solid var(--line-dark); border-radius: 0; background: white; color: var(--ink);
}
input:hover, select:hover { border-color: var(--accent-dark); }
.printer-section { margin-top: auto; padding-top: 20px; border-top: 2px solid var(--ink); }
.printer-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.printer-heading > span { color: var(--ink-2); font-size: 12px; font-weight: 700; }
.printer-heading > span.is-connected { color: var(--accent-dark); }
.option-row { display: grid; grid-template-columns: 86px 1fr; align-items: end; gap: 14px; }
.field.compact { margin: 0; }
.switch-field { min-height: 42px; display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; font-weight: 600; }
.switch-field input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 34px; height: 19px; flex: 0 0 auto; background: #91a3aa; border: 1px solid #687f89; }
.switch::after { content: ""; position: absolute; width: 13px; height: 13px; left: 2px; top: 2px; background: white; transition: transform .15s ease; }
.switch-field input:checked + .switch { background: var(--accent); border-color: var(--accent-dark); }
.switch-field input:checked + .switch::after { transform: translateX(15px); }
.system-print-button, .connect-button, .print-button { width: 100%; min-height: 48px; margin-top: 12px; padding: 10px 14px; border-radius: 0; cursor: pointer; font-weight: 800; }
.system-print-button { background: var(--ink); color: white; border: 1px solid var(--ink); }
.system-print-button:hover:not(:disabled) { background: var(--ink-2); }
.system-print-button:disabled { background: #9aabb2; border-color: #879aa2; cursor: not-allowed; }
.transport-divider { position: relative; margin: 17px 0 3px; border-top: 1px solid var(--line); text-align: center; }
.transport-divider span { position: relative; top: -10px; padding: 0 8px; background: white; color: var(--ink-2); font-size: 11px; }
.connect-button { background: white; color: var(--ink); border: 1px solid var(--ink); }
.connect-button:hover { background: #edf4f6; }
.print-button { min-height: 58px; display: flex; align-items: center; justify-content: space-between; background: var(--accent); color: white; border: 1px solid var(--accent-dark); font-family: var(--font-display); font-size: 21px; text-transform: uppercase; }
.print-button:hover:not(:disabled) { background: var(--accent-dark); }
.print-button:disabled { background: #9aabb2; border-color: #879aa2; cursor: not-allowed; }
.print-arrow { font-size: 28px; line-height: 1; }
.usb-note { margin: 10px 0 0; color: var(--ink-2); font-size: 11px; }
.privacy-note { margin-top: 18px; padding: 13px 16px; display: grid; grid-template-columns: max-content 1fr; gap: 12px; border-left: 5px solid var(--accent); background: #eff6f7; color: var(--ink-2); font-size: 13px; }
.privacy-note strong { color: var(--ink); }

.toast { position: fixed; z-index: 10; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); padding: 13px 16px; background: var(--ink); color: white; border-left: 5px solid var(--signal); box-shadow: 0 8px 24px rgb(0 0 0 / .2); font-weight: 600; }
.toast.is-error { border-color: #ff786f; }
.toast.is-ok { border-color: #52d0b4; }

@media (max-width: 1180px) {
  .bench { grid-template-columns: 290px minmax(430px, 1fr); }
  .control-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
  .control-panel .panel-heading { grid-column: 1 / -1; }
  .parameter-form { max-height: none; }
  .printer-section { margin-top: 0; padding-top: 0; padding-left: 28px; border-top: 0; border-left: 2px solid var(--ink); }
}

@media (max-width: 820px) {
  .topbar { padding: 0 18px; }
  .runtime-status { max-width: 150px; text-align: right; }
  main { padding: 24px 14px 36px; }
  .intro { grid-template-columns: 1fr; gap: 22px; }
  .process-strip { max-width: 520px; }
  .bench { grid-template-columns: 1fr; }
  .template-rack, .preview-panel, .control-panel { grid-column: auto; }
  .control-panel { display: block; }
  .printer-section { margin-top: 22px; padding-top: 20px; padding-left: 0; border-top: 2px solid var(--ink); border-left: 0; }
  .preview-stage { min-height: 390px; padding: 48px 34px 40px 48px; }
  #label-preview { max-height: 315px; }
}

@media (max-width: 520px) {
  .brand { font-size: 20px; }
  .runtime-status { font-size: 12px; }
  h1 { font-size: 44px; }
  .intro p { font-size: 16px; }
  .process-strip span { font-size: 11px; }
  .panel { padding: 17px; }
  .panel-heading { align-items: center; }
  .preview-actions { flex-direction: column; align-items: flex-end; gap: 4px; }
  .preview-stage { min-height: 330px; padding: 44px 24px 38px 40px; }
  .privacy-note { grid-template-columns: 1fr; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

@media print {
  @page { margin: 0; }
  html, body { width: auto; min-width: 0; margin: 0; padding: 0; background: white; }
  .topbar, .intro, .template-rack, .control-panel, .privacy-note,
  .preview-panel > .panel-heading, .ruler, .diagnostics, .toast,
  .preview-stage::after { display: none !important; }
  main, .bench, .preview-panel, .preview-stage {
    width: auto; min-height: 0; margin: 0; padding: 0; display: block;
    overflow: visible; border: 0; box-shadow: none; background: white;
  }
  #label-preview {
    width: var(--print-width); height: var(--print-height); max-width: none; max-height: none;
    margin: 0; border: 0; box-shadow: none;
  }
}
