:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page: #080c11;
  --surface: #10161e;
  --surface-strong: #0b1016;
  --surface-soft: #151c25;
  --line: #2b3541;
  --line-strong: #3b4857;
  --text: #f4f6f8;
  --muted: #98a4b1;
  --muted-strong: #c2c9d0;
  --yellow: #f5d72f;
  --yellow-bright: #ffe765;
  --green: #54dc88;
  --amber: #e8b94a;
  --red: #ff847c;
  --focus: #fff3a3;
  --radius: 1rem;
  --shadow: 0 24px 70px rgb(0 0 0 / 28%);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { min-height: 100%; background: var(--page); }

body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 58% -12%, rgb(245 215 47 / 7%), transparent 33rem),
    var(--page);
}

button,
input { font: inherit; }

button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 20;
  padding: .75rem 1rem;
  border-radius: .65rem;
  color: #111;
  background: var(--yellow);
  font-weight: 800;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  position: relative;
  z-index: 5;
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem clamp(1rem, 2.5vw, 2.4rem);
  border-bottom: 1px solid var(--line);
  background: rgb(10 14 19 / 92%);
  backdrop-filter: blur(14px);
}

.brand {
  position: relative;
  display: inline-flex;
  color: var(--text);
  text-decoration: none;
  font-size: clamp(1.55rem, 2vw, 2.1rem);
  font-weight: 860;
  letter-spacing: -.055em;
  line-height: 1;
}

.brand-r { color: var(--yellow); }

.brand-line {
  position: absolute;
  right: -.02em;
  bottom: -.36rem;
  width: 1.2em;
  height: .14rem;
  border-radius: 999px;
  background: var(--yellow);
}

.topbar-meta {
  margin: 0;
  color: var(--muted-strong);
  font-size: .84rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.studio {
  width: min(100%, 110rem);
  min-height: calc(100vh - 4.25rem);
  display: grid;
  grid-template-columns: minmax(17rem, 21rem) minmax(30rem, 1fr) minmax(16rem, 19rem);
  grid-template-areas: "design preview export";
  gap: .9rem;
  margin: 0 auto;
  padding: .9rem;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgb(18 25 34 / 97%), rgb(11 16 22 / 97%));
  box-shadow: var(--shadow);
}

.design-panel {
  grid-area: design;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.preview-panel {
  grid-area: preview;
  display: flex;
  flex-direction: column;
  padding: .8rem;
}

.export-panel {
  grid-area: export;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: .72rem;
}

.section-heading h1,
.section-heading h2 {
  margin: .05rem 0 0;
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: -.02em;
}

.section-heading p {
  margin: .26rem 0 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
}

.step-number {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #11151a;
  background: var(--yellow);
  font-size: .9rem;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 28%);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .52rem;
  margin-top: .8rem;
}

.template-card {
  min-width: 0;
  padding: .32rem;
  border: 1px solid var(--line-strong);
  border-radius: .78rem;
  color: var(--muted-strong);
  background: var(--surface-strong);
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, color .15s ease;
}

.template-card:hover {
  transform: translateY(-1px);
  border-color: #637080;
  color: white;
}

.template-card[aria-checked="true"] {
  border-color: var(--yellow);
  color: white;
  box-shadow: 0 0 0 2px rgb(245 215 47 / 18%);
}

.template-art {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  align-content: center;
  justify-items: center;
  overflow: hidden;
  border-radius: .48rem;
  color: var(--template-fg);
  background: var(--template-bg);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 16%);
}

.template-art.is-festive {
  background-image: linear-gradient(rgb(0 0 0 / 16%), rgb(0 0 0 / 58%)), url("./assets/holiday-bulbs-background.jpg");
  background-size: cover;
  background-position: center;
}

.template-art span {
  position: relative;
  z-index: 1;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Black", sans-serif;
  font-weight: 900;
  line-height: .88;
  letter-spacing: .01em;
  text-shadow: 0 2px 5px rgb(0 0 0 / 28%);
}

.template-art span:first-child { font-size: clamp(.72rem, 1.1vw, 1rem); }
.template-art span:nth-child(2) { font-size: clamp(1.08rem, 1.7vw, 1.55rem); }

.template-name {
  display: flex;
  align-items: center;
  gap: .38rem;
  padding: .34rem .1rem .08rem;
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.2;
}

