@font-face {
  font-family: "Geist";
  src: url("fonts/geist-400.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("fonts/geist-600.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --ad-paper: #fdfcf9;
  --ad-ink: #141414;
  --ad-ink-2: #555552;
  --ad-line: rgb(20 20 20 / 0.14);
  --ad-line-soft: rgb(20 20 20 / 0.08);
  --ad-canvas-bg: #f1f0ec;
  --ad-accent: #20c4b7;
  --ad-focus: #5b81fe;
}

html.ad-page,
html.ad-page body {
  margin: 0;
  height: 100%;
  background: var(--ad-canvas-bg);
  color: var(--ad-ink);
  font-family: "Geist", ui-sans-serif, system-ui, sans-serif;
}

body:has(.ad-app) {
  margin: 0;
  overflow: hidden;
}

.ad-app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.45;
}

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

.ad-app button,
.ad-app input,
.ad-app textarea {
  font: inherit;
}

.ad-app button { cursor: pointer; }

.ad-app :focus-visible {
  outline: 2px solid var(--ad-focus);
  outline-offset: 2px;
}

/* ---------- top bar: one hairline, almost no words ---------- */

.ad-topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 18px;
  background: var(--ad-paper);
  border-bottom: 1px solid var(--ad-line-soft);
}

.ad-topbar__brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ad-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.ad-topbar__by {
  font-weight: 400;
  font-size: 12.5px;
  color: var(--ad-ink-2);
}

.ad-topbar__nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ad-topbar__hint {
  font-size: 12px;
  color: var(--ad-ink-2);
}

.ad-textbutton {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ad-ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.ad-textbutton:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- studio layout ---------- */

.ad-studio {
  flex: 1;
  display: flex;
  min-height: 0;
}

.ad-canvasarea {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 28px 28px 54px;
}

.ad-statusline {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 11.5px;
  color: var(--ad-ink-2);
  letter-spacing: -0.01em;
}

/* ---------- the stage ---------- */

.ad-stage-wrap {
  position: relative;
  box-shadow: 0 1px 2px rgb(20 20 20 / 0.08), 0 12px 36px rgb(20 20 20 / 0.10);
}
.ad-stage-wrap[data-active="true"] {
  outline: 2px dashed var(--ad-focus);
  outline-offset: 6px;
}

.ad-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: top left;
  overflow: hidden;
}

.ad-stage-el {
  position: absolute;
  white-space: pre-wrap;
  word-break: break-word;
}
.ad-stage-el[data-editable] { cursor: text; }
.ad-stage-el[data-editable]:hover {
  outline: 1px dashed rgb(20 20 20 / 0.35);
  outline-offset: 4px;
}
.ad-stage-el[data-editable]:focus {
  outline: 1.5px solid var(--ad-focus);
  outline-offset: 4px;
}

.ad-stage-wordmark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ad-stage-image {
  position: absolute;
  object-fit: cover;
}

.ad-editor-note {
  position: absolute;
  font-size: 20px;
  font-weight: 600;
  color: rgb(20 20 20 / 0.55);
  background: rgb(253 252 249 / 0.86);
  border: 1px dashed rgb(20 20 20 / 0.4);
  padding: 10px 14px;
  pointer-events: none;
}

/* ---------- control rail ---------- */

.ad-panel {
  flex: none;
  width: 292px;
  background: var(--ad-paper);
  border-left: 1px solid var(--ad-line-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ad-panel__scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.ad-panel-section {
  padding: 14px 16px 16px;
  border-bottom: 1px solid var(--ad-line-soft);
}

.ad-panel-label {
  margin: 0 0 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ad-ink-2);
}

/* layout thumbnails */
.ad-thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.ad-thumb {
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ad-thumb__frame {
  display: block;
  position: relative;
  aspect-ratio: 1080 / 1350;
  border: 1px solid var(--ad-line);
  overflow: hidden;
  background: var(--ad-paper);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.ad-thumb:hover .ad-thumb__frame { border-color: rgb(20 20 20 / 0.45); }
.ad-thumb[data-active="true"] .ad-thumb__frame {
  border-color: var(--ad-ink);
  box-shadow: 0 0 0 1px var(--ad-ink);
}

.ad-thumb__name {
  font-size: 10px;
  color: var(--ad-ink-2);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ad-thumb[data-active="true"] .ad-thumb__name { color: var(--ad-ink); font-weight: 600; }

.ad-thumb__frame .ad-stage { pointer-events: none; }

/* segmented controls */
.ad-segmented {
  display: flex;
  border: 1px solid var(--ad-line);
  background: var(--ad-paper);
}

.ad-segmented button {
  flex: 1;
  border: 0;
  background: none;
  padding: 7px 4px;
  font-size: 12px;
  color: var(--ad-ink-2);
  min-height: 34px;
  border-left: 1px solid var(--ad-line-soft);
}
.ad-segmented button:first-child { border-left: 0; }
.ad-segmented button[aria-pressed="true"] {
  background: var(--ad-ink);
  color: var(--ad-paper);
  font-weight: 600;
}

/* colour swatches */
.ad-swatches {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 7px;
}

.ad-swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: var(--sw);
  border-radius: 0;
  position: relative;
  cursor: pointer;
}
.ad-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--ad-paper), 0 0 0 4px var(--ad-ink);
}

/* photograph drop */
.ad-drop {
  width: 100%;
  border: 1px dashed rgb(20 20 20 / 0.35);
  background: none;
  padding: 14px 10px;
  font-size: 12.5px;
  color: var(--ad-ink-2);
}
.ad-drop:hover { border-color: var(--ad-ink); color: var(--ad-ink); }

.ad-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* export footer */
.ad-panel__footer {
  flex: none;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--ad-line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ad-export {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: var(--ad-ink);
  color: var(--ad-paper);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.ad-export:hover { background: #000; }

.ad-quiet {
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--ad-ink-2);
  padding: 2px 0;
  align-self: center;
}
.ad-quiet:hover { color: var(--ad-ink); text-decoration: underline; text-underline-offset: 3px; }

/* toast */
.ad-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ad-ink);
  color: var(--ad-paper);
  font-size: 12.5px;
  padding: 9px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 50;
}
.ad-toast[data-show="true"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- mobile: canvas first, rail below ---------- */

@media (max-width: 860px) {
  body:has(.ad-app) { overflow: auto; }
  .ad-app { height: auto; min-height: 100dvh; }
  .ad-topbar__hint { display: none; }
  .ad-studio { flex-direction: column; }
  .ad-canvasarea {
    flex: none;
    height: 62dvh;
    padding: 18px 18px 48px;
  }
  .ad-panel {
    width: auto;
    border-left: 0;
    border-top: 1px solid var(--ad-line-soft);
  }
  .ad-panel__scroll { overflow: visible; }
  .ad-thumbs { grid-template-columns: repeat(4, 1fr); }
  .ad-thumb__name { display: none; }
}
