html {
  font-size: 19px;
  /* Reserve the scrollbar gutter so centred content doesn't jump sideways
     as expanders lengthen the page */
  scrollbar-gutter: stable;
}

:root {
  --black: #111;
  --accent: #E70565;
  --grey-mid: #767676;
  --grey-light: #e8e8e8;
  --grey-bg: #f5f5f5;
  --white: #fff;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Ensure attribute-hidden elements are always hidden, even if CSS sets display */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--black);
  background: var(--white);
  margin: 0;
  padding: 0;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--black);
}

.description {
  color: var(--grey-mid);
  margin: 0 0 2rem;
}

/* Layout */

.qr-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}

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

  /* Preview is hidden by default on mobile; shown as full-screen modal via sheet-open */
  .qr-layout__preview {
    display: none;
  }

  /* Full-screen overlay — only applied when open */
  .qr-layout__preview.sheet-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 200;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--white);
  }

  .qr-preview {
    position: static;
    min-height: 100%;
    padding: 1.25rem 1.25rem 2rem;
  }

  .qr-preview__back {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--grey-mid);
    cursor: pointer;
    padding: 0;
    margin-bottom: 1rem;
  }

  .mobile-preview-btn {
    display: flex;
  }

  main {
    padding-bottom: 5rem;
  }
}

@media (min-width: 701px) {
  .qr-preview__back { display: none; }
  .mobile-preview-btn { display: none !important; }
}

.mobile-preview-btn {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

/* Type tabs */

.qr-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}

.qr-type-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.35em 0.8em;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--grey-light);
  background: var(--white);
  color: var(--black);
  border-radius: 3px;
  line-height: 1.25;
}

.qr-type-tab:hover {
  border-color: var(--black);
  background: var(--grey-bg);
}

.qr-type-tab:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.qr-type-tab[aria-selected="true"] {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

/* Content panel */

.qr-content-panel {
  display: none;
}

.qr-content-panel[aria-hidden="false"] {
  display: block;
}

/* Form fields */

.field {
  margin-bottom: 1.1rem;
}

.field__label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.9375rem;
}

.field__hint {
  color: var(--grey-mid);
  font-size: 0.8125rem;
  margin: 0.2rem 0 0.4rem;
}

.field__hint-inline {
  color: var(--grey-mid);
  font-weight: 400;
}

.field__input,
.field__textarea,
.field__select {
  width: 100%;
  padding: 0.45em 0.6em;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--black);
  background: var(--white);
  border: 2px solid var(--black);
  border-radius: 3px;
}

.field__input:hover,
.field__textarea:hover,
.field__select:hover {
  border-color: #444;
}

.field__input:focus,
.field__textarea:focus,
.field__select:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.field__textarea {
  height: 7rem;
  resize: vertical;
}

.field__input--short {
  width: auto;
}

.field__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Slider */

.slider-field {
  margin-bottom: 1.1rem;
}

.slider-field__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.slider-field__label {
  font-weight: 600;
  font-size: 0.9375rem;
}

.slider-field__value {
  font-size: 0.875rem;
  color: var(--grey-mid);
  font-variant-numeric: tabular-nums;
  min-width: 2rem;
  text-align: right;
}

.slider-field__input {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 1.5rem;
}

/* Colour swatches */

.colour-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.colour-field {
  flex: 1;
}

.colour-field__label {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.3rem;
}

.colour-field__swatch-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.colour-field__input {
  width: 2.5rem;
  height: 2.5rem;
  padding: 2px;
  border: 2px solid var(--black);
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

.colour-field__input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.colour-field__hex {
  font-size: 0.875rem;
  font-family: monospace;
  padding: 0.3em 0.5em;
  border: 2px solid var(--black);
  border-radius: 3px;
  width: 6rem;
  color: var(--black);
  background: var(--white);
}

.colour-field__hex:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Dot/corner style pickers */

.style-picker {
  margin-bottom: 1.1rem;
}

.style-picker__label {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.4rem;
}

.style-picker__options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.style-picker__option {
  position: relative;
}

.style-picker__option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.style-picker__option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem 0.5rem;
  border: 2px solid var(--grey-light);
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--grey-mid);
  background: var(--white);
}

.style-picker__option label:hover {
  border-color: var(--black);
  color: var(--black);
}

.style-picker__option input:checked + label {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff0f5;
}

.style-picker__option input:focus-visible + label {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.style-picker__swatch {
  width: 28px;
  height: 28px;
}

/* Logo upload */

.logo-upload {
  margin-bottom: 1.1rem;
}

.logo-upload__dropzone {
  border: 2px dashed var(--grey-light);
  border-radius: 3px;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--grey-mid);
  cursor: pointer;
  transition: border-color 0.15s;
}

.logo-upload__dropzone:hover,
.logo-upload__dropzone--over {
  border-color: var(--black);
  color: var(--black);
}

/* Preview panel */

.qr-preview {
  position: sticky;
  top: 1.5rem;
}

.qr-preview__canvas-wrap {
  background: var(--grey-bg);
  border: 2px solid var(--grey-light);
  border-radius: 6px;
  padding: 1.25rem;
  position: relative;
  aspect-ratio: 1;
  margin-bottom: 1rem;
}

#qr-canvas {
  display: none;
}

.qr-preview__img {
  display: block;
  width: 100%;
  height: auto;
  cursor: grab;
}

.qr-preview__img:active {
  cursor: grabbing;
}

#qr-canvas-wrap.has-transparency {
  background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0 / 16px 16px;
}

.qr-preview__empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-mid);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.25rem;
  pointer-events: none;
}

/* Download section */

