/* ─────────────────────────────  TOKENS  ───────────────────────────── */
:root {
  --bg: #0b0b10;
  --bg-2: #12121b;
  --bg-3: #191925;
  --line: rgba(255,255,255,.10);
  --line-strong: rgba(255,255,255,.18);
  --ink: #f4f3f7;
  --ink-2: #a9a7b8;
  --ink-3: #74728a;
  --accent: #ff5c38;
  --accent-2: #ffb020;
  --accent-3: #7c5cff;
  --good: #34d399;
  --radius: 16px;
  --radius-lg: 26px;
  --wrap: 1160px;
  --shadow: 0 24px 60px -24px rgba(0,0,0,.8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Space Grotesk', 'Inter', sans-serif; line-height: 1.08; margin: 0; letter-spacing: -.02em; }
h1 { font-size: clamp(2.6rem, 6.4vw, 4.6rem); font-weight: 700; }
h2 { font-size: clamp(1.8rem, 3.6vw, 2.7rem); font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 600; letter-spacing: -.01em; }
p  { margin: 0; }
a  { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 22px; }
.wrap-narrow { max-width: 820px; }
.muted { color: var(--ink-2); }
.muted.narrow { max-width: 60ch; margin-inline: auto; }
.small { font-size: .88rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 10px; z-index: 200;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 10px;
}
.skip-link:focus { left: 16px; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ─────────────────────────────  BUTTONS  ───────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 14px 26px; font-weight: 600; font-size: .96rem;
  cursor: pointer; background: none; transition: transform .12s ease, background .2s ease, border-color .2s ease, opacity .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #ff8a3d); color: #14060a; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); background: rgba(255,255,255,.03); }
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-sm { padding: 9px 18px; font-size: .88rem; }
.btn-lg { padding: 17px 34px; font-size: 1.05rem; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }

.spinner { display: none; width: 15px; height: 15px; border: 2px solid rgba(0,0,0,.25); border-top-color: #14060a; border-radius: 50%; animation: spin .7s linear infinite; }
.is-busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--ink);
  width: 38px; height: 38px; border-radius: 50%; font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }

/* ─────────────────────────────  NAV  ───────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 60;
  background: rgba(11,11,16,.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 26px; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #14060a;
  font-family: 'Space Grotesk', sans-serif; font-weight: 700;
}
.brand-name { font-family: 'Space Grotesk', sans-serif; font-size: 1.12rem; }
.nav-links { display: flex; gap: 24px; margin-left: auto; font-size: .93rem; color: var(--ink-2); }
.nav-links a:hover { color: var(--ink); }
.nav .btn-primary { margin-left: 6px; }

/* ─────────────────────────────  HERO  ───────────────────────────── */
.hero { position: relative; padding: clamp(48px, 8vw, 92px) 0 60px; overflow: hidden; }
.hero-glow {
  position: absolute; inset: -30% 10% auto; height: 620px; pointer-events: none;
  background:
    radial-gradient(46% 50% at 26% 40%, rgba(255,92,56,.30), transparent 70%),
    radial-gradient(40% 45% at 74% 30%, rgba(124,92,255,.28), transparent 70%),
    radial-gradient(30% 40% at 50% 70%, rgba(255,176,32,.18), transparent 70%);
  filter: blur(18px);
}
.hero-inner { position: relative; text-align: center; }
.eyebrow {
  display: inline-block; font-size: .78rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 15px;
  background: rgba(255,255,255,.03); margin-bottom: 22px;
}
.hero h1 { margin-bottom: 20px; }
.lede { max-width: 62ch; margin: 0 auto; color: var(--ink-2); font-size: clamp(1rem, 1.4vw, 1.1rem); }

/* composer */
.composer { max-width: 780px; margin: 38px auto 0; }
.composer-drop {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow); text-align: left;
  transition: border-color .2s ease, background .2s ease;
}
.composer-drop.is-dragging { border-color: var(--accent); background: rgba(255,92,56,.08); }
.composer textarea {
  width: 100%; background: none; border: 0; resize: vertical; min-height: 82px;
  font-size: 1.02rem; line-height: 1.55; padding: 6px 8px;
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--ink-3); }

