/* ============================================================================
   ORBIT AI — styles (dark theme, amber branding)
   Self-contained; uses its own variables so it works on both dashboards.
   ============================================================================ */
.oai-root {
  --oai-amber: #f5930a;
  --oai-amber-h: #ffb23e;
  --oai-bg: #0e1014;
  --oai-bg2: #15181e;
  --oai-line: #262b34;
  --oai-text: #e8ecf3;
  --oai-muted: #8a96a8;
  /* --oai-bottom-inset: clearance for a page's own fixed bottom bar. The
     launcher is bottom-right fixed, so on pages that also pin a bar to the
     bottom on mobile it landed ON the bar — on owner-dashboard it covered the
     "More" tab, and at z-index 9000 vs the bar's 200 it took the tap, so More
     opened Orbit AI instead of the sheet. Pages owning such a bar declare its
     height inside their own mobile media query; everyone else inherits 0px. */
  position: fixed; right: 24px; bottom: calc(24px + var(--oai-bottom-inset, 0px)); z-index: 9000;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* launcher */
.oai-fab {
  position: relative; width: 58px; height: 58px; border-radius: 50%;
  border: none; cursor: pointer; color: #1a1205;
  background: linear-gradient(135deg, var(--oai-amber), var(--oai-amber-h));
  box-shadow: 0 10px 30px rgba(245, 147, 10, .4), 0 2px 8px rgba(0, 0, 0, .3);
  display: grid; place-items: center; transition: transform .2s ease, box-shadow .2s ease;
  animation: oai-rise .4s cubic-bezier(.2, .8, .2, 1);
}
.oai-fab svg { width: 30px; height: 30px; position: relative; z-index: 1; animation: oai-spin 18s linear infinite; }
.oai-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 16px 40px rgba(245, 147, 10, .5); }
.oai-fab.hidden { display: none; }
.oai-dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: #ff5a5a; border: 2px solid var(--oai-bg); box-shadow: 0 0 0 2px rgba(255,90,90,.3); animation: oai-pulse 2s ease-in-out infinite; }
.oai-fab-glow { position: absolute; inset: -4px; border-radius: 50%; background: var(--oai-amber); opacity: .35; filter: blur(10px); animation: oai-pulse 2.6s ease-in-out infinite; }

/* ── PROACTIVE NUDGE — the brief reaches the owner without a click.
   Appears above the FAB on dashboard load ONLY when there's something
   genuinely actionable (never for "all clear" days — that's what the
   quiet dot is for, no need to interrupt with good news). ── */
