:root {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  color-scheme: dark light;
  --surface: #0d1117;
  --surface-alt: #161b22;
  --surface-muted: #1f242d;
  --text: #e6edf3;
  --text-muted: #9da7b5;
  --accent: #58a6ff;
  --border: #30363d;
  --danger: #ff6b6b;
  background-color: var(--surface);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(88, 166, 255, 0.12), transparent 45%),
    radial-gradient(circle at bottom right, rgba(58, 226, 130, 0.08), transparent 40%),
    var(--surface);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.75rem clamp(1.5rem, 3vw, 3rem);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(13, 17, 23, 0.95), rgba(22, 27, 34, 0.95));
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__title h1 {
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  margin: 0;
}

.app-header__title p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  line-height: 1.4;
}

.app-header__nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.app-header__nav a {
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(88, 166, 255, 0.4);
  border-radius: 999px;
  transition: background 150ms ease;
}

.app-header__nav a:hover {
  background: rgba(88, 166, 255, 0.12);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 640px);
  gap: 1.5rem;
  padding: 1.5rem clamp(1.5rem, 3vw, 3rem) 3rem;
}

.layout__column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-section {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(15, 22, 33, 0.75);
  display: grid;
  gap: 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.form-section h2 {
  margin: 0;
  font-size: 1.1rem;
}

/* Accordion: collapsible form sections */
.form-section > h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.form-section > h2::after {
  content: '▾';
  display: inline-block;
  font-size: 0.95em;
  color: var(--text-muted);
  transform: rotate(0deg);
  transition: transform 160ms ease;
}

.form-section.is-collapsed > h2::after {
  transform: rotate(-90deg);
}

.form-section.is-collapsed > *:not(h2) {
  display: none !important;
}

.form-section h3 {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  color: var(--text-muted);
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(88, 166, 255, 0.16);
  background: rgba(13, 17, 23, 0.9);
  color: var(--text);
  font-size: 0.95rem;
  transition: border 120ms ease, box-shadow 120ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(88, 166, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.18);
}

textarea {
  resize: vertical;
  min-height: 3.25rem;
}

input[type='color'] {
  padding: 0.2rem;
  height: 2.25rem;
}

input[type='checkbox'] {
  width: auto;
  height: auto;
  accent-color: var(--accent);
}

/* Better looking selects */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2358a6ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 18px;
}

select:hover {
  border-color: rgba(88, 166, 255, 0.32);
}

.checkbox {
  align-items: center;
  grid-auto-flow: column;
  justify-content: start;
  column-gap: 0.6rem;
  font-weight: 500;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

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

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

.grid-item {
  display: grid;
  gap: 0.6rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px dashed rgba(88, 166, 255, 0.18);
  background: rgba(22, 27, 34, 0.65);
}

.beacon-items {
  display: grid;
  gap: 0.85rem;
}

.beacon-item {
  border: 1px solid rgba(88, 166, 255, 0.25);
  border-radius: 12px;
  padding: 0.85rem;
  background: rgba(16, 22, 32, 0.7);
}

.help-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: -0.25rem 0 0.5rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn {
  border: 1px solid rgba(88, 166, 255, 0.3);
  background: rgba(11, 17, 24, 0.9);
  color: var(--text);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.btn--primary {
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.25), rgba(88, 166, 255, 0.45));
  border: none;
}

.form-feedback {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1em;
}

.preview {
  position: sticky;
  top: calc(1.75rem + 74px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview__tabs {
  display: flex;
  gap: 0.5rem;
}

.preview__platform {
  display: flex;
  gap: 0.5rem;
}

.preview__tab {
  flex: 1;
  padding: 0.6rem;
  background: rgba(22, 27, 34, 0.65);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.preview__tab--active {
  color: var(--text);
  border-color: rgba(88, 166, 255, 0.5);
  box-shadow: 0 0 18px rgba(88, 166, 255, 0.18);
}

.preview__card {
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), rgba(12, 18, 26, 0.9)),
    linear-gradient(135deg, rgba(13, 17, 23, 0.85), rgba(13, 17, 23, 0.65));
  border-radius: 24px;
  border: 1px solid rgba(88, 166, 255, 0.2);
  padding: 1.6rem 1.4rem 1.4rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  min-height: 540px;
  display: grid;
  gap: 1rem;
}

.preview__card--hidden {
  display: none;
}

.preview-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.preview-card__logos {
  display: flex;
  gap: 0.75rem;
}

.preview-card__logos img {
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

/* Apple Wallet: Logo 90x30px (optional) */
#preview-apple-logo {
  width: 90px;
  height: 30px;
}

/* Google Wallet: Logo 36x36px (required for some types) */
#preview-google-logo {
  width: 36px;
  height: 36px;
}

