/* TokenHunger host overlay — a fixed top strip rendered outside the React root,
   so it always stands. We reserve space for it (body padding + push the app's
   sticky header below it) so it never overlaps the app's own header. */

body { padding-top: 46px !important; }
.cb-header { top: 46px !important; }      /* OSS sticky header sticks below the bar */

#th-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 46px;
  z-index: 50;                            /* above header (40), below drawers (60) */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: #0e0c0b;                      /* Ember warm-black, matches app canvas */
  color: #f4f1ec;
  font: 13px/1.2 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-shadow: inset 0 -1px 0 rgba(255, 106, 26, 0.18), 0 1px 0 rgba(0, 0, 0, 0.3);
}

/* Flame + two-tone wordmark — same mark as the app header */
#th-bar .th-brand {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: "Poppins", "Inter", sans-serif; font-weight: 600; letter-spacing: -0.01em;
}
#th-bar .th-brand .th-flame { flex: none; display: inline-flex; }
#th-bar .th-brand .tk { color: #f4f1ec; }
#th-bar .th-brand .hg { color: #ff6a1a; }
#th-bar .th-link { color: #9a8f86; text-decoration: none; font-weight: 600; }
#th-bar .th-link:hover { color: #f4f1ec; }
#th-bar .th-spacer { flex: 1; }
#th-bar .th-user { color: #7c736c; }

#th-bar .th-credits {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(52, 214, 160, 0.16);    /* mint = the flame's green core */
  color: #34d6a0;
}

#th-bar .th-btn {
  text-decoration: none;
  font-weight: 600;
  color: #0e0c0b;
  background: #ff6a1a;                      /* ember primary */
  padding: 6px 13px;
  border-radius: 999px;
  transition: transform 0.06s ease, filter 0.12s ease;
}
#th-bar .th-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
#th-bar .th-btn.th-ghost {
  background: transparent;
  color: #9a8f86;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 5px 12px;
}
#th-bar .th-btn.th-ghost:hover { color: #f4f1ec; filter: none; }

/* Anonymous value-prop hero (in flow, below the fixed bar; removed on sign-in) */
#th-hero {
  background: linear-gradient(180deg, #0f1117 0%, #181b24 100%);
  color: #f4f5f7;
  padding: 44px 20px 40px;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#th-hero .th-hero-in { max-width: 860px; margin: 0 auto; }
#th-hero .th-hero-panel {
  margin: 0 auto 24px;
  overflow: hidden;
  border: 1px solid #241c17;
  border-radius: 8px;
  background: #17120f;
  aspect-ratio: 1400 / 788;
}
#th-hero .th-hero-panel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#th-hero .th-eyebrow {
  text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 12px; font-weight: 700; color: #7ee2a0; margin-bottom: 10px;
}
#th-hero h1 {
  font-size: 30px; line-height: 1.15; letter-spacing: -0.02em;
  margin: 0 0 12px; font-weight: 750;
}
#th-hero p {
  font-size: 15px; line-height: 1.6; color: #c7c9d1;
  margin: 0 auto 20px; max-width: 680px;
}
#th-hero .th-hero-copy a {
  color: #7ee2a0;
  font-weight: 650;
  text-underline-offset: 3px;
}
#th-hero .th-promo {
  max-width: 780px;
  margin: 22px auto 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 18px;
  align-items: center;
  text-align: left;
}
#th-hero .th-promo-copy b {
  display: block;
  color: #f4f5f7;
  font-size: 15px;
  margin-bottom: 4px;
}
#th-hero .th-promo-copy span {
  display: block;
  color: #aeb4c0;
  font-size: 13.5px;
  line-height: 1.5;
}
#th-hero .th-promo-frame {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #0e0c0b;
  aspect-ratio: 9 / 16;
}
#th-hero .th-promo-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
#th-hero .th-diff {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 780px;
  margin: 22px auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
}
#th-hero .th-diff-item {
  padding: 15px 18px;
}
#th-hero .th-diff-item + .th-diff-item {
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}
#th-hero .th-diff b {
  display: block;
  margin-bottom: 5px;
  color: #f4f5f7;
  font-size: 13.5px;
}
#th-hero .th-diff span {
  display: block;
  color: #aeb4c0;
  font-size: 13px;
  line-height: 1.5;
}
#th-hero .th-diff code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #d6f5df;
  background: rgba(126, 226, 160, 0.12);
  padding: 1px 4px;
  border-radius: 4px;
}
#th-hero .th-hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
#th-hero .th-hero-cta .th-btn {
  text-decoration: none; font-weight: 600; color: #0b0c0f;
  background: #fff; padding: 9px 18px; border-radius: 999px;
}
#th-hero .th-hero-cta .th-btn.th-ghost {
  background: transparent; color: #c7c9d1; border: 1px solid rgba(255, 255, 255, 0.22);
}
#th-hero .th-hero-note { margin-top: 16px; font-size: 12.5px; color: #8b909c; }