.composer-bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.composer-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-right: auto; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--ink-2);
  border-radius: 999px; padding: 8px 14px; font-size: .86rem;
}
.chip-btn:hover { color: var(--ink); background: rgba(255,255,255,.09); }
.chip-btn svg { width: 15px; height: 15px; fill: currentColor; }

.ref-slot {
  display: flex; align-items: center; gap: 12px; margin: 10px 8px 0;
  border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px 8px 8px; background: rgba(255,255,255,.03);
}
.ref-slot img { width: 42px; height: 42px; object-fit: cover; border-radius: 9px; }
.ref-meta { display: flex; flex-direction: column; font-size: .82rem; color: var(--ink-2); line-height: 1.3; }
.ref-meta strong { color: var(--ink); font-size: .86rem; }
.ref-remove { margin-left: auto; border: 0; background: none; color: var(--ink-2); font-size: 1.3rem; cursor: pointer; }
.ref-remove:hover { color: var(--ink); }

.style-picker { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.style-chip {
  border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--ink-2);
  border-radius: 999px; padding: 8px 15px; font-size: .85rem; cursor: pointer; transition: .18s ease;
}
.style-chip:hover { color: var(--ink); border-color: var(--line-strong); }
.style-chip.is-active { background: var(--ink); color: #10101a; border-color: var(--ink); font-weight: 600; }
.composer-hint { margin-top: 14px; text-align: center; color: var(--ink-3); font-size: .84rem; }

.badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 26px; list-style: none; padding: 0; margin: 34px 0 0; color: var(--ink-2); font-size: .92rem; }
.badges li { display: inline-flex; align-items: center; gap: 9px; }
.tick { width: 18px; height: 18px; border-radius: 50%; background: rgba(52,211,153,.15); position: relative; }
.tick::after {
  content: ""; position: absolute; left: 6px; top: 3px; width: 4px; height: 9px;
  border: solid var(--good); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* ─────────────────────────────  SECTIONS  ───────────────────────────── */
.section { padding: clamp(56px, 8vw, 96px) 0; }
.section-tight { padding-block: clamp(40px, 5vw, 64px); }
.section-head { text-align: center; margin-bottom: 42px; display: grid; gap: 12px; }
.section-head.row { display: flex; align-items: end; justify-content: space-between; text-align: left; gap: 20px; flex-wrap: wrap; }
.section-head p { color: var(--ink-2); }

/* results */
.results { padding-bottom: 20px; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.result-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--bg-2); cursor: pointer; transition: transform .18s ease, border-color .18s ease;
  padding: 0; display: block; width: 100%;
}
.result-card:hover { transform: translateY(-4px); border-color: var(--line-strong); }
.result-card canvas { width: 100%; height: auto; display: block; }
.result-card .card-cta {
  position: absolute; inset: auto 0 0 0; padding: 10px 12px; font-size: .82rem; font-weight: 600;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; text-align: center;
  opacity: 0; transition: opacity .18s ease;
}
.result-card:hover .card-cta { opacity: 1; }
.result-card.is-skeleton { cursor: default; aspect-ratio: 5 / 6; background: linear-gradient(100deg, var(--bg-2) 30%, var(--bg-3) 50%, var(--bg-2) 70%); background-size: 220% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -120% 0; } }

/* examples + styles */
.example-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.example-tile { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg-2); }
.example-tile canvas { width: 100%; height: auto; display: block; }
.example-tile figcaption { padding: 12px 14px; font-size: .86rem; color: var(--ink-2); border-top: 1px solid var(--line); }

