:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #5b8cff;
  --accent-2: #7fd8a6;
  --danger: #ff6b6b;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f0f1f4;
  --border: #dde1e8;
  --text: #1c1f26;
  --muted: #626a7a;
  --accent: #3a66d1;
  --accent-2: #2f9e63;
  --danger: #d9403f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.logo__icon {
  width: 28px;
  height: 28px;
  fill: var(--accent);
  flex-shrink: 0;
}

.logo__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
}

.logo__text-main {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo__text-accent {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.hero {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 8px;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.lang-switcher {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 3px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.lang-btn {
  flex: none;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.lang-btn:hover {
  color: var(--text);
  filter: none;
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

.theme-toggle {
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}

@media (max-width: 480px) {
  .site-header {
    padding: 10px 12px;
    gap: 10px;
  }

  .header-actions {
    gap: 10px;
  }

  .lang-btn {
    padding: 4px 8px;
    font-size: 12px;
  }
}

.theme-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-toggle__track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 56px;
  height: 28px;
  padding: 0 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 30px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle__icon {
  position: relative;
  z-index: 0;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.2s ease;
}

.theme-toggle__icon--moon {
  fill: var(--muted);
  stroke: none;
}

.theme-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.35s ease;
  z-index: 1;
}

.theme-toggle__input:checked ~ .theme-toggle__track .theme-toggle__thumb {
  transform: translateX(28px);
}

.theme-toggle__input:focus-visible ~ .theme-toggle__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px 40px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 14px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}

.controls {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12.5px;
  color: var(--muted);
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

select,
input[type="number"],
input[type="color"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
}

input[type="color"] {
  padding: 3px;
  height: 36px;
  cursor: pointer;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

button {
  flex: 1;
  min-width: 140px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  transition: filter 0.15s ease;
}

button:hover {
  filter: brightness(1.1);
}

button.secondary {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}

#results {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-content: flex-start;
}

.barcode-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  cursor: pointer;
  user-select: none;
}

.barcode-card svg {
  max-width: 100%;
}

.barcode-value {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  text-align: center;
}

.barcode-error {
  color: var(--danger);
  font-size: 12.5px;
  text-align: center;
  max-width: 220px;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
  width: 100%;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding-bottom: 30px;
}

.barcode-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.barcode-overlay.active {
  opacity: 1;
  visibility: visible;
}

.barcode-overlay__content {
  background: var(--panel);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  width: 50vw;
  height: 50vh;
  max-width: 90vw;
  max-height: 90vh;
}

.barcode-overlay__content svg {
  width: 100%;
  height: 100%;
}

@media (max-width: 768px) {
  .barcode-overlay__content {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    max-width: none;
    max-height: none;
    padding: 32px;
    border-radius: 0;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}
