:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --line: #dde2e9;
  --text: #15181d;
  --muted: #66707c;
  --accent: #1f6feb;
  --radius: 14px;
}
[data-theme="dark"] {
  --bg: #0b0d10;
  --card: #12151a;
  --line: #22272f;
  --text: #f2f4f6;
  --muted: #98a1ab;
  --accent: #4da3ff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
header { max-width: 560px; margin: 0 auto; padding: 34px 20px 6px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
header h1::before {
  content: "";
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.5em;
  vertical-align: -0.06em;
  border-radius: 3px;
  background: linear-gradient(90deg,
    var(--accent) 0 16%, transparent 16% 28%,
    var(--accent) 28% 52%, transparent 52% 62%,
    var(--accent) 62% 100%);
}
header .sub { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }
main { max-width: 560px; margin: 0 auto; padding: 14px 20px 8px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
input, select, button { font: inherit; }
input, select {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input::placeholder { color: #5c646d; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.16);
}
.row { display: flex; gap: 12px; }
.row .field { flex: 1; min-width: 0; }
button.primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #06121f;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
button.primary:active { transform: scale(0.99); }
.preview {
  background: #ffffff;
  border-radius: 10px;
  padding: 14px 10px 10px;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
}
.preview svg { max-width: 100%; height: auto; }
.preview .muted, .preview .error { font-size: 0.9rem; }
.error { color: #ff7a7a; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Saved codes: note cards with the barcode always visible */
.saved { list-style: none; margin: 0; padding: 0; }
.note {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  cursor: pointer;
}
.note:last-child { margin-bottom: 0; }
.note:active { border-color: var(--accent); }
.note-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.note-head .name {
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-code {
  background: #ffffff;
  border-radius: 8px;
  padding: 12px 8px 8px;
}
/* In light mode the white barcode area needs a border to stand out */
[data-theme="light"] .note-code { border: 1px solid var(--line); }
.note-code svg { width: 100%; height: auto; display: block; }
.note-meta { color: var(--muted); font-size: 0.78rem; margin-top: 10px; }
.del-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.85rem;
  flex-shrink: 0;
  cursor: pointer;
}
.del-btn:active { color: #ff7a7a; border-color: #ff7a7a; }
.theme-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 18px 20px 40px;
  max-width: 560px;
  margin: 0 auto;
}

/* Fullscreen scan overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: #ffffff;
  color: #000000;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.overlay.hidden { display: none; }
.ov-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 0;
}
.ov-label { font-size: 1.15rem; font-weight: 700; }
.ov-close {
  background: #f0f0f0;
  color: #000;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}
.ov-code {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  min-height: 0;
}
.ov-code svg { width: 100%; max-width: 640px; height: auto; max-height: 100%; }
.ov-hint { text-align: center; color: #555; padding: 0 20px 26px; margin: 0; }
