/* Doble · estudio. One dark theme; every colour and size comes from the tokens below. */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("fonts/figtree-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #15132b;
  --card: #1e1b3a;
  --card-2: #2a2650;
  --line: #38336a;
  --text: #f6f4ff;
  --muted: #a9a3d1;
  --coral: #ff6a4d;
  --coral-soft: rgb(255 106 77 / 0.14);
  --lavender: #c9c2ff;
  --lavender-soft: rgb(201 194 255 / 0.12);
  --success: #7fe0b0;
  --danger: #ff8a8a;

  --font-title: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --gap: 16px;
  --page-width: 1120px;
  --tap: 44px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ink);
  color: var(--text);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 {
  font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem);
}
h2 {
  font-size: 1.35rem;
}
h3 {
  font-size: 1.05rem;
}
p {
  margin: 0;
  text-wrap: pretty;
}
a {
  color: var(--lavender);
}
img,
video {
  display: block;
  max-width: 100%;
}
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  background: var(--lavender);
  color: var(--ink);
  font-weight: 700;
  z-index: 20;
}
.skip-link:focus {
  top: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgb(21 19 43 / 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 40px;
  height: 28px;
}
.mark-coral {
  fill: var(--coral);
}
.mark-lavender {
  fill: var(--lavender);
  fill-opacity: 0.85;
}
.brand-word {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.nav a[aria-current="page"] {
  background: var(--card-2);
  color: var(--text);
}

.test-banner {
  padding: 8px 16px;
  background: var(--lavender-soft);
  border-bottom: 1px solid var(--line);
  color: var(--lavender);
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Page ---------- */

main {
  width: min(100% - 32px, var(--page-width));
  margin: 0 auto;
  padding: 28px 0 calc(64px + env(safe-area-inset-bottom));
}
main:focus {
  outline: none;
}

.loading,
.noscript {
  padding: 48px 0;
  color: var(--muted);
  text-align: center;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 24px;
}
.page-head p {
  margin-top: 6px;
  color: var(--muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.stack {
  display: grid;
  gap: var(--gap);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--gap);
}

.card {
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
}
.card > h2,
.card > h3 {
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
}
.small-text {
  font-size: 0.875rem;
}
.error-text {
  color: var(--danger);
  font-size: 0.9rem;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 48px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-l);
  color: var(--muted);
  text-align: center;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--coral);
  color: var(--ink);
  font: 700 0.95rem/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background-color 160ms ease, opacity 160ms ease;
  touch-action: manipulation;
  user-select: none;
}
.button:active:not(:disabled) {
  transform: scale(0.97);
}
.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.button.secondary {
  background: var(--card-2);
  border-color: var(--line);
  color: var(--text);
}
.button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.button.danger {
  background: transparent;
  border-color: rgb(255 138 138 / 0.4);
  color: var(--danger);
}
.button.small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.875rem;
}
.button.wide {
  width: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .button:hover:not(:disabled) {
    background: #ff8166;
  }
  .button.secondary:hover:not(:disabled),
  .button.ghost:hover:not(:disabled) {
    background: var(--line);
  }
  .button.danger:hover:not(:disabled) {
    background: rgb(255 138 138 / 0.12);
  }
  .nav a:hover {
    color: var(--text);
  }
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ---------- Forms ---------- */

/* align-content keeps fields in one row level when a neighbour has a hint below. */
.field {
  display: grid;
  gap: 6px;
  align-content: start;
}
.field > span,
.field-label {
  font-weight: 600;
  font-size: 0.9rem;
}
.field small {
  color: var(--muted);
  font-size: 0.82rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--ink);
  color: var(--text);
  font: 400 16px/1.4 var(--font-body);
}
textarea {
  resize: vertical;
  min-height: 84px;
}
input::placeholder,
textarea::placeholder {
  color: rgb(169 163 209 / 0.7);
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--lavender);
  outline: none;
  box-shadow: 0 0 0 3px var(--lavender-soft);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: var(--tap);
  font-size: 0.92rem;
  cursor: pointer;
}
.check input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--coral);
  flex: none;
}

.form {
  display: grid;
  gap: 14px;
}
.form-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

/* ---------- Sign-in ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 120px);
}
.auth .card {
  width: min(100%, 420px);
  padding: 32px 28px;
}
.auth .brand {
  margin-bottom: 20px;
}
.auth h1 {
  font-size: 1.8rem;
  margin-bottom: 6px;
}
.auth p.lead {
  margin-bottom: 20px;
  color: var(--muted);
}

/* ---------- Media tiles ---------- */

