/* ==========================================================================
   MUSE SHELL — Muse-style app shell for Ask Big Mama (branch muse-look-clone)
   --------------------------------------------------------------------------
   Layout/UX patterns only — no Muse branding, logos, or name. Big Mama
   branding, gold BM mark, Midnight Pro tokens, and all 34 holiday themes
   are untouched: this file only READS the existing tokens
   (--bg, --bg2, --surface, --sidebar, --card, --text, --muted, --border,
   --accent, --accent-soft) plus the holiday vars holiday-theme.js sets
   (--holiday-bg, --holiday-bg2, --holiday-sidebar, --holiday-card).
   On phones (<1024px) the app keeps its current bottom-tab layout; the
   sidebar becomes a slide-over, and only the composer pill + in-chat
   call card change. Nothing here removes a feature or a route.
   ========================================================================== */

/* ---------- Sidebar (all widths) ---------- */
#muse-sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 70;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  min-height: 0;
}
.sb-brand .logo-mark { width: 32px; height: 32px; border-radius: 9px; flex: none; }
.sb-brand-name { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-collapse {
  background: none; border: none; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
}
.sb-collapse:hover { background: rgba(255,255,255,.07); color: var(--text); }
.sb-new {
  margin: 2px 12px 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--accent); color: #1a1206; border: none;
  font-size: 14px; font-weight: 700; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 8px;
}
.sb-new:active { transform: scale(.98); }
.sb-search {
  margin: 0 12px 8px; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 14px; width: calc(100% - 24px);
}
.sb-search::placeholder { color: var(--muted); }
.sb-nav { display: flex; flex-direction: column; gap: 1px; padding: 2px 8px; }
.sb-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 10px; border-radius: 9px; border: none; background: none;
  color: var(--text); font-size: 14.5px; font-weight: 550; cursor: pointer; text-align: left;
}
.sb-item:hover { background: rgba(255,255,255,.06); }
.sb-item.active { background: var(--accent-soft); color: var(--accent); }
.sb-item .sb-ico { font-size: 17px; width: 22px; text-align: center; flex: none; }
.sb-item .sb-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-section {
  font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted); padding: 14px 18px 6px;
}
#sidebar-conv-list {
  flex: 1; overflow-y: auto; padding: 0 8px 8px; min-height: 60px;
}
#sidebar-conv-list .list-item {
  padding: 9px 10px; border-radius: 9px; margin-bottom: 2px; cursor: pointer;
}
#sidebar-conv-list .list-item:hover { background: rgba(255,255,255,.06); }
#sidebar-conv-list .list-item > div:first-child {
  font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#sidebar-conv-list .list-item .checkin-btn, #sidebar-conv-list .list-item .del-btn { display: none; }
/* Keep just Open visible in the rail: a tap opens the chat. Rename/share/
   delete stay in More → My conversations, exactly as before. */
