/* ===== Tokens ===== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #14171c;
  --muted: #5b6472;
  --line: #e3e6eb;
  --accent: #0e7c66;
  --accent-hover: #0b6654;
  --accent-ink: #ffffff;
  --accent-soft: #e5f3ef;
  --danger: #c62828;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --line: #2a2f3a;
    --accent: #2fb391;
    --accent-hover: #3cc7a3;
    --accent-ink: #062a21;
    --accent-soft: #15302a;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.015em; }
a { color: var(--accent); }
code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .05em .35em;
}
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .container { padding: 0 24px; } }
.muted { color: var(--muted); margin: 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand-icon { width: 26px; height: 26px; color: var(--accent); }
.nav { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .94rem; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
@media (max-width: 560px) {
  .nav li:not(:last-child) { display: none; }
  .brand span { font-size: .95rem; }
}

/* ===== Hero ===== */
.hero { padding: 40px 0 28px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; }
.lead { margin: 10px 0 0; max-width: 640px; color: var(--muted); font-size: 1.08rem; }

/* ===== Cards & layout ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head h2 { font-size: 1.1rem; }
.hint { font-size: .82rem; color: var(--muted); }

.app {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .preview-col { order: -1; }
  .tips { display: none; }
}
.form { padding: 22px; }
.preview-col { display: grid; gap: 16px; position: sticky; top: 80px; }
@media (max-width: 900px) { .preview-col { position: static; } }

/* ===== Form ===== */
.field { margin: 0 0 16px; min-width: 0; }
fieldset.field { border: 0; padding: 0; }
.field > label, legend {
  display: block;
  font-size: .86rem;
  font-weight: 600;
  margin-bottom: 6px;
  padding: 0;
}
.opt { font-weight: 400; color: var(--muted); margin-left: 4px; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--line)); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[aria-invalid="true"] { border-color: var(--danger); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.error { color: var(--danger); font-size: .82rem; margin: 6px 0 0; }
.row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
#price { font-weight: 700; font-size: 1.1rem; }

.more {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  margin-bottom: 16px;
}
.more[open] { padding-bottom: 2px; }
.more summary {
  cursor: pointer;
  list-style: none;
  font-size: .9rem;
  font-weight: 600;
  padding: 12px 0;
  color: var(--accent);
  display: flex; align-items: center; gap: 8px;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+"; font-size: 1.1rem; width: 1em; text-align: center; }
.more[open] summary::before { content: "−"; }

/* Style swatches */
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 500;
  transition: border-color .15s, background .15s;
}
.swatch input, .segmented input { position: absolute; opacity: 0; pointer-events: none; }
.sw { width: 40px; height: 24px; border-radius: 5px; border: 1px solid rgba(0,0,0,.12); }
.sw-classic { background: linear-gradient(#e11d2e 0 5px, #fff 5px); }
.sw-sale { background: linear-gradient(#e11d2e 0 5px, #ffd60a 5px); }
.sw-fresh { background: linear-gradient(#15803d 0 5px, #fff 5px); }
.sw-dark { background: linear-gradient(#facc15 0 5px, #111 5px); }
.swatch:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.swatch:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* Segmented size control */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px; gap: 4px;
}
.segmented label { position: relative; cursor: pointer; }
.segmented span {
  display: flex; flex-direction: column; align-items: center;
  padding: 7px 4px;
  border-radius: 7px;
  font-size: .88rem; font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.segmented small { font-weight: 400; font-size: .72rem; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }

.form-foot { display: flex; align-items: flex-end; gap: 12px; margin-top: 4px; }
.copies { margin: 0; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; height: 48px; }
.stepper input { width: 46px; border: 0; text-align: center; min-height: 0; padding: 0; border-radius: 0; -moz-appearance: textfield; font-weight: 600; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { box-shadow: none; }
.step { width: 36px; height: 100%; border: 0; background: var(--surface-2); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.step:hover { background: var(--line); }
.form-foot .btn-primary { flex: 1; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .94rem;
  min-height: 42px; padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-lg { min-height: 48px; font-size: 1rem; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .84rem; }

/* ===== Preview ===== */
.preview-card { padding: 20px; }
.preview-stage {
  display: flex; align-items: center; justify-content: center;
  min-height: 240px;
  padding: 24px 12px;
  border-radius: var(--radius-sm);
  background:
    radial-gradient(circle, color-mix(in srgb, var(--muted) 22%, transparent) 1px, transparent 1.2px) 0 0 / 14px 14px,
    var(--surface-2);
  overflow: hidden;
}
.preview-stage .label { box-shadow: 0 10px 30px rgba(0,0,0,.14), 0 2px 6px rgba(0,0,0,.08); }
.tips { padding: 18px 20px; }
.tips h3 { font-size: .95rem; margin-bottom: 8px; }
.tips ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: .9rem; }
.tips li + li { margin-top: 4px; }

/* ===== Sheet ===== */
.sheet-section { margin-top: 40px; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.sheet-head h2 { font-size: 1.35rem; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.paper-select select { min-height: 42px; width: auto; font-weight: 600; font-size: .94rem; }
.paper-wrap {
  overflow-x: auto;
  padding: 24px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
@media (max-width: 640px) { .paper-wrap { padding: 12px; } }
.paper {
  position: relative;
  width: 210mm;
  min-height: 140mm;
  margin: 0 auto;
  padding: 8mm;
  background: #fff;
  color: #111;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.paper[data-paper="letter"] { width: 8.5in; }
.sheet-grid { display: flex; flex-wrap: wrap; align-content: flex-start; }
.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; color: #6b7280; padding: 24px;
}
.empty svg { width: 48px; height: 48px; color: #b6bcc6; }
.empty p { margin: 0; }
.empty[hidden] { display: none; }

.cut { position: relative; outline: .25mm dashed #b9bec7; outline-offset: -.125mm; break-inside: avoid; page-break-inside: avoid; }
.cut-actions {
  position: absolute; top: 4px; right: 4px;
  display: flex; gap: 4px;
  opacity: 0; transition: opacity .15s;
}
.cut:hover .cut-actions, .cut:focus-within .cut-actions { opacity: 1; }
@media (hover: none) { .cut-actions { opacity: 1; } }
.cut-actions button {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: rgba(17, 17, 17, .82); color: #fff;
  cursor: pointer;
}
.cut-actions button:hover { background: #111; }
.cut-actions button.del:hover { background: #c62828; }
.cut-actions svg { width: 16px; height: 16px; }
.cut.is-editing { outline: .6mm solid var(--accent); z-index: 1; }

/* ===== Label (print-accurate, mm based) ===== */
.label {
  --bg: #fff; --fg: #111; --price: #111; --band: #e11d2e; --sub: #4b5563;
  --badge-bg: #e11d2e; --badge-fg: #fff;
  position: relative;
  display: flex; flex-direction: column;
  width: 80mm; height: 40mm;
  font-size: 3.2mm;
  padding: .55em .8em .6em;
  border-top: .55em solid var(--band);
  background: var(--bg);
  color: var(--fg);
  font-family: "Helvetica Neue", Helvetica, Arial, var(--font);
  overflow: hidden;
  line-height: 1.15;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.label.size-s { width: 60mm; height: 30mm; font-size: 2.4mm; }
.label.size-l { width: 100mm; height: 50mm; font-size: 4mm; }
.theme-sale  { --bg: #ffd60a; --price: #c1121f; --sub: #3d3d3d; --band: #c1121f; }
.theme-fresh { --band: #15803d; --price: #14532d; --badge-bg: #15803d; }
.theme-dark  { --bg: #121212; --fg: #fff; --price: #fff; --band: #facc15; --sub: #c4c4c4; --badge-bg: #facc15; --badge-fg: #111; }

.l-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .6em; }
.l-name {
  font-weight: 800;
  font-size: 1.3em;
  text-transform: uppercase;
  letter-spacing: .01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.l-badge {
  flex: none;
  background: var(--badge-bg); color: var(--badge-fg);
  font-weight: 800; font-size: .95em;
  padding: .2em .45em;
  border-radius: .3em;
  white-space: nowrap;
}
.l-details { margin-top: .2em; color: var(--sub); font-size: .95em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-bottom { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: .6em; min-width: 0; }
.l-meta { display: flex; flex-direction: column; gap: .15em; font-size: .9em; color: var(--sub); min-width: 0; padding-bottom: .35em; }
.l-meta > div { white-space: nowrap; }
.l-old { text-decoration: line-through; text-decoration-thickness: .12em; }
.l-old b { font-weight: 400; }
.l-unit { font-weight: 600; }
.l-price {
  display: flex; align-items: flex-start;
  color: var(--price);
  font-weight: 800;
  line-height: .85;
  white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums;
  margin-left: auto;
}
.l-price .cur { font-size: 1.6em; margin: .12em .12em 0 0; }
.l-price .cur.after { margin: .12em 0 0 .12em; }
.l-price .int { font-size: 4.4em; letter-spacing: -.04em; }
.l-price .frac { font-size: 1.9em; margin: .05em 0 0 .06em; letter-spacing: -.02em; }
.l-price.is-long .int { font-size: 3.4em; }
.l-price.is-xlong .int { font-size: 2.6em; }
.label.is-placeholder .l-name, .label.is-placeholder .l-price { opacity: .35; }

/* ===== Content sections ===== */
.content { margin-top: 72px; }
.content h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); margin-bottom: 20px; }
.content > p { color: var(--muted); max-width: 900px; margin: 0; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.steps li, .features article {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.step-num {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; margin-bottom: 12px;
}
.steps h3, .features h3 { font-size: 1.02rem; margin-bottom: 6px; }
.steps p, .features p { margin: 0; color: var(--muted); font-size: .95rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.faq { display: grid; gap: 10px; max-width: 860px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 18px; }
.faq summary {
  cursor: pointer; list-style: none; font-weight: 600; padding: 16px 28px 16px 0; position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 0; top: 13px; font-size: 1.3rem; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 16px; color: var(--muted); }

.site-footer { margin-top: 80px; border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: .88rem; }
.site-footer p { margin: 0; }

/* ===== Dialog & toast ===== */
.dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.dialog::backdrop { background: rgba(15, 17, 21, .45); backdrop-filter: blur(2px); }
.dialog h2 { font-size: 1.2rem; margin-bottom: 8px; }
.dialog .muted { font-size: .9rem; margin-bottom: 14px; }
.dialog textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  transform: translate(-50%, 20px);
  background: #111; color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: .92rem; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* ===== Print ===== */
@media print {
  .no-print, .cut-actions, .empty { display: none !important; }
  html, body { background: #fff !important; }
  main, .sheet-section, .container, .paper-wrap {
    margin: 0 !important; padding: 0 !important; max-width: none !important;
    border: 0 !important; background: none !important; box-shadow: none !important; overflow: visible !important;
  }
  .paper { width: auto !important; min-height: 0 !important; padding: 0 !important; box-shadow: none !important; }
  .cut.is-editing { outline: .25mm dashed #b9bec7; }
}
