/* =========================================================================
   Growth Chicken base stylesheet.
   Warm paper, hard ink borders, simple utility-minded components.
   ========================================================================= */

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(21, 21, 21, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 21, 21, 0.035) 1px, transparent 1px),
    var(--color-canvas);
  background-size: 22px 22px;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: var(--fw-regular);
  font-feature-settings: "ss01", "ss02", "cv11";
  line-height: 1.5;
  letter-spacing: 0;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow-x: hidden;
  min-width: 320px;
}

[hidden] {
  display: none !important;
}

body > main {
  flex-grow: 1;
}

/* ---------- Layout containers ---------- */
body > main,
body > header,
body > footer,
body > nav {
  width: min(100% - 2 * var(--gutter), var(--content-width));
  margin: 0 auto;
}

.narrow-shell {
  max-width: var(--narrow-width);
}

.app-shell,
.public-shell,
.auth-shell {
  padding: clamp(2rem, 5vw, 3.5rem) 0 4rem;
}

footer {
  padding-bottom: 2rem;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5rem;
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: 1.25;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 1.2rem;
  font-weight: var(--fw-semibold);
}

h3 {
  font-size: 0.98rem;
  font-weight: var(--fw-semibold);
}

p {
  margin: 0 0 1rem;
  word-break: break-word;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--color-primary);
  cursor: pointer;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a.is-link {
  text-decoration: underline;
}

hr {
  border: 0;
  border-top: 2px solid var(--color-border);
  margin: 1.5rem 0;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  text-transform: uppercase;
}

.meta-line {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0;
}

.token-amount {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  color: inherit;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.token-icon {
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  color: var(--color-success);
}

.phosphor-icon {
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
}

.token-amount.is-metric {
  gap: 0.42rem;
}

.token-amount.is-metric .token-icon {
  width: 0.78em;
  height: 0.78em;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.55rem;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-weight: var(--fw-medium);
}

.page-breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.page-breadcrumb a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.page-breadcrumb span:last-child {
  color: var(--color-text);
}

.measure-wide {
  max-width: 60ch;
}

.hint,
.form-note {
  color: var(--color-text-subtle);
  font-size: 0.86rem;
  display: inline-block;
}

/* ---------- Navigation ---------- */
#main-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  max-width: none;
  margin: 0;
  background: rgba(255, 243, 216, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 2px solid var(--color-border);
  box-shadow: 0 3px 0 rgba(21, 21, 21, 0.08);
}

#main-nav section {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: min(100% - 2 * var(--gutter), var(--content-width));
  height: 60px;
  margin: 0 auto;
}

#main-nav .fg1 {
  flex: 1;
}

#main-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 0.65rem;
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: var(--fw-regular);
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

#main-nav a.selected {
  font-weight: var(--fw-semibold);
}

#main-nav a:hover {
  background: var(--color-surface);
  border-color: var(--color-border);
  text-decoration: none;
}

#main-nav a.selected {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

.brand-link,
.brand-link:hover {
  background: transparent !important;
  border-color: transparent !important;
  padding-left: 0 !important;
  gap: 0.55rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  overflow: visible;
}

.brand-mark-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-name {
  color: var(--color-text);
  font-weight: var(--fw-medium);
  font-size: 0.95rem;
  letter-spacing: -0.005em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-primary {
  background: var(--color-text) !important;
  border-color: var(--color-text) !important;
  color: #ffffff !important;
  box-shadow: 2px 2px 0 var(--color-primary);
}

.nav-primary:hover {
  background: #000 !important;
  border-color: #000 !important;
}

.token-count {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 0.7rem !important;
  background: var(--color-surface) !important;
  border: 2px solid var(--color-border) !important;
  border-radius: var(--radius-pill) !important;
  color: var(--color-success) !important;
  font-size: 0.82rem;
  font-weight: var(--fw-semibold);
  box-shadow: 2px 2px 0 var(--color-border);
}

.token-count .token-icon,
.button .token-icon,
.split-button .token-icon {
  color: currentColor;
}

.profile-link {
  padding: 0 0.2rem !important;
}

.profile-icon {
  display: inline-block;
  width: 28px;
  height: 28px;
  background-color: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  border-radius: 100%;
  object-fit: cover;
}

.profile-icon.is-large {
  width: 56px;
  height: 56px;
  box-shadow: 3px 3px 0 var(--color-border);
}

.profile-icon-demo {
  background-image: linear-gradient(120deg, var(--color-blue), var(--color-pink));
}

/* ---------- Flashes ---------- */
.flash-shell {
  position: fixed;
  top: calc(60px + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: grid;
  gap: 0.5rem;
  width: min(100% - 2 * var(--gutter), var(--content-width));
  pointer-events: none;
}

.flash-message {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.8rem 1rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-weight: var(--fw-regular);
  box-shadow: var(--shadow-sm);
  transition: opacity 200ms ease, transform 200ms ease;
}

.flash-message.is-dismissing {
  opacity: 0;
  transform: translateY(-8px);
}

.flash-close {
  flex: 0 0 auto;
  margin-left: auto;
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 120ms ease, background-color 120ms ease;
}

.flash-close:hover {
  opacity: 1;
  background: rgba(21, 21, 21, 0.08);
  box-shadow: none;
  transform: none;
}

.flash-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.flash-alert {
  background: var(--color-danger-soft);
  border-color: var(--color-border);
}

.flash-alert .flash-dot {
  background: var(--color-danger);
}

.flash-notice {
  background: var(--color-success-soft);
  border-color: var(--color-border);
}

.flash-notice .flash-dot {
  background: var(--color-success);
}

/* ---------- Page headers ---------- */
.control-header,
.profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.control-header h1,
.profile-header h1 {
  margin: 0 0 0.5rem;
}

.control-header > div p:last-child,
.profile-header > div p:last-child {
  margin-bottom: 0;
}

.header-actions,
.row-actions,
.form-actions,
.job-choice-actions,
.purchase-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* Keep the Generate button reachable from anywhere in a tall form by pinning
   the actions row to the bottom of the viewport as the form scrolls. */
.form-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 1rem 0;
  background:
    linear-gradient(rgba(21, 21, 21, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 21, 21, 0.035) 1px, transparent 1px),
    var(--color-canvas);
  background-size: 22px 22px;
  background-attachment: fixed;
  border-top: 2px solid var(--color-border);
}

/* The panels above cast a hard offset shadow (var(--shadow-sm)) 3px to their
   right. As they scroll beneath this sticky bar, that shadow pokes past the
   bar's right edge into the gutter and shows through. Extend the bar's
   background a few px to the right to keep it masked. */
.form-actions-sticky::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 100%;
  width: 4px;
  background: var(--color-canvas);
  pointer-events: none;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem 0.7rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.5rem 0 0.8rem;
}

.section-heading:first-child {
  margin-top: 0;
}

.section-heading h2 {
  margin: 0;
}

.section-heading p {
  margin: 0.25rem 0 0;
}

/* ---------- Cards / surfaces ---------- */
.metric-panel,
.empty-state,
.quiet-panel,
.resource-row,
.job-choice-panel,
.form-panel,
.estimate-panel,
.preview-panel,
.job-side-panel,
.auth-panel,
.public-band article,
.profile-header,
.table-card,
.unlock-panel {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.form-panel,
.auth-panel,
.preview-panel,
.job-side-panel,
.quiet-panel,
.table-card {
  padding: 1.25rem;
}

.form-panel h1,
.form-panel h2 {
  margin-bottom: 1rem;
}

.panel-heading,
.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

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

.panel-heading h2,
.field-heading label {
  margin-bottom: 0;
}

.field-heading {
  margin-bottom: 0.35rem;
}

.profile-header {
  align-items: center;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.profile-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  flex: 1 1 auto;
}

.profile-title > div {
  min-width: 0;
}

.profile-title h1 {
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.profile-title h1,
.profile-title p {
  margin: 0;
}

.profile-title .meta-line {
  overflow-wrap: anywhere;
}

/* ---------- Metric grid ---------- */
.metric-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.75rem;
}

.profile-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.profile-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.profile-links .button {
  width: 100%;
}

.metric-panel {
  padding: 1.1rem 1.15rem;
}

a.metric-panel-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: filter 120ms ease;
}

a.metric-panel-link:hover {
  filter: brightness(0.95);
}

.metric-panel:nth-child(4n + 1) {
  background: var(--color-surface);
}

.metric-panel:nth-child(4n + 2) {
  background: #e5f4ff;
}

.metric-panel:nth-child(4n + 3) {
  background: #fff0a8;
}

.metric-panel:nth-child(4n + 4) {
  background: #ffe0cf;
}