.style-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.style-card {
  display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-2); border-radius: var(--radius); padding: 12px; transition: .18s ease;
}
.style-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.style-card canvas { width: 74px; height: 89px; border-radius: 10px; background: #fff; flex: none; }
.style-card b { display: block; font-size: .96rem; }
.style-card span { font-size: .82rem; color: var(--ink-2); }

/* platforms */
.platforms { padding: 28px 0 8px; border-block: 1px solid var(--line); background: var(--bg-2); }
.platforms-title { text-align: center; color: var(--ink-2); font-size: .92rem; margin-bottom: 18px; }
.marquee { overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.marquee-track {
  display: flex; gap: 56px; list-style: none; padding: 0 0 22px; margin: 0; width: max-content;
  animation: slide 32s linear infinite;
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.22rem; color: var(--ink-3);
  white-space: nowrap;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes slide { to { transform: translateX(-50%); } }

/* steps */
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; counter-reset: step; }
.steps li { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: var(--bg-2); display: grid; gap: 10px; align-content: start; }
.step-num {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(255,92,56,.14); color: var(--accent); font-weight: 700; font-family: 'Space Grotesk', sans-serif;
}
.steps p { color: var(--ink-2); font-size: .93rem; }

.protip { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 20px; padding: 18px 22px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: rgba(255,176,32,.05); }
.protip-tag { font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); font-weight: 700; }
.protip p { color: var(--ink-2); font-size: .93rem; flex: 1 1 320px; }

/* features */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature { border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; background: var(--bg-2); display: grid; gap: 10px; align-content: start; }
.feature-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.1rem; background: rgba(124,92,255,.16); color: #b6a4ff; }
.feature p { color: var(--ink-2); font-size: .93rem; }

/* comparison */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.compare-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; background: var(--bg-2); }
.compare-card.is-good { border-color: rgba(255,92,56,.5); background: linear-gradient(180deg, rgba(255,92,56,.09), transparent 60%), var(--bg-2); }
.compare-brand { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.02rem; margin-bottom: 4px; }
.compare-card.is-good .compare-brand { color: var(--accent); }
.compare-card.is-bad .compare-brand { color: var(--ink-3); }
.compare-card h3 { margin-bottom: 18px; font-size: 1.25rem; }
.tick-list, .cross-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; color: var(--ink-2); font-size: .94rem; }
.tick-list li, .cross-list li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; }
.tick-list li::before { content: "✓"; color: var(--good); font-weight: 700; }
.cross-list li::before { content: "✕"; color: #ef6b6b; font-weight: 700; }

/* printing */
.print-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.print-grid li {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--bg-2);
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; text-align: center;
}

