/* ============================================================
   Stan Shell — one cohesive app frame for StanChat.
   Persistent bottom nav (Home · Chats · Browser · Tools · You),
   full-screen design-language screens, chat.js kept as the engine.
   Supersedes the bolted-on dashboard overlay + the old drawer/
   topbar clutter. Purple/Stan, dark. Injected by stan-shell.js.
   ============================================================ */

/* ---- persistent bottom tab bar ---------------------------------------- */
#stan-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  height: calc(64px + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: rgba(13,13,18,0.86); backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border-top: 1px solid var(--accent-dim);
  display: flex; align-items: stretch; justify-content: space-around;
  font-family: var(--font-ui);
}
#stan-nav.hidden { display: none; }
.sn-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  -webkit-tap-highlight-color: transparent; padding-top: 8px; transition: color .15s ease;
}
.sn-tab svg { width: 24px; height: 24px; }
.sn-tab span { font-size: 10px; letter-spacing: .1px; }
.sn-tab.active { color: var(--accent-soft); }
.sn-tab.active span { font-weight: 600; }
.sn-tab .sn-fab {
  width: 44px; height: 44px; margin-top: -14px; border-radius: 15px;
  background: var(--gradient-accent); box-shadow: 0 6px 18px rgba(124,92,255,0.5);
  display: flex; align-items: center; justify-content: center;
}
.sn-tab .sn-fab svg { width: 24px; height: 24px; stroke: #fff; }

/* ---- generic full-screen shell screen --------------------------------- */
.stan-screen {
  position: fixed; inset: 0; bottom: calc(64px + var(--safe-bottom)); z-index: 60;
  background: var(--bg); color: var(--text-primary); font-family: var(--font-ui);
  display: flex; flex-direction: column; overflow: hidden;
}
.stan-screen.hidden { display: none; }
.ss-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 22px) 18px 24px; }
.ss-h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.6px; margin: 0 0 4px; }
.ss-label { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; margin: 22px 4px 10px; }

/* search field */
.ss-search { height: 42px; background: var(--bg-input); border: 1px solid var(--accent-dim);
  border-radius: 12px; display: flex; align-items: center; gap: 9px; padding: 0 13px; margin-top: 14px; }
.ss-search svg { width: 16px; height: 16px; flex-shrink: 0; }
.ss-search input { flex: 1; background: none; border: none; outline: none; color: var(--text-primary);
  font-size: 15px; font-family: inherit; }
.ss-search input::placeholder { color: var(--text-dim); }

/* generic list rows (chats, tools, settings) */
.ss-row { display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: left; width: 100%;
  background: var(--bg-card); border: 1px solid var(--accent-dim); border-radius: 15px; padding: 13px 14px;
  color: inherit; font-family: inherit; transition: transform .1s ease, border-color .15s ease; margin-bottom: 9px; }
.ss-row:active { transform: scale(0.985); border-color: var(--accent-border); }
.ss-row .ic { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; background: rgba(124,92,255,0.16); color: var(--accent-soft); }
.ss-row .ic svg { width: 20px; height: 20px; }
.ss-row .bd { flex: 1; min-width: 0; }
.ss-row .bd .t { font-size: 15.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-row .bd .s { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-row .bd .s.st-working, .sh-item .s.st-working { color: var(--accent-soft); font-weight: 600; }
.ss-row .bd .s.st-done, .sh-item .s.st-done { color: var(--green); }
.ss-row .bd .s.st-idle, .sh-item .s.st-idle { color: var(--text-dim); }
.ss-row .rt { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.ss-row .chev { color: var(--text-dim); flex-shrink: 0; }
.ss-empty { font-size: 14px; color: var(--text-dim); padding: 10px 4px; }

/* A chat Claude is still working in — the one you most likely want to reopen. */
.ss-row.live, .sh-item.live { border-color: var(--accent-border); }
.ss-row.live .ic, .sh-item.live .ico { position: relative; }
.ss-row.live .ic::after, .sh-item.live .ico::after {
  content: ''; position: absolute; top: -2px; right: -2px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 2px var(--bg);
  animation: ss-pulse 1.6s ease-in-out infinite;
}
@keyframes ss-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .ss-row.live .ic::after, .sh-item.live .ico::after { animation: none; }
}

/* ---- Browser screen --------------------------------------------------- */
#stan-browser { bottom: calc(64px + var(--safe-bottom)); }
.sb-bar { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-top) + 12px) 12px 12px;
  border-bottom: 1px solid var(--accent-dim); background: rgba(20,17,32,0.6);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.sb-bar button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--accent-dim);
  background: var(--bg-card); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sb-bar button svg { width: 18px; height: 18px; }