@media (max-width: 640px) {
  #th-hero { padding: 34px 16px 32px; }
  #th-hero h1 { font-size: 25px; }
  #th-hero .th-promo {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  #th-hero .th-promo-frame {
    width: min(100%, 260px);
  }
  #th-hero .th-diff { grid-template-columns: 1fr; }
  #th-hero .th-diff-item + .th-diff-item {
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }
}

/* Live run progress bar (driven by run-stream events) */
#th-progress {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9998;
  height: 30px;
  background: #0b0908;
  display: flex;
  align-items: center;
  transform: translateY(34px);
  transition: transform 0.2s ease;
}
#th-progress.th-show { transform: translateY(0); }
#th-progress .th-pfill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0; background: linear-gradient(90deg, #ff6a1a, #34d6a0);  /* burn → lean */
  transition: width 0.3s ease;
}
#th-progress .th-plabel {
  position: relative; z-index: 1;
  color: #fff; font: 12px/1 "JetBrains Mono", ui-monospace, Menlo, monospace;
  padding-left: 14px; font-variant-numeric: tabular-nums;
}

/* Toast for gate messages (login / credits) */
#th-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 24px);
  z-index: 9999;
  max-width: 90vw;
  padding: 11px 16px;
  border-radius: 10px;
  font: 14px/1.35 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f4f1ec;
  background: #17120f;
  border: 1px solid #241c17;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#th-toast.th-show { opacity: 1; transform: translate(-50%, 0); }
#th-toast.th-warn { background: #2a1a10; border-color: #5a2f12; }
#th-toast.th-info { background: #17120f; }

/* Live cost recommendation — un-hides the price + cheapest models the host already
   computes on every estimate. Sibling of #root (React-safe), docked bottom-right,
   floating above where the run-progress bar appears. */
#th-rec {
  position: fixed;
  right: 16px;
  bottom: 44px;                 /* clears the 30px run-progress bar */
  z-index: 49;                  /* below the top bar (50); transient toast/progress sit above */
  width: 320px;
  max-width: calc(100vw - 32px);
  background: #17120f;
  color: #f4f1ec;
  border: 1px solid #241c17;
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  font: 13px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 13px 15px 14px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#th-rec.th-show { opacity: 1; transform: translateY(0); pointer-events: auto; }

#th-rec .th-rec-head { display: flex; align-items: center; margin-bottom: 9px; }
#th-rec .th-rec-title {
  flex: 1;
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: #34d6a0;
}
#th-rec .th-rec-x {
  border: 0; background: transparent; color: #7c736c; cursor: pointer;
  font-size: 17px; line-height: 1; padding: 0 2px;
}
#th-rec .th-rec-x:hover { color: #f4f1ec; }

#th-rec .th-rec-list { list-style: none; margin: 0 0 9px; padding: 0; }
#th-rec .th-rec-list li {
  display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 9px;
  padding: 4px 0; border-bottom: 1px solid #241c17;
}
#th-rec .th-rec-list li:last-child { border-bottom: 0; }
#th-rec .th-rec-rank { color: #7c736c; font-variant-numeric: tabular-nums; font-size: 12px; }
#th-rec .th-rec-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12.5px; color: #f4f1ec;
}
#th-rec .th-rec-best .th-rec-name { font-weight: 700; }
#th-rec .th-rec-best .th-rec-rank { color: #34d6a0; }
#th-rec .th-rec-cost {
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; font-size: 12.5px; color: #ff6a1a; white-space: nowrap;
}

#th-rec .th-rec-spread {
  font-size: 12px; color: #9a8f86; margin-bottom: 11px; font-variant-numeric: tabular-nums;
}
#th-rec .th-rec-spread b { color: #f4f1ec; }

#th-rec .th-rec-cta { display: flex; flex-direction: column; gap: 3px; }
#th-rec .th-rec-run {
  display: block; text-align: center; text-decoration: none;
  background: #ff6a1a; color: #0e0c0b; font-weight: 700;
  padding: 8px 12px; border-radius: 999px;
  transition: transform 0.06s ease, filter 0.12s ease;
}
#th-rec .th-rec-run:hover { transform: translateY(-1px); filter: brightness(1.06); }
#th-rec .th-rec-run-info { font-weight: 600; color: #f4f1ec; }
#th-rec .th-rec-sub { font-size: 11.5px; color: #7c736c; }
#th-rec .th-rec-note { font-size: 12px; color: #9a8f86; }
#th-rec .th-rec-note.th-warn { color: #e8a06a; }

@media (max-width: 640px) {
  #th-rec { right: 8px; left: 8px; bottom: 38px; width: auto; }
}