/* faq */
.faq { display: grid; gap: 12px; }
.faq details { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); overflow: hidden; }
.faq summary {
  cursor: pointer; list-style: none; padding: 18px 22px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq-sign { position: relative; width: 14px; height: 14px; flex: none; }
.faq-sign::before, .faq-sign::after {
  content: ""; position: absolute; inset: 50% 0 auto; height: 2px; background: var(--ink-2); border-radius: 2px; transition: transform .2s ease;
}
.faq-sign::after { transform: rotate(90deg); }
.faq details[open] .faq-sign::after { transform: rotate(0); }
.faq details p { padding: 0 22px 20px; color: var(--ink-2); font-size: .95rem; }

/* cta + footer */
.cta { padding: clamp(56px, 8vw, 92px) 0; }
.cta-inner {
  text-align: center; border: 1px solid var(--line-strong); border-radius: 34px; padding: clamp(36px, 6vw, 62px) 24px;
  background: radial-gradient(60% 120% at 50% 0%, rgba(255,92,56,.18), transparent 70%), var(--bg-2);
  display: grid; gap: 16px; justify-items: center;
}
.cta-inner p { color: var(--ink-2); }

.footer { border-top: 1px solid var(--line); padding: 40px 0 26px; }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-inner .brand { margin-bottom: 8px; }
.footer nav { display: flex; gap: 22px; font-size: .92rem; color: var(--ink-2); flex-wrap: wrap; align-items: start; }
.footer nav a:hover { color: var(--ink); }
.copyright { text-align: center; color: var(--ink-3); font-size: .82rem; margin-top: 30px; }

/* ─────────────────────────────  EDITOR  ───────────────────────────── */
.editor { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.editor-backdrop { position: absolute; inset: 0; background: rgba(4,4,8,.78); backdrop-filter: blur(6px); }
.editor-panel {
  position: relative; width: min(1080px, 100%); max-height: min(94vh, 900px);
  background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: 22px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.editor-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.editor-head h2 { font-size: 1.15rem; }
.editor-body { display: grid; grid-template-columns: 1fr 330px; min-height: 0; flex: 1; }
.editor-stage { padding: 22px; display: grid; place-items: center; align-content: center; gap: 12px; background: var(--bg); min-height: 0; overflow: auto; }
.stage-wrap {
  position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e6e6ee 25%, transparent 25%, transparent 75%, #e6e6ee 75%),
    linear-gradient(45deg, #e6e6ee 25%, transparent 25%, transparent 75%, #e6e6ee 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px;
}
#stage { display: block; max-height: 64vh; width: auto; height: auto; touch-action: none; cursor: grab; }
#stage.is-dragging { cursor: grabbing; }
.stage-hint { color: var(--ink-3); font-size: .82rem; text-align: center; }

.editor-side { border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; display: grid; gap: 20px; align-content: start; }
.side-block { display: grid; gap: 10px; }
.side-block h3 { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.side-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line-strong); cursor: pointer; padding: 0; }
.swatch.is-active { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch.is-none { background:
  linear-gradient(45deg, #ddd 25%, #fff 25%, #fff 75%, #ddd 75%),
  linear-gradient(45deg, #ddd 25%, #fff 25%, #fff 75%, #ddd 75%);
  background-size: 12px 12px; background-position: 0 0, 6px 6px; }

.layer-list { display: grid; gap: 6px; }
.layer-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,.03); border-radius: 10px; padding: 9px 11px; font-size: .87rem;
}
.layer-item:hover { background: rgba(255,255,255,.08); }
.layer-item.is-active { border-color: var(--accent); background: rgba(255,92,56,.1); }
.layer-item.is-hidden { opacity: .45; }
.layer-kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-left: auto; }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.field { display: grid; gap: 6px; font-size: .84rem; color: var(--ink-2); }
.field b { color: var(--ink); font-weight: 600; }
.field input[type=text], .field select {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%;
}
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 9px; font-size: .88rem; color: var(--ink-2); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ─────────────────────────────  RESPONSIVE  ───────────────────────────── */
@media (max-width: 980px) {
  .nav-links { display: none; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .example-grid, .style-grid, .feature-grid, .print-grid { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .compare { grid-template-columns: 1fr; }
  .editor-body { grid-template-columns: 1fr; }
  .editor-side { border-left: 0; border-top: 1px solid var(--line); }
  #stage { max-height: 42vh; }
}
@media (max-width: 620px) {
  .example-grid, .style-grid, .steps, .feature-grid, .print-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .composer-bar .btn-primary { width: 100%; }
  .section-head.row { flex-direction: column; align-items: stretch; }
  .editor { padding: 0; }
  .editor-panel { max-height: 100vh; height: 100%; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

/* ─────────────────────────────  API KEY  ───────────────────────────── */
.key-pill {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--ink-2);
  border-radius: 999px; padding: 8px 15px; font-size: .85rem; white-space: nowrap;
}
.key-pill:hover { color: var(--ink); border-color: var(--line-strong); }
.key-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.key-pill.is-set .key-dot { background: var(--good); box-shadow: 0 0 0 3px rgba(52,211,153,.16); }

.count-field select {
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--ink-2);
  border-radius: 999px; padding: 9px 13px; font-size: .86rem; cursor: pointer;
}
.count-field select:hover { color: var(--ink); }

/* The closed control above inherits the dark theme fine, but the open
   dropdown popup is native browser chrome — Chromium is one of the few
   engines that honours colours set directly on <option>, so without this
   every option renders near-illegible pale-grey text on a white popup. */
.count-field select option {
  background: var(--bg-3);
  color: var(--ink);
}
.count-field select option:disabled { color: var(--ink-3); }

.composer-alert {
  margin-top: 12px; text-align: center; font-size: .88rem;
  color: #ffb4a2; background: rgba(255,92,56,.09);
  border: 1px solid rgba(255,92,56,.32); border-radius: 12px; padding: 11px 15px;
}
.composer-alert a { text-decoration: underline; }

/* shared modal shell (key dialog) */
.modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,4,8,.78); backdrop-filter: blur(6px); }
.modal-panel {
  position: relative; width: min(520px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: 22px;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.15rem; }
.modal-body { padding: 22px; display: grid; gap: 16px; }
.modal-body .field span { font-size: .84rem; }
.modal-body input[type=password], .modal-body select {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; width: 100%;
}
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.key-hint { font-size: .84rem; color: var(--ink-3); }
.key-hint a { color: var(--accent-2); text-decoration: underline; }
.key-error {
  font-size: .86rem; color: #ffb4a2; background: rgba(255,92,56,.09);
  border: 1px solid rgba(255,92,56,.32); border-radius: 10px; padding: 10px 13px;
}

@media (max-width: 620px) {
  .key-pill span:not(.key-dot) { display: none; }
  .key-pill { padding: 9px; }
}

.key-advanced { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(255,255,255,.02); }
.key-advanced summary { cursor: pointer; font-size: .86rem; color: var(--ink-2); font-weight: 600; }
.key-advanced summary:hover { color: var(--ink); }
.key-advanced > *:not(summary) { margin-top: 12px; }
.key-advanced input[type=text] {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; font-size: .88rem;
}

.probe-results { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.probe-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px;
  background: rgba(255,255,255,.02); font-size: .82rem; color: var(--ink-3); text-align: left;
}
.probe-row code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); }
.probe-row.is-hit { border-color: rgba(52,211,153,.45); background: rgba(52,211,153,.08); color: var(--ink); cursor: pointer; }
.probe-row.is-hit code { color: var(--ink); }
.probe-row.is-hit:hover { background: rgba(52,211,153,.16); }
.probe-row.is-info { border-style: dashed; }
.cost-note { font-size: .8rem; color: var(--accent-2); padding-left: 4px; white-space: nowrap; }

/* ─────────────────────────────  HISTORY  ───────────────────────────── */
.history-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.history-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-2); overflow: hidden; display: flex; flex-direction: column;
}
.history-open {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer;
}
.history-open img { width: 100%; aspect-ratio: 5 / 6; object-fit: contain; background: #fff; display: block; }
.history-open:hover img { opacity: .9; }
.history-meta { padding: 11px 13px; display: grid; gap: 5px; border-top: 1px solid var(--line); }
.history-prompt {
  font-size: .86rem; color: var(--ink); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.history-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .74rem; color: var(--ink-3); }
.history-model {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-remove {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: rgba(10,10,16,.75); color: var(--ink-2);
  font-size: 1rem; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s ease;
}
.history-card:hover .history-remove { opacity: 1; }
.history-remove:hover { color: #fff; background: rgba(200,60,40,.85); }

@media (max-width: 980px) { .history-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) { .history-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented-btn {
  flex: 1; padding: 8px 6px; font-size: .8rem; border: 0; border-right: 1px solid var(--line);
  background: var(--bg-3); color: var(--ink-2); cursor: pointer;
}
.segmented-btn:last-child { border-right: 0; }
.segmented-btn:hover { color: var(--ink); }
.segmented-btn.is-active { background: var(--accent); color: #14060a; font-weight: 600; }
.toggle i { display: block; font-style: normal; color: var(--ink-3); font-size: .78rem; margin-top: 1px; }

/* ─────────────────────────────  TOP-BAR API KEY LINK  ───────────────────────────── */
.get-key-link { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.get-key-link svg { width: 15px; height: 15px; fill: currentColor; flex: none; }

@media (max-width: 760px) {
  .get-key-link span { display: none; }
  .get-key-link { padding: 9px; }
}

@media (max-width: 520px) {
  .nav .wrap { padding-inline: 14px; }
  .nav-inner { gap: 8px; }
  .nav .btn-primary.btn-sm { padding: 9px 13px; font-size: .82rem; }
  .brand-name { display: none; }   /* the mark alone still identifies the brand */
}

/* ─────────────────────────────  FOOTER: CONNECT  ───────────────────────────── */
.footer-connect { display: grid; gap: 10px; align-content: start; }
.footer-connect-label {
  font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 700;
}
.social-row { display: flex; flex-direction: column; gap: 8px; }
.social-btn {
  display: inline-flex; align-items: center; gap: 9px; border: 1px solid var(--line);
  background: rgba(255,255,255,.03); color: var(--ink-2); border-radius: 999px;
  padding: 9px 15px; font-size: .87rem; font-weight: 600; transition: .18s ease; white-space: nowrap;
}
.social-btn:hover { color: var(--ink); border-color: var(--line-strong); background: rgba(255,255,255,.08); transform: translateY(-1px); }
.social-btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.social-btn .ico-youtube { fill: #ff3b3b; }

.footer-inner { grid-template-columns: 1fr; }
@media (min-width: 760px) {
  .footer-inner { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 32px; align-items: start; }
  .footer-inner nav { display: grid; gap: 10px; }
}

.copyright strong { color: var(--ink-2); font-weight: 700; }