.metric-label {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric-value {
  margin: 0.6rem 0 0.35rem;
  color: var(--color-text);
  font-size: 2.2rem;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.small-value {
  font-size: 1.6rem;
}

.metric-note {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.86rem;
}

/* ---------- Resource list ---------- */
.resource-list {
  display: grid;
  gap: 0.7rem;
}

.resource-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
}

.resource-row.is-large {
  align-items: flex-start;
  padding: 1.2rem 1.25rem;
}

.resource-row h2,
.resource-row h3 {
  margin: 0 0 0.2rem;
  color: var(--color-text);
}

.resource-row h2 { font-size: 1.05rem; font-weight: var(--fw-semibold); }
.resource-row h3 { font-size: 0.95rem; font-weight: var(--fw-medium); }

.resource-row p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ---------- Stacked list (API keys, etc.) ---------- */
.stacked-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.25rem;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.list-row strong {
  display: block;
  color: var(--color-text);
  font-weight: var(--fw-semibold);
}

.list-row .meta-line {
  margin-top: 0.2rem;
  font-size: 0.85rem;
}

.token-reveal {
  display: block;
  padding: 0.85rem 1rem;
  background: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  word-break: break-all;
  overflow-x: auto;
}

.list-empty {
  margin: 1.25rem 0 0;
  padding: 1.1rem 1.15rem;
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border: 2px dashed var(--color-border-muted);
  border-radius: var(--radius-md);
  text-align: center;
}

.resource-card-link {
  color: var(--color-text);
  text-decoration: none;
  transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.resource-card-link:hover {
  background: #ffffff;
  box-shadow: var(--shadow-md);
  transform: translate(-1px, -1px);
  text-decoration: none;
}

.resource-card-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.resource-card-cue {
  flex: 0 0 auto;
  color: var(--color-text-subtle);
  font-size: 0.82rem;
  font-weight: var(--fw-medium);
}

.quiet-panel {
  color: var(--color-text-muted);
}

/* ---------- Dashboard ---------- */
.dashboard-header {
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.dashboard-grid {
  display: grid;
  align-items: start;
  gap: 1.35rem;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
}

.dashboard-project-rail {
  position: sticky;
  top: 88px;
}

.dashboard-project-rail .section-heading,
.dashboard-ads .section-heading {
  margin-top: 0;
}

.dashboard-project-link {
  align-items: center;
  padding: 0.8rem 0.85rem;
}

.dashboard-project-link .project-avatar {
  width: 42px;
  height: 42px;
}

.dashboard-project-link h3 {
  overflow-wrap: anywhere;
}

.dashboard-project-link .project-signals {
  margin-top: 0.35rem;
}

.dashboard-ad-gallery {
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.dashboard-ad-fallback {
  background:
    linear-gradient(135deg, rgba(249, 111, 53, 0.18), rgba(45, 120, 207, 0.16)),
    var(--color-surface-muted);
}

.dashboard-ad-fallback .phosphor-icon {
  width: 2rem;
  height: 2rem;
  color: var(--color-text-subtle);
}

.dashboard-empty-ads {
  justify-content: space-between;
  gap: 1rem;
}

.dashboard-empty-ads h2,
.dashboard-empty-ads p {
  margin: 0;
}

.dashboard-empty-ads p {
  margin-top: 0.25rem;
  color: var(--color-text-muted);
}

.composition-waiting-panel {
  display: grid;
  place-items: center;
  gap: 0.85rem;
  min-height: min(70vh, 520px);
  text-align: center;
}

.loading-spinner {
  width: 1.9rem;
  height: 1.9rem;
  border: 3px solid var(--color-border-muted);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: button-spin 760ms linear infinite;
}

.egg-pan-loader {
  width: 220px;
  height: 160px;
  display: block;
  overflow: visible;
}

.egg-pan-loader.is-card {
  width: 78%;
  max-width: 200px;
  height: auto;
}

.egg-pan-loader__pan-group {
  transform-origin: 80px 80px;
  animation: egg-pan-swirl 2s linear infinite;
  animation-delay: var(--egg-pan-phase, 0ms);
  will-change: transform;
}

.egg-pan-loader__egg {
  transform-box: fill-box;
  transform-origin: center;
  animation: egg-swirl 2s linear infinite;
  animation-delay: var(--egg-pan-phase, 0ms);
  will-change: transform;
}

.egg-pan-loader__white {
  animation: egg-white-morph 3s linear infinite;
  animation-delay: var(--egg-pan-phase, 0ms);
}

.egg-pan-loader__yolk {
  transform-box: fill-box;
  transform-origin: center;
  animation: egg-yolk-jiggle 2s ease-in-out infinite;
  animation-delay: var(--egg-pan-phase, 0ms);
}

@keyframes egg-pan-swirl {
  0%    { transform: translate(0, 0) rotate(0deg); }
  12%   { transform: translate(-2px, 6px) rotate(-2.5deg); }
  22%   { transform: translate(3px, 9px) rotate(-3deg); }
  34%   { transform: translate(7px, 2px) rotate(-1deg); }
  46%   { transform: translate(6px, -5px) rotate(2.5deg); }
  58%   { transform: translate(-1px, -8px) rotate(4deg); }
  70%   { transform: translate(-6px, -3px) rotate(2.5deg); }
  82%   { transform: translate(-5px, 4px) rotate(-1deg); }
  92%   { transform: translate(-1px, 6px) rotate(-2.5deg); }
  100%  { transform: translate(0, 0) rotate(0deg); }
}

@keyframes egg-swirl {
  0%    { transform: translate(0, 0) rotate(0deg); }
  12%   { transform: translate(8px, -12px) rotate(8deg); }
  22%   { transform: translate(-6px, -16px) rotate(-5deg); }
  34%   { transform: translate(-14px, -6px) rotate(-10deg); }
  46%   { transform: translate(-12px, 10px) rotate(-6deg); }
  58%   { transform: translate(4px, 16px) rotate(8deg); }
  70%   { transform: translate(14px, 8px) rotate(10deg); }
  82%   { transform: translate(12px, -8px) rotate(5deg); }
  92%   { transform: translate(2px, -14px) rotate(-2deg); }
  100%  { transform: translate(0, 0) rotate(0deg); }
}

@keyframes egg-white-morph {
  0%   { d: path("M102 80 C102 89 92 97 80 97 C68 97 58 89 58 80 C58 71 68 63 80 63 C92 63 102 71 102 80 Z"); }
  20%  { d: path("M106 78 C106 88 94 95 80 94 C66 93 54 86 54 78 C54 70 66 63 80 64 C94 65 106 70 106 78 Z"); }
  40%  { d: path("M104 76 C104 88 92 96 78 94 C66 92 56 84 58 74 C60 64 70 60 84 62 C96 64 104 66 104 76 Z"); }
  60%  { d: path("M98 80 C98 92 90 100 80 100 C70 100 62 92 62 80 C62 68 70 60 80 60 C90 60 98 68 98 80 Z"); }
  80%  { d: path("M102 80 C100 92 88 96 76 94 C64 92 58 80 60 70 C62 60 74 56 86 60 C96 64 104 68 102 80 Z"); }
  100% { d: path("M102 80 C102 89 92 97 80 97 C68 97 58 89 58 80 C58 71 68 63 80 63 C92 63 102 71 102 80 Z"); }
}

@keyframes egg-yolk-jiggle {
  0%, 100% { transform: scale(1, 1); }
  20%      { transform: scale(1.03, 0.97); }
  40%      { transform: scale(0.98, 1.02); }
  60%      { transform: scale(1.02, 0.98); }
  80%      { transform: scale(0.98, 1.02); }
}

@media (prefers-reduced-motion: reduce) {
  .egg-pan-loader__pan-group,
  .egg-pan-loader__egg,
  .egg-pan-loader__white,
  .egg-pan-loader__yolk {
    animation: none;
  }
}

/* ---------- Loading bar ---------- */
.loading-bar {
  display: grid;
  gap: 0.55rem;
  width: 100%;
}

.loading-bar[hidden] {
  display: none;
}

.loading-bar__track {
  position: relative;
  height: 0.85rem;
  width: 100%;
  background: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.loading-bar__fill {
  height: 100%;
  width: 0;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
}

.loading-bar.is-running .loading-bar__fill {
  /* First a quick ease-out fill, then an ultra-slow creep that takes over and
     keeps inching toward the line - it decelerates but never visibly stops. */
  animation:
    loading-bar-fill var(--loading-bar-duration, 7s) cubic-bezier(0.16, 0.84, 0.44, 1) forwards,
    loading-bar-creep 600s linear var(--loading-bar-duration, 7s) forwards;
}

.loading-bar.is-looping .loading-bar__fill {
  animation: loading-bar-fill var(--loading-bar-duration, 7s) cubic-bezier(0.16, 0.84, 0.44, 1) infinite;
}

.loading-bar__label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

@keyframes loading-bar-fill {
  0%   { width: 0; }
  55%  { width: 64%; }
  100% { width: 88%; }
}

/* Front-loaded so motion is brisk just after the handoff and then crawls,
   asymptotically approaching the finish without ever quite reaching it. */
@keyframes loading-bar-creep {
  0%   { width: 88%; }
  20%  { width: 94%; }
  45%  { width: 97%; }
  100% { width: 99.5%; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-bar.is-running .loading-bar__fill,
  .loading-bar.is-looping .loading-bar__fill {
    animation: none;
    width: 94%;
  }
}

/* ---------- Onboarding (first project) ---------- */
.onboarding-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  max-width: 36rem;
  margin: clamp(3rem, 10vh, 6rem) auto 0;
  padding: 2.5rem 2rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.onboarding-icon {
  display: inline-flex;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--color-text);
}

.onboarding-card h1 {
  margin: 0;
}

.onboarding-card p {
  margin: 0 0 0.5rem;
  max-width: 30rem;
  color: var(--color-text-muted);
}

/* ---------- Empty / choice / estimate ---------- */
.empty-state,
.job-choice-panel,
.estimate-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.empty-state h2,
.job-choice-panel h2 {
  margin: 0 0 0.35rem;
}

.empty-state p,
.job-choice-panel p {
  margin: 0;
  color: var(--color-text-muted);
}

.estimate-panel {
  align-items: stretch;
}

.estimate-panel > div {
  flex: 1;
}

/* ---------- Two-column layouts ---------- */
.two-column,
.job-output-grid,
.public-band {
  display: grid;
  gap: 1.25rem;
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.job-output-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
}

.public-band {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ---------- Buttons ---------- */
.button,
button,
input[type=submit] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-height: 36px;
  padding: 0.48rem 0.95rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: var(--fw-semibold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease, transform 120ms ease;
}

/* The explicit display above would otherwise defeat the `hidden` attribute. */
.button[hidden],
button[hidden],
input[type=submit][hidden] {
  display: none;
}

.button:hover,
button:hover,
input[type=submit]:hover {
  background: #ffffff;
  text-decoration: none;
}

/* Press effect lives on :active, not :hover. A hover transform shifts the
   button out from under a stationary cursor and thrashes hover on/off at the
   edges; :active only fires while the pointer is held down, so it can't loop. */
.button:active,
button:active,
input[type=submit]:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--color-border);
}

.button:focus-visible,
button:focus-visible,
input[type=submit]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.button[disabled],
button[disabled],
input[type=submit][disabled],
.button.disabled,
button.disabled,
.button.is-disabled {
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.68;
}

.button.is-loading,
button.is-loading,
input[type=submit].is-loading {
  position: relative;
}

.is-locked,
.is-locked:focus {
  cursor: wait;
  opacity: 0.6;
  background-color: var(--color-surface-muted);
}

.button.is-loading::before,
button.is-loading::before {
  content: "";
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: button-spin 700ms linear infinite;
}

input[type=submit].is-loading {
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0.75rem center;
  background-repeat: no-repeat;
  background-size: 0.8em 0.8em;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

.button.is-primary,
button.is-primary,
input[type=submit].is-primary {
  background: var(--color-primary);
  border-color: var(--color-border);
  color: var(--color-text);
}

.button.is-primary:hover,
button.is-primary:hover,
input[type=submit].is-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-border);
}

.button.is-primary[disabled],
button.is-primary[disabled],
input[type=submit].is-primary[disabled],
.button.is-primary.is-disabled {
  background: #4f8fd8;
  border-color: var(--color-border);
  color: var(--color-text);
}

@keyframes button-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 168, 70, 0.55);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 10px rgba(255, 168, 70, 0);
  }
}