#sidebar-conv-list .list-item [data-open-conv] { display: inline-flex !important; }
.sb-foot {
  border-top: 1px solid var(--border); padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.sb-plan { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-foot button {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.sb-foot button:hover { color: var(--text); }
#sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 65;
}

/* ---------- Activity status strip: Midnight Pro tokens ----------
   ROOT CAUSE of the white bar: .activity-snippet never had a style
   rule anywhere, so the <button> rendered with the browser's default
   light button face on the dark theme. Flat #171717-family tokens,
   no gradients/glows. Applies at every width, not just desktop. */
#mama-activity-snippet {
  display: block; width: 100%;
  background: var(--surface); color: var(--text);
  border: none; border-bottom: 1px solid var(--border); border-radius: 0;
  padding: 10px 16px; font-size: 13.5px; font-weight: 600; text-align: left;
  cursor: pointer;
}
#mama-activity-snippet:hover { background: var(--bg2); }
html[data-holiday] #mama-activity-snippet { background: var(--holiday-card, var(--surface)); }

/* ---------- Desktop shell (Muse-style): sidebar + centered column ---------- */
@media (min-width: 1024px) {
  body { max-width: none; display: block; margin-left: 0; }
  #app-view {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
    height: 100dvh;
    min-height: 100dvh;
  }
  /* Layout B — Floating Rail: the rail is the in-flow column; the full
     sidebar is an OVERLAY above the chat (fixed, left of the rail's right
     edge), so opening it never squeezes the chat. It is hidden off-canvas
     until body.sb-overlay-open, and the backdrop dismisses it. */
  #muse-rail { grid-column: 1; grid-row: 1 / -1; }
  #muse-sidebar {
    position: fixed; left: 72px; top: 0; bottom: 0; width: 280px; max-width: 84vw;
    z-index: 80; /* above the backdrop (65) and the rail (75) */
    /* LIVE FIX 2026-11-16: translateX(-110%) only moved the 280px sidebar
       308px left from left:72px, leaving a 44px strip visible that covered
       the rail's buttons (icons clipped to slivers, "Log out" read "out",
       the « button peeked out). -100% - 72px clears the viewport exactly. */
    transform: translateX(calc(-100% - 72px)); transition: transform .25s ease-out;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  body.sb-overlay-open #muse-sidebar { transform: none; }
  body.sb-overlay-open { overflow: hidden; }
  #app-view > header { grid-column: 2; grid-row: 1; }
  #mama-activity-snippet { grid-column: 2; grid-row: 2; }
  #upgrade-banner { grid-column: 2; grid-row: 3; }
  #pw-nudge { grid-column: 2; grid-row: 4; }
  #install-banner { grid-column: 2; grid-row: 5; }
  #app-view > main { grid-column: 2; grid-row: 6; min-height: 0; }
  #tabbar { display: none !important; } /* sidebar replaces the bottom tabs */
  /* Layout B: the old sb-collapsed rules are deleted. The 72px rail is
     now the default grid, and nothing sets sb-collapsed any more — the
     class would have hidden the overlay sidebar's labels, search, and
     chats list, so dead rules are a live hazard here. */
  /* Centered chat column, Muse-style. */
  #view-chat #messages, #view-chat #chips, #view-chat #starter-card,
  #view-chat #attach-chip, #view-chat #mic-hint {
    width: 100%; max-width: 768px; margin-left: auto; margin-right: auto;
  }
  #view-chat #convo-view { width: 100%; max-width: 768px; margin-left: auto; margin-right: auto; }
  #view-chat #composer { width: 100%; max-width: 768px; margin-left: auto; margin-right: auto; }
  /* Other tabs get a wider centered column; their cards keep working as-is. */
  #view-reminders > *, #view-goals > *, #view-more > * { width: 100%; max-width: 860px; margin-left: auto; margin-right: auto; }
  #app-view > header { max-width: 860px; width: 100%; margin: 0 auto; }
  /* Sidebar toggle in the header collapses the rail on desktop. */
  #sidebar-toggle { display: inline-flex !important; }
  /* Legacy history drawer: the new sidebar IS the chats list at
     desktop widths. ROOT CAUSE of the duplication: a pre-shell rule
     in styles.css (@media min-width:1150px) pins .drawer open with
     `transform: none !important` and hides its backdrop, so the
     drawer rendered beside the new sidebar and Close/backdrop could
     never dismiss it (removing .open changes nothing under
     !important). Kill it outright at desktop widths — the sidebar
     list + More > My conversations keep every drawer action — and
     hide the header history button that only opens it. The drawer
     keeps its normal slide-over behaviour below 1024px. */
  #history-drawer { display: none !important; }
  #history-backdrop { display: none !important; }
  #history-btn { display: none !important; }
}


/* ---------- Floating Rail (Layout B, desktop) ----------
   Slim 72px icon rail, always visible at >=1024px. Midnight Pro tokens
   only: flat #171717-family sidebar background, white text, muted gold
   #c9a86a accent — no gradients/glows. Tooltips come from data-tip on
   hover/focus (title attribute is the fallback). */
/* LIVE FIX 2026-11-16: a horizontal scrollbar appeared at desktop widths
   (the suggestion-chip row is intentionally scrollable — #chips already
   has overflow-x:auto in styles.css — so the page itself must never
   scroll sideways). overflow-x:clip contains it without creating a
   scroll container, so sticky/fixed children keep working. */
html, body { overflow-x: clip; }
#muse-rail {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 10px 0; min-height: 0; overflow-y: auto;
  position: relative; z-index: 75;
}
.rail-btn {
  position: relative;
  width: 48px; height: 48px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 12px;
  color: var(--text); font-size: 20px; cursor: pointer;
}
.rail-btn:hover, .rail-btn:focus-visible { background: rgba(255,255,255,.06); outline: none; }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.rail-btn .logo-mark { width: 32px; height: 32px; border-radius: 9px; }
.rail-sep { width: 32px; border-top: 1px solid var(--border); margin: 6px 0; flex: none; }
#rail-settings { margin-top: auto; }
.rail-btn[data-tip]:hover::after, .rail-btn[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600;
  white-space: nowrap; z-index: 90; pointer-events: none;
}

