* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #0f172a;
  color: #e5e7eb;
  overflow-x: hidden;
}

html {
  overflow-x: hidden;
}

.tool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: #020617;
  border-bottom: 1px solid #1e293b;
}

.tool-header > div {
  min-width: 0;
}

.tool-header h1 {
  margin: 8px 0 4px;
  font-size: clamp(23px, 7vw, 32px);
  white-space: nowrap;
}

.tool-header p {
  margin: 0;
  color: #94a3b8;
  white-space: nowrap;
  line-height: 1.35;
  overflow-wrap: normal;
}

@media (max-width: 430px) {
  .tool-header h1 {
    font-size: 27px;
  }

  .tool-header p {
    font-size: 13px;
    line-height: 1.35;
  }
}

.back-link {
  color: #38bdf8;
  text-decoration: none;
  font-size: 14px;
  font-weight: bold;
}

.back-link:hover {
  text-decoration: underline;
}

.version-pill {
  background: #082f49;
  color: #67e8f9;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: bold;
}

.tool-layout {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.panel {
  min-width: 0;
  background: #111827;
  border: 1px solid #263244;
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.full-width {
  grid-column: 1 / -1;
}

.eyebrow {
  color: #38bdf8;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: bold;
}

.panel h2 {
  margin: 10px 0;
  font-size: 26px;
}

.helper-text {
  color: #94a3b8;
  line-height: 1.5;
}

.form-group {
  margin-top: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #cbd5e1;
  font-weight: bold;
}

input,
select {
  width: 100%;
  padding: 14px 16px;
  background: #020617;
  color: #e5e7eb;
  border: 1px solid #334155;
  border-radius: 12px;
  font-size: 16px;
}

input:focus,
select:focus {
  outline: none;
  border-color: #38bdf8;
}

input:disabled,
select:disabled {
  color: #64748b;
  border-color: #1e293b;
  background: #0b1120;
  cursor: not-allowed;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: #cbd5e1;
  font-weight: bold;
}

.checkbox-row input {
  width: auto;
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.button-row.center {
  justify-content: center;
}

button {
  padding: 12px 18px;
  background: #0284c7;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}

button:hover {
  background: #0369a1;
}

.secondary-btn {
  background: #334155;
}

.secondary-btn:hover {
  background: #475569;
}

.label-preview {
  background: #ffffff;
  color: #000000;
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  transform-origin: center;
}

.label-measurement-frame {
  --label-width: 2in;
  --label-height: 1in;
  --ruler-gutter: 32px;
  display: grid;
  grid-template-columns: var(--ruler-gutter) var(--label-width);
  grid-template-rows: var(--ruler-gutter) var(--label-height);
  width: calc(var(--label-width) + var(--ruler-gutter));
  max-width: none;
  align-items: stretch;
  justify-content: center;
  transform-origin: center;
}

.ruler-corner {
  border-right: 1px solid #38bdf8;
  border-bottom: 1px solid #38bdf8;
}

.label-ruler {
  position: relative;
  color: #67e8f9;
  font-size: 11px;
  font-weight: bold;
}

.horizontal-ruler {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  border-bottom: 1px solid #38bdf8;
}

.horizontal-ruler::before,
.horizontal-ruler::after {
  content: "";
  position: absolute;
  top: 0;
  width: 1px;
  height: calc(100% + 6px);
  background: #38bdf8;
}

.horizontal-ruler::before {
  left: 0;
}

.horizontal-ruler::after {
  right: 0;
}

.vertical-ruler {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 0;
  border-right: 1px solid #38bdf8;
}

.vertical-ruler::before,
.vertical-ruler::after {
  content: "";
  position: absolute;
  right: -6px;
  width: calc(100% + 6px);
  height: 1px;
  background: #38bdf8;
}

.vertical-ruler::before {
  top: 0;
}

.vertical-ruler::after {
  bottom: 0;
}

.horizontal-ruler span {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 6px;
  padding: 0 6px;
  background: #020617;
  line-height: 1;
  white-space: nowrap;
  z-index: 1;
}

.horizontal-ruler span::before,
.horizontal-ruler span::after,
.vertical-ruler span::before,
.vertical-ruler span::after {
  content: "";
  flex: 0 0 16px;
  height: 1px;
  background: #38bdf8;
}

.vertical-ruler span {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 6px;
  left: -22px;
  top: 50%;
  width: 76px;
  text-align: center;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center;
  background: #020617;
  line-height: 1;
  white-space: nowrap;
  z-index: 1;
}

.label-preview.is-screen-fit {
  max-width: 100%;
}

#barcode {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.preview-panel {
  display: flex;
  flex-direction: column;
}

.barcode-preview-box {
  min-height: 520px;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.qr-preview-box {
  --qr-label-size: 1in;
  width: var(--qr-label-size);
  height: var(--qr-label-size);
  background: #ffffff;
  color: #000000;
  padding: 10px;
  border-radius: 12px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  overflow: hidden;
  min-width: 0;
}

.qr-preview-stage {
  min-height: 520px;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.qr-measurement-frame {
  --label-width: 1in;
  --label-height: 1in;
}

.qr-measurement-frame .horizontal-ruler span {
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
  background: transparent;
}

.qr-preview-box.is-screen-fit {
  max-width: 100%;
  min-width: 0;
}

#qrCode {
  display: flex;
  justify-content: center;
  align-items: center;
}

#qrCode img,
#qrCode canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.qr-text-display {
  color: #000000;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  width: 100%;
  max-width: 100%;
  overflow: visible;
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.size-grid button {
  background: #334155;
}

.size-grid button:hover {
  background: #475569;
}

.size-grid button.selected {
  background: #0284c7;
  color: #ffffff;
}

#barcodeGeneratorSection .settings-panel {
  align-self: start;
}

#barcodeGeneratorSection #sizeButtons {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

#barcodeGeneratorSection #sizeButtons button {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.hidden {
  display: none;
}

.generator-selector-panel {
  padding: 18px 28px 22px;
}

.generator-selector-panel .eyebrow {
  display: block;
  margin-bottom: 12px;
}

.generator-selector-panel h3 {
  margin: 0;
  font-size: 20px;
}

.generator-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.generator-option {
  width: 100%;
  min-width: 0;
  background: #020617;
  border: 1px solid #334155;
  color: #e5e7eb;
  padding: 12px 18px;
  min-height: 64px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
}

.generator-option span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.generator-option.active {
  border-color: #38bdf8;
  background: #082f49;
  color: #67e8f9;
}

.generator-icon {
  font-size: 28px;
}

.generator-section {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  grid-column: 1 / -1;
}

#barcodeGeneratorSection {
  grid-template-columns: minmax(300px, 0.62fr) minmax(0, 1.38fr);
  align-items: start;
}

#barcodeGeneratorSection .settings-panel,
#barcodeGeneratorSection .input-panel {
  grid-column: 1;
}