.radio-mark {
  width: .72rem;
  height: .72rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.template-card[aria-checked="true"] .radio-mark {
  border-color: var(--yellow);
  box-shadow: inset 0 0 0 2px var(--surface-strong);
  background: var(--yellow);
}

.panel-divider {
  height: 1px;
  margin: 1.05rem 0;
  background: var(--line);
}

.phone-heading { margin-bottom: .85rem; }

.phone-field label {
  display: block;
  margin-bottom: .45rem;
  color: var(--muted-strong);
  font-size: .78rem;
  font-weight: 750;
}

.phone-input-wrap {
  min-height: 3.15rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 .8rem;
  border: 1px solid var(--line-strong);
  border-radius: .7rem;
  background: #080d12;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.phone-input-wrap:focus-within {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgb(245 215 47 / 13%);
}

.phone-input-wrap > svg {
  flex: 0 0 auto;
  width: 1rem;
  color: var(--yellow);
}

.phone-input-wrap input {
  min-width: 0;
  width: 100%;
  padding: .72rem 0;
  border: 0;
  outline: 0;
  color: white;
  background: transparent;
  font-size: 1rem;
  font-weight: 780;
  letter-spacing: .025em;
}

.phone-input-wrap input::placeholder { color: #65717e; }

.valid-check {
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #0d2917;
  background: var(--green);
  font-size: .82rem;
  font-weight: 900;
  opacity: 0;
  transform: scale(.75);
  transition: opacity .15s ease, transform .15s ease;
}

.valid-check.is-visible { opacity: 1; transform: scale(1); }

.field-hint {
  min-height: 1.15rem;
  margin: .42rem 0 0;
  color: var(--muted);
  font-size: .74rem;
}

.field-hint.is-error { color: var(--red); }

.privacy-note {
  display: flex;
  align-items: center;
  gap: .42rem;
  margin: auto 0 0;
  padding-top: 1.25rem;
  color: #75808c;
  font-size: .72rem;
}

.privacy-note svg { width: .85rem; }

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .35rem .25rem .85rem;
}

.eyebrow {
  margin: 0 0 .18rem;
  color: var(--yellow);
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.preview-toolbar h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .48rem .68rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  background: rgb(255 255 255 / 2.5%);
  font-size: .72rem;
  font-weight: 750;
}

.status-dot {
  width: .48rem;
  height: .48rem;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgb(232 185 74 / 10%);
}

.status-pill.is-ready .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgb(84 220 136 / 10%);
}

.status-pill.is-rendering .status-dot {
  background: var(--yellow);
  animation: pulse 1s ease-in-out infinite;
}

.status-pill.is-error .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgb(255 132 124 / 10%);
}

.preview-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(.45rem, 1.5vw, 1rem);
  border: 1px solid #222c36;
  border-radius: .82rem;
  background:
    linear-gradient(45deg, #151c24 25%, transparent 25%),
    linear-gradient(-45deg, #151c24 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151c24 75%),
    linear-gradient(-45deg, transparent 75%, #151c24 75%),
    #10161d;
  background-position: 0 0, 0 .7rem, .7rem -.7rem, -.7rem 0;
  background-size: 1.4rem 1.4rem;
  overflow: hidden;
}

#preview {
  width: min(100%, calc((100vh - 9.5rem) * 4 / 3));
  max-height: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  background: #06090d;
  box-shadow: 0 24px 60px rgb(0 0 0 / 42%), 0 0 0 1px rgb(255 255 255 / 10%);
}

.preview-prompt {
  position: absolute;
  left: 50%;
  bottom: clamp(1.2rem, 4vw, 2.2rem);
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: .55rem .75rem;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: .58rem;
  color: rgb(255 255 255 / 78%);
  background: rgb(7 10 14 / 82%);
  backdrop-filter: blur(8px);
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
  transform: translateX(-50%);
  transition: opacity .15s ease, transform .15s ease;
}

.preview-prompt.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, .25rem);
}

.export-heading { margin-bottom: 1rem; }

.spec-list {
  display: grid;
  gap: .12rem;
  margin: 0;
}

.spec-list > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .76rem .1rem;
  border-bottom: 1px solid var(--line);
}

.spec-list dt {
  color: var(--muted);
  font-size: .75rem;
}

.spec-list dd {
  margin: 0;
  color: var(--text);
  font-size: .8rem;
  font-weight: 800;
  text-align: right;
}

.export-state {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  margin-top: 1rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: rgb(255 255 255 / 2.5%);
}

.export-state-icon {
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #2a220c;
  background: var(--amber);
  font-size: 0;
}

.export-state-icon::before {
  content: "";
  width: .4rem;
  height: .4rem;
  border-radius: 50%;
  background: currentColor;
}

.export-state.is-ready .export-state-icon {
  color: #0f301c;
  background: var(--green);
}

.export-state.is-ready .export-state-icon::before {
  content: "✓";
  width: auto;
  height: auto;
  background: none;
  font-size: .83rem;
  font-weight: 950;
}

.export-state strong {
  display: block;
  color: var(--muted-strong);
  font-size: .8rem;
}

.export-state.is-ready strong { color: var(--green); }

.export-state p {
  margin: .2rem 0 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.4;
}

.download-button {
  min-height: 3.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  margin-top: 1rem;
  padding: .85rem 1rem;
  border: 0;
  border-radius: .76rem;
  color: #11151a;
  background: linear-gradient(180deg, var(--yellow-bright), var(--yellow));
  box-shadow: 0 12px 32px rgb(245 215 47 / 15%);
  font-weight: 850;
  transition: transform .15s ease, filter .15s ease;
}

