:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --panel: #ffffff;
  --soft: #f8fafc;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --radius: 18px;
  --shadow: 0 16px 48px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #f8fafc;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }

.site-header {
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

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

.brand-mark {
  width: 28px;
  height: 28px;
  padding: 6px 5px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  background: var(--ink);
  border-radius: 8px;
}
.brand-mark i { width: 2px; background: #fff; border-radius: 2px; }
.brand-mark i:nth-child(2) { width: 4px; }
.brand-mark i:nth-child(4) { width: 3px; }

.github-button {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.github-button:hover { background: var(--soft); border-color: #cbd5e1; transform: translateY(-1px); }
.github-button svg { width: 18px; height: 18px; fill: currentColor; }

main { width: 100%; }

.tool-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 48px;
}

.tool-intro { margin: 0 0 24px; }
.tool-intro h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: -.045em;
}
.tool-intro p { margin: 12px 0 0; color: var(--muted); font-size: 17px; }

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 22px;
  align-items: stretch;
}

.input-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.input-panel { padding: 26px; display: flex; flex-direction: column; gap: 20px; }
.result-panel { padding: 26px; }

.field-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-group label { font-size: 14px; font-weight: 750; }
.field-note, .field-row-meta { color: var(--muted); font-size: 12px; }
.field-row-meta { min-height: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-status { font-weight: 700; text-align: right; }
.field-status.success { color: var(--success); }
.field-status.error { color: var(--error); }

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus,
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
input[aria-invalid="true"] { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .08); }

.form-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px; }
.compact-field input { text-align: center; letter-spacing: .12em; }
.is-hidden { display: none; }
.form-actions { margin-top: auto; padding-top: 2px; }

.primary-button,
.secondary-button,
.icon-button {
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 750;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.primary-button:hover:not(:disabled), .secondary-button:hover:not(:disabled), .icon-button:hover:not(:disabled) { transform: translateY(-1px); }
.primary-button { min-height: 44px; padding: 0 16px; color: #fff; background: var(--accent); }
.primary-button:hover:not(:disabled) { background: var(--accent-dark); }
.secondary-button { min-height: 44px; padding: 0 16px; color: var(--ink); background: #fff; border-color: #cbd5e1; }
.secondary-button:hover:not(:disabled) { background: var(--soft); }
.icon-button { min-height: 32px; padding: 0 10px; color: var(--ink); background: #fff; border-color: #cbd5e1; font-size: 12px; }

.result-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.result-heading h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.02em; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.result-state { padding: 5px 9px; color: var(--success); background: var(--success-bg); border-radius: 999px; font-size: 12px; font-weight: 800; }
.result-state.error { color: var(--error); background: var(--error-bg); }

.barcode-preview {
  min-height: 226px;
  margin: 20px 0;
  padding: 24px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
}
.barcode-preview svg { display: block; width: min(100%, 560px); height: auto; max-height: 210px; }
.empty-preview { max-width: 330px; text-align: center; color: var(--muted); font-size: 14px; }

.result-details { margin: 0; border-top: 1px solid var(--line); }
.result-details > div { display: grid; grid-template-columns: 122px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.result-details dt { color: var(--muted); font-size: 13px; }
.result-details dd { margin: 0; min-width: 0; text-align: right; font-size: 13px; font-weight: 750; overflow-wrap: anywhere; }
.gtin-row dd { display: flex; justify-content: flex-end; align-items: center; gap: 9px; }
.gtin-row code { color: var(--ink); font-size: 14px; }

.action-status { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.action-status.success { color: var(--success); }
.action-status.error { color: var(--error); }
.download-actions { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.content-section {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0;
  border-top: 1px solid var(--line);
}
.content-section > h2 { max-width: 760px; margin: 0 0 24px; font-size: 28px; letter-spacing: -.035em; }
.content-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.content-grid article { padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.content-grid h3 { margin: 18px 0 8px; font-size: 17px; }
.content-grid p, .compact-content p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.step-number { color: var(--accent); font-size: 12px; font-weight: 850; letter-spacing: .08em; }
.compact-content { padding-bottom: 70px; }
.compact-content p { max-width: 860px; }

footer {
  padding: 24px 20px;
  color: var(--muted);
  background: #fff;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
}
footer p { margin: 0; }

@media (max-width: 820px) {
  .header-inner, .tool-shell, .content-section { width: min(100% - 28px, 680px); }
  .tool-shell { padding-top: 36px; }
  .tool-grid { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .result-panel { order: 2; }
}

@media (max-width: 520px) {
  .header-inner { min-height: 62px; }
  .brand span:last-child { display: none; }
  .github-button span { display: none; }
  .github-button { width: 40px; padding: 0; justify-content: center; }
  .tool-shell, .content-section { width: calc(100% - 24px); }
  .tool-shell { padding: 28px 0 36px; }
  .tool-intro h1 { font-size: 34px; }
  .tool-intro p { font-size: 15px; }
  .input-panel, .result-panel { padding: 18px; border-radius: 15px; }
  .form-row { grid-template-columns: 1fr; }
  .field-row-meta { align-items: flex-start; flex-direction: column; gap: 3px; }
  .field-status { text-align: left; }
  .barcode-preview { min-height: 190px; padding: 18px 10px; }
  .result-details > div { grid-template-columns: 1fr; gap: 4px; }
  .result-details dd { text-align: left; }
  .gtin-row dd { justify-content: space-between; }
  .download-actions { grid-template-columns: 1fr; }
  .content-section { padding: 40px 0; }
}

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