#barcodeGeneratorSection .barcode-output-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 100%;
}

#qrGeneratorSection {
  grid-template-columns: minmax(300px, 0.62fr) minmax(0, 1.38fr);
  align-items: start;
}

#qrGeneratorSection .settings-panel,
#qrGeneratorSection .input-panel {
  grid-column: 1;
}

#qrGeneratorSection .qr-output-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 100%;
}

#qrGeneratorSection #qrSizeButtons {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

#qrGeneratorSection #qrSizeButtons button {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.generator-section.hidden {
  display: none;
}


@media (max-width: 850px) {
  .tool-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
  }

  .tool-layout {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 18px;
    overflow: hidden;
  }

  .panel {
    padding: 18px;
    border-radius: 16px;
  }

  .generator-selector,
  .generator-section {
    grid-template-columns: 1fr;
  }

  #barcodeGeneratorSection {
    grid-template-columns: 1fr;
  }

  #qrGeneratorSection {
    grid-template-columns: 1fr;
  }

  #barcodeGeneratorSection .settings-panel,
  #barcodeGeneratorSection .input-panel,
  #barcodeGeneratorSection .barcode-output-panel {
    grid-column: auto;
    grid-row: auto;
  }

  #qrGeneratorSection .settings-panel,
  #qrGeneratorSection .input-panel,
  #qrGeneratorSection .qr-output-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .generator-option {
    padding: 12px 14px;
    min-height: 56px;
    justify-content: flex-start;
  }

  .size-grid {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }

  #barcodeGeneratorSection #sizeButtons {
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  }

  #barcodeGeneratorSection #sizeButtons button {
    min-height: 36px;
    padding: 7px 8px;
    font-size: 12px;
  }

  #qrGeneratorSection #qrSizeButtons {
    grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  }

  #qrGeneratorSection #qrSizeButtons button {
    min-height: 36px;
    padding: 7px 8px;
    font-size: 12px;
  }

  .barcode-preview-box {
    min-height: 320px;
    padding: 16px;
  }

  .qr-preview-stage {
    min-height: 320px;
    padding: 16px;
  }

  .button-row button {
    flex: 1 1 140px;
  }

  .bottom-back-button {
    min-width: 0;
    font-size: 16px;
  }
}


footer {
  max-width: none;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
  color: #64748b;
}

.bottom-back-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.bottom-back-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: min(340px, 100%);
  background: #111827;
  border: 1px solid #263244;
  color: #38bdf8;
  text-decoration: none;
  padding: 18px 24px;
  border-radius: 18px;
  font-size: 18px;
  font-weight: bold;
  transition: 0.2s ease;
}

.bottom-back-button:hover {
  border-color: #38bdf8;
  background: #1e293b;
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.12);
}

@media (max-width: 850px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
  }

  body {
    min-width: 0;
  }

  .tool-header,
  .tool-layout,
  footer,
  .bottom-back-container {
    width: 100%;
    max-width: 100%;
  }

  .tool-header {
    padding: 20px;
  }

  .tool-header p,
  .helper-text {
    font-size: 14px;
  }

  .tool-layout {
    padding: 20px;
  }

  .panel,
  .generator-selector,
  .generator-section,
  .button-row,
  .size-grid,
  input,
  select,
  button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .generator-selector {
    display: flex;
    flex-direction: column;
  }

  .generator-option {
    flex: 0 1 auto;
  }

  .generator-icon {
    flex: 0 0 auto;
  }

  .preview-panel,
  .barcode-preview-box {
    overflow: hidden;
  }

  .label-preview {
    aspect-ratio: var(--label-ratio, 2 / 1);
    transform: none !important;
  }

  .qr-preview-box {
    max-width: none;
    min-width: 0;
    overflow: hidden;
  }

  #qrCode img,
  #qrCode canvas {
    width: 100% !important;
    height: auto !important;
  }

  .bottom-back-button {
    min-width: 0;
  }
}

@media (max-width: 430px) {
  .tool-header p {
    font-size: 13px;
    line-height: 1.35;
  }
}