.download-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.03); }
.download-button:active:not(:disabled) { transform: translateY(0); }
.download-button:disabled { cursor: not-allowed; filter: grayscale(.75); opacity: .48; }
.download-button svg { width: 1.15rem; }

.export-footnote {
  margin: .7rem 0 0;
  color: #737f8b;
  font-size: .7rem;
  line-height: 1.4;
  text-align: center;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: .82rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: .72rem;
  color: white;
  background: #151d26;
  box-shadow: 0 18px 55px rgb(0 0 0 / 40%);
  font-size: .82rem;
  opacity: 0;
  transform: translateY(.65rem);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }

.save-dialog {
  width: min(31rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  color: var(--text);
  background: linear-gradient(180deg, #171f29, #0d131a);
  box-shadow: 0 30px 90px rgb(0 0 0 / 60%);
}

.save-dialog::backdrop {
  background: rgb(2 5 8 / 72%);
  backdrop-filter: blur(5px);
}

.dialog-close {
  position: absolute;
  top: .65rem;
  right: .65rem;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--muted-strong);
  background: rgb(255 255 255 / 5%);
  font-size: 1.55rem;
  line-height: 1;
}

.dialog-close:hover { color: white; background: rgb(255 255 255 / 10%); }

.dialog-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  margin-bottom: .9rem;
  border-radius: 50%;
  color: #10301c;
  background: var(--green);
  font-size: 1.25rem;
  font-weight: 950;
}

.save-dialog h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -.035em;
}

.dialog-copy {
  margin: .45rem 0 0;
  color: var(--muted-strong);
  font-size: .88rem;
  line-height: 1.5;
}

.prepared-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: .72rem;
  background: rgb(255 255 255 / 3%);
}

.prepared-file strong,
.prepared-file span { display: block; }

.prepared-file strong {
  max-width: 18rem;
  overflow: hidden;
  color: white;
  font-size: .82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prepared-file div > span,
.prepared-file > span {
  color: var(--muted);
  font-size: .72rem;
}

.prepared-file div > span { margin-top: .2rem; }

.save-actions {
  display: grid;
  gap: .65rem;
  margin-top: 1rem;
}

.share-button,
.files-button {
  min-height: 3.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .62rem;
  padding: .75rem 1rem;
  border-radius: .72rem;
  font-weight: 850;
}

.share-button {
  border: 0;
  color: #11151a;
  background: linear-gradient(180deg, var(--yellow-bright), var(--yellow));
}

.files-button {
  border: 1px solid var(--line-strong);
  color: white;
  background: #101720;
}

.share-button:hover,
.files-button:hover { filter: brightness(1.05); }

.share-button svg,
.files-button svg { width: 1.12rem; }

.dialog-note {
  margin: .85rem 0 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.45;
}

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

@keyframes pulse {
  50% { opacity: .45; transform: scale(.8); }
}

@media (max-width: 75rem) {
  .studio {
    grid-template-columns: minmax(0, 1fr) minmax(17rem, 20rem);
    grid-template-areas:
      "preview preview"
      "design export";
  }

  .preview-panel { min-height: min(62vh, 41rem); }
  #preview { width: min(100%, calc((62vh - 6rem) * 4 / 3)); }
  .template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .privacy-note { margin-top: 1rem; }
}

@media (max-width: 45rem) {
  .topbar {
    min-height: 3.7rem;
    position: sticky;
    top: 0;
  }

  .topbar-meta { display: none; }

  .studio {
    min-height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "preview"
      "design"
      "export";
    gap: .7rem;
    padding: .7rem;
  }

  .panel { border-radius: .85rem; box-shadow: 0 16px 44px rgb(0 0 0 / 24%); }

  .preview-panel {
    min-height: auto;
    padding: .65rem;
  }

  .preview-toolbar { padding-bottom: .65rem; }
  .preview-toolbar h2 { font-size: .9rem; }
  .status-pill { padding: .4rem .55rem; font-size: .68rem; }

  .preview-frame { min-height: 0; padding: .42rem; }
  #preview { width: 100%; max-height: none; }

  .preview-prompt {
    bottom: 1rem;
    font-size: .68rem;
  }

  .design-panel,
  .export-panel { padding: .9rem; }

  .template-grid {
    display: flex;
    gap: .62rem;
    margin-right: -.9rem;
    padding-right: .9rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }

  .template-card {
    flex: 0 0 8rem;
    scroll-snap-align: start;
  }

  .template-art span:first-child { font-size: .77rem; }
  .template-art span:nth-child(2) { font-size: 1.15rem; }

  .panel-divider { margin: .95rem 0; }

  .export-panel { padding-bottom: calc(.9rem + env(safe-area-inset-bottom)); }

  .download-button { min-height: 3.25rem; }

  .save-dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 1rem 1rem 0 0;
  }
}

@media (max-width: 26rem) {
  .brand { font-size: 1.5rem; }
  .preview-toolbar { align-items: flex-start; }
  .status-pill { max-width: 8.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