.oai-nudge {
  position: fixed; right: 24px; bottom: calc(96px + var(--oai-bottom-inset, 0px)); z-index: 8999;
  width: min(320px, calc(100vw - 48px));
  background: var(--oai-bg2); border: 1px solid var(--oai-line); border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 16px 44px rgba(0,0,0,.5);
  font-family: 'Inter', system-ui, sans-serif; color: var(--oai-text);
  opacity: 0; transform: translateY(10px) scale(.97); pointer-events: none;
  transition: opacity .35s cubic-bezier(.22,1,.36,1), transform .35s cubic-bezier(.22,1,.36,1);
}
.oai-nudge.on { opacity: 1; transform: none; pointer-events: all; }
.oai-nudge-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.oai-nudge-tag { display: flex; align-items: center; gap: 6px; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--oai-amber-h); font-weight: 600; }
.oai-nudge-tag .d { width: 6px; height: 6px; border-radius: 50%; background: var(--oai-amber); box-shadow: 0 0 6px var(--oai-amber); }
.oai-nudge-x { background: none; border: none; color: var(--oai-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; }
.oai-nudge-x:hover { color: var(--oai-text); }
.oai-nudge-body { font-size: 13px; line-height: 1.5; color: var(--oai-text); margin-bottom: 10px; }
.oai-nudge-body b { color: var(--oai-amber-h); }
.oai-nudge-cta { font-size: 12.5px; font-weight: 600; color: var(--oai-amber-h); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.oai-nudge-cta:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .oai-nudge { transition: opacity .15s; } }
@media (max-width: 520px) { .oai-nudge { right: 12px; left: 12px; width: auto; bottom: calc(88px + var(--oai-bottom-inset, 0px)); } }
@keyframes oai-pulse { 0%, 100% { transform: scale(1); opacity: .3; } 50% { transform: scale(1.18); opacity: .12; } }
@keyframes oai-spin { to { transform: rotate(360deg); } }
@keyframes oai-rise { from { transform: translateY(20px) scale(.8); opacity: 0; } }

/* panel */
.oai-panel {
  position: absolute; right: 0; bottom: 0; width: 384px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - 48px);
  background: radial-gradient(140% 100% at 100% 0%, rgba(245,147,10,.05), transparent 45%), var(--oai-bg);
  border: 1px solid var(--oai-line); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55), 0 0 0 1px rgba(245,147,10,.04), 0 0 40px rgba(245,147,10,.03);
  display: none; flex-direction: column; overflow: hidden;
  transform-origin: bottom right;
}
.oai-panel.on { display: flex; animation: oai-open .26s cubic-bezier(.2, .8, .2, 1); }
@keyframes oai-open { from { transform: translateY(16px) scale(.96); opacity: 0; } }

.oai-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--oai-line); background: linear-gradient(180deg, var(--oai-bg2), var(--oai-bg)); }
.oai-brand { display: flex; align-items: center; gap: 11px; }
.oai-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #1a1205; background: linear-gradient(135deg, var(--oai-amber), var(--oai-amber-h)); box-shadow: 0 4px 14px rgba(245, 147, 10, .35); }
.oai-mark svg { width: 22px; height: 22px; animation: oai-spin 24s linear infinite; }
.oai-name { font-size: 15px; font-weight: 800; color: var(--oai-text); letter-spacing: .2px; }
.oai-sub { font-size: 11px; color: var(--oai-amber); font-weight: 600; margin-top: 1px; }
.oai-x { background: none; border: none; color: var(--oai-muted); cursor: pointer; padding: 6px; border-radius: 8px; transition: background .15s, color .15s; }
.oai-x:hover { background: var(--oai-bg2); color: var(--oai-text); }
.oai-x svg { width: 18px; height: 18px; }

.oai-hist-btn { background: none; border: none; color: var(--oai-muted); cursor: pointer; padding: 7px; border-radius: 8px; transition: background .15s, color .15s; margin-right: 4px; }
.oai-hist-btn:hover { background: var(--oai-bg2); color: var(--oai-text); }
.oai-hist-btn svg { width: 18px; height: 18px; }

.oai-model-btn { display: flex; align-items: center; gap: 6px; background: linear-gradient(135deg, var(--oai-bg2), var(--oai-bg)); border: 1px solid var(--oai-line); color: var(--oai-text); font-size: 12.5px; font-weight: 700; padding: 6px 11px; border-radius: 9px; cursor: pointer; transition: border-color .18s, box-shadow .18s; }
.oai-model-btn:hover { border-color: var(--oai-amber); box-shadow: 0 0 0 1px rgba(245,147,10,.15); }
.oai-model-btn svg { width: 13px; height: 13px; opacity: .6; }
.oai-model-btn-ic { font-size: 13px; line-height: 1; }

.oai-model-menu { display: none; position: absolute; top: 58px; right: 54px; z-index: 30; background: linear-gradient(160deg, var(--oai-bg2), var(--oai-bg)); border: 1px solid var(--oai-line); border-radius: 16px; padding: 8px; width: 288px; box-shadow: 0 20px 50px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.03) inset; }
.oai-model-menu.on { display: block; animation: oai-model-in .18s cubic-bezier(.2,.8,.2,1); }
@keyframes oai-model-in { from { opacity: 0; transform: translateY(-6px); } }