.preview-card__logo-text {
  flex: 1;
  text-align: right;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.preview-card__hero {
  /* Default to Google strip height ~112px; can be overridden via --hero-height */
  height: var(--hero-height, 112px);
  border-radius: 16px;
  background: rgba(20, 25, 35, 0.8);
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(88, 166, 255, 0.15);
}

/* Narrow images → centered with left/right margins (contain) */
.preview-card__hero[data-fit='contain'] {
  background-size: contain;
  background-repeat: no-repeat;
}

.preview-card__body {
  display: grid;
  gap: 0.75rem;
}

.preview-card__body h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
}

.preview-card__subheader {
  margin: 0;
  color: var(--text-muted);
}

.preview-card__header-field,
.preview-card__secondary,
.preview-card__auxiliary,
.preview-card__back {
  display: grid;
  gap: 0.6rem;
}

.preview-field {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: rgba(15, 20, 28, 0.66);
  border: 1px solid rgba(88, 166, 255, 0.08);
}

.preview-field .label {
  color: var(--text-muted);
  font-weight: 600;
}

.preview-field .text {
  font-weight: 500;
}

.preview-card__barcode {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 16px;
  background: rgba(12, 18, 26, 0.78);
  border: 1px dashed rgba(88, 166, 255, 0.18);
  text-align: center;
}

/* Apple Wallet: Footer Image area (295x65px), only for some pass types */
.preview-card__footer {
  margin-top: 0.5rem;
  height: 65px; /* fixed height as per spec */
  border-radius: 12px;
  background: rgba(12, 18, 26, 0.78);
  border: 1px solid rgba(88, 166, 255, 0.12);
  display: none; /* toggled on via JS for eligible Apple pass types */
  position: relative;
}

.preview-card__footer::after {
  content: 'Footer Image (295×65)';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

#preview-qr canvas {
  width: 140px !important;
  height: 140px !important;
  margin: 0 auto;
  display: block;
}

#preview-barcode-alt {
  margin: 0.6rem 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.preview-card__back {
  min-height: 320px;
  padding: 1rem;
  border-radius: 16px;
  background: rgba(12, 18, 26, 0.78);
  border: 1px solid rgba(88, 166, 255, 0.12);
}

/* Toast notifications */
.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  max-width: min(92vw, 420px);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 22, 33, 0.95);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  z-index: 1000;
}

.toast--show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast--info {
  border-left: 4px solid var(--accent);
  padding-left: calc(1rem - 4px);
}

.toast--success {
  border-left: 4px solid #3ee282;
  padding-left: calc(1rem - 4px);
}

.toast--error {
  border-left: 4px solid var(--danger);
  padding-left: calc(1rem - 4px);
}

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

  .preview {
    position: static;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-header__nav {
    width: 100%;
  }

  .form-section {
    padding: 1rem 1.2rem;
  }

  .preview__card {
    min-height: 460px;
  }
}
.form-feedback.is-info {
  color: var(--text-muted);
}

.form-feedback.is-success {
  color: #3ee282;
}

.form-feedback.is-error {
  color: var(--danger);
}

.app-header__nav a.is-disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.qr-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 140px;
  border-radius: 12px;
  border: 1px dashed rgba(88, 166, 255, 0.2);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.preview-back__section {
  display: grid;
  gap: 0.75rem;
}

.preview-back__links {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.preview-back__links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.preview-back__links a:hover {
  text-decoration: underline;
}
.form-actions {
  flex-wrap: wrap;
  align-items: center;
}

.form-actions__buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.wallet-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.wallet-actions .btn {
  min-width: 160px;
}

.wallet-actions .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    color-scheme: light;
    --surface: #f5f7fa;
    --surface-alt: #ffffff;
    --surface-muted: #ecf1f9;
    --text: #1b1f27;
    --text-muted: #626c7a;
    --accent: #005fcc;
    --border: #d0d8e6;
    --danger: #d13c3c;
  }

  html:not([data-theme]) body {
    background: radial-gradient(circle at top left, rgba(0, 95, 204, 0.12), transparent 45%),
      radial-gradient(circle at bottom right, rgba(0, 149, 255, 0.08), transparent 40%),
      var(--surface);
    color: var(--text);
  }

  html:not([data-theme]) .form-section,
  html:not([data-theme]) .grid-item,
  html:not([data-theme]) .beacon-item,
  html:not([data-theme]) .preview__card,
  html:not([data-theme]) .preview-field,
  html:not([data-theme]) .preview-card__barcode {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(0, 95, 204, 0.16);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    color: var(--text);
  }

  html:not([data-theme]) .preview-card__hero {
    background: rgba(230, 235, 244, 0.9);
    border-color: rgba(0, 95, 204, 0.12);
  }

  html:not([data-theme]) input,
  html:not([data-theme]) textarea,
  html:not([data-theme]) select {
    background: #ffffff;
    color: var(--text);
    border-color: rgba(0, 95, 204, 0.28);
    box-shadow: none;
  }

  html:not([data-theme]) input:focus,
  html:not([data-theme]) textarea:focus,
  html:not([data-theme]) select:focus {
    border-color: rgba(0, 95, 204, 0.6);
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.18);
  }

  html:not([data-theme]) label {
    color: var(--text-muted);
  }

  html:not([data-theme]) .form-section h2,
  html:not([data-theme]) .form-section h3,
  html:not([data-theme]) .preview-card__body h2 {
    color: var(--text);
  }

  html:not([data-theme]) .preview-field .label,
  html:not([data-theme]) .preview-card__subheader,
  html:not([data-theme]) .preview-card__barcode p,
  html:not([data-theme]) .form-feedback {
    color: var(--text-muted);
  }

  html:not([data-theme]) .btn {
    background: #ffffff;
    color: var(--accent);
    border-color: rgba(0, 95, 204, 0.35);
    box-shadow: 0 6px 14px rgba(0, 95, 204, 0.12);
  }

  html:not([data-theme]) .btn:hover:not([disabled]) {
    box-shadow: 0 10px 22px rgba(0, 95, 204, 0.18);
  }

  html:not([data-theme]) .btn--primary {
    background: linear-gradient(135deg, #e4f0ff, #bed8ff);
    color: #003a80;
    border: none;
  }

  html:not([data-theme]) .wallet-actions .btn[disabled] {
    background: #eef3fb;
    color: rgba(0, 95, 204, 0.5);
    border-color: rgba(0, 95, 204, 0.18);
  }
}

