:root {
  color-scheme: light;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: #f8fafc;
  color: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.bx-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.bx-header h1 {
  margin: 0 0 8px;
}

.bx-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.bx-lang {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
}

.bx-lang-label {
  font-size: 12px;
  color: #475569;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bx-lang-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5f5;
  background: #ffffff;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.bx-lang-btn.is-active {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
}

.bx-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 24px;
  align-items: start;
}

.bx-panel {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.bx-form {
  display: grid;
  gap: 16px;
}

.bx-group,
.bx-fieldset {
  display: grid;
  gap: 12px;
}

.bx-fieldset {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
select,
textarea,
button {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5f5;
  background: #ffffff;
}

textarea {
  resize: vertical;
}

.bx-summary {
  background: #f1f5f9;
  padding: 12px;
  border-radius: 10px;
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.bx-actions {
  display: grid;
  gap: 8px;
}

.bx-actions button {
  background: #111827;
  color: #ffffff;
  border: none;
  cursor: pointer;
}

.bx-actions button:hover {
  background: #1f2937;
}

.bx-details summary {
  cursor: pointer;
  font-weight: 600;
}

.bx-notice {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.bx-notice-title {
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 6px;
}

.bx-notice-body {
  font-size: 13px;
  color: #334155;
  line-height: 1.4;
}

.bx-checkout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.bx-price-label {
  font-size: 12px;
  color: #475569;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bx-price-value {
  font-size: 28px;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.1;
}

.bx-currency {
  font-size: 16px;
  font-weight: 800;
  color: #334155;
}

.bx-order-btn {
  width: 100%;
  padding: 14px 14px;
  border-radius: 14px;
  background: #16a34a;
  border: none;
  color: #ffffff;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(22, 163, 74, 0.22);
}

.bx-order-btn:hover {
  background: #15803d;
}

.bx-submetrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: #64748b;
  font-size: 12px;
}

.bx-metric-label {
  font-weight: 700;
}

.bx-font-preview {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px dashed #cbd5f5;
  background: #f8fafc;
  font-size: 16px;
}

.bx-preview {
  min-height: 540px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  padding: 12px;
  overflow: hidden;
}

#bx-canvas {
  width: 100%;
  height: 100%;
  min-height: 520px;
  overscroll-behavior: contain;
}

/* Ensure the canvas does NOT control layout size */
#bx-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.bx-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.bx-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  padding: 0;
  cursor: pointer;
}

.bx-swatch:hover {
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
}

.bx-swatch.is-selected {
  outline: 3px solid #0f172a;
  outline-offset: 2px;
}

.bx-help {
  margin: 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.4;
}

.bx-swatch:focus-visible {
  outline: 3px solid #0f172a;
  outline-offset: 2px;
}

@media (max-width: 960px) {
  .bx-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .bx-lang {
    margin-top: 10px;
    margin-bottom: 14px; /* space between language frame and the preview below */
    align-self: flex-end; /* keep desktop-like right alignment, but below title/description */
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
  }

  .bx-lang-label {
    flex: 0 0 100%;
    text-align: right;
    margin-bottom: 6px; /* space between label line and buttons line */
  }

  .bx-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "preview"
      "panel";
  }

  .bx-panel {
    grid-area: panel;
  }

  .bx-preview {
    grid-area: preview;
    /* Not sticky: sticky preview blocks scrolling on phones */
    min-height: unset;
    padding: 8px;
    /* Keep preview compact; avoid canvas reflow making it huge */
    height: clamp(280px, 40svh, 380px);
  }

  #bx-canvas {
    /* Clamp height to avoid the "gets bigger" effect when mobile browser UI collapses */
    min-height: 0;
    height: 100%;
    max-height: none;
  }

  .bx-swatches {
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
  }

  .bx-swatch {
    border-radius: 8px;
  }
}