.download-section {
  display: flex;
  flex-direction: column;
}

.download-section__label {
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
}

/* Output size control */

.size-control {
  margin: 0.4rem 0 0.75rem;
}

.size-control__label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--grey-mid);
  margin-bottom: 0.35rem;
}

.size-control__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.size-control__range {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  height: 1.5rem;
}

.size-control__number {
  width: 5rem;
  padding: 0.3em 0.5em;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--black);
  background: var(--white);
  border: 2px solid var(--black);
  border-radius: 3px;
  text-align: right;
}

.size-control__number:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.size-control__unit {
  font-size: 0.875rem;
  color: var(--grey-mid);
}

/* Download button */

.button--download {
  width: 100%;
  justify-content: center;
  padding: 0.7em 1em;
  font-size: 1rem;
  margin-top: 0.25rem;
}

.copy-svg-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  margin-top: 0.25rem;
  display: block;
}

.copy-svg-link:hover {
  color: #c40454;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.45em 0.9em;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  border: 2px solid var(--black);
  background: var(--white);
  color: var(--black);
  border-radius: 3px;
  text-align: center;
}

.button:hover {
  background: var(--grey-bg);
}

.button:active {
  background: var(--grey-light);
}

.button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

.button--primary:hover {
  background: #c40454;
  border-color: #c40454;
}

.button--primary:active {
  background: #a3033f;
  border-color: #a3033f;
}

.button--small {
  font-size: 0.8rem;
  padding: 0.3em 0.6em;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Details / advanced */

details {
  margin-bottom: 1.1rem;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--grey-mid);
  user-select: none;
  padding: 0.3rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

details summary::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform 0.15s;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

details .details-content {
  padding: 0.75rem 0.875rem;
  background: var(--grey-bg);
  border-radius: 4px;
  margin-top: 0.35rem;
}

/* Error level radio group */

.radio-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.radio-group__option {
  position: relative;
}

.radio-group__option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-group__option label {
  display: block;
  padding: 0.3em 0.75em;
  border: 2px solid var(--grey-light);
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--grey-mid);
}

.radio-group__option label:hover {
  border-color: var(--black);
  color: var(--black);
}

.radio-group__option input:checked + label {
  border-color: var(--black);
  background: var(--black);
  color: var(--white);
}

.radio-group__option input:focus-visible + label {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Capacity indicator */

.qr-capacity {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--grey-mid);
}

.qr-capacity__bar-wrap {
  height: 5px;
  background: var(--grey-light);
  border-radius: 3px;
  margin-top: 0.3rem;
  overflow: hidden;
}

.qr-capacity__bar {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.2s;
}

.qr-capacity__bar--warning {
  background: #f59e0b;
}

.qr-capacity__bar--danger {
  background: var(--accent);
}

.ecl-boost-note {
  font-size: 0.75rem;
  color: var(--grey-mid);
  margin: 0.25rem 0 0;
}

/* Error */

.error {
  color: var(--accent);
  background: #fff0f5;
  border-left: 4px solid var(--accent);
  padding: 0.6rem 0.875rem;
  margin-top: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Wifi security toggle */
.wifi-password-wrap {
  position: relative;
}

.wifi-password-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--grey-mid);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 600;
}

.wifi-password-toggle:hover {
  color: var(--black);
}

.wifi-password-wrap .field__input {
  padding-right: 4rem;
}

/* Section divider */
.section-divider {
  border: none;
  border-top: 1px solid var(--grey-light);
  margin: 1.25rem 0;
}

/* Corner pickers inline */

.corner-pickers-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.corner-pickers-row .style-picker {
  margin-bottom: 0;
}

/* Colour actions */

.colour-actions {
  margin: -0.5rem 0 1.1rem;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-button:hover {
  color: #c40454;
}

.link-button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Logo loaded row */

.logo-trigger {
  margin-bottom: 1.1rem;
}

.logo-loaded-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.logo-loaded-row__img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border: 1px solid var(--grey-light);
  border-radius: 3px;
}

.logo-loaded-row__actions {
  display: flex;
  gap: 0.4rem;
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--white);
  border-radius: 6px;
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.modal__close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--grey-mid);
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: 3px;
  font-family: inherit;
}

.modal__close:hover {
  color: var(--black);
  background: var(--grey-bg);
}

.modal__close:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* File size note */

.file-size-note {
  font-size: 0.8125rem;
  color: var(--grey-mid);
  margin: 0.4rem 0 0;
  min-height: 1.2em;
}

.file-size-note--computing {
  opacity: 0.55;
}

.transparency-warning {
  color: var(--accent);
  background: #fff0f5;
  border-left: 4px solid var(--accent);
  padding: 0.5rem 0.875rem;
  margin: 0.5rem 0;
  font-size: 0.875rem;
}

.uppercase-suggestion {
  font-size: 0.875rem;
  color: var(--grey-mid);
  margin: 0.5rem 0 0;
}

.uppercase-suggestion__btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: inherit;
  text-decoration: underline;
}

/* Page header */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.page-header h1 {
  margin: 0;
}

.description__link {
  color: var(--accent);
  text-underline-offset: 2px;
}

.description__link:hover {
  color: #c40454;
}

/* Transparent colour toggle */

.colour-field__transparent {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--grey-mid);
  cursor: pointer;
  margin-top: 0.4rem;
  width: fit-content;
}

.colour-field__transparent:hover {
  color: var(--black);
}

.colour-field--transparent .colour-field__swatch-row {
  opacity: 0.35;
  pointer-events: none;
}

/* Download save animation */

@keyframes btn-saved {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

.button--saved {
  animation: btn-saved 0.2s ease-out;
}