/* ---------- Phone / narrow: sidebar is a slide-over, tabs stay ---------- */
@media (max-width: 1023px) {
  /* Layout B, phone choice: NO rail. A 72px left rail + the existing
     bottom tab bar would crowd a 360px phone; the bottom tabs already
     are the phone rail, and the sidebar keeps its slide-over. */
  #muse-rail { display: none !important; }
  #muse-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 300px; max-width: 84vw;
    transform: translateX(-105%); transition: transform .25s ease-out;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  body.sb-open #muse-sidebar { transform: none; }
  body.sb-open { overflow: hidden; }
  #sidebar-toggle { display: inline-flex !important; }
}
@media (min-width: 1024px) {
  /* Layout B: the backdrop must show while the overlay sidebar is open,
     so a tap outside it dismisses it; hidden the rest of the time. */
  body:not(.sb-overlay-open) #sidebar-backdrop { display: none !important; }
  body.sb-overlay-open #sidebar-backdrop { display: block !important; }
}

/* ---------- Composer: Muse-style pill (all widths) ---------- */
#composer {
  border-radius: 24px !important;
  padding: 6px 8px !important;
  gap: 4px;
}
#composer:focus-within { border-color: rgba(201,168,106,.55); }
#chat-input { font-size: 16px; }
#call-btn.in-call { color: var(--accent); animation: pulse 1.2s infinite; }

/* ---------- In-chat voice call card (replaces the full-screen takeover) ----------
   The same #convo-view markup + ids, now living inside #view-chat above the
   composer, so the call stays in the thread: you see the chat, the captions,
   and the orb, and you can keep typing. Tap the logo orb to interrupt,
   End to hang up — both handlers untouched. */
#view-chat #convo-view {
  position: static;
  inset: auto;
  z-index: 5;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin: 8px 2px;
  animation: none;
  flex: none;
}
#view-chat #convo-view.hidden { display: none !important; }
#view-chat .convo-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 12px;
  row-gap: 6px;
  width: 100%;
  max-width: none;
  text-align: left;
  align-items: center;
}
#view-chat #convo-orb {
  grid-column: 1; grid-row: 1;
  width: 52px; height: 52px; margin: 0;
}
#view-chat #convo-status {
  grid-column: 2; grid-row: 1;
  margin: 0; font-size: 15px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#view-chat #convo-end {
  grid-column: 3; grid-row: 1;
  padding: 8px 12px; font-size: 13px; white-space: nowrap;
}
#view-chat #convo-captions {
  grid-column: 1 / -1; grid-row: 2;
  max-height: 110px; margin: 0; text-align: left;
}
#view-chat #convo-lang {
  grid-column: 1 / -1; grid-row: 3;
  margin: 0; font-size: 12.5px;
}
#view-chat #convo-lang-list { grid-column: 1 / -1; grid-row: 4; margin: 0; }
/* Call-card rows 5-8: avatar toggle, avatar canvas, beta label, retry.
   Without explicit rows these auto-flowed side-by-side into the
   3-column grid. The toggle also inherited .checkin-btn's dark
   #1a1206 text on the dark panel — token colours instead. */
#view-chat #live-avatar-toggle { grid-column: 1 / -1; grid-row: 5; justify-self: start; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
#view-chat #live-avatar-canvas { grid-column: 1 / -1; grid-row: 6; }
#view-chat .convo-card > .section-sub { grid-column: 1 / -1; grid-row: 7; margin: 0; font-size: 12.5px; }
#view-chat #convo-retry { grid-column: 1 / -1; grid-row: 8; justify-self: start; }
/* Call-card display modes (full screen / voice only). Same tokens
   as the avatar toggle — no new colours. No explicit grid-row: the
   PR #41 record controls (record button, REC pill, Save, record canvas)
   auto-flow into rows 9-12, so the modes row takes the next free row
   by auto-flow instead of colliding with them. */
#view-chat #convo-modes { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
#view-chat #convo-modes .checkin-btn { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
/* Full-screen call: the same in-chat panel, fixed over the app, avatar big.
   End conversation (stopConvo) removes this class, so a new call always
   starts back in the thread. */
