:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #101828;
  --muted: #667085;
  --border: #dfe3e8;
  --border-strong: #c8ced7;
  --accent: #111827;
  --accent-hover: #293241;
  --success: #137a46;
  --success-bg: #ecfdf3;
  --warning: #9a6700;
  --warning-bg: #fff8e6;
  --danger: #b42318;
  --danger-bg: #fff2f0;
  --shadow: 0 16px 42px rgba(16, 24, 40, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, textarea, select { font: inherit; }
button, select { touch-action: manipulation; }
button:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid rgba(17, 24, 39, 0.2); outline-offset: 2px; }

.site-header { max-width: 1200px; margin: 0 auto; min-height: 70px; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: -0.02em; }
.brand-mark { width: 29px; height: 22px; padding: 3px; display: flex; gap: 2px; align-items: stretch; border: 2px solid var(--text); border-radius: 5px; }
.brand-mark i { display: block; background: var(--text); flex: 1; }
.brand-mark i:nth-child(2) { flex: 0.45; }
.brand-mark i:nth-child(4) { flex: 0.7; }
.github-button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 10px; color: var(--text); background: var(--surface); text-decoration: none; font-size: 14px; font-weight: 700; }
.github-button:hover { border-color: #9aa3af; }
.github-button svg { width: 19px; height: 19px; fill: currentColor; }

.page-shell { width: min(1200px, calc(100% - 48px)); margin: 8px auto 0; }
.intro { margin: 24px 0 20px; }
.intro h1 { margin: 0; font-size: clamp(30px, 5vw, 48px); letter-spacing: -0.045em; line-height: 1.05; }
.intro p { max-width: 760px; margin: 10px 0 0; color: var(--muted); font-size: 16px; line-height: 1.6; }

.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.panel { min-width: 0; padding: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-heading { min-height: 46px; margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading h2 { margin: 2px 0 0; font-size: 19px; letter-spacing: -0.02em; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.text-button { padding: 7px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.text-button:hover { color: var(--text); }

textarea { width: 100%; min-height: 250px; resize: vertical; padding: 16px; border: 1px solid var(--border-strong); border-radius: 12px; background: #fcfcfd; color: var(--text); line-height: 1.55; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 14px; }
textarea:focus { border-color: #7f8997; background: #fff; }
.input-meta, .output-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.input-meta strong { color: var(--text); font-variant-numeric: tabular-nums; }

.advanced-settings { margin-top: 16px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.advanced-settings summary { padding: 13px 0; cursor: pointer; font-size: 13px; font-weight: 750; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 0 14px; }
.settings-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.settings-grid select { width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); }

.primary-button { width: 100%; min-height: 48px; margin-top: 16px; padding: 0 18px; border: 0; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 800; cursor: pointer; }
.primary-button:hover { background: var(--accent-hover); }
.primary-button:disabled { opacity: 0.55; cursor: not-allowed; }
.message { min-height: 18px; margin-top: 10px; font-size: 13px; color: var(--danger); }

.status-chip { flex: 0 0 auto; padding: 7px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-working { color: #475467; background: #f2f4f7; }
.status-success { color: var(--success); background: var(--success-bg); }
.status-warning { color: var(--warning); background: var(--warning-bg); }
.status-error { color: var(--danger); background: var(--danger-bg); }
.status-idle { color: #475467; background: #f2f4f7; }

.preview-stage { min-height: 250px; display: grid; place-items: center; overflow: auto; padding: 22px; border: 1px solid var(--border); border-radius: 12px; background-color: #fff; background-image: linear-gradient(#f2f4f7 1px, transparent 1px), linear-gradient(90deg, #f2f4f7 1px, transparent 1px); background-size: 18px 18px; }
#barcode-canvas { display: block; max-width: 100%; height: auto; image-rendering: pixelated; background: #fff; box-shadow: 0 4px 18px rgba(16, 24, 40, 0.08); }
.empty-preview { max-width: 280px; color: var(--muted); text-align: center; line-height: 1.5; }
.verification-card { margin-top: 14px; padding: 13px 14px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.verification-card > div { min-width: 0; display: grid; gap: 3px; }
.verification-card strong { font-size: 13px; }
.verification-card > span:last-child { color: var(--muted); font-size: 12px; text-align: right; }
.verification-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.verification-card.is-success { border-color: #abefc6; background: var(--success-bg); }
.verification-card.is-warning { border-color: #fedf89; background: var(--warning-bg); }
.verification-card.is-error { border-color: #fecdca; background: var(--danger-bg); }

.download-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
.download-grid button { min-height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-weight: 750; cursor: pointer; }
.download-grid button:hover:not(:disabled) { border-color: #7f8997; background: var(--surface-soft); }
.download-grid button:disabled { color: #98a2b3; background: #f9fafb; cursor: not-allowed; }

.support-content { max-width: 800px; margin: 34px auto 0; padding: 10px 0 36px; text-align: center; }
.support-content h2 { margin: 0 0 9px; font-size: 20px; letter-spacing: -0.025em; }
.support-content p { margin: 0; color: var(--muted); line-height: 1.7; }
footer { padding: 26px 20px 34px; color: #98a2b3; text-align: center; font-size: 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; }

@media (max-width: 760px) {
  .site-header { padding: 12px 16px; }
  .page-shell { width: min(100% - 24px, 640px); margin-top: 0; }
  .intro { margin: 18px 0 16px; }
  .intro h1 { font-size: 32px; }
  .intro p { font-size: 14px; }
  .tool-grid { grid-template-columns: 1fr; }
  .panel { padding: 16px; border-radius: 15px; }
  textarea { min-height: 210px; }
  .preview-stage { min-height: 220px; padding: 14px; }
  .settings-grid { grid-template-columns: 1fr; }
  .verification-card { align-items: flex-start; flex-direction: column; gap: 7px; }
  .verification-card > span:last-child { text-align: left; }
}

@media (max-width: 430px) {
  .github-button { width: 40px; padding: 0; justify-content: center; font-size: 0; }
  .download-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  button, a, textarea, select { transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, opacity 140ms ease; }
}

@media print {
  body { background: #fff; }
  .site-header, .intro, .input-panel, .verification-card, .download-grid, .support-content, footer, .output-meta, .status-chip { display: none !important; }
  .page-shell, .tool-grid, .output-panel { width: 100%; margin: 0; padding: 0; border: 0; box-shadow: none; display: block; }
  .preview-stage { border: 0; min-height: 0; background: #fff; }
}