.oai-model-opt { display: flex; gap: 12px; padding: 12px; border-radius: 12px; cursor: pointer; transition: background .15s; border: 1px solid transparent; }
.oai-model-opt:hover { background: rgba(255,255,255,.03); }
.oai-model-opt.on { background: rgba(245, 147, 10, .07); border-color: rgba(245, 147, 10, .18); }
.oai-model-opt + .oai-model-opt { margin-top: 3px; }

.oai-model-opt-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.oai-model-ic-swift { background: linear-gradient(150deg, rgba(245,147,10,.22), rgba(245,147,10,.08)); }
.oai-model-ic-pulse { background: linear-gradient(150deg, rgba(45,212,191,.22), rgba(45,212,191,.08)); }
.oai-model-ic-nexus { background: linear-gradient(150deg, rgba(167,139,250,.22), rgba(167,139,250,.08)); }

.oai-model-opt-body { flex: 1; min-width: 0; }
.oai-model-opt-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.oai-model-opt-name { font-size: 13.5px; font-weight: 800; color: var(--oai-text); letter-spacing: -.1px; }
.oai-model-opt-check { color: var(--oai-amber); font-size: 13px; opacity: 0; flex: none; }
.oai-model-opt.on .oai-model-opt-check { opacity: 1; }
.oai-model-opt-tag { font-size: 9.5px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: #a78bfa; background: rgba(167,139,250,.14); padding: 2px 8px; border-radius: 6px; flex: none; }
.oai-model-opt-desc { font-size: 11.5px; color: var(--oai-muted); margin-top: 3px; line-height: 1.4; }
.oai-model-opt-warn { font-size: 10.5px; color: #fbbf24; margin-top: 6px; font-weight: 600; display: flex; align-items: center; gap: 4px; }

.oai-hist-panel { display: none; position: absolute; top: 58px; left: 0; right: 0; bottom: 70px; z-index: 25; background: var(--oai-bg); border-bottom: 1px solid var(--oai-line); flex-direction: column; }
.oai-hist-panel.on { display: flex; }
.oai-hist-toolbar { display: flex; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--oai-line); }
.oai-hist-toolbar input { flex: 1; background: var(--oai-bg2); border: 1px solid var(--oai-line); border-radius: 8px; padding: 8px 10px; color: var(--oai-text); font-size: 12.5px; }
.oai-hist-new { background: var(--oai-amber); color: #1a1205; border: none; border-radius: 8px; padding: 8px 12px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.oai-hist-list { flex: 1; overflow-y: auto; padding: 6px; }
.oai-hist-item { padding: 10px 12px; border-radius: 9px; cursor: pointer; transition: background .15s; position: relative; }
.oai-hist-item:hover { background: var(--oai-bg2); }
.oai-hist-item.active { background: rgba(245, 147, 10, .1); }
.oai-hist-title { font-size: 12.5px; color: var(--oai-text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 16px; }
.oai-hist-when { font-size: 10.5px; color: var(--oai-muted); margin-top: 2px; }
.oai-hist-pin { position: absolute; top: 10px; right: 10px; color: var(--oai-amber); font-size: 11px; }
.oai-hist-empty { padding: 24px 14px; text-align: center; color: var(--oai-muted); font-size: 12.5px; }

.oai-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.oai-body::-webkit-scrollbar { width: 7px; }
.oai-body::-webkit-scrollbar-thumb { background: var(--oai-line); border-radius: 4px; }

.oai-msg { display: flex; max-width: 88%; }
.oai-msg-in { padding: 11px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; word-wrap: break-word; }
.oai-bot { align-self: flex-start; }
.oai-bot .oai-msg-in { background: var(--oai-bg2); color: var(--oai-text); border: 1px solid var(--oai-line); border-bottom-left-radius: 5px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.oai-user { align-self: flex-end; }
.oai-user .oai-msg-in { background: linear-gradient(135deg, var(--oai-amber), var(--oai-amber-h)); color: #1a1205; font-weight: 500; border-bottom-right-radius: 5px; box-shadow: 0 3px 12px rgba(245,147,10,.25); }

.oai-typing { display: flex; gap: 5px; align-items: center; }
.oai-dots { display: flex; gap: 5px; align-items: center; }
.oai-link { color: var(--oai-amber-h); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.oai-link:hover { color: var(--oai-amber); }
.oai-typing .oai-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--oai-muted); animation: oai-blink 1.3s infinite both; }
.oai-typing .oai-dots span:nth-child(2) { animation-delay: .2s; }
.oai-typing .oai-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes oai-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.oai-suggest { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 18px 12px; }
.oai-chip { font-size: 12px; color: var(--oai-muted); background: var(--oai-bg2); border: 1px solid var(--oai-line); border-radius: 16px; padding: 7px 12px; cursor: pointer; transition: border-color .15s, color .15s; }
.oai-chip:hover { border-color: var(--oai-amber); color: var(--oai-text); }

.oai-followups { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.oai-followup { font-size: 11.5px; color: var(--oai-amber); background: rgba(245,147,10,.08); border: 1px solid rgba(245,147,10,.25); border-radius: 14px; padding: 5px 11px; cursor: pointer; transition: background .15s; }
.oai-followup:hover { background: rgba(245,147,10,.16); }

.oai-input { display: flex; align-items: flex-end; gap: 9px; padding: 12px 14px; border-top: 1px solid var(--oai-line); background: var(--oai-bg2); }
.oai-input textarea { flex: 1; resize: none; background: var(--oai-bg); border: 1px solid var(--oai-line); border-radius: 11px; color: var(--oai-text); font: inherit; font-size: 13.5px; padding: 10px 13px; line-height: 1.4; max-height: 120px; outline: none; transition: border-color .15s; }
.oai-input textarea:focus { border-color: var(--oai-amber); }
.oai-send { flex: none; width: 40px; height: 40px; border-radius: 11px; border: none; cursor: pointer; color: #1a1205; background: linear-gradient(135deg, var(--oai-amber), var(--oai-amber-h)); display: grid; place-items: center; transition: transform .15s, opacity .15s; }
.oai-send:hover { transform: scale(1.06); }
.oai-send:disabled { opacity: .5; cursor: default; transform: none; }
.oai-send svg { width: 18px; height: 18px; }

@media (max-width: 480px) {
  .oai-root { right: 16px; bottom: calc(16px + var(--oai-bottom-inset, 0px)); }
  .oai-panel { width: calc(100vw - 24px); height: calc(100vh - 90px); }
}

/* ── Error / timeout bubble + Retry (reliability phase) ── */
.oai-error { background: rgba(255,92,108,.10); border: 1px solid rgba(255,92,108,.35); color: #ffb3ba; }
.oai-retry { display: inline-block; margin-top: 9px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--oai-amber); background: var(--oai-amber); color: #1a1205; font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: inherit; }
.oai-retry:hover { filter: brightness(1.05); }

/* ── Rotating progress text next to the typing dots (reliability v2) ── */
.oai-typing { display: flex; align-items: center; gap: 9px; }
.oai-dots { display: inline-flex; gap: 3px; }
.oai-progress { font-size: 12px; color: var(--oai-text-dim, #8a9ab0); font-style: italic; animation: oaiFade .4s ease; }
@keyframes oaiFade { from { opacity: 0; } to { opacity: 1; } }

/* ── Failure-recovery action row ── */
.oai-err-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.oai-err-btn { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--oai-line, rgba(255,255,255,.15)); background: transparent; color: var(--oai-text, #e8edf4); font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; }
.oai-err-btn:hover { background: var(--oai-bg2, rgba(255,255,255,.06)); }