html[data-theme='light'] {
  color-scheme: light;
  --surface: #f5f7fa;
  --surface-alt: #ffffff;
  --surface-muted: #ecf1f9;
  --text: #1b1f27;
  --text-muted: #626c7a;
  --accent: #005fcc;
  --border: #d0d8e6;
  --danger: #d13c3c;
}

html[data-theme='light'] body {
  background: radial-gradient(circle at top left, rgba(0, 95, 204, 0.12), transparent 45%),
    radial-gradient(circle at bottom right, rgba(0, 149, 255, 0.08), transparent 40%),
    var(--surface);
  color: var(--text);
}

html[data-theme='light'] .form-section,
html[data-theme='light'] .grid-item,
html[data-theme='light'] .beacon-item,
html[data-theme='light'] .preview__card,
html[data-theme='light'] .preview-field,
html[data-theme='light'] .preview-card__barcode {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(0, 95, 204, 0.16);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  color: var(--text);
}

html[data-theme='light'] .preview-card__hero {
  background: rgba(230, 235, 244, 0.9);
  border-color: rgba(0, 95, 204, 0.12);
}

html[data-theme='light'] input,
html[data-theme='light'] textarea,
html[data-theme='light'] select {
  background: #ffffff;
  color: var(--text);
  border-color: rgba(0, 95, 204, 0.28);
  box-shadow: none;
}

html[data-theme='light'] input:focus,
html[data-theme='light'] textarea:focus,
html[data-theme='light'] select:focus {
  border-color: rgba(0, 95, 204, 0.6);
  box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.18);
}

html[data-theme='light'] label {
  color: var(--text-muted);
}

html[data-theme='light'] .form-section h2,
html[data-theme='light'] .form-section h3,
html[data-theme='light'] .preview-card__body h2 {
  color: var(--text);
}

html[data-theme='light'] .preview-field .label,
html[data-theme='light'] .preview-card__subheader,
html[data-theme='light'] .preview-card__barcode p,
html[data-theme='light'] .form-feedback {
  color: var(--text-muted);
}

html[data-theme='light'] .btn {
  background: #ffffff;
  color: var(--accent);
  border-color: rgba(0, 95, 204, 0.35);
  box-shadow: 0 6px 14px rgba(0, 95, 204, 0.12);
}

html[data-theme='light'] .btn:hover:not([disabled]) {
  box-shadow: 0 10px 22px rgba(0, 95, 204, 0.18);
}

html[data-theme='light'] .btn--primary {
  background: linear-gradient(135deg, #e4f0ff, #bed8ff);
  color: #003a80;
  border: none;
}

html[data-theme='light'] .wallet-actions .btn[disabled] {
  background: #eef3fb;
  color: rgba(0, 95, 204, 0.5);
  border-color: rgba(0, 95, 204, 0.18);
}
html:not([data-theme]) .app-header,
html[data-theme='light'] .app-header {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(240, 245, 255, 0.92));
  border-bottom-color: rgba(0, 95, 204, 0.18);
}

html:not([data-theme]) .app-header__nav a,
html[data-theme='light'] .app-header__nav a {
  border-color: rgba(0, 95, 204, 0.25);
}

html:not([data-theme]) .app-header__nav a:hover,
html[data-theme='light'] .app-header__nav a:hover {
  background: rgba(0, 95, 204, 0.12);
}
