:root {
  --bg: #0d0f14;
  --panel: #161a21;
  --panel-2: #1d222b;
  --border: #2a313c;
  --text: #e7ebf0;
  --muted: #95a0b0;
  --accent: #d97757;
  --accent-2: #e89b82;
  --accent-grad: linear-gradient(135deg, #e0855f 0%, #d9605a 100%);
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --shadow-accent: 0 8px 30px rgba(217,119,87,.22);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* beat .gallery/.controls display rules */
html, body { margin: 0; height: 100%; }
body {
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 100% -5%, rgba(217,119,87,.10), transparent 60%),
    radial-gradient(700px 400px at -5% 0%, rgba(99,102,241,.06), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--accent-2); transition: color .12s; }
a:hover { color: #f0b39c; }
button { font-family: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(29,34,43,.85), rgba(22,26,33,.75));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(217,119,87,.18);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand[role="link"] { transition: opacity .12s, transform .12s; border-radius: 10px; }
.brand[role="link"]:hover { opacity: .9; transform: translateY(-1px); }
.brand-logo {
  height: 46px; width: auto; border-radius: 8px; background: #f5f1e8;
  padding: 4px 8px; display: block;
}
.brand-text h1 {
  font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -.01em;
  background: linear-gradient(90deg, #fff, #e89b82); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent;
}
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.key-area { display: flex; gap: 8px; align-items: center; }
.key-field { position: relative; display: flex; align-items: center; }
.key-field input {
  width: 330px; max-width: 44vw; padding: 9px 58px 9px 12px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
}
.key-field input:focus { outline: none; border-color: var(--accent); }
.show-toggle {
  position: absolute; right: 5px; border: none; background: transparent;
  color: var(--accent-2); font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px 6px;
}
.key-area select {
  padding: 9px 10px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
}
.key-note {
  font-size: 12px; color: var(--muted); padding: 8px 22px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}

/* ---------- Controls ---------- */
.controls {
  display: flex; gap: 10px; align-items: center; padding: 14px 22px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  /* not sticky: the global toolbar is already pinned — two stacked sticky bars overlapped. */
}
.controls input, .controls select {
  padding: 9px 13px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 13px;
}
.controls input { flex: 1; min-width: 200px; max-width: 480px; }
.controls input:focus, .controls select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,119,87,.15); }
.count { color: var(--muted); font-size: 12px; margin-left: auto; }
.lang-select { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.lang-select select {
  padding: 7px 9px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font: inherit; font-size: 13px;
}
.lang-select select:focus { outline: none; border-color: var(--accent); }

/* ---------- Main / gallery ---------- */
.main { flex: 1; padding: 22px; }
.gallery {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
}
.skill-card {
  text-align: left; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px 17px 18px; cursor: pointer;
  color: var(--text); display: flex; flex-direction: column; gap: 7px;
  position: relative; overflow: hidden;
  transition: border-color .15s, transform .15s, background .15s, box-shadow .15s;
}
.skill-card::before {
  content: ""; position: absolute; left: 0; top: 0; height: 100%; width: 3px;
  background: var(--accent-grad); opacity: 0; transition: opacity .15s;
}
.skill-card:hover {
  border-color: rgba(217,119,87,.5); transform: translateY(-3px);
  background: var(--panel-2); box-shadow: var(--shadow-accent);
}
.skill-card:hover::before { opacity: 1; }
.card-title { transition: color .12s; }
.skill-card:hover .card-title { color: var(--accent-2); }
.card-bundle {
  font-size: 10.5px; letter-spacing: .03em; text-transform: uppercase;
  color: var(--accent-2); font-weight: 600;
}
.card-title { margin: 0; font-size: 15.5px; line-height: 1.28; font-weight: 600; }
.card-summary { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.empty-msg { color: var(--muted); padding: 40px; text-align: center; grid-column: 1 / -1; }

/* ---------- Tier badges ---------- */
.card-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-tags .card-bundle { margin: 0; }
.card-tier {
  font-size: 10px; font-weight: 600; letter-spacing: .02em; padding: 2px 7px;
  border-radius: 99px; border: 1px solid transparent; white-space: nowrap; margin-left: auto;
}
.tier-production { color: #6ee7b7; background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.35); }
.tier-stable     { color: #93c5fd; background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.35); }
.tier-experimental { color: #fcd34d; background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.35); }

/* ---------- Runner ---------- */
.runner { max-width: 880px; margin: 0 auto; }
.back {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 13px; border-radius: 8px; font-size: 13px; cursor: pointer; margin-bottom: 18px;
}
.back:hover { border-color: var(--accent); }

.skill-head { margin-bottom: 18px; }
.bundle-tag {
  display: inline-block; font-size: 11px; color: var(--accent-2);
  background: rgba(217,119,87,.12); padding: 3px 9px; border-radius: 99px; margin-bottom: 8px;
}
.skill-head h2 { margin: 0 0 6px; font-size: 23px; }
.skill-desc { color: var(--muted); font-size: 13.5px; line-height: 1.55; margin: 0; }
.tier-tag {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: 99px; margin: 0 0 8px 6px; border: 1px solid transparent;
}

/* ---------- Use in another tool ---------- */
.elsewhere {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px 14px; margin-bottom: 4px;
}
.elsewhere summary {
  cursor: pointer; font-size: 13px; font-weight: 600; padding: 9px 0; color: var(--accent-2);
}
.elsewhere-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 4px 0 12px; }
.elsewhere-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-bottom: 12px; }
.copy-msg { font-size: 12px; color: #6ee7b7; }

.input-form { display: flex; flex-direction: column; gap: 14px; margin: 22px 0; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .opt { color: var(--muted); font-weight: 400; }
.field .hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.field input, .field textarea {
  width: 100%; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13.5px; font-family: inherit; resize: vertical;
}
.field textarea { min-height: 90px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }

.actions { display: flex; align-items: center; gap: 12px; }
button.primary {
  background: var(--accent-grad); color: #1a1207; border: none; padding: 11px 19px;
  border-radius: 9px; font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-accent); transition: transform .12s, box-shadow .12s, filter .12s;
}
button.primary:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 10px 34px rgba(217,119,87,.32); }
button.primary:active { transform: translateY(0); }
button.primary:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
button.ghost {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 13px; border-radius: 8px; font-size: 13px; cursor: pointer; transition: border-color .12s, background .12s;
}
button.ghost:hover { border-color: var(--accent); background: var(--panel); }
.status { font-size: 13px; color: var(--muted); }
.status.err { color: #e07a6f; }

/* ---------- Output ---------- */
.output-wrap { margin-top: 24px; }
.output-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
.output-toolbar > div { display: flex; gap: 8px; flex-wrap: wrap; }
.feedback-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.feedback-bar button { padding: 3px 9px; font-size: 14px; line-height: 1.4; }
.feedback-bar .bs-link { color: var(--muted); }
.brain-save {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 10px; padding: 10px 12px;
  background: var(--panel-2, var(--panel)); border: 1px solid var(--border); border-radius: 10px;
}
.brain-save .bs-title { font-size: 13px; font-weight: 600; }
.brain-save input { flex: 1; min-width: 200px; padding: 7px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: inherit; font-size: 13px; }
.brain-save select { padding: 6px 8px; }
.brain-save .bs-link { font-size: 12px; color: var(--muted); margin-left: auto; }
.output {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 26px; line-height: 1.6; font-size: 14.5px;
}
.markdown h1, .markdown h2, .markdown h3 { line-height: 1.3; }
.markdown h1 { font-size: 22px; }
.markdown h2 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.markdown h3 { font-size: 15px; }
.markdown code { background: var(--panel-2); padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.markdown pre { background: var(--panel-2); padding: 14px; border-radius: 8px; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; font-size: 13px; }
.markdown th { background: var(--panel-2); }
.markdown blockquote { border-left: 3px solid var(--accent); margin: 12px 0; padding: 2px 14px; color: var(--muted); }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Role onboarding ---------- */
.onboarding {
  max-width: 1100px; margin: 16px auto 0; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(217,119,87,.10); border: 1px solid rgba(217,119,87,.35); border-radius: 12px;
}
.onboarding-q { font-size: 14px; font-weight: 600; }
.role-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.role-chip {
  font-size: 13px; padding: 6px 13px; border-radius: 99px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
}
.role-chip:hover { border-color: var(--accent); background: rgba(217,119,87,.18); }
.role-skip { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 12.5px; cursor: pointer; text-decoration: underline; }

.starter-banner {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 4px;
  background: rgba(217,119,87,.10); border: 1px solid rgba(217,119,87,.30); border-radius: 10px; font-size: 13.5px;
}
.link-btn { background: none; border: 0; color: var(--accent-2); cursor: pointer; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Tools bar ---------- */
.toolbar-nav {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center;
  margin: 0; padding: 12px 22px;
  background: rgba(13,15,20,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;   /* always reachable while scrolling */
}
.toolbar-nav .tool {
  font-size: 13px; font-weight: 600; text-decoration: none; padding: 7px 14px; border-radius: 99px;
  color: var(--muted); background: transparent; border: 1px solid transparent; white-space: nowrap;
  transition: color .12s, background .12s, border-color .12s, transform .12s;
}
.toolbar-nav .tool:hover { color: var(--text); background: var(--panel-2); border-color: var(--border); transform: translateY(-1px); }
.toolbar-nav .tool.active { background: var(--accent-grad); border-color: transparent; color: #1a1207; box-shadow: var(--shadow-accent); }
/* GitHub / repo CTA — outlined-accent so "back to the source" is always obvious. */
.toolbar-nav .tool.cta { color: var(--text); border-color: var(--accent); font-weight: 700; }
.toolbar-nav .tool.cta:hover { background: var(--accent-grad); color: #1a1207; border-color: transparent; box-shadow: var(--shadow-accent); }
/* Grouped dropdowns keep the bar short */
.toolbar-nav .tool-group { position: relative; display: inline-flex; }
.toolbar-nav .group-btn { cursor: pointer; font-family: inherit; }
.toolbar-nav .group-menu {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; gap: 3px; min-width: 200px; padding: 7px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0,0,0,.45);
}
.toolbar-nav .group-menu[hidden] { display: none; }
.toolbar-nav .group-menu .tool { white-space: nowrap; text-align: left; }
html[data-theme="light"] .toolbar-nav .group-menu { background: #fff; }

/* ---------- Focus rings (polish) ---------- */
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 0 0 0 3px rgba(217,119,87,.20); }

/* ---------- Eval-scored filter ---------- */
.eval-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #6ee7b7; cursor: pointer; background: rgba(16,185,129,.10); border: 1px solid rgba(16,185,129,.30); border-radius: 8px; padding: 7px 11px; transition: background .12s; }
.eval-filter:hover { background: rgba(16,185,129,.18); }

/* ---------- Critique mode ---------- */
.mode-bar { margin-bottom: 12px; }
.mode-toggle {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px;
  color: var(--accent-2); background: rgba(217,119,87,.10);
  border: 1px solid rgba(217,119,87,.30); border-radius: 99px; padding: 6px 13px;
}

/* ---------- Framework attribution ---------- */
.skill-source { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.skill-source em { color: var(--accent-2); font-style: italic; }

/* 🔥 Trending strip */
.trending { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; padding: 10px 14px; background: linear-gradient(90deg, rgba(217,119,87,.10), transparent); border: 1px solid var(--border); border-radius: 12px; }
.trending .trend-lead { font-size: 13px; font-weight: 700; color: var(--accent-2); margin-right: 2px; }
.trend-chip { font: inherit; font-size: 12.5px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--text); cursor: pointer; transition: border-color .12s, background .12s; }
.trend-chip:hover { border-color: var(--accent); background: var(--panel-2); }

/* Workspace / history panel */
.history-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; }
.history-panel .hist-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.history-panel .hist-sub { font-size: 12px; color: var(--muted); }
.history-panel .hist-head .ghost { margin-left: auto; }
.history-panel .hist-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }
.history-panel .hist-item { display: flex; align-items: stretch; gap: 6px; }
.history-panel .hist-open { flex: 1; display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px; cursor: pointer; color: var(--text); }
.history-panel .hist-open:hover { border-color: var(--accent); }
.history-panel .hist-title { font-weight: 600; font-size: 14px; }
.history-panel .hist-meta { font-size: 11.5px; color: var(--muted); }
.history-panel .hist-del { border: 1px solid var(--border); background: var(--panel-2); border-radius: 9px; color: var(--muted); cursor: pointer; padding: 0 11px; }
.history-panel .hist-del:hover { border-color: #c0504d; color: #c0504d; }
#exportFmt.ghost { padding: 5px 8px; }

.skill-related { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 14px; }
.skill-related .rel-lead { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: 1px; }
.skill-related .rel-lead:not(:first-child) { margin-left: 8px; }
.rel-chip { font: inherit; font-size: 12.5px; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-2); color: var(--text); cursor: pointer; transition: border-color .12s, background .12s; }
.rel-chip:hover { border-color: var(--accent); background: var(--panel); }
.rel-chip.rel-first { border-color: var(--accent); color: var(--accent-2); font-weight: 600; }

/* ---------- Skill Memory (context box) ---------- */
.context-box {
  max-width: 1100px; margin: 12px auto 0; padding: 4px 16px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.context-box summary { cursor: pointer; font-size: 13.5px; font-weight: 600; padding: 10px 0; color: var(--accent-2); }
.context-status { color: #6ee7b7; font-weight: 600; font-size: 12px; margin-left: 6px; }
.context-box textarea {
  width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 10px 12px; font-size: 13.5px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; resize: vertical; font-family: inherit;
}
.context-box textarea:focus { outline: none; border-color: var(--accent); }
.context-hint { font-size: 11.5px; color: var(--muted); padding-bottom: 10px; }
.context-actions-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.file-load { font-size: 12.5px; cursor: pointer; color: var(--accent-2); background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; }
.file-load:hover { border-color: var(--accent); }

/* ---------- Recommender ---------- */
.recommend { max-width: 1100px; margin: 18px auto 0; padding: 0 4px; }
.recommend > input {
  width: 100%; box-sizing: border-box; padding: 12px 14px; font-size: 14px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
}
.recommend > input:focus { outline: none; border-color: var(--accent); }
.recommend-results {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px;
}
.recommend-lead { font-size: 12.5px; color: var(--muted); }
.recommend-empty { font-size: 12.5px; color: var(--muted); }
.recommend-chip {
  font-size: 12.5px; padding: 6px 11px; border-radius: 99px; cursor: pointer;
  background: rgba(217,119,87,.12); color: var(--accent-2);
  border: 1px solid rgba(217,119,87,.35);
}
.recommend-chip:hover { background: rgba(217,119,87,.22); }

/* ---------- Eval badges ---------- */
.card-eval, .eval-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .02em; padding: 2px 7px;
  border-radius: 99px; white-space: nowrap;
  color: #6ee7b7; background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.35);
}
.eval-badge { display: inline-block; font-size: 11px; margin: 0 0 8px 6px; }
/* Real 👍 helpful% proof badge (shown only once a skill has enough ratings) */
.card-proof, .proof-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .02em; padding: 2px 7px;
  border-radius: 99px; white-space: nowrap;
  color: #fbbf64; background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.35);
}
.proof-badge { display: inline-block; font-size: 11px; margin: 0 0 8px 6px; }

/* ---------- Share button ---------- */
.share-btn { margin-top: 10px; }
.sample-btn { margin-top: 10px; margin-right: 8px; border-color: var(--accent); color: var(--accent-2); }
.sample-banner {
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 13px; margin-bottom: 14px; font-size: 13px; color: var(--muted);
}
.sample-banner .sample-input { display: inline-block; margin-top: 5px; font-size: 12px; opacity: .85; }

/* ---------- Live run-flow animation ---------- */
.run-flow { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.run-flow .rf-stage { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--border); white-space: nowrap; }
.run-flow .rf-skill { border-color: var(--accent); color: var(--accent-2); }
.run-flow .rf-out { animation: rfpulse 1.2s ease-in-out infinite; }
.run-flow .rf-brain { border-color: #6f9d7f; color: #9ad8a8; }
.run-flow .rf-pipe { flex: 1; height: 3px; min-width: 20px; border-radius: 2px; opacity: .75;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 50%, var(--accent) 100%);
  background-size: 200% 100%; animation: rfflow 1s linear infinite; }
@keyframes rfflow { from { background-position: 200% 0; } to { background-position: 0 0; } }
@keyframes rfpulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .run-flow .rf-pipe, .run-flow .rf-out { animation: none; } }

/* ---------- Sample-output gallery ---------- */
.sample-card {
  max-width: 880px; margin: 0 auto 14px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 4px 18px;
}
.sample-card summary {
  cursor: pointer; padding: 12px 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.sample-title { font-size: 15px; font-weight: 600; }
.sample-source { font-size: 11px; color: var(--muted); }
.sample-run { margin-left: auto; font-size: 12.5px; color: var(--accent-2); text-decoration: none; }
.sample-run:hover { text-decoration: underline; }
.sample-input { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0 0 8px; }
.sample-output { border-top: 1px solid var(--border); padding-top: 12px; }

/* ---------- Compare mode ---------- */
.compare-toggle { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.compare-pane { min-width: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.compare-label {
  font-size: 12px; font-weight: 600; padding: 8px 12px;
  background: var(--panel-2); border-bottom: 1px solid var(--border);
}
.compare-pane .output { padding: 12px 14px; }

@media (max-width: 620px) {
  .key-field input { width: 200px; }
  .brand-text h1 { font-size: 15px; }
  .gallery { grid-template-columns: 1fr; }
  .compare-grid { grid-template-columns: 1fr; }
}

/* ===== Light theme ===== */
html[data-theme="light"] {
  --bg: #f7f6f3; --panel: #ffffff; --panel-2: #f1efe9; --border: #e4e0d8;
  --text: #1b2027; --muted: #667085;
}
html[data-theme="light"] body {
  background:
    radial-gradient(900px 500px at 100% -5%, rgba(217,119,87,.10), transparent 60%),
    radial-gradient(700px 400px at -5% 0%, rgba(99,102,241,.05), transparent 55%),
    var(--bg);
}
html[data-theme="light"] .topbar { background: linear-gradient(180deg, #ffffff, #f7f6f3); }
html[data-theme="light"] .toolbar-nav { background: rgba(255,255,255,.75); }
html[data-theme="light"] .brand-text h1 { background: linear-gradient(90deg, #1b2027, #d9605a); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
html[data-theme="light"] .toolbar-nav .tool.active,
html[data-theme="light"] button.primary,
html[data-theme="light"] .toolbar-nav .tool.active { color: #fff; }

/* ===== Theme toggle button ===== */
.theme-toggle { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 15px; line-height: 1; }
.theme-toggle:hover { border-color: var(--accent); }

/* ===== ⌘K command palette ===== */
.kbtn { background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 12px; font-weight: 600; }
.kbtn:hover { border-color: var(--accent); color: var(--text); }
.cmdk-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.cmdk { width: min(620px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.5); overflow: hidden; }
.cmdk input { width: 100%; box-sizing: border-box; padding: 16px 18px; font-size: 16px; background: transparent; border: none; border-bottom: 1px solid var(--border); color: var(--text); outline: none; }
.cmdk-list { max-height: 50vh; overflow: auto; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; font-size: 14px; }
.cmdk-item .ci-sub { color: var(--muted); font-size: 12px; margin-left: auto; }
.cmdk-item.sel, .cmdk-item:hover { background: var(--panel-2); }
.cmdk-item .ci-kind { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--accent-2); }
.cmdk-empty { padding: 18px; color: var(--muted); text-align: center; }

/* ===== Hero ===== */
.hero { max-width: 1100px; margin: 26px auto 8px; padding: 0 4px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 26px; align-items: center; }
@media (max-width: 760px){ .hero { grid-template-columns: 1fr; } }
.hero h2 { font-size: 34px; line-height: 1.08; margin: 0 0 12px; letter-spacing: -.025em; }
.hero h2 .grad { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { color: var(--muted); font-size: 15px; margin: 0 0 18px; max-width: 50ch; line-height: 1.55; }
.hero-stats { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.hero-stats > div { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px 15px; text-align: center; min-width: 74px; }
.hero-stats b { font-size: 22px; display: block; color: var(--text); } .hero-stats span { color: var(--muted); font-size: 11px; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-gif img { width: 100%; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); }

/* ===== Favorites / recents strip ===== */
.fav-strip { margin: 0 0 6px; }
.fav-strip h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-2); margin: 14px 0 8px; }
.card-fav { margin-left: 6px; background: none; border: none; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; filter: grayscale(1); opacity: .5; transition: opacity .12s, filter .12s; }
.card-fav.on, .card-fav:hover { filter: none; opacity: 1; }

.gallery-head { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-2); margin: 10px 0 2px; }
.gallery-head:first-child { margin-top: 0; }

/* ===== Save-as-image card (rendered off-screen by html2canvas) ===== */
.img-card { position: fixed; left: -9999px; top: 0; width: 720px; padding: 30px 34px; background: #0d0f14; color: #e7ebf0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.img-card .ic-top { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: #e89b82; }
.img-card .ic-badge { font-size: 13px; color: #6ee7b7; background: rgba(16,185,129,.14); border: 1px solid rgba(16,185,129,.4); border-radius: 99px; padding: 3px 10px; margin-left: auto; }
.img-card .ic-title { font-size: 26px; font-weight: 800; margin: 12px 0 14px; }
.img-card .ic-body { max-height: 760px; overflow: hidden; font-size: 14.5px; line-height: 1.55; }
.img-card .ic-body h1, .img-card .ic-body h2 { font-size: 18px; }
.img-card .ic-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid #2a313c; font-size: 13px; color: #95a0b0; }

/* ===== Make the API-key field impossible to miss when empty ===== */
.key-field input:placeholder-shown { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,119,87,.22); }
.key-field.pulse input { animation: keypulse .45s ease 3; }
@keyframes keypulse { 0%,100% { box-shadow: 0 0 0 3px rgba(217,119,87,.22); } 50% { box-shadow: 0 0 0 7px rgba(217,119,87,.55); } }
.key-hint { font-size: 11px; color: var(--accent-2); font-weight: 600; white-space: nowrap; }