.tile {
  display: grid;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.tile-cover {
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: linear-gradient(135deg, var(--coral-soft), var(--lavender-soft)), var(--card-2);
  display: grid;
  place-items: center;
  color: var(--muted);
}
.tile-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (hover: hover) and (pointer: fine) {
  a.tile .tile-cover {
    transition: transform 200ms var(--ease-out);
  }
  a.tile:hover .tile-cover {
    transform: translateY(-2px);
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.badge.coral {
  background: var(--coral-soft);
  color: var(--coral);
}
.badge.lavender {
  background: var(--lavender-soft);
  color: var(--lavender);
}
.badge.ok {
  background: rgb(127 224 176 / 0.12);
  color: var(--success);
}
.badge.warn {
  background: rgb(255 138 138 / 0.12);
  color: var(--danger);
}

.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.photo {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--card-2);
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: rgb(21 19 43 / 0.82);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.add-photo {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px dashed var(--line);
  border-radius: var(--radius-s);
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.add-photo input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.add-photo:focus-within {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
}

/* A file picker that looks like a button; the real input stays reachable by keyboard. */
.file-button {
  position: relative;
}
.file-button input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.file-button:focus-within {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
}

/* ---------- Ad editor ---------- */

.editor {
  display: grid;
  gap: 24px;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.88rem;
}
.steps li {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.steps li.done {
  border-color: transparent;
  background: var(--lavender-soft);
  color: var(--lavender);
}

.lines {
  display: grid;
  gap: var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.line {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
}
.line-head {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.line-number {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--coral);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.9rem;
}
.line-head .spacer {
  flex: 1;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}
.icon-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.panel {
  display: grid;
  align-content: start;
  gap: 10px;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.frame {
  position: relative;
  aspect-ratio: 9 / 16;
  max-height: 340px;
  overflow: hidden;
  border-radius: var(--radius-m);
  background: var(--card-2);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}
.frame img,
.frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.frame .placeholder {
  padding: 16px;
}
.frame.is-pending::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgb(201 194 255 / 0.12) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
.frame.is-stale {
  outline: 2px solid var(--coral);
  outline-offset: -2px;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

audio {
  width: 100%;
  height: 40px;
}

.recording {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--coral);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.recording-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--coral);
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.35;
  }
}

.final {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
  gap: 24px;
  align-items: start;
}
.final .frame {
  max-height: 520px;
}

.spend-total {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 800;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th,
.table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.table th {
  color: var(--muted);
  font-weight: 600;
}
.table-wrap {
  overflow-x: auto;
}

.copy-box {
  display: flex;
  gap: 8px;
}
.copy-box input {
  font-size: 0.88rem;
}

/* ---------- Dialogs and toasts ---------- */

dialog {
  width: min(100% - 32px, 520px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--card);
  color: var(--text);
}
dialog::backdrop {
  background: rgb(10 9 22 / 0.7);
}
dialog[open] {
  animation: dialog-in 200ms var(--ease-out);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}
.dialog-body {
  display: grid;
  gap: 16px;
  padding: 24px;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}
.price {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: var(--radius-m);
  background: var(--coral-soft);
}
.price strong {
  font-family: var(--font-title);
  font-size: 1.8rem;
  color: var(--coral);
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(100% - 32px, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--card-2);
  color: var(--text);
  font-weight: 600;
  animation: toast-in 220ms var(--ease-out);
}
.toast.error {
  border-color: rgb(255 138 138 / 0.5);
  color: var(--danger);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- AI helpers ---------- */

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

/* The note and the results are live regions: they stay rendered so screen
   readers announce new content, and only take space once they have some. */
.idea-output:not(:empty) {
  margin-top: var(--gap);
}
.idea-tool {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 16px;
  background: var(--card-2);
  border-radius: var(--radius-m);
}
.idea-tool .button {
  justify-self: start;
}

.idea {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.idea-lines {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.4em;
}
.idea-lines li {
  padding-left: 4px;
}
.idea-lines li > span {
  display: block;
}

.hooks,
.review-issues {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.hook {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  background: var(--card-2);
  border-radius: var(--radius-m);
}
.review-issues li {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.review-issues .badge {
  flex: none;
}

.ai-state {
  display: grid;
  gap: 6px;
}

/* ---------- Narrow screens ---------- */

@media (max-width: 860px) {
  .line {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .line > .panel:first-of-type {
    grid-column: 1 / -1;
  }
  .final {
    grid-template-columns: minmax(0, 1fr);
  }
  .idea-tools {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-wrap: wrap;
  }
  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
  .topbar [data-action="logout"] {
    margin-left: auto;
  }
  .line {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px;
  }
  .card {
    padding: 16px;
  }
  .hook {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