#view-chat #convo-view.convo-fullscreen {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 0; border-radius: 0;
  margin: 0; padding: 24px;
}
#view-chat #convo-view.convo-fullscreen .convo-card { max-width: 560px; }
#view-chat #convo-view.convo-fullscreen #convo-orb { width: 96px; height: 96px; }
#view-chat #convo-view.convo-fullscreen #live-avatar-canvas { width: 320px; height: 320px; }
#view-chat #convo-view.convo-fullscreen #convo-captions { max-height: 40vh; }
#view-chat .convo-cap { font-size: 13.5px; }

/* ---------- In-chat browser card: same card, Muse-shell polish ---------- */
.browser-card {
  border-radius: 16px !important;
  width: 100%;
  max-width: 768px;
  margin-left: auto;
  margin-right: auto;
}
.browser-card-shot { border-radius: 10px !important; }

/* ---------- Holiday themes follow the new shell ----------
   holiday-theme.js already swaps --accent/--season/--holiday-* on :root;
   the sidebar + call card just need to read the holiday tokens. */
html[data-holiday] #muse-sidebar { background: var(--holiday-sidebar); }
html[data-holiday] #view-chat #convo-view { background: var(--holiday-card); }
html[data-holiday] .sb-item.active { background: var(--accent-soft); }
html[data-holiday] .sb-new { background: var(--accent); }

/* MULTI-TAB tab bar (Midnight Pro): dark chips, gold active chip. */
.hands-tab{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;max-width:180px;background:#1e1e1e;color:#a3a3a3;border:1px solid #2a2a2a;border-radius:8px 8px 0 0;padding:7px 8px;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap;overflow:hidden}
.hands-tab .hands-tab-title{overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0}
.hands-tab.active{background:#2a2418;color:#c9a86a;border-color:#c9a86a}
.hands-tab .hands-tab-close{background:none;border:none;color:#a3a3a3;font-size:14px;line-height:1;cursor:pointer;padding:0 2px}
.hands-tab.active .hands-tab-close{color:#c9a86a}
.hands-tab-new{flex:0 0 auto;background:#1e1e1e;color:#c9a86a;border:1px solid #2a2a2a;border-radius:8px 8px 0 0;padding:7px 10px;font-size:13px;font-weight:700;cursor:pointer}
.hands-tab-new:disabled{opacity:.45;cursor:default}

/* ---------- More page: grouped, collapsible sections (no long scroll) ---------- */
/* Midnight Pro only: flat #171717 / #1e1e1e, white text, muted gold #c9a86a, no gradients/glows. */
.more-jump { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.more-jump a { color: #c9a86a; border: 1px solid #c9a86a; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; text-decoration: none; background: #171717; }
.more-jump a:active { background: #2a2418; }
/* LIVE FIX 2026-11-17 (settings nav + clipped group bars, after PR #56):
   #view-more is a flex column (styles.css .tab-view: display:flex;
   flex-direction:column; overflow-y:auto) with a definite height, so its
   children are flex items. A flex item with overflow other than visible
   has automatic minimum size 0 (flexbox §4.5) — and .more-group sets
   overflow:hidden — so without flex-shrink:0 every group SHRANK to fit
   the container instead of overflowing it. Measured in Chromium with the
   live rules: scrollHeight == clientHeight (no scrollable overflow at
   all, so the Settings settle loop's scrollTo clamped to scrollTop 0 and
   the hub never left the top), closed group bars rendered 41px tall
   against a 59px summary (clipped headings), and the open Account group
   squeezed to 487px against 734px of cards (cards vanished while still
   `open`; opening a second group squeezed it further to 445px). The old
   flat hub never hit this because .card has no overflow (visible), so its
   automatic minimum size is its content. flex-shrink:0 restores normal
   overflow-and-scroll: after the fix scrollHeight 1369 vs 1000 viewport,
   closed bars 61px vs 59px summary, Account group 736px vs 734px content,
   and scrollTo lands. Do NOT remove this declaration. */
.more-group { border: 1px solid var(--border); border-radius: 12px; background: #1e1e1e; margin-bottom: 10px; overflow: hidden; flex-shrink: 0; }
.more-group > summary { cursor: pointer; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; list-style: none; }
.more-group > summary::-webkit-details-marker { display: none; }
.more-group > summary:active { background: #262626; }
.more-group-title { color: #fff; font-size: 16px; font-weight: 700; }
.more-group-title::before { content: "▸ "; color: #c9a86a; }
.more-group[open] > summary .more-group-title::before { content: "▾ "; }
.more-group-sub { color: #a3a3a3; font-size: 13px; }
.more-group > .card { border: 0; border-top: 1px solid var(--border); border-radius: 0; margin-bottom: 0; }
.more-group > .card:first-of-type { border-top: 0; }