.button.is-pulsing,
button.is-pulsing,
input[type=submit].is-pulsing {
  animation: button-pulse 1.8s ease-in-out infinite;
  transform-origin: center;
}

@media (prefers-reduced-motion: reduce) {
  .button.is-pulsing,
  button.is-pulsing,
  input[type=submit].is-pulsing {
    animation: none;
  }
}

.button.is-ghost,
button.is-ghost {
  border-color: transparent;
  box-shadow: none;
}

.button.is-danger,
button.is-danger {
  background: var(--color-danger);
  border-color: var(--color-border);
  color: #ffffff;
}

.button.is-link,
button.is-link {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--color-primary);
  font-weight: var(--fw-semibold);
}

.button.is-link:hover,
button.is-link:hover {
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
}

.button.is-small,
button.is-small {
  min-height: 30px;
  padding: 0.28rem 0.7rem;
  font-size: 0.8rem;
}

.button.is-tiny,
button.is-tiny {
  min-height: 24px;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
}

.button .phosphor-icon,
button .phosphor-icon {
  width: 1em;
  height: 1em;
}

.button-group {
  display: inline-flex;
}

.button-group .button {
  border-radius: 0;
  box-shadow: none;
}

.button-group .button:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.button-group .button:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.button-group .button:not(:last-child) {
  border-right: 0;
}

.variant-button-group {
  margin-top: 0.35rem;
}

.variant-button {
  min-width: 42px;
  position: relative;
}

.variant-button input {
  position: absolute;
  inline-size: 1px !important;
  block-size: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.variant-button:has(input:checked) {
  background: var(--color-primary);
  border-color: var(--color-border);
  color: var(--color-text);
}

.variant-button:has(input:focus-visible) {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.split-button {
  gap: 0;
  min-height: 42px;
  padding: 0;
  overflow: hidden;
}

.split-button > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.55rem 1rem;
}

/* The leading icon is a bare <svg>, not a <span>, so it misses the padding
   above. Give it the segment's left padding and tighten the gap to the label. */
.split-button > .phosphor-icon:first-child {
  padding-left: 1rem;
}

.split-button > .phosphor-icon:first-child + span {
  padding-left: 0.42rem;
}

.split-button .button-cost {
  border-left: 2px solid var(--color-border);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
}

.split-button.is-loading {
  gap: 0.42rem;
  padding: 0.55rem 1rem;
}

.split-button.is-loading > span {
  min-height: 0;
  padding: 0;
}

/* ---------- Forms ---------- */
.field {
  margin-bottom: 1rem;
}

.field:last-child {
  margin-bottom: 0;
}

.payment-element-shell {
  display: block;
  width: 100%;
  padding: 0.9rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.stacked-form,
.compact-form {
  display: grid;
  gap: 1rem;
}

label,
legend,
.label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: var(--fw-medium);
}

textarea,
select,
input[type=email],
input[type=password],
input[type=number],
input[type=text],
input[type=url],
input[type=tel],
input[type=date],
input[type=datetime-local],
input[type=time],
input[type=file] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 38px;
  padding: 0.45rem 0.7rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 2px 2px 0 rgba(21, 21, 21, 0.14);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.4;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea {
  line-height: 1.5;
  min-height: 8rem;
  padding: 0.65rem 0.7rem;
}

select,
input[type=file] {
  padding: 0.4rem 0.6rem;
}

textarea:focus,
select:focus,
input[type=email]:focus,
input[type=password]:focus,
input[type=number]:focus,
input[type=text]:focus,
input[type=url]:focus,
input[type=tel]:focus {
  border-color: var(--color-primary);
  box-shadow: 3px 3px 0 var(--color-border), 0 0 0 3px rgba(249, 111, 53, 0.2);
}

.field_with_errors input,
.field_with_errors textarea,
input.is-invalid,
textarea.is-invalid {
  border-color: var(--color-danger);
}

.field_with_errors label {
  color: var(--color-danger);
}

input[type=checkbox],
input[type=radio] {
  width: 16px !important;
  height: 16px;
  min-width: 16px !important;
  margin-right: 0.5rem;
  accent-color: var(--color-primary);
}

input[type=file]::-webkit-file-upload-button,
input[type=file]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.3rem 0.7rem;
  background: var(--color-primary);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: var(--fw-medium);
  cursor: pointer;
}

input[type=file]::-webkit-file-upload-button:hover,
input[type=file]::file-selector-button:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* ---------- Option grid (checkbox cards) ---------- */
.option-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.8rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.92rem;
  cursor: pointer;
}

.check-option:has(input:checked) {
  background: var(--color-yellow);
  border-color: var(--color-border);
}

.check-option span {
  font-weight: var(--fw-regular);
}

.check-option-inline {
  display: inline-flex;
  margin-bottom: 1rem;
}

.check-option-inline.is-compact {
  gap: 0.4rem;
  padding: 0.45rem 0.55rem;
  margin-bottom: 0;
  font-size: 0.8rem;
}

.surprise-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  cursor: pointer;
}

