:root {
  --accent: #8c00ff;
  --bg: #090910;
  --panel: #262626eb;
  --panel-2: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f5f2ff;
  --muted: rgba(255, 255, 255, 0.72);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --front-bg: linear-gradient(135deg, #0b0b12 0%, #121225 55%, #08080d 100%);
  --back-bg: linear-gradient(135deg, #0b0b12 0%, #161629 55%, #090910 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top, rgba(140, 0, 255, 0.18), transparent 30%),
    linear-gradient(180deg, #07070c 0%, #0b0b12 100%);
  color: var(--text);
}

.app {
  min-height: 100vh;
  padding: 24px;
}

.shell {
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(360px, 540px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel,
.stage {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.stage {
  padding: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.56);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.8rem, 2vw, 2.35rem);
  margin-bottom: 10px;
}

.intro {
  color: var(--muted);
  line-height: 1.65;
  max-width: 62ch;
  margin-bottom: 20px;
}

.toolbar,
.segmented,
.mini-actions,
.gradient-controls,
.upload-grid,
.palette-grid,
.card-meta,
.stage-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar,
.stage-toolbar {
  margin-bottom: 18px;
}

button,
select,
input,
textarea {
  font: inherit;
}

button,
.buttonish {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: white;
  border-radius: 14px;
  padding: 11px 14px;
  cursor: pointer;
  transition: 160ms ease;
}

button:hover,
.buttonish:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.11);
}

.primary {
  background: linear-gradient(135deg, #a83cff 0%, #7a00ff 100%);
  border-color: transparent;
}

input[type="file"]:hover {
  transform: translate(-1px);
  background: rgba(255, 255, 255, 0.1);
}

input[type="file"]::file-selector-button {
  border: none;
  background: linear-gradient(135deg, #a83cff 0%, #7a00ff 100%);
  color: white;
  border-radius: 10px;
  padding: 6px 10px;
  margin-right: 10px;
  cursor: pointer;
}

.ghost-active,
.segmented button.active,
.view-toggle button.active {
  background: rgba(140, 0, 255, 0.18);
  border-color: rgba(140, 0, 255, 0.4);
  color: #fff;
}

.segmented,
.view-toggle {
  padding: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  width: fit-content;
}

.segmented button,
.view-toggle button {
  padding: 10px 14px;
  border-radius: 12px;
  background: transparent;
  border-color: transparent;
}

.section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head p,
.helper {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.94rem;
  line-height: 1.55;
  margin-bottom: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full {
  grid-column: 1 / -1;
}

label {
  display: block;
}

label > span {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.93rem;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: white;
  padding: 12px 14px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input[type="color"] {
  width: 54px;
  min-width: 54px;
  height: 46px;
  padding: 4px;
  cursor: pointer;
}

input[type="file"] {
  padding: 10px;
}

.inline-colour {
  display: flex;
  gap: 10px;
  align-items: center;
}

.advanced-only[hidden] {
  display: none !important;
}

.dropzone {
  padding: 14px;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px dashed rgba(255, 255, 255, 0.14);
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.upload-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 12px;
}

.upload-preview {
  aspect-ratio: 1.5 / 1;
  width: 100%;
  margin-top: 10px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.86rem;
  text-align: center;
  padding: 8px;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.gradient-colour {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 10px;
}

.gradient-colour input[type="text"] {
  min-width: 0;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.card-wrap {
  display: grid;
  gap: 16px;
  justify-items: center;
}

.viewer {
  width: min(100%, 920px);
  perspective: 1600px;
}

.flip-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1.75 / 1;
}

.flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.flip-card.show-back {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  overflow: hidden;
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  padding: 30px;
  isolation: isolate;
}

.card-back {
  transform: rotateY(180deg);
}

.card-bg,
.card-overlay,
.cover-art,
.accent-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-bg,
.card-overlay,
.cover-art,
.accent-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-bg {
  z-index: 0;
}

.cover-art {
  z-index: 1;
}

.card-overlay {
  z-index: 2;
}

.accent-glow {
  z-index: 3;
}

.card-face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.2));
  z-index: 4;
  pointer-events: none;
}

.card-safe,
.card-inner {
  position: relative;
  z-index: 5;
}

.cover-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.2;
}

.card-face.has-cover .cover-art img {
  opacity: 0.28;
}

.accent-glow::before,
.accent-glow::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(55px);
  opacity: 0.7;
}

.accent-glow::before {
  width: 220px;
  height: 220px;
  top: -32px;
  right: -32px;
  background: var(--accent);
  opacity: 0.22;
}

.accent-glow::after {
  width: 180px;
  height: 180px;
  bottom: -34px;
  left: -34px;
  background: rgba(255, 255, 255, 0.08);
}

.accent-glow,
.accent-glow::before,
.accent-glow::after {
  display: none;
}

.card-inner {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 1rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.brand-stack h2 {
  font-size: clamp(1.9rem, 3vw, 2.55rem);
  margin-bottom: 8px;
  line-height: 1.04;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.logo-box {
  width: 74px;
  height: 74px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  flex-shrink: 0;
}

.logo-box img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  margin: 0 auto;
}

.logo-fallback {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.front-bottom {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
}

.name-block strong {
  display: block;
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.contact {
  text-align: right;
  font-size: 0.97rem;
  line-height: 1.65;
  color: var(--text);
}

.back-layout {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 20px;
  align-items: end;
}

.qr-shell {
  min-height: 120px;
  border-radius: 18px;
  background: var(--background);
  padding: 12px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.qr-grid {
  display: grid;
  place-items: center;
  width: 100%;
}

.qr-grid canvas,
.qr-grid img {
  width: 100% !important;
  max-width: 96px;
  height: auto !important;
  display: block;
  image-rendering: pixelated;
}

.feature-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.9rem;
}

.card-meta {
  justify-content: center;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.92rem;
}

.stage-note {
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

.flip-card {
  transform-style: preserve-3d;
}

.flip-card.show-back {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  overflow: hidden;
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  padding: 0;
  isolation: isolate;
}

.card-safe {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.safe-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.safe-overlay::before {
  content: "";
  position: absolute;
  inset: 48px 56px;
  border: 2px dashed rgba(0, 255, 150, 0.6);
  border-radius: 12px;
}

.exporting .safe-overlay {
  display: none;
}

.exporting .card-back {
  transform: none !important;
}

.exporting .flip-card,
.exporting .flip-card.show-back {
  transform: none !important;
}

.stage-head {
  position: relative;
  z-index: 20;
}

.stage-toolbar {
  position: relative;
  z-index: 21;
}

.dropdown {
  position: relative;
  z-index: 22;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 9999;
  min-width: 220px;
}
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;

  display: flex;
  flex-direction: column;
  gap: 4px;

  margin-top: 6px;
  padding: 6px;

  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;

  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

/* Hide when attribute is present */
.dropdown-menu[hidden] {
  display: none;
}

.dropdown-menu button {
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: #eee;
  cursor: pointer;
  border-radius: 6px;
}

.dropdown-menu button:hover {
  background: #2a2a2a;
}

#frontBusinessName,
#frontTagline,
#frontName,
#frontRole,
#frontEmail,
#frontWebsite,
#frontPhone,
#backServicesHeader,
#backServices,
#backQrText {
  color: var(--text);
}

.logo-size-controls {
  margin-top: 12px;
}

.logo-size-controls label > span:first-child {
  margin-bottom: 6px;
}

#logoScaleNum {
  display: inline-block;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
}

#logoScale {
  width: 100%;
}

footer {
    margin-top: 32px;
    padding: 14px 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.56);
    font-size: 0.9rem;
}

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

  .panel {
    position: relative;
    top: 0;
    max-height: none;
  }

  .stage-head {
    flex-direction: column;
    align-items: stretch;
  }

  .stage-head > div:last-child {
    width: 100%;
  }

  .stage-toolbar {
    justify-content: flex-start;
  }

  .viewer {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .app {
    padding: 18px;
  }

  .panel,
  .stage {
    padding: 18px;
    border-radius: 22px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .upload-grid,
  .palette-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .gradient-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .flip-shell {
    aspect-ratio: 1.58 / 1;
  }

  .card-safe {
    padding: 32px 34px;
  }

  .safe-overlay::before {
    inset: 32px 34px;
  }

  .brand-stack h2 {
    font-size: clamp(1.55rem, 4vw, 2.1rem);
  }

  .front-bottom {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .contact {
    text-align: left;
  }

  .back-layout {
    grid-template-columns: 110px 1fr;
    gap: 16px;
  }

  .logo-box {
    width: 64px;
    height: 64px;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 14px;
  }

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

  h1 {
    font-size: 1.6rem;
  }

  .intro {
    font-size: 0.96rem;
    line-height: 1.55;
  }

  .toolbar,
  .stage-toolbar,
  .mini-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar button,
  .stage-toolbar button,
  .mini-actions button,
  .segmented,
  .view-toggle {
    width: 100%;
  }

  .segmented,
  .view-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .segmented button,
  .view-toggle button {
    width: 100%;
  }

  .inline-colour {
    flex-direction: column;
    align-items: stretch;
  }

  input[type="color"] {
    width: 100%;
    min-width: 0;
    height: 46px;
  }

  .viewer {
    width: 100%;
  }

  .flip-shell {
    aspect-ratio: 1.42 / 1;
  }

  .card-safe {
    padding: 24px 22px;
  }

  .safe-overlay::before {
    inset: 24px 22px;
  }

  .card-head {
    gap: 14px;
  }

  .brand-stack h2 {
    font-size: clamp(1.35rem, 5vw, 1.8rem);
    line-height: 1.08;
  }

  .name-block strong {
    font-size: 1.05rem;
  }

  .contact,
  .muted,
  #backServices,
  #backQrText {
    font-size: 0.92rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .back-layout {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .qr-shell {
    width: 110px;
    min-height: 110px;
  }

  .dropdown {
    width: 100%;
  }

  .dropdown-menu {
    left: 0;
    right: 0;
    min-width: 0;
    width: 100%;
  }

  .dropdown-menu button {
    width: 100%;
  }

  .card-meta {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .stage-note {
    font-size: 0.94rem;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 10px;
  }

  .panel,
  .stage {
    padding: 14px;
    border-radius: 16px;
  }

  .eyebrow {
    font-size: 11px;
    letter-spacing: 0.18em;
  }

  h1 {
    font-size: 1.4rem;
  }

  .section {
    margin-top: 18px;
    padding-top: 18px;
  }

  label > span {
    font-size: 0.9rem;
  }

  input,
  select,
  textarea,
  button,
  .buttonish {
    padding: 11px 12px;
    border-radius: 12px;
  }

  .flip-shell {
    aspect-ratio: 1.28 / 1;
  }

  .card-safe {
    padding: 18px 16px;
  }

  .safe-overlay::before {
    inset: 18px 16px;
    border-width: 1.5px;
  }

  .card-head {
    align-items: flex-start;
  }

  .logo-box {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .logo-box img {
    padding: 6px;
  }

  .brand-stack h2 {
    font-size: 1.2rem;
  }

  #backServicesHeader {
    font-size: 1.35rem !important;
    line-height: 1.15;
  }

  .qr-shell {
    width: 96px;
    min-height: 96px;
    padding: 10px;
  }

  .qr-grid canvas,
  .qr-grid img {
    max-width: 76px;
  }
}

@media (max-width: 400px) {
  .app {
    padding: 8px;
  }

  .panel,
  .stage {
    padding: 12px;
  }

  .flip-shell {
    aspect-ratio: 1.18 / 1;
  }

  .card-safe {
    padding: 14px 12px;
  }

  .safe-overlay::before {
    inset: 14px 12px;
  }

  .brand-stack h2 {
    font-size: 1.05rem;
  }

  .contact,
  .muted,
  #backServices,
  #backQrText {
    font-size: 0.86rem;
  }

  .name-block strong {
    font-size: 0.98rem;
  }

  #backServicesHeader {
    font-size: 1.15rem !important;
  }
}

@media print {
  .safe-overlay {
    display: none;
  }
}