/* Raw API dollars are owner-only — users see credits + the relative spread.
   These selectors target OSS (costbench) classes the host can't edit, so it
   hides them here and reveals them under body.th-owner (set in overlay.js once
   /api/me resolves; absent = treated as a user, so cost never flashes).
   NOTE: this couples to OSS class names — `.cb-estchip`/`.cb-estpanel`/
   `.cb-cheapest-*`. A future costbench pin that renames them would silently let
   dollars resurface; the overlay smoke test guards against that.
     - cb-estchip lab/amt/div : RunBar "Est. cost $X–$Y" (keep .meta tokens/cases)
     - cb-disclosure/estpanel : the per-model "Estimate detail" cost breakdown
     - cb-cheapest .price      : per-model $ in the OSS "Cheapest to try" panel
     - cb-cheapest-foot .spread: that panel's "$X vs $Y · N×" (overlay supplies N×) */
body:not(.th-owner) .cb-estchip .lab,
body:not(.th-owner) .cb-estchip .amt,
body:not(.th-owner) .cb-estchip .div,
body:not(.th-owner) .cb-disclosure,
body:not(.th-owner) .cb-estpanel,
body:not(.th-owner) .cb-cheapest-row .price,
body:not(.th-owner) .cb-cheapest-foot .spread {
  display: none !important;
}

/* De-dupe the brand. The host top bar (#th-bar) already shows the flame +
   wordmark; the OSS app header (.cb-header) repeats it. Hide only the OSS
   header's logo (flame + wordmark) — its tagline (.sub) + Connectors/theme
   controls stay. Scoped to .cb-header so the host bar's own mark is untouched
   (both share the th-flame/.wm classes). Couples to OSS class names; if a
   costbench pin renames them the duplicate logo reappears (cosmetic only). */
.cb-header .th-flame,
.cb-header .wm {
  display: none !important;
}

/* --- Bring-your-own-data import modal ---------------------------------- */
/* The host bar's .th-link is an <a>; the import opener is a <button> — reset it
   so it matches the other nav links instead of looking like a form control. */
#th-bar .th-link-btn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-weight: 600;
}

#th-im {
  position: fixed; inset: 0; z-index: 9990;
  background: rgba(0, 0, 0, 0.62);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
#th-im .th-im-card {
  width: 92%; max-width: 560px; max-height: 88vh; overflow: auto;
  background: #17120f; color: #f4f1ec;
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
#th-im .th-im-head { display: flex; align-items: center; justify-content: space-between; }
#th-im .th-im-head b { font-size: 16px; }
#th-im .th-im-x {
  background: none; border: 0; color: #9a8f86; font-size: 22px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
#th-im .th-im-x:hover { color: #f4f1ec; }
#th-im .th-im-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 10px; }
#th-im .th-im-tab {
  background: transparent; color: #9a8f86; cursor: pointer; font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 5px 12px;
}
#th-im .th-im-tab.th-on { color: #0e0c0b; background: #ff6a1a; border-color: #ff6a1a; }
#th-im .th-hide { display: none; }
#th-im .th-im-hint { color: #9a8f86; font-size: 13px; margin: 4px 0 8px; }
#th-im .th-im-hint code {
  background: rgba(255, 255, 255, 0.07); padding: 1px 5px; border-radius: 5px; color: #d8cfc7;
}
#th-im .th-im-text, #th-im .th-im-f {
  width: 100%; box-sizing: border-box;
  background: #0e0c0b; color: #f4f1ec;
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 8px;
  padding: 8px 10px; font: inherit; margin-bottom: 8px;
}
#th-im .th-im-text { resize: vertical; min-height: 120px; font-family: ui-monospace, monospace; font-size: 13px; }
#th-im .th-im-row { display: flex; gap: 8px; }
#th-im .th-im-row .th-im-f { flex: 1; }
#th-im .th-im-adv { margin: 4px 0 2px; }
#th-im .th-im-adv summary { color: #9a8f86; cursor: pointer; font-weight: 600; margin-bottom: 8px; }
#th-im .th-im-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
#th-im .th-im-status { color: #9a8f86; font-size: 13px; }
#th-im .th-im-status.th-warn { color: #e8a06a; }
#th-im .th-im-btn {
  text-decoration: none; font-weight: 600; color: #0e0c0b; background: #ff6a1a;
  border: 0; cursor: pointer; padding: 8px 15px; border-radius: 999px;
  transition: transform 0.06s ease, filter 0.12s ease;
}
#th-im .th-im-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
#th-im .th-im-btn:disabled { opacity: 0.6; cursor: default; transform: none; filter: none; }
#th-im .th-im-btn.th-ghost {
  background: transparent; color: #ff6a1a;
  border: 1px solid rgba(255, 106, 26, 0.5);
}
#th-im .th-im-btn.th-ghost:hover { filter: none; background: rgba(255, 106, 26, 0.1); }

/* Site footer — legal/info links (privacy, terms, contact, …). Sibling of
   #root, appended by overlay.js mountFooter(). Plain flow, full width. */
#th-footer {
  max-width: 980px; margin: 48px auto 0; padding: 20px 24px 40px;
  border-top: 1px solid #241c17;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  font-size: 13px; color: #7c736c;
}
#th-footer .th-foot-c { color: #9a8f86; margin-right: auto; }
#th-footer a { color: #9a8f86; text-decoration: none; }
#th-footer a:hover { color: #f4f1ec; }