.surprise-toggle input {
  position: absolute;
  inline-size: 1px !important;
  block-size: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.surprise-toggle span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.3rem 0.65rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  font-size: 0.82rem;
  font-weight: var(--fw-medium);
  line-height: 1.1;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.surprise-toggle.is-small span {
  min-height: 26px;
  padding: 0.22rem 0.55rem;
  font-size: 0.76rem;
}

.surprise-toggle input:checked + span {
  background: var(--color-primary);
  border-color: var(--color-border);
  color: var(--color-text);
}

.surprise-toggle input:focus-visible + span {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.surprise-field .field-body {
  max-height: 14rem;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 180ms ease, opacity 140ms ease, transform 180ms ease, margin-top 180ms ease;
}

.surprise-field.is-surprised .field-body {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  transform: translateY(-4px);
}

.surprise-note {
  display: none;
  margin: 0.4rem 0 0;
  color: var(--color-text-subtle);
  font-size: 0.84rem;
}

.surprise-field.is-surprised .surprise-note {
  display: block;
  animation: surprise-note-in 160ms ease both;
}

@keyframes surprise-note-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.output-toggle {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0.75rem;
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.75rem 0.85rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.toggle-option:has(input:checked) {
  background: var(--color-primary-soft);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

/* ---------- Project workspace ---------- */
/* Ads are the hero of the project page; Assets and Audiences sit beneath as
   secondary sections. A shared rhythm keeps the stack evenly spaced and a
   hairline rule separates the hero from everything below it. */
.workspace-section + .workspace-section {
  margin-top: clamp(1.75rem, 3.5vw, 2.5rem);
  padding-top: clamp(1.75rem, 3.5vw, 2.5rem);
  border-top: 1px solid var(--color-border);
}

.composition-board {
  scroll-margin-top: 84px;
}

.composition-gallery {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.composition-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.composition-card-link {
  display: grid;
  grid-template-rows: auto 1fr;
  color: var(--color-text);
  text-decoration: none;
}

.composition-card-link:hover {
  text-decoration: none;
}

.composition-card-link:hover .composition-card-media {
  box-shadow: var(--shadow-md);
}

.composition-card-link:focus-visible {
  border-radius: var(--radius-md);
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

.composition-card-media {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 9 / 16;
  min-height: 0;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.composition-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Static, scaled preview of an editable composition inside a render card. */
.composition-preview {
  container-type: inline-size;
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #151515;
}

.composition-card-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 1rem;
  color: var(--color-text-subtle);
  font-size: 0.86rem;
  font-weight: var(--fw-medium);
}

.composition-card-placeholder.is-cooking {
  padding: 0.5rem;
}

.composition-card-placeholder.is-cracked {
  background: var(--color-surface-muted);
}

.cracked-egg-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--color-danger, #c0392b);
}

.cracked-egg-placeholder__icon {
  width: clamp(3rem, 42%, 5rem);
  height: auto;
}

.composition-card-status {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 1;
}

.composition-card-body {
  padding-top: 0.65rem;
}

.composition-card-body h3 {
  margin: 0 0 0.25rem;
  font-size: 0.96rem;
  font-weight: var(--fw-medium);
}

.composition-card-body p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.composition-card-body .composition-card-meta {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: var(--color-text-subtle, var(--color-text-muted));
}

.composition-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: var(--color-surface);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.section-note {
  color: var(--color-text-muted);
}

.ad-show-layout {
  display: grid;
  grid-template-columns: minmax(220px, 420px) minmax(260px, 1fr);
  align-items: start;
  gap: 1.5rem;
}

.ad-show-preview {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 9 / 16;
  min-height: 0;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ad-show-list {
  display: grid;
  gap: 0.8rem;
  margin: 0;
}

.ad-show-list div {
  display: grid;
  gap: 0.25rem;
}

.ad-show-list dt {
  color: var(--color-text-subtle);
  font-size: 0.76rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
}

.ad-show-list dd {
  margin: 0;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.ad-show-output-style {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--color-surface-subtle, rgba(0, 0, 0, 0.05));
  color: var(--color-text-subtle);
  font-size: 0.72rem;
  font-weight: var(--fw-medium);
  vertical-align: middle;
}

.ad-show-secondary-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.editor-details .ad-show-secondary-actions,
.editor-details .ad-feedback-actions {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.ad-feedback-actions {
  align-items: center;
  gap: 0.25rem;
}

.ad-feedback-trigger,
button.ad-feedback-trigger {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  min-height: 0;
  padding: 0;
  color: var(--color-text-subtle);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.ad-feedback-trigger:hover,
button.ad-feedback-trigger:hover {
  color: var(--color-text);
  background: var(--color-surface-muted);
  box-shadow: none;
  text-decoration: none;
  transform: none;
}

.ad-feedback-trigger .phosphor-icon {
  width: 1.08rem;
  height: 1.08rem;
}

.ad-feedback-trigger.is-selected,
button.ad-feedback-trigger.is-selected {
  color: var(--color-text);
  background: var(--color-surface-muted);
}

.ad-feedback-trigger.is-dimmed,
button.ad-feedback-trigger.is-dimmed {
  opacity: 0.42;
}

.ad-feedback-trigger.is-dimmed:hover,
button.ad-feedback-trigger.is-dimmed:hover {
  opacity: 0.78;
}

.ad-delete-form {
  margin: 0;
}

.ad-delete-button,
button.ad-delete-button {
  padding-left: 0;
  padding-right: 0;
  color: var(--color-text-subtle);
}

.ad-delete-button:hover,
button.ad-delete-button:hover {
  color: var(--color-danger);
}

.editor-details {
  width: 100%;
  max-width: none;
  margin: 0 0 2.5rem;
}

.ad-feedback-modal {
  padding: 1.25rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.ad-feedback-form {
  display: grid;
  gap: 1rem;
}

/* Focused, single-column composition editor: a slim toolbar over a centered
   canvas. Copy and geometry are edited directly on the ad, so there is no side
   panel of redundant inputs. */
.creative-editor {
  max-width: 1100px;
}

/* Flat, low-chrome button variant for secondary editor actions (Back,
   Download) so the orange Save reads as the one primary action. */
.button.is-ghost {
  background: transparent;
  box-shadow: none;
}

.button.is-ghost:hover {
  background: var(--color-surface);
  transform: none;
  box-shadow: none;
}

/* Top bar: Back · ad name (grows) · Download · Save. */
.editor-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.editor-back {
  flex: 0 0 auto;
}

.editor-name-form {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  margin: 0;
}

/* The name reads as a heading and only shows its field chrome on hover/focus. */
.editor-name-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  font-size: 1.15rem;
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.editor-name-input:hover {
  border-color: var(--color-border-muted);
}

.editor-name-input:focus,
.editor-name-input:focus-visible {
  background: var(--color-surface);
  border-color: var(--color-border);
  outline: none;
}

.editor-save {
  flex: 0 0 auto;
}

/* Native disclosure used as a lightweight Download menu (no JS needed). */
.editor-download {
  position: relative;
  flex: 0 0 auto;
}

.editor-download > summary {
  list-style: none;
  cursor: pointer;
}

.editor-download > summary::-webkit-details-marker {
  display: none;
}

.editor-download-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: 0.3rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.editor-download-menu form {
  margin: 0;
}

.editor-download-item {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  gap: 0.5rem;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: var(--radius-sm);
  font-weight: var(--fw-medium);
}

.editor-download-item:hover {
  background: var(--color-surface-muted);
  transform: none;
  box-shadow: none;
}

/* Export button busy state: swap the icon for a small spinner; the label
   becomes a live "Rendering… N%" while the in-browser encode runs. */
.editor-download-item--export[disabled] {
  opacity: 1;
  cursor: progress;
}

.editor-download-item__spinner {
  display: none;
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  border: 2px solid var(--color-border-muted);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: button-spin 760ms linear infinite;
}

.editor-download-item.is-busy .editor-download-item__icon {
  display: none;
}

.editor-download-item.is-busy .editor-download-item__spinner {
  display: inline-block;
}

/* Centered segmented size switcher above the canvas. */
.editor-sizebar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem;
  margin-bottom: 1.1rem;
  padding: 0.3rem;
  background: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
}

.editor-size-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 32px;
  padding: 0.3rem 0.8rem;
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  box-shadow: none;
  font-size: 0.82rem;
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

.editor-size-button:hover {
  color: var(--color-text);
  background: var(--color-surface);
  transform: none;
  box-shadow: none;
}

.editor-size-button.is-active {
  color: #ffffff;
  background: var(--color-text);
  box-shadow: none;
}

.editor-size-button svg {
  width: 1.05rem;
  height: 1.05rem;
}

.editor-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 1.25rem;
  align-items: start;
}

.editor-preview-column {
  min-width: 0;
}

.creative-editor-stage {
  display: flex;
  justify-content: center;
  padding-bottom: 1rem;
}

.editor-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.35rem auto 1rem;
  color: var(--color-text-subtle);
  font-size: 0.76rem;
  line-height: 1.25;
}

.editor-hint svg {
  width: 0.85rem;
  height: 0.85rem;
}

.editor-hint strong {
  color: var(--color-text-muted);
  font-weight: var(--fw-semibold);
}

/* Collapsible recap of the brief that produced the ad. */
.editor-inputs {
  max-width: 540px;
  margin: 0 auto 2.5rem;
}

.editor-inputs > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  list-style: none;
  color: var(--color-text-subtle);
  font-size: 0.84rem;
  font-weight: var(--fw-semibold);
}

.editor-inputs > summary::-webkit-details-marker {
  display: none;
}

.editor-inputs > summary svg {
  width: 1rem;
  height: 1rem;
}

.editor-inputs[open] > summary {
  margin-bottom: 0.75rem;
}

.editor-inputs-grid {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0.9rem 1.1rem;
  background: var(--color-surface-muted);
  border-radius: 12px;
}

.editor-inputs-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.75rem;
  align-items: start;
}

.editor-inputs-row dt {
  margin: 0;
  color: var(--color-text-subtle);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.editor-inputs-row dd {
  margin: 0;
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1.4;
}

.editor-inputs-row.is-prompt dd {
  font-weight: var(--fw-semibold);
}

/* Floating type-size control pinned above the selected text element. */
.editor-export-status {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  max-width: min(90vw, 28rem);
  padding: 0.5rem 1rem;
  color: #ffffff;
  background: var(--color-text);
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  font-size: 0.85rem;
  font-weight: var(--fw-bold);
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
}

/* No text = no toast, so it never occupies space or reflows the header. */
.editor-export-status:empty {
  display: none;
}

.font-toolbar {
  position: fixed;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.25rem;
  background: var(--color-text);
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.font-toolbar[hidden] {
  display: none;
}

.font-toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  min-width: 30px;
  padding: 0.1rem 0.45rem;
  color: #ffffff;
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  box-shadow: none;
  font-size: 0.82rem;
  font-weight: var(--fw-bold);
  line-height: 1;
  cursor: pointer;
}

.font-toolbar-button.is-grow {
  font-size: 1.05rem;
}

.font-toolbar-button:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: none;
  box-shadow: none;
}

.font-toolbar-button .font-toolbar-minus,
.font-toolbar-button .font-toolbar-plus {
  margin-left: 0.05rem;
  font-size: 0.7em;
}

.font-toolbar-value {
  min-width: 2.1rem;
  padding: 0 0.15rem;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.8rem;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

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

.asset-library-panel {
  padding-top: 0;
}

.asset-library-panel .section-heading {
  align-items: flex-start;
  margin-bottom: 0.45rem;
}

/* Only reveal the header actions (Generate + Upload) once the asset list is
   expanded. When no assets exist there is no disclosure, so they stay visible. */
.asset-library-panel:has(.asset-disclosure:not([open])) .asset-actions {
  display: none;
}

.asset-actions {
  gap: 0.5rem;
}

.section-note {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
}

.asset-disclosure summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
  padding: 0.4rem 0.85rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  font-size: 0.84rem;
  font-weight: var(--fw-semibold);
  list-style: none;
}

.asset-disclosure summary::-webkit-details-marker {
  display: none;
}

.asset-disclosure[open] summary {
  margin-bottom: 0.85rem;
}

.asset-disclosure-caret {
  transition: transform 120ms ease;
}

.asset-disclosure[open] .asset-disclosure-caret {
  transform: rotate(180deg);
}

.asset-list {
  display: grid;
  gap: 0.55rem;
}

.asset-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 2px 2px 0 rgba(21, 21, 21, 0.12);
}

.asset-row:first-child {
  border-top: 2px solid var(--color-border);
}

/* Audience rows have no thumbnail, so drop the leading media column. */
.asset-row.is-audience {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.asset-thumb {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  background: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

/* Checkerboard behind image previews so transparent assets are obvious. */
.asset-thumb:has(img) {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, rgba(21, 21, 21, 0.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(21, 21, 21, 0.12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(21, 21, 21, 0.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(21, 21, 21, 0.12) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.asset-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.asset-thumb-icon {
  width: 1.35rem;
  height: 1.35rem;
  color: var(--color-text-subtle);
}

.asset-row-body {
  min-width: 0;
}

.asset-row h3,
.asset-row p {
  margin: 0;
}

.asset-row h3 {
  font-size: 0.92rem;
  font-weight: var(--fw-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-row p {
  color: var(--color-text-muted);
  font-size: 0.84rem;
}

.asset-row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.asset-download {
  padding: 0.4rem 0.55rem;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--color-text-muted);
}

.asset-download:hover {
  background: var(--color-surface-muted);
  box-shadow: none;
  transform: none;
  color: var(--color-text);
}

/* Generating / failed placeholder rows sit above the disclosure so an
   in-flight or errored generation is always visible (matching how composition
   cards surface their status). */
.asset-generating-list {
  margin-bottom: 0.85rem;
}

.asset-row--pending,
.asset-row--failed {
  border-style: dashed;
}

.asset-row--failed {
  border-color: var(--color-danger, #c0392b);
}

.asset-thumb--status {
  background: var(--color-surface-muted);
}

.egg-pan-loader.is-asset {
  width: 100%;
  max-width: 56px;
  height: auto;
}

.asset-dismiss {
  margin: 0;
}

.asset-upload-modal,
.asset-generate-modal,
.audience-modal {
  padding: 1.25rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* The audience modal is a compact form, so it doesn't need the wide media
   layout the asset modals use. */
.audience-modal {
  width: 540px;
}

.audience-modal-form .field + .field {
  margin-top: 0.85rem;
}

.audience-modal-form .form-actions {
  margin-top: 1.25rem;
}

/* Inline audience picker on the new-ad form: select sits next to its
   "Add Audience" trigger. */
.field-with-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-with-action select {
  flex: 1 1 auto;
  min-width: 0;
}

.field-with-action .button {
  flex: 0 0 auto;
}

.form-error {
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--color-danger-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.88rem;
}

.asset-generate-note {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 1rem;
  color: var(--color-text-muted);
  font-size: 0.84rem;
}

.asset-generate-note svg {
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-header h2 {
  margin: 0;
}

.modal-close,
button.modal-close {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  min-height: 0;
  padding: 0;
  color: var(--color-text-subtle);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.modal-close:hover,
button.modal-close:hover {
  color: var(--color-text);
  background: var(--color-surface-muted);
  box-shadow: none;
  transform: none;
}

.modal-close .phosphor-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.asset-dropzone {
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 2rem;
  background: var(--color-surface-muted);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.asset-dropzone.is-dragging {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(249, 111, 53, 0.18);
}

.asset-dropzone.is-compact {
  min-height: 180px;
  padding: 1.35rem;
}

.asset-dropzone.is-compact .asset-dropzone-title {
  font-size: 1.1rem;
}

.asset-dropzone-title {
  color: var(--color-text);
  font-size: 1.6rem;
  font-weight: var(--fw-semibold);
}

.asset-dropzone-copy {
  max-width: 30rem;
  color: var(--color-text-muted);
}

.asset-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.asset-upload-selected {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.asset-upload-selected ul {
  display: grid;
  gap: 0.55rem;
  padding: 0;
  margin: 0;
  list-style: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.asset-upload-selected li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.asset-selection-thumb {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.asset-selection-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.asset-selection-icon {
  display: grid;
  place-items: center;
  max-width: 2.4rem;
  color: var(--color-text-subtle);
  font-size: 0.62rem;
  font-weight: var(--fw-semibold);
  line-height: 1;
}

.asset-selection-body {
  min-width: 0;
}

.asset-selection-name {
  display: block;
  overflow: hidden;
  color: var(--color-text);
  font-weight: var(--fw-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-selection-meta {
  display: block;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.asset-upload-progress {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.asset-upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.asset-upload-meter {
  height: 8px;
  overflow: hidden;
  background: var(--color-surface-muted);
  border-radius: var(--radius-pill);
}

.asset-upload-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--color-primary);
  transition: width 140ms ease;
}

.asset-upload-progress p {
  margin: 0.6rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.86rem;
}

.asset-upload-form .form-actions {
  margin-top: 1rem;
}

.danger-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-top: 2rem;
  border-color: var(--color-border);
  background: var(--color-danger-soft);
}

.danger-panel h2,
.danger-panel p {
  margin: 0;
}

.danger-panel p {
  margin-top: 0.35rem;
  color: var(--color-text-muted);
}

/* ---------- Tags / pills ---------- */
.tag {
  display: inline-block;
  padding: 0.22rem 0.5rem;
  background: #ffffff;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag.is-success {
  background: var(--color-success-soft);
  color: var(--color-text);
}

.tag.is-danger {
  background: var(--color-danger-soft);
  color: var(--color-text);
}

.tag.is-live {
  background: var(--color-primary-soft);
  color: var(--color-text);
}

.tag.is-neutral {
  background: var(--color-surface);
  color: var(--color-text);
}

/* ---------- Project avatar ---------- */
.project-avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background-color: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  overflow: hidden;
}

.project-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.project-avatar.is-empty {
  background-color: var(--color-surface-muted);
}

.resource-row-body {
  flex: 1 1 auto;
  min-width: 0;
}

.field-with-preview {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.field-with-preview input {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---------- Project signal rows ---------- */
.project-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.signal {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.6rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: var(--fw-regular);
}

.signal.is-complete {
  background: var(--color-success-soft);
  border-color: var(--color-border);
  color: var(--color-text);
}

/* ---------- Job artifact / preview ---------- */
.preview-panel {
  min-height: 480px;
}

.artifact-preview-frame,
.artifact-image,
.artifact-video {
  display: block;
  width: auto;
  max-width: min(100%, 380px);
  height: auto;
  max-height: min(70vh, 700px);
  margin: 0 auto;
  background: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  object-fit: contain;
  overflow: hidden;
}

.artifact-preview-frame,
.artifact-video {
  aspect-ratio: 9 / 16;
  width: min(100%, 380px);
}

.qa-json {
  max-height: 260px;
  padding: 1rem;
  background: var(--color-ink);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: #f6f8fa;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  overflow: auto;
}

.job-side-panel {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.unlock-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--color-surface-muted);
}

.revision-panel {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--color-surface-muted);
}

.revision-form {
  display: grid;
  gap: 0.65rem;
}

.revision-form textarea {
  min-height: 7rem;
}

/* ---------- Tables ---------- */
.table-card {
  padding: 0;
  overflow-x: auto;
}

table {
  width: 100%;
  background: var(--color-surface);
  border-collapse: separate;
  border-spacing: 0;
}

table th,
table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 2px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

table th {
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0;
  text-transform: uppercase;
}

table tr:last-child td {
  border-bottom: 0;
}

/* ---------- Pricing ---------- */
.price-tag {
  color: var(--color-text);
  font-size: 1.15rem;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.price-tag.is-large {
  font-size: 1.7rem;
}

.price-period {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: var(--fw-medium);
}

.price-period.is-large {
  font-size: 0.95rem;
}

.purchase-summary {
  justify-content: space-between;
  margin: 1.25rem 0 0.5rem;
}

.bonus-badge {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--color-success-soft);
  color: var(--color-success);
  font-size: 0.8rem;
  font-weight: var(--fw-semibold);
}

/* Token packs: a touch more vertical breathing room so the title, subtext
   and price don't read as cramped inside the card. */
.product-list .resource-row.is-large {
  padding-top: 1.45rem;
  padding-bottom: 1.45rem;
}

.product-list .resource-row.is-large > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.product-list .resource-row.is-large h2 {
  margin-bottom: 0;
}

/* Token packs spill a little cluster of coins out past the top-right corner of
   each card. The cluster grows by tier (data-tier 0/1/2) so the bigger packs
   visibly carry more coins. overflow stays visible so the coins break the box. */
.product-list .resource-row.is-large {
  position: relative;
  overflow: visible;
}

/* Anchor at the right edge, vertically centred. The price + Buy button are inset
   from the border by the row padding, so the coins hug the edge and spill OUT
   into the gutter — their inner edge stays within the empty padding strip and
   never crosses over the controls. */
.pack-coins {
  position: absolute;
  top: 50%;
  right: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.pack-coin {
  position: absolute;
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  border: 2px solid var(--color-ink);
  border-radius: var(--radius-pill);
  background:
    radial-gradient(circle at 34% 30%, var(--color-yellow) 0%, var(--color-orange) 78%);
  box-shadow: var(--shadow-sm);
  color: var(--color-ink);
  transform: rotate(var(--rot, 0deg));
}

.pack-coin .phosphor-icon {
  width: 1.5rem;
  height: 1.5rem;
  opacity: 0.92;
}

/* A small cluster tucked against the right edge, leaning out into the gutter.
   Inner edges sit ~0.9rem inside the border at most — within the empty padding,
   clear of the price and button. More coins per tier = a fuller cluster.
   --rot is the resting tilt; the hover hop animation spins on from it. */
.pack-coin:nth-child(1) { --rot: 7deg;   right: -1.7rem; top: 0.1rem; }
.pack-coin:nth-child(2) { --rot: -6deg;  right: -1.8rem; top: -2.2rem; }
.pack-coin:nth-child(3) { --rot: 4deg;   right: -3.3rem; top: -0.9rem; }
.pack-coin:nth-child(4) { --rot: -11deg; right: -3.2rem; top: -3.1rem; }

@media (max-width: 560px) {
  .pack-coins { transform: scale(0.8); transform-origin: center right; }
}

/* ---------- The whole pack is the buy button ---------- */
.product-card {
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  transition: transform 170ms ease, box-shadow 170ms ease, background-color 170ms ease;
}

.product-card:hover,
.product-card:focus-visible {
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  transform: translate(-3px, -4px);
  text-decoration: none;
}

.product-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

.product-card:active {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-md);
}

/* On hover the Buy chip pops up big with a springy overshoot, so it's obvious
   the whole card is the buy action you're about to trigger. */
.buy-cta {
  transform-origin: center;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 140ms ease, box-shadow 200ms ease;
}

.product-card:hover .buy-cta,
.product-card:focus-visible .buy-cta {
  transform: scale(1.2);
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
}

/* The pack "opens up" to present the Buy chip: the price eases aside and the
   coins spread out into the gutter, clearing room for the bigger button. */
.price-tag {
  transition: transform 200ms ease, opacity 200ms ease;
}

.product-card:hover .price-tag,
.product-card:focus-visible .price-tag {
  transform: translateX(-0.25rem);
  opacity: 0.8;
}

.pack-coins {
  transition: transform 220ms ease;
}

.product-card:hover .pack-coins,
.product-card:focus-visible .pack-coins {
  transform: translateX(0.7rem);
}

/* Coins toss up and flip, one after another, like the pack just got paid out. */
@keyframes coin-hop {
  0%   { transform: translateY(0) rotate(var(--rot)); }
  35%  { transform: translateY(-1.1rem) rotate(calc(var(--rot) + 190deg)); }
  70%  { transform: translateY(0) rotate(calc(var(--rot) + 360deg)); }
  100% { transform: translateY(0) rotate(calc(var(--rot) + 360deg)); }
}

.product-card:hover .pack-coin,
.product-card:focus-visible .pack-coin {
  animation: coin-hop 650ms ease;
}

.product-card:hover .pack-coin:nth-child(2),
.product-card:focus-visible .pack-coin:nth-child(2) { animation-delay: 70ms; }
.product-card:hover .pack-coin:nth-child(3),
.product-card:focus-visible .pack-coin:nth-child(3) { animation-delay: 140ms; }
.product-card:hover .pack-coin:nth-child(4),
.product-card:focus-visible .pack-coin:nth-child(4) { animation-delay: 210ms; }

@media (prefers-reduced-motion: reduce) {
  .product-card,
  .buy-cta {
    transition: background-color 120ms ease;
  }
  .product-card:hover,
  .product-card:focus-visible {
    transform: none;
  }
  .product-card:hover .buy-cta,
  .product-card:focus-visible .buy-cta {
    transform: none;
  }
  .product-card:hover .price-tag,
  .product-card:focus-visible .price-tag {
    transform: none;
  }
  .product-card:hover .pack-coins,
  .product-card:focus-visible .pack-coins {
    transform: none;
  }
  .product-card:hover .pack-coin,
  .product-card:focus-visible .pack-coin {
    animation: none;
  }
}

.text-success {
  color: var(--color-green);
}

/* ---------- Auth ---------- */
.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 60px);
}

.auth-panel {
  width: min(100%, 460px);
  padding: 1.75rem;
}

.auth-panel h1 {
  font-size: 1.6rem;
  font-weight: var(--fw-semibold);
  margin-bottom: 0.4rem;
}

.auth-panel p {
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

/* ---------- Public landing ---------- */
.public-hero {
  display: grid;
  align-items: center;
  gap: clamp(2rem, 6vw, 4rem);
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 360px);
  padding: 2rem 0 3rem;
}

.hero-copy h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: var(--fw-bold);
  letter-spacing: 0;
  line-height: 1.08;
  margin-bottom: 1rem;
  max-width: 18ch;
}

.hero-copy p {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1.5;
  max-width: 50ch;
  margin-bottom: 1.5rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.hero-actions .button {
  min-height: 38px;
  padding-left: 1.1rem;
  padding-right: 1.1rem;
  font-size: 0.92rem;
}

.hero-proof {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.5rem;
}

.hero-proof span {
  padding: 0.3rem 0.6rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-size: 0.8rem;
  font-weight: var(--fw-semibold);
}

.hero-preview {
  display: flex;
  justify-content: center;
}

.phone-frame {
  width: 100%;
  max-width: 300px;
  background: var(--color-ink);
  border: 9px solid var(--color-ink);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.ad-preview-bg {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  aspect-ratio: 9 / 16;
  padding: 1.1rem;
  background-color: var(--color-yellow);
  background-image:
    radial-gradient(circle at 68% 46%, rgba(255, 255, 255, 0.9) 0 13%, rgba(255, 255, 255, 0) 13.5%),
    radial-gradient(circle at 58% 48%, rgba(249, 111, 53, 0.95) 0 15%, rgba(249, 111, 53, 0) 15.5%),
    linear-gradient(180deg, rgba(45, 120, 207, 0.08) 0 54%, rgba(21, 21, 21, 0.7) 100%);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.ad-pill,
.ad-cta {
  align-self: flex-start;
  padding: 0.4rem 0.7rem;
  background: #ffffff;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-size: 0.74rem;
  font-weight: var(--fw-medium);
}

.ad-copy {
  display: grid;
  gap: 0.4rem;
  color: #ffffff;
}

.ad-copy strong {
  font-size: 1.8rem;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: 1.05;
  letter-spacing: 0;
}

.ad-copy span {
  padding: 0.45rem 0.55rem;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-weight: var(--fw-regular);
  font-size: 0.86rem;
}

.ad-cta {
  align-self: stretch;
  border-radius: var(--radius-sm);
  text-align: center;
}

.public-story {
  margin-top: 1rem;
}

.public-band article {
  padding: 1.25rem;
}

.public-band h2 {
  margin: 0.25rem 0 0.4rem;
  font-size: 1.05rem;
  font-weight: var(--fw-semibold);
}

.public-band p {
  margin: 0;
  color: var(--color-text-muted);
}

/* ---------- Landing v2 ---------- */
body.static.landing_v2 {
  --v2-ink: var(--color-ink);
  --v2-paper: var(--color-paper);
  --v2-paper-deep: var(--color-paper-deep);
  --v2-orange: var(--color-orange);
  --v2-red: var(--color-red);
  --v2-yellow: var(--color-yellow);
  --v2-green: var(--color-green);
  --v2-blue: var(--color-blue);
  --v2-pink: var(--color-pink);
  --v2-border: var(--color-border);
}

body.static.landing_v2 #main-nav {
  background: rgba(255, 243, 216, 0.92);
}

body.static.landing_v2 #main-nav a {
  border-radius: 7px;
  color: var(--v2-ink);
}

body.static.landing_v2 #main-nav a:hover,
body.static.landing_v2 #main-nav a.selected {
  background: #ffffff;
  border-color: var(--v2-border);
}

body.static.landing_v2 .nav-primary {
  background: var(--v2-ink) !important;
  border-color: var(--v2-ink) !important;
  color: #ffffff !important;
  box-shadow: 2px 2px 0 var(--v2-orange);
}

.landing-v2-shell {
  width: 100%;
  max-width: none;
  padding: 0 0 4rem;
}

.landing-v2-shell .button {
  border: 2px solid var(--v2-border);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--v2-border);
  font-weight: var(--fw-semibold);
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.landing-v2-shell .button:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--v2-border);
}

.landing-v2-hero {
  position: relative;
  min-height: clamp(620px, calc(100vh - 60px), 760px);
  overflow: hidden;
  padding: clamp(3rem, 7vw, 6rem) var(--gutter) clamp(5rem, 10vw, 7rem);
  background:
    radial-gradient(circle at 88% 20%, rgba(255, 207, 70, 0.9) 0 8rem, transparent 8.1rem),
    linear-gradient(135deg, #fff8e8 0%, #fff3d8 52%, #ffd6bf 100%);
  border-bottom: 3px solid var(--v2-border);
}

.landing-v2-hero::before {
  content: none;
}

.landing-v2-hero-copy {
  position: relative;
  z-index: 1;
  width: min(100%, var(--content-width));
  margin: 0 auto;
}

.landing-v2-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin: 0 0 1rem;
  padding: 0.24rem 0.7rem;
  background: var(--v2-yellow);
  border: 2px solid var(--v2-border);
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--v2-border);
  color: var(--v2-ink);
  font-size: 0.82rem;
  font-weight: var(--fw-semibold);
}

.landing-v2-hero h1 {
  max-width: 9ch;
  margin: 0;
  color: var(--v2-ink);
  font-size: clamp(4rem, 13vw, 9.5rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0;
}

.landing-v2-lede {
  max-width: 54ch;
  margin: 1.25rem 0 1.6rem;
  color: #3d3327;
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  line-height: 1.42;
}

.landing-v2-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.landing-v2-primary-action {
  background: var(--v2-orange) !important;
  border-color: var(--v2-border) !important;
  color: var(--v2-ink) !important;
}

.landing-v2-secondary-action {
  background: #ffffff !important;
  color: var(--v2-ink) !important;
}

.landing-v2-hero-mascot {
  position: absolute;
  right: max(var(--gutter), calc((100vw - var(--content-width)) / 2));
  bottom: clamp(1rem, 4vw, 3rem);
  z-index: 0;
  width: min(40vw, 460px);
  max-height: 76%;
  object-fit: contain;
  object-position: bottom right;
  filter: drop-shadow(5px 6px 0 rgba(21, 21, 21, 0.2));
}

.landing-v2-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  width: min(100% - 2 * var(--gutter), var(--content-width));
  margin: -4.5rem auto 0;
  position: relative;
  z-index: 2;
  border: 3px solid var(--v2-border);
  background: #ffffff;
  box-shadow: 6px 6px 0 var(--v2-border);
}

.landing-v2-flow article {
  min-height: 230px;
  padding: 1.25rem;
  border-right: 2px solid var(--v2-border);
}

.landing-v2-flow article:nth-child(1) {
  background: #ffffff;
}

.landing-v2-flow article:nth-child(2) {
  background: #e5f4ff;
}

.landing-v2-flow article:nth-child(3) {
  background: #fff0a8;
  border-right: 0;
}

.landing-v2-flow article > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 1rem;
  background: var(--v2-pink);
  border: 2px solid var(--v2-border);
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--v2-border);
}

.landing-v2-step {
  margin: 0 0 0.35rem;
  color: #6d5f4e;
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
}

.landing-v2-flow h2 {
  margin-bottom: 0.5rem;
  color: var(--v2-ink);
  font-size: 1.35rem;
  letter-spacing: 0;
}

.landing-v2-flow p:last-child {
  color: #4c4034;
  font-size: 0.98rem;
}

.landing-v2-product {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(320px, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  width: min(100% - 2 * var(--gutter), var(--content-width));
  margin: clamp(3.5rem, 7vw, 5.5rem) auto 0;
}

.landing-v2-product h2 {
  max-width: 13ch;
  color: var(--v2-ink);
  font-size: clamp(2.2rem, 5vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.landing-v2-product p:not(.landing-v2-kicker) {
  max-width: 48ch;
  color: #4c4034;
  font-size: 1.05rem;
}

.landing-v2-product-visual {
  position: relative;
  padding-bottom: clamp(3rem, 7vw, 4.5rem);
}

.landing-v2-reel-preview {
  overflow: hidden;
  background: #fffaf0;
  border: 3px solid var(--v2-border);
  border-radius: 10px;
  box-shadow: 7px 7px 0 var(--v2-border);
}

.landing-v2-section-mascot {
  position: absolute;
  right: clamp(-1.5rem, -2vw, -0.75rem);
  bottom: -0.4rem;
  z-index: 2;
  width: min(34vw, 260px);
  filter: drop-shadow(4px 5px 0 rgba(21, 21, 21, 0.18));
  pointer-events: none;
}

.landing-v2-preview-bar {
  display: flex;
  gap: 0.45rem;
  padding: 0.85rem;
  background: var(--v2-green);
  border-bottom: 3px solid var(--v2-border);
}

.landing-v2-preview-bar span {
  width: 12px;
  height: 12px;
  background: #fffaf0;
  border: 2px solid var(--v2-border);
  border-radius: 50%;
}

.landing-v2-reel-window {
  overflow: hidden;
  padding: 1.2rem 0;
  background:
    linear-gradient(rgba(21, 21, 21, 0.05) 1px, transparent 1px),
    #f7e4ff;
  background-size: 18px 18px;
}

.landing-v2-reel-track {
  display: flex;
  gap: 1rem;
  width: max-content;
  animation: landing-v2-reel 24s linear infinite;
}

.landing-v2-ad-card {
  flex: 0 0 170px;
  padding: 0.7rem;
  background: #ffffff;
  border: 2px solid var(--v2-border);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--v2-border);
}

.landing-v2-ad-card p {
  margin: 0.65rem 0 0;
  color: var(--v2-ink);
  font-size: 0.86rem;
  font-weight: var(--fw-semibold);
}

.landing-v2-ad-image {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border: 2px solid var(--v2-border);
  border-radius: 6px;
}

.landing-v2-ad-image::before,
.landing-v2-ad-image::after {
  content: "";
  position: absolute;
  border: 2px solid var(--v2-border);
}

.landing-v2-ad-image::before {
  inset: 0.85rem 0.85rem auto;
  height: 52px;
  background: rgba(255, 255, 255, 0.82);
}

.landing-v2-ad-image::after {
  right: 1rem;
  bottom: 1rem;
  width: 54px;
  height: 54px;
  background: #ffffff;
  border-radius: 50%;
}

.landing-v2-ad-image-a {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.72) 0 22%, transparent 22%),
    var(--v2-orange);
}

.landing-v2-ad-image-b {
  min-height: 170px;
  background:
    linear-gradient(45deg, transparent 0 46%, rgba(255, 255, 255, 0.7) 46% 58%, transparent 58%),
    var(--v2-blue);
}

.landing-v2-ad-image-c {
  background:
    radial-gradient(circle at 30% 72%, rgba(255, 255, 255, 0.75) 0 2rem, transparent 2.05rem),
    var(--v2-green);
}

.landing-v2-ad-image-d {
  min-height: 120px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.74) 0 36%, transparent 36%),
    var(--v2-yellow);
}

.landing-v2-formats {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(320px, 1.28fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: start;
  width: min(100% - 2 * var(--gutter), var(--content-width));
  margin: clamp(3.5rem, 7vw, 5.5rem) auto 0;
  padding-top: clamp(1rem, 3vw, 2rem);
}

.landing-v2-formats h2 {
  max-width: 11ch;
  color: var(--v2-ink);
  font-size: clamp(2.2rem, 5vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.landing-v2-formats p:not(.landing-v2-kicker) {
  max-width: 50ch;
  color: #4c4034;
  font-size: 1.05rem;
}

.landing-v2-format-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.landing-v2-format-grid article {
  min-height: 230px;
  padding: 1rem;
  background: #ffffff;
  border: 3px solid var(--v2-border);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--v2-border);
}

.landing-v2-format-grid article:nth-child(2) {
  background: #e5f4ff;
}

.landing-v2-format-grid article:nth-child(3) {
  background: #fff0a8;
}

.landing-v2-format-grid span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 1rem;
  background: var(--v2-pink);
  border: 2px solid var(--v2-border);
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--v2-border);
}

.landing-v2-format-grid h3 {
  margin-bottom: 0.55rem;
  color: var(--v2-ink);
  font-size: 1.1rem;
  letter-spacing: 0;
}

.landing-v2-format-grid p {
  color: #4c4034;
  font-size: 0.96rem;
}

.landing-v2-footer {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  min-height: 150px;
  width: min(100% - 2 * var(--gutter), var(--content-width));
  margin: clamp(3.5rem, 7vw, 5.5rem) auto 0;
  padding: 1.25rem 1.25rem 1.25rem clamp(9rem, 18vw, 13rem);
  background: #151515;
  border: 3px solid var(--v2-border);
  border-radius: 10px;
  box-shadow: 6px 6px 0 var(--v2-orange);
  color: #ffffff;
}

.landing-v2-footer-copy {
  display: grid;
  gap: 0.35rem;
}

.landing-v2-footer-copy p {
  max-width: 34ch;
  margin: 0;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: var(--fw-semibold);
}

.landing-v2-footer-copy small {
  color: rgba(255, 255, 255, 0.72);
}

.landing-v2-footer-mascot {
  position: absolute;
  left: 1rem;
  bottom: -0.15rem;
  width: clamp(115px, 16vw, 180px);
  max-height: 190px;
  object-fit: contain;
  object-position: bottom left;
  filter: drop-shadow(4px 5px 0 rgba(249, 111, 53, 0.3));
}

/* ---------- Landing 2: agent-first API section ---------- */
.landing-2-api {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, 0.78fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  width: min(100% - 2 * var(--gutter), var(--content-width));
  margin: clamp(3.5rem, 7vw, 5.5rem) auto 0;
}

.landing-2-api h2 {
  max-width: 12ch;
  color: var(--v2-ink);
  font-size: clamp(2.2rem, 5vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.landing-2-api p:not(.landing-v2-kicker) {
  max-width: 48ch;
  color: #4c4034;
  font-size: 1.05rem;
}

.landing-2-code {
  overflow: hidden;
  background: #151515;
  border: 3px solid var(--v2-border);
  border-radius: 10px;
  box-shadow: 7px 7px 0 var(--v2-border);
}

.landing-2-code-body {
  margin: 0;
  padding: 1.4rem 1.5rem;
  overflow-x: auto;
  color: #f4ede0;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre;
}

.landing-2-code-req { color: #ffcf46; font-weight: var(--fw-bold); }
.landing-2-code-key { color: #7cc4ff; }
.landing-2-code-str { color: #ffd6bf; }
.landing-2-code-bool { color: var(--v2-orange); }
.landing-2-code-tok { color: #9a8c78; }
.landing-2-code-ok { color: #8be58b; font-weight: var(--fw-semibold); }

.landing-2-agent {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  width: min(100% - 2 * var(--gutter), var(--content-width));
  margin: clamp(3.5rem, 7vw, 5.5rem) auto 0;
}

.landing-2-agent h2 {
  max-width: 16ch;
  color: var(--v2-ink);
  font-size: clamp(2.2rem, 5vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.landing-2-agent p:not(.landing-v2-kicker) {
  max-width: 56ch;
  color: #4c4034;
  font-size: 1.05rem;
}

.landing-2-agent .code-block {
  width: 100%;
}

/* Keep hero copy clear of the mascot so the lede stays readable. */
.landing-2 .landing-v2-lede {
  max-width: 34ch;
}

.landing-2 .landing-v2-actions {
  max-width: 34ch;
}

/* Let format cards size to their content instead of leaving a tall empty box. */
.landing-2 .landing-v2-format-grid article {
  min-height: 0;
}

/* Inline the card icon beside its heading instead of floating above the copy. */
.landing-2-card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
}

.landing-2-card-head > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  margin: 0;
  background: var(--v2-pink);
  border: 2px solid var(--v2-border);
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--v2-border);
}

.landing-2-card-head h2,
.landing-2-card-head h3 {
  margin: 0;
}

@keyframes landing-v2-reel {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(calc(-50% - 0.5rem));
  }
}

/* ---------- Style guide ---------- */
.style-guide-shell {
  display: grid;
  gap: 1.25rem;
}

.style-guide-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--color-yellow);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.style-guide-band h2,
.style-guide-band p {
  margin: 0;
}

.style-guide-band p {
  max-width: 58ch;
  color: var(--color-text-muted);
}

.style-guide-swatches {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.style-guide-swatch {
  display: grid;
  align-content: end;
  min-height: 118px;
  padding: 0.8rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
}

.style-guide-swatch span {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
}

.style-guide-swatch code {
  color: inherit;
  font-size: 0.78rem;
}

.style-guide-swatch.is-paper { background: var(--color-paper); }
.style-guide-swatch.is-ink { background: var(--color-ink); color: #ffffff; }
.style-guide-swatch.is-orange { background: var(--color-orange); }
.style-guide-swatch.is-yellow { background: var(--color-yellow); }
.style-guide-swatch.is-green { background: var(--color-green); color: #ffffff; }
.style-guide-swatch.is-blue { background: var(--color-blue); color: #ffffff; }
.style-guide-swatch.is-pink { background: var(--color-pink); }
.style-guide-swatch.is-red { background: var(--color-red); color: #ffffff; }

.style-guide-modal-preview {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: rgba(21, 21, 21, 0.08);
  border: 2px dashed var(--color-border-muted);
  border-radius: var(--radius-md);
}

.style-guide-modal-example {
  position: static;
  width: min(100%, 520px);
  max-width: none;
  max-height: none;
  overflow: visible;
  transform: none;
}

.style-guide-button-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* ---------- Misc ---------- */
.highlight {
  background-color: var(--color-highlight);
}

summary {
  cursor: pointer;
}

details summary::marker,
details[open] > summary::marker {
  content: normal;
}

.pagination {
  font-family: var(--font-sans);
  font-size: 1rem;
}

.pagination a,
.pagination em {
  padding: 0 0.25rem;
}

.pagination em.current {
  font-style: normal;
  opacity: 0.55;
  pointer-events: none;
}

.pagination .disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(21, 21, 21, 0.45);
  cursor: pointer;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 9000;
  width: 800px;
  max-width: 90vw;
  max-height: calc(90vh - 64px);
  overflow: auto;
  transform: translate(-50%, -50%);
}

/* ---------- Legacy compat ---------- */
.box {
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.box:empty { display: none; }

.box.is-danger,
.box.is-red {
  background: var(--color-danger-soft);
  border-color: var(--color-border);
  color: var(--color-text);
}

.box.is-blue,
.box.notice {
  background: var(--color-primary-soft);
}

.flashes {
  animation: flashes 5s forwards;
}

@keyframes flashes {
  0%   { transform: translateX(0);    opacity: 1; }
  1%   { transform: translateX(-6px); opacity: 1; }
  2%   { transform: translateX(6px);  opacity: 1; }
  3%   { transform: translateX(-6px); opacity: 1; }
  4%   { transform: translateX(0);    opacity: 1; }
  85%  { transform: translateX(0);    opacity: 1; }
  100% { transform: translateX(0);    opacity: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .public-hero {
    grid-template-columns: 1fr;
    padding-top: 1rem;
  }

  .hero-preview {
    order: -1;
  }

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

  .editor-details {
    max-width: 540px;
    margin-right: auto;
    margin-left: auto;
  }
}

@media (max-width: 760px) {
  :root {
    --gutter: 1rem;
  }

  #main-nav section {
    gap: 0.2rem;
    overflow-x: auto;
  }

  #main-nav a {
    flex-grow: 0;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  .brand-name,
  .nav-links {
    display: none;
  }

  .control-header,
  .profile-header,
  .empty-state,
  .job-choice-panel,
  .estimate-panel,
  .danger-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .metric-grid,
  .profile-metrics,
  .profile-links,
  .two-column,
  .ad-show-layout,
  .dashboard-grid,
  .job-output-grid,
  .dom-editor-grid,
  .public-band,
  .option-grid,
  .output-toggle {
    grid-template-columns: 1fr;
  }

  .header-actions,
  .row-actions,
  .form-actions,
  .job-choice-actions,
  .hero-actions,
  .purchase-summary {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions .button,
  .row-actions .button,
  .form-actions .button,
  .job-choice-actions .button,
  .hero-actions .button,
  .purchase-summary .button {
    width: 100%;
  }

  .list-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
  }

  .dashboard-project-rail {
    position: static;
  }

  .dashboard-ad-gallery {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  }

  .list-row form,
  .list-row .button {
    width: 100%;
    justify-content: center;
  }

  .asset-library-panel .section-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .asset-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .asset-thumb {
    width: 56px;
    height: 56px;
  }

  .asset-row .tag {
    grid-column: 2;
    justify-self: start;
  }

  .asset-dropzone {
    min-height: 240px;
    padding: 1.4rem;
  }

  .asset-dropzone-title {
    font-size: 1.3rem;
  }

  .hero-copy h1 {
    font-size: clamp(2rem, 9vw, 2.6rem);
  }

  .landing-v2-hero {
    min-height: auto;
    padding: 2.5rem var(--gutter) 18rem;
  }

  .landing-v2-hero h1 {
    font-size: clamp(3.4rem, 18vw, 5.4rem);
  }

  .landing-v2-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .landing-v2-actions .button {
    width: 100%;
  }

  .landing-v2-hero-mascot {
    right: var(--gutter);
    bottom: 0.75rem;
    width: min(78vw, 320px);
    max-height: 290px;
  }

  .landing-v2-flow,
  .landing-v2-product,
  .landing-2-api,
  .landing-v2-formats,
  .landing-v2-format-grid {
    grid-template-columns: 1fr;
  }

  .landing-2-api-visual {
    order: 2;
  }

  .landing-v2-flow {
    margin-top: -2rem;
  }

  .landing-v2-flow article {
    min-height: 0;
    border-right: 0;
    border-bottom: 2px solid var(--v2-border);
  }

  .landing-v2-flow article:nth-child(3) {
    border-bottom: 0;
  }

  .landing-v2-product h2 {
    max-width: 14ch;
  }

  .landing-v2-format-grid article {
    min-height: 0;
  }

  .landing-v2-product-visual {
    padding-bottom: 7.5rem;
  }

  .landing-v2-section-mascot {
    right: 0.5rem;
    width: min(58vw, 220px);
  }

  .landing-v2-footer {
    align-items: stretch;
    min-height: 0;
    padding: 1.25rem;
  }

  .landing-v2-footer .button {
    width: 100%;
  }

  .landing-v2-footer-mascot {
    position: static;
    width: min(54vw, 170px);
    max-height: none;
    margin: -0.5rem auto 0;
  }

  .style-guide-band {
    flex-direction: column;
    align-items: stretch;
  }

  .style-guide-swatches {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .landing-v2-reel-track {
    animation: none;
  }
}


/* =========================================================================
   API docs (/docs/api)
   ========================================================================= */
.api-docs {
  --api-nav-offset: 5rem;
}

.api-docs-hero {
  margin-bottom: 2rem;
}

.api-docs-hero h1 {
  margin-bottom: 0.6rem;
}

/* ---- Two-column layout: sticky sidebar + content ---- */
.api-docs-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
}

@media (min-width: 900px) {
  .api-docs-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 2.5rem;
    align-items: start;
  }
}

/* ---- Sidebar: search + table of contents ---- */
.api-sidebar {
  min-width: 0;
}

@media (min-width: 900px) {
  .api-sidebar {
    position: sticky;
    top: var(--api-nav-offset);
    max-height: calc(100vh - var(--api-nav-offset) - 1rem);
    overflow-y: auto;
  }
}

.api-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.7rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
}

.api-search svg {
  width: 1.05rem;
  height: 1.05rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.api-search-input {
  width: 100%;
  padding: 0.55rem 0;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font-size: 0.92rem;
}

.api-search-input:focus {
  outline: none;
}

.api-toc {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 1rem;
}

.api-toc-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.api-toc-heading {
  margin: 0.9rem 0 0.3rem;
  color: var(--color-text-muted);
  font-size: 0.74rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.api-toc-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 0.86rem;
  text-decoration: none;
}

.api-toc-link:hover {
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
}

.api-toc-link.is-section {
  font-weight: var(--fw-semibold);
  color: var(--color-text);
}

.api-toc-link .toc-path {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-method {
  flex-shrink: 0;
  width: 3.1rem;
  padding: 0.05rem 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.03em;
  text-align: center;
  color: var(--color-ink);
}

/* On mobile, collapse the TOC into a compact wrapped row of chips. */
@media (max-width: 899px) {
  .api-toc {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .api-toc-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
  }

  .api-toc-heading {
    display: none;
  }

  .api-toc-link {
    border: 2px solid var(--color-border);
    background: var(--color-surface);
  }
}

/* ---- Content sections ---- */
.api-content {
  min-width: 0;
}

.api-section {
  scroll-margin-top: var(--api-nav-offset);
}

.api-section + .api-section {
  margin-top: 2.5rem;
}

.api-section-title {
  margin: 0 0 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 2px solid var(--color-border);
  font-size: 1.5rem;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
}

.api-quickstart {
  margin-top: 1.75rem;
}

.api-subsection-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
}

/* ---- Get started / auth shared bits ---- */
.api-key-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0 0;
}

.api-key-fresh-panel {
  padding: 1rem 1.1rem;
  background: var(--color-success-soft);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
}

.api-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.api-meta-label {
  margin: 0 0 0.4rem;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.api-placeholder-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.api-placeholder-note svg {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.api-docs p code,
.api-docs li code {
  padding: 0.1rem 0.35rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-muted);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* ---- Endpoint groups ---- */
.api-group + .api-group {
  margin-top: 2.25rem;
}

.api-group-title {
  margin: 0 0 0.9rem;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  scroll-margin-top: var(--api-nav-offset);
}

.api-endpoint-list {
  display: grid;
  gap: 1rem;
}

.api-endpoint {
  min-width: 0;
  padding: 1.15rem 1.25rem;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: var(--api-nav-offset);
}

.api-endpoint:target {
  border-color: var(--color-primary);
  box-shadow: 4px 4px 0 var(--color-primary);
}

.api-endpoint-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.6rem;
}

.api-endpoint-path {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: var(--fw-medium);
  word-break: break-all;
  text-decoration: none;
}

.api-endpoint-path:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.api-endpoint-anchor {
  display: inline-flex;
  opacity: 0;
  color: var(--color-text-muted);
  transition: opacity 120ms ease;
}

.api-endpoint-anchor svg {
  width: 0.95rem;
  height: 0.95rem;
}

.api-endpoint-path:hover .api-endpoint-anchor,
.api-endpoint:target .api-endpoint-anchor {
  opacity: 1;
}

.api-endpoint-summary {
  margin: 0 0 0.5rem;
  font-weight: var(--fw-semibold);
}

.api-endpoint .meta-line {
  margin-bottom: 0.5rem;
}

.api-empty {
  margin-top: 1.5rem;
  padding: 1.1rem;
  color: var(--color-text-muted);
  text-align: center;
  border: 2px dashed var(--color-border-muted);
  border-radius: var(--radius-md);
}

/* HTTP method badges */
.method-badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  color: var(--color-ink);
}

.method-get,
.toc-method.method-get { background: #bcd9ff; }
.method-post,
.toc-method.method-post { background: #aee4b0; }
.method-patch,
.toc-method.method-patch { background: var(--color-purple-soft); }
.method-put,
.toc-method.method-put { background: var(--color-purple-soft); }
.method-delete,
.toc-method.method-delete { background: var(--color-danger-soft); }

/* Collapsible example response */
.api-response {
  margin-top: 0.85rem;
}

.api-response > summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
}

.api-response > summary:hover {
  color: var(--color-text);
}

/* ---- Copy-to-clipboard code block ---- */
.code-block {
  position: relative;
  min-width: 0;
  margin-top: 0.75rem;
  background: var(--color-ink);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-block-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem 0.35rem 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.code-block-label {
  color: #c9bda9;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.code-block-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
  color: #c9bda9;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: var(--fw-semibold);
  line-height: 1;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.code-block-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #f4ede0;
}

/* Keep the lightweight copy button flat — no press translate or shadow. */
.code-block-copy:active {
  transform: none;
  box-shadow: none;
}

.code-block-copy.is-copied {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #ffffff;
}

.code-block-copy svg {
  width: 0.85rem;
  height: 0.85rem;
}

.code-block-body {
  margin: 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  color: #f4ede0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.65;
  white-space: pre;
}

/* Highlighted placeholders inside code */
.code-ph {
  padding: 0.05rem 0.3rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 207, 70, 0.22);
  color: #ffd864;
  font-weight: var(--fw-semibold);
}

.api-placeholder-note .code-ph {
  background: var(--color-highlight);
  color: var(--color-ink);
}

/* ---- Secret field (API key show/hide) ---- */
.secret-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.secret-field-label {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.secret-field-row {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.secret-field-value {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0.6rem 0.85rem;
  background: var(--color-surface-muted);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  word-break: break-all;
  overflow-x: auto;
}

.secret-field-actions {
  display: flex;
  gap: 0.5rem;
}

/* ---- API key list (profile) ---- */
/* Anchor each row's action to the top-right and let the key details flow below. */
.api-key-list .list-row {
  align-items: flex-start;
}

.list-row-main {
  min-width: 0;
}

.list-row.is-revoked {
  opacity: 0.62;
}

/* Subtle, shadowless row action (revoke / unrevoke). */
.button.is-quiet,
button.is-quiet {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--color-text-muted);
}

.button.is-quiet:hover,
button.is-quiet:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-border-muted);
  color: var(--color-text);
}

.api-key-ref {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  word-break: break-all;
}

/* Subtle inline reveal toggle for a key reference. */
.key-reveal-toggle {
  margin-left: 0.4rem;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.key-reveal-toggle:hover {
  color: var(--color-text);
}

.meta-line-quiet {
  color: var(--color-text-muted);
  font-size: 0.7rem;
}

/* Create-key form, visually separated from the existing keys above it. */
.api-key-create {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--color-border);
}

.api-key-create-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.api-key-create-form .field {
  flex: 1 1 220px;
  margin-bottom: 0;
}

/* ---- Usage card (spend chart + limit) ---- */
.usage-card + .usage-card {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--color-border);
}

/* Simple day-over-day spend bars; each track is one calendar day. */
.usage-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 120px;
  margin-top: 0.25rem;
}

.usage-bar-track {
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  height: 100%;
}

.usage-bar {
  width: 100%;
  min-height: 2px;
  background: var(--color-primary);
  border-radius: 3px 3px 0 0;
}

.usage-caption {
  margin: 0.5rem 0 0;
}

/* Daily spend-limit editor, stacked below the usage chart. */
.spend-limit-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--color-border);
}

.spend-limit-label {
  flex-basis: 100%;
  margin-bottom: 0;
}

.spend-limit-field {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.spend-limit-field input[type="number"] {
  width: 6.5rem;
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .api-meta-grid {
    grid-template-columns: 1fr;
  }
}
