/* ============================================================
   Fusion Observatory — chat-first shell (additive overrides)
   Loaded AFTER styles.css. Turns the classic side-menu layout
   into a dark Fusion frame with a floating white panel, a
   collapsible sidebar (menu + local chat history + user), a
   shared header action set (Search · Feedback · Ecosystem),
   and the zoom/rotate entrance on the Ecosystem constellation.
   The sidebar markup and #sideUser stay intact so auth.js keeps
   working; shell.js only augments them.
   ============================================================ */

/* ---------- Dark frame ---------- */
body {
  background: #000;
  background-image:
    radial-gradient(120% 80% at 80% -10%, rgba(255,120,20,.16), transparent 60%),
    radial-gradient(90% 70% at -10% 110%, rgba(255,120,20,.10), transparent 55%);
}
.app {
  display: flex; gap: 12px; padding: 12px; height: 100vh;
  box-sizing: border-box; overflow: hidden;
}

/* ---------- Sidebar ---------- */
.side {
  width: 274px; flex: none; background: #0C0D0F;
  border: 1px solid #1D2024; border-right: 1px solid #1D2024;
  border-radius: 20px; overflow: hidden; display: flex; flex-direction: column;
  transition: width .28s cubic-bezier(.3,.8,.3,1);
}
.app.side-collapsed .side { width: 72px; }
.side-head { padding: 15px 14px 8px; }
.logo-text { color: #fff; }
.logo-text small { color: #949CA8; }
.side-collapse {
  width: 31px; height: 31px; border-radius: 9px; border: 1px solid #24272C;
  background: transparent; color: #949CA8; display: grid; place-items: center;
  cursor: pointer; flex: none;
}
.side-collapse:hover { background: #16181C; color: #fff; }
.side-collapse svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; }

.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb { background: #20232a; border-radius: 8px; }
.side-group { color: #5C636D; }
.side-link { color: #B7BCC4; }
.side-link:hover { background: #141619; color: #fff; }
.side-link.active { background: #16181C; color: #fff; }
.side-link.active .ico svg { stroke: var(--fusion-gradient-end); }
/* Accordion parents (shell.js MENU children) */
.side-acc-head { width: 100%; background: none; border: 0; font-family: inherit; text-align: left; cursor: pointer; }
.side-acc-head .lbl { flex: 1; }
.side-acc-head .chev { width: 14px; height: 14px; flex: none; opacity: .6; transition: transform .16s; }
.side-acc.open .side-acc-head .chev { transform: rotate(90deg); }
.side-acc-head.in { color: #fff; }
.side-acc-head.in .ico svg { stroke: var(--fusion-gradient-end); }
.side .side-sub { display: flex; flex-direction: column; margin: 0 0 4px; padding: 0; border: 0; }
.side .side-sub[hidden] { display: none; }
.side .side-sublink { display: block; color: #8B919B; padding: 7px 10px 7px 42px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; }
.side .side-sublink:hover { background: #141619; color: #fff; }
.side .side-sublink.active { background: #16181C; color: #fff; font-weight: 600; }
.app.side-collapsed .side-sub, .app.side-collapsed .side-acc-head .chev { display: none; }
.side-link.cta {
  background: var(--fusion-gradient); color: #241000; font-weight: 600;
  justify-content: center; margin: 4px 2px 6px;
}
.side-link.cta:hover { background: var(--fusion-gradient); color: #241000; filter: brightness(1.05); }
.side-link.cta .ico svg { stroke: #241000; }

/* chat history */
.hist-wrap { margin-top: 6px; }
.hist-item {
  display: block; padding: 8px 11px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; color: #E7E9EC;
}
.hist-item:hover { background: #141619; }
.hist-item.active { background: #16181C; border-color: #26292F; }
.hist-item .h-t { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item .h-d { font-size: 11px; color: #6B727C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.hist-empty { font-size: 11.5px; color: #5C636D; padding: 4px 11px; }

/* user + role */
.side-user { border-top: 1px solid #1D2024; }
.side-user .nm { color: #fff; }
.side-user .em { color: #6B727C; }
.side-user .role-badge {
  display: inline-block; margin-top: 3px; font-size: 10px; font-weight: 600;
  color: #241000; background: var(--fusion-gradient); padding: 2px 7px; border-radius: 6px;
  border: 0; letter-spacing: 0; text-transform: none;
}
.side-user .signout { color: #6B727C; background: transparent; border: 0; cursor: pointer; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.side-user .signout:hover { background: #16181C; color: #fff; }
/* Not signed in: the sidebar offers sign-in instead of a user. */
.side-user:has(.side-signin) { flex-direction: column; align-items: stretch; gap: 6px; }
.side-signin { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: #fff; background: #16181C; border: 1px solid #2A2E34; border-radius: 10px; padding: 9px 12px; }
.side-signin:hover { background: #1F2228; border-color: #3A3F47; }
.side-signin:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.side-signin-note { font-size: 11.5px; color: #6B727C; line-height: 1.4; text-align: center; }
.app.side-collapsed .side-signin span, .app.side-collapsed .side-signin-note { display: none; }

/* collapsed state — icons only, no overflow */
.app.side-collapsed .side-head { justify-content: center; }
.app.side-collapsed .logo, .app.side-collapsed .side-group,
.app.side-collapsed .hist-wrap { display: none; }
.app.side-collapsed .side-link { font-size: 0; justify-content: center; padding: 9px 0; gap: 0; }
.app.side-collapsed .side-link .ico svg { stroke-width: 1.7; }
.app.side-collapsed .side-user { justify-content: center; padding: 12px 0; }
.app.side-collapsed .side-user > div, .app.side-collapsed .side-user .signout { display: none; }

/* ---------- White panel (stage) ---------- */
.stage {
  flex: 1; min-width: 0; height: auto; background: var(--surface);
  border: 1px solid #1D2024; border-radius: 20px; overflow: hidden;
  display: flex; flex-direction: column;
}
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar > div { flex: 1; min-width: 0; }
.topbar h1 { font-size: 16px; }

/* ---------- Shared header actions ---------- */
.hdr-actions { display: flex; gap: 8px; margin-left: auto; flex: none; }
.hdr-actions .icon-btn {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--sub); display: grid; place-items: center; cursor: pointer;
}
.hdr-actions .icon-btn:hover { background: var(--surface-soft); color: var(--ink); }
.hdr-actions .icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.hdr-actions .icon-btn.galaxy { border-color: #F0CE9A; color: #B4560F; }
.hdr-actions .icon-btn.galaxy:hover { background: #FFF6E9; }
.hdr-actions .icon-btn.galaxy svg .g-core { fill: currentColor; stroke: none; }

/* ---------- Overlays (hub search + feedback) ---------- */
.obs-ov { position: fixed; inset: 0; z-index: 95; background: rgba(10,12,20,.5); backdrop-filter: blur(4px); display: none; place-items: flex-start center; padding: 12vh 24px 24px; }
.obs-ov.open { display: grid; }
.obs-card { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-md); padding: 22px; position: relative; animation: obsPop .2s ease; }
@keyframes obsPop { from { transform: translateY(8px) scale(.98); opacity: .6; } to { transform: none; opacity: 1; } }
.obs-close { position: absolute; top: 13px; right: 13px; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--sub); cursor: pointer; }
.obs-h3 { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.obs-p { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.obs-fld { width: 100%; box-sizing: border-box; border: 1px solid var(--line-strong); border-radius: 12px; padding: 11px 13px; font-family: inherit; font-size: 14px; color: var(--ink); background: var(--surface-soft); outline: none; resize: vertical; }
.obs-fld:focus { border-color: var(--fusion-gradient-start); }
.obs-send { margin-top: 12px; background: var(--fusion-gradient); color: #241000; border: 0; border-radius: 11px; padding: 10px 16px; font-weight: 600; font-size: 13px; cursor: pointer; }
.obs-res { margin-top: 12px; max-height: 46vh; overflow-y: auto; }
.obs-sr { display: flex; align-items: center; justify-content: space-between; padding: 9px 11px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.obs-sr:hover { background: var(--surface-soft); border-color: var(--line); }
.obs-sr .sr-t { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.obs-sr .sr-k { font-size: 10.5px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; }
.obs-thanks { text-align: center; padding: 8px 0; }
.obs-thanks b { font-size: 15px; font-weight: 600; }
.obs-thanks span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* ---------- Ecosystem: zoom + rotate entrance ---------- */
.eco-const { transform-origin: 50% 50%; animation: ecoZoomIn 1.05s cubic-bezier(.2,.8,.2,1) both; }
@keyframes ecoZoomIn { from { transform: scale(.32) rotate(-26deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .eco-const { animation: none; } }

/* ---------- Sidebar "wip" badge ---------- */
.side-link .wip {
  margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: #8a5a00; background: rgba(249,197,84,.18); border: 1px solid rgba(249,197,84,.4);
  border-radius: 999px; padding: 1px 6px; line-height: 1.5;
}
.app.side-collapsed .side-link .wip { display: none; }

/* ---------- Getting-started style cards ---------- */
.gs-section { margin-bottom: 34px; }
.gs-h2 { font-size: 19px; font-weight: 600; letter-spacing: -.2px; margin: 0 0 6px; }
.gs-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 12px; margin-top: 16px; }
.gs-card { display: flex; flex-direction: column; gap: 9px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-decoration: none; color: var(--ink); transition: transform .15s, border-color .15s, box-shadow .15s; }
.gs-card:hover { transform: translateY(-3px); border-color: var(--fusion-gradient-start); box-shadow: var(--shadow-sm); }
.gs-card.soon { cursor: default; }
.gs-card.soon:hover { transform: none; border-color: var(--line); box-shadow: none; }
.gs-card .gc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gs-card .gc-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-soft); display: grid; place-items: center; }
.gs-card .gc-ico svg { width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gs-card .gc-t { font-size: 14px; font-weight: 600; letter-spacing: -.1px; }
.gs-card .gc-d { font-size: 12px; color: var(--muted); line-height: 1.45; }
.gs-card .gc-arrow { margin-top: auto; padding-top: 2px; color: var(--fusion-gradient-end); font-size: 12.5px; font-weight: 600; }
.gs-card.soon .gc-t, .gs-card.soon .gc-ico svg { color: var(--sub); }

/* mobile: sidebar becomes the existing drawer; drop the collapse rail */
@media (max-width: 900px) {
  .app { padding: 0; gap: 0; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; border-radius: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .side.open { transform: none; }
  .app.side-collapsed .side { width: 274px; }
  .stage { border-radius: 0; border: 0; }
  .side-collapse { display: none; }
}