.sb-url { flex: 1; height: 38px; background: var(--bg-input); border: 1px solid var(--accent-dim); border-radius: 19px;
  padding: 0 15px; color: var(--text-primary); font-size: 14px; outline: none; font-family: var(--font-ui); min-width: 0; }
.sb-stage { flex: 1; min-height: 0; position: relative; background: #0b0a12; }
.sb-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.sb-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 30px; color: var(--text-dim); }
.sb-hint img { width: 120px; height: auto; filter: drop-shadow(0 10px 24px rgba(124,92,255,0.4)); }
.sb-hint .big { font-size: 18px; font-weight: 700; color: var(--text-primary); }
/* Stan watching dock */
.sb-dock { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 9px;
  background: rgba(26,19,48,0.92); border: 1px solid var(--accent-border); border-radius: 22px; padding: 8px 8px 8px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.sb-dock .av { width: 30px; height: 30px; border-radius: 50%; background: #17131f; border: 1px solid var(--accent-border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sb-dock .av img { width: 26px; height: 26px; object-fit: contain; }
.sb-dock input { flex: 1; background: none; border: none; outline: none; color: var(--text-primary); font-size: 14px; font-family: var(--font-ui); min-width: 0; }
.sb-dock .go { width: 36px; height: 36px; border-radius: 50%; background: var(--gradient-accent); border: none;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 4px 12px rgba(124,92,255,0.45); }
.sb-dock .go svg { width: 18px; height: 18px; stroke: #fff; }

/* ---- hide the OLD cockpit clutter so it's one professional app -------- */
body[data-stanchat-standalone] #topbar #pi-btn,
body[data-stanchat-standalone] #topbar #clip-btn,
body[data-stanchat-standalone] #topbar #fleet-btn,
body[data-stanchat-standalone] #topbar #term-btn,
body[data-stanchat-standalone] #topbar #flipper-btn,
body[data-stanchat-standalone] #topbar #bolt-btn,
body[data-stanchat-standalone] #topbar #menu-btn { display: none; }
/* keep the chat clear of the nav when in chat view */
body[data-stanchat-standalone].shell-on #composer { padding-bottom: calc(10px + var(--safe-bottom)); }

/* a Back button we add to the chat header to return to the shell */
#chat-back { display: none; }
body[data-stanchat-standalone].shell-on #chat-back { display: flex; }

/* #stan-home is reused from stan-home.css as a shell screen — clear the nav */
#stan-home.stan-screen {
  position: fixed; inset: 0; bottom: calc(64px + var(--safe-bottom));
  background: radial-gradient(120% 60% at 50% 0%, #1a1330 0%, #0d0d12 50%, #08080c 100%);
}
#stan-home.stan-screen .sh-scroll { padding-bottom: 24px; }

/* tool overlays (opened from Tools hub) must cover the persistent nav */
body[data-stanchat-standalone].shell-on #pi-monitor,
body[data-stanchat-standalone].shell-on #fleet,
body[data-stanchat-standalone].shell-on #terminal,
body[data-stanchat-standalone].shell-on #flipper { z-index: 200; }

/* live browser view (screencast frames) */
.sb-view { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; object-position: top center; background: #0b0a12; touch-action: none; -webkit-user-select: none; user-select: none; }

/* browser toolbar extras: keyboard / copy / paste + hidden keystroke input + toast */
.sb-ico { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--accent-dim); background: var(--bg-card); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sb-ico svg { width: 18px; height: 18px; }
.sb-ico[data-b="kbd"].lit { color: var(--accent-soft); border-color: var(--accent-border); background: rgba(124,92,255,0.18); }
.sb-kbd { position: absolute; left: 8px; bottom: 70px; width: 2px; height: 2px; opacity: 0.01; font-size: 16px; border: 0; padding: 0; margin: 0; background: transparent; color: transparent; caret-color: transparent; z-index: 1; }
.sb-toast { position: absolute; left: 50%; top: 76px; transform: translateX(-50%); background: rgba(26,19,48,0.96); border: 1px solid var(--accent-border); color: var(--text-primary); font-size: 13px; font-weight: 600; padding: 8px 15px; border-radius: 20px; z-index: 25; opacity: 0; pointer-events: none; transition: opacity .2s ease; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.sb-toast.show { opacity: 1; }

/* browser tab strip */
.sb-tabs { display: flex; gap: 6px; align-items: center; padding: 6px 10px; overflow-x: auto; background: rgba(20,17,32,0.5); border-bottom: 1px solid var(--accent-dim); flex-shrink: 0; -webkit-overflow-scrolling: touch; }
.sb-tabs::-webkit-scrollbar { display: none; }
.sb-tab { display: flex; align-items: center; gap: 6px; flex-shrink: 0; max-width: 150px; padding: 5px 6px 5px 11px; border-radius: 12px; background: var(--bg-card); border: 1px solid var(--accent-dim); color: var(--text-dim); font-size: 12.5px; cursor: pointer; }
.sb-tab.active { background: rgba(124,92,255,0.18); border-color: var(--accent-border); color: var(--text-primary); }
.sb-tab .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-tab .x { flex-shrink: 0; opacity: 0.55; font-size: 15px; line-height: 1; padding: 0 3px; }
.sb-tab .x:active { opacity: 1; }
.sb-newtab { flex-shrink: 0; width: 30px; height: 30px; border-radius: 10px; border: 1px solid var(--accent-dim); background: var(--bg-card); color: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1; cursor: pointer; }

/* Stan proactive "watching" — glowing avatar toggle + glance bubble */
.sb-dock .av { -webkit-appearance: none; appearance: none; padding: 0; cursor: pointer; }
.sb-dock.watching .av { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 14px var(--glow-accent); animation: sbwatch 2.4s ease-in-out infinite; }
@keyframes sbwatch { 0%,100%{ box-shadow:0 0 0 2px var(--accent-soft), 0 0 9px var(--glow-accent-soft);} 50%{ box-shadow:0 0 0 2px var(--accent-soft), 0 0 18px var(--glow-accent);} }
.sb-glance { position: absolute; left: 12px; right: 12px; bottom: 68px; z-index: 22; background: rgba(26,19,48,0.96); border: 1px solid var(--accent-border); color: var(--text-primary); font-size: 13.5px; line-height: 1.45; padding: 10px 14px; border-radius: 16px 16px 16px 6px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); opacity: 0; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.sb-glance.show { opacity: 1; transform: none; }
.sb-glance.loading { opacity: 0.75; font-style: italic; color: var(--text-dim); }

/* ---- Voice mode (#04) ---- */
#stan-voice { bottom: 0; background: radial-gradient(90% 55% at 50% 38%, #2a1e55 0%, #12112a 45%, #08080c 100%); }
.sv-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; padding: calc(var(--safe-top) + 26px) 26px 0; position: relative; min-height: 0; }
.sv-close { position: absolute; top: calc(var(--safe-top) + 14px); left: 14px; width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--accent-dim); background: var(--bg-card); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.sv-close svg { width: 20px; height: 20px; }
.sv-label { font-family: var(--font-mono); font-size: 13px; letter-spacing: 2px; color: var(--accent-soft); }
.sv-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; }
.sv-orb { position: relative; width: 230px; height: 230px; display: flex; align-items: center; justify-content: center; }
.sv-ring { position: absolute; width: 170px; height: 170px; border-radius: 50%; border: 1.5px solid rgba(124,92,255,0.5); opacity: 0; }
#stan-voice.recording .sv-ring { animation: svring 2.6s ease-out infinite; }
#stan-voice.recording .sv-ring.r2 { animation-delay: 1.3s; }
@keyframes svring { 0%{transform:scale(0.55);opacity:0.65;} 100%{transform:scale(1.75);opacity:0;} }
.sv-core { width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #241a44, #17131f); border: 1px solid rgba(124,92,255,0.45); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 50px rgba(124,92,255,0.55); }
.sv-core img { width: 118px; height: 118px; object-fit: contain; }
.sv-status { font-size: 21px; font-weight: 700; margin-top: 26px; text-align: center; }
.sv-wave { display: flex; align-items: flex-end; gap: 4px; height: 34px; margin-top: 16px; opacity: 0; transition: opacity .2s; }
#stan-voice.recording .sv-wave { opacity: 1; }
.sv-wave i { width: 4px; height: 34px; background: linear-gradient(#B18CFF,#7C5CFF); border-radius: 2px; transform-origin: bottom; transform: scaleY(0.28); }
#stan-voice.recording .sv-wave i { animation: svwave 0.9s ease-in-out infinite; }
.sv-wave i:nth-child(2){animation-delay:.15s}.sv-wave i:nth-child(3){animation-delay:.3s}.sv-wave i:nth-child(4){animation-delay:.45s}.sv-wave i:nth-child(5){animation-delay:.6s}.sv-wave i:nth-child(6){animation-delay:.75s}.sv-wave i:nth-child(7){animation-delay:.9s}
@keyframes svwave { 0%,100%{transform:scaleY(0.28);} 50%{transform:scaleY(1);} }
.sv-transcript { font-size: 15px; color: var(--text-secondary); line-height: 1.5; text-align: center; margin-top: 20px; max-width: 300px; min-height: 22px; }
.sv-controls { display: flex; align-items: center; justify-content: center; padding: 16px 0 calc(24px + var(--safe-bottom)); }
.sv-mic { width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(135deg,#7C5CFF,#B18CFF); border: none; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 26px rgba(124,92,255,0.5); cursor: pointer; }
.sv-mic svg { width: 30px; height: 30px; }
#stan-voice.recording .sv-mic { background: linear-gradient(135deg,#FF4455,#c9354a); box-shadow: 0 8px 26px rgba(255,68,85,0.5); animation: svpulse 1.3s ease-in-out infinite; }
@keyframes svpulse { 0%,100%{transform:scale(1);} 50%{transform:scale(1.08);} }

/* browser polish: loading bar, bookmarks, tappable download toast */
.sb-load { position: absolute; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg,#7C5CFF,#B18CFF); z-index: 15; opacity: 0; box-shadow: 0 0 8px rgba(124,92,255,0.6); }
.sb-load.on { animation: sbload 1.3s ease-in-out infinite; opacity: 1; }
@keyframes sbload { 0%{width:5%;left:0;} 50%{width:70%;} 100%{width:100%;left:0;opacity:.5;} }
.sb-ico#sb-star.on { color: #FFB020; border-color: rgba(255,176,32,0.4); background: rgba(255,176,32,0.14); }
.sb-ico#sb-star.on svg path { fill: #FFB020; stroke: #FFB020; }
.sb-marks { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.sb-mark { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--accent-soft); background: rgba(124,92,255,0.12); border: 1px solid var(--accent-border); border-radius: 16px; padding: 7px 11px; cursor: pointer; }
.sb-mark b { font-weight: 400; opacity: 0.55; font-size: 14px; }
.sb-toast.dl { pointer-events: auto; cursor: pointer; border-color: var(--accent-soft); }
