/* Global split view: left = main app, right = #globalSplitPane (an embedded copy of the app).
   Both sides share ONE top bar: logo + light/dark and the main tabs on the left half, the right
   pane's tabs and the split controls on the right half (#splitBarRight). The pane itself is plain
   content, exactly like the left side. --split-left is the main side's share of the width; the
   divider drags it (25%-75%). html.split-bar is set while the shared bar is in use. */
:root { --split-left: 50%; --split-bar-h: 44px; }

body.split-open .view { width: var(--split-left); max-width: var(--split-left); }
body.split-open #insiderTabContent,
body.split-open #insiderPersonTabsContainer { right: calc(100% - var(--split-left)); }
body.split-open .lock-screen { width: var(--split-left); }
body.split-open #scriptDocOverlay { right: calc(100% - var(--split-left)) !important; }
body.split-open #globalSplitPane { width: calc(100% - var(--split-left)) !important; }
body.split-right-full #globalSplitPane { width: 100% !important; border-left: none !important; }

/* ---------- shared top bar ---------- */
/* Same auto-hiding bar as without split (revealed at the top edge), just shared: the main tabs use
   the left half, #splitBarRight (the right side's tabs) slides in with it over the right half, and
   the account menu stays at the far right. */
html.tabbar-autohide.split-bar #tabBar.tab-bar {
  padding-right: calc(100% - var(--split-left) + 8px) !important; overflow: hidden;
}
html.split-bar #splitCanvasTab,
html.split-bar #splitLayoutControls { display: none !important; }
html.split-bar body.split-left-full #tabBar.tab-bar { padding-right: calc(var(--split-auth-w, 220px) + 24px) !important; }
/* Focusing the right side: the main tabs give way to the right side's */
html.split-bar body.split-right-full #tabBar :is(.tab-item, .tab-add, .sv-focus) { display: none !important; }

#splitBarRight {
  display: none; position: fixed; top: 0; left: var(--split-left); right: calc(var(--split-auth-w, 220px) + 24px);
  height: 44px; z-index: 100001; align-items: center; gap: 6px; padding: 0 0 0 10px;
  border-left: 1px solid color-mix(in srgb, var(--console-fg, #fff) 10%, transparent);
  font-family: Geist, system-ui, sans-serif;
  transform: translateY(-100%); opacity: 0; pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
}
html.split-bar #splitBarRight { display: flex; }
html.split-bar.tabbar-shown #splitBarRight { transform: none; opacity: 1; pointer-events: auto; }
html.split-bar body.split-left-full #splitBarRight { display: none; }
html.split-bar body.split-right-full #splitBarRight { left: 190px; border-left: 0; }

.sv-tabs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.sv-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; flex-shrink: 0;
  border: 0; border-radius: 6px; background: transparent; cursor: pointer; white-space: nowrap;
  font-size: 12.5px; letter-spacing: .01em; color: color-mix(in srgb, var(--console-fg, #fff) 55%, transparent);
}
.sv-tab:hover { background: color-mix(in srgb, var(--console-fg, #fff) 8%, transparent); color: var(--console-fg, #fff); }
.sv-tab.is-active { color: var(--console-fg, #fff); box-shadow: inset 0 -2px 0 var(--console-fg, #fff); border-radius: 0; }
.sv-tab .sv-tab-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.sv-tab .sv-tab-close { opacity: 0; font-size: 14px; line-height: 1; padding: 0 2px; border-radius: 4px; }
.sv-tab:hover .sv-tab-close { opacity: .7; }
.sv-tab .sv-tab-close:hover { opacity: 1; background: color-mix(in srgb, var(--console-fg, #fff) 12%, transparent); }
.sv-tab-add {
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  height: 28px; width: 28px; flex-shrink: 0; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
  color: color-mix(in srgb, var(--console-fg, #fff) 60%, transparent); font-size: 16px;
}
.sv-tab-add:hover { background: color-mix(in srgb, var(--console-fg, #fff) 8%, transparent); color: var(--console-fg, #fff); }

.sv-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.sv-seg { display: flex; padding: 2px; border: 1px solid color-mix(in srgb, var(--console-fg, #fff) 12%, transparent); border-radius: 8px; gap: 2px; }
.sv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 26px; min-width: 26px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent;
  color: color-mix(in srgb, var(--console-fg, #fff) 55%, transparent); font: 500 11px/1 Geist, system-ui, sans-serif; cursor: pointer;
}
.sv-btn:hover { background: color-mix(in srgb, var(--console-fg, #fff) 8%, transparent); color: var(--console-fg, #fff); }
.sv-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--console-fg, #fff) 14%, transparent); color: var(--console-fg, #fff); }
.sv-btn:focus-visible, .sv-tab:focus-visible { outline: 2px solid var(--theme-accent-1, #8b9cff); outline-offset: 1px; }
.sv-btn svg { width: 15px; height: 15px; }
.sv-sep { width: 1px; height: 18px; background: color-mix(in srgb, var(--console-fg, #fff) 12%, transparent); margin: 0 2px; }

/* The pane: plain content under the shared bar */
#globalSplitPane { background: var(--console-bg, #000) !important; border-left: 1px solid color-mix(in srgb, var(--console-fg, #fff) 10%, transparent) !important; }
#globalSplitFrame { background: var(--console-bg, #000); }

/* ---------- the app inside the pane ---------- */
/* No tab bar, logo, light/dark button or account menu of its own: the shared bar covers them, and
   the main side's light/dark switch applies to both. */
html.split-embed #tabBar,
html.split-embed #floatingBrand,
html.split-embed #tabbarHandle { display: none !important; }
/* the shared bar sits over the pane's top 44px (as it does over the left side): the home starts below it, like there,
   and its greeting is sized for the window, not just this half (the frame's own width would make it smaller) */
html.split-embed #researchView { padding-top: 64px !important; }
html.split-embed #researchView .ih-home #personalizedHeader .ih-title { font-size: clamp(26px, 6vw, 36px); }
html.split-embed #crmView .pi-view-switch { padding-left: 24px !important; }
html.split-embed :is(#insiderTabContent, #insiderPersonTabsContainer) .insider-standalone-header { padding-left: 24px !important; }
html.split-embed :is(#insiderTabContent, #insiderPersonTabsContainer) { top: 0 !important; }
html.split-embed #worldMapView .leaflet-top.leaflet-left { top: 10px !important; }
html.split-embed #scriptNotesSidebar { padding-top: 12px !important; }

/* ---------- divider and restore pill ---------- */
#globalSplitDivider {
  display: none; position: fixed; top: 0; bottom: 0; left: var(--split-left); width: 10px;
  transform: translateX(-5px); z-index: 100000; cursor: col-resize; touch-action: none;
}
body.split-open #globalSplitDivider { display: block; }
#globalSplitDivider::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 4px; height: 44px; border-radius: 4px;
  transform: translate(-50%, -50%); background: color-mix(in srgb, var(--console-fg, #fff) 22%, transparent); opacity: 0; transition: opacity .15s;
}
#globalSplitDivider:hover::after, body.split-dragging #globalSplitDivider::after { opacity: 1; }
body.split-dragging, body.split-dragging * { cursor: col-resize !important; user-select: none !important; }
body.split-dragging #globalSplitFrame { pointer-events: none; }

#splitRestorePill {
  display: none; position: fixed; right: 14px; top: 50%; transform: translateY(-50%); z-index: 100000;
  align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--console-fg, #fff) 14%, transparent);
  background: color-mix(in srgb, var(--console-bg, #000) 92%, transparent); color: var(--console-fg, #fff);
  font: 500 12px/1 Geist, system-ui, sans-serif; cursor: pointer; box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
#splitRestorePill svg { width: 14px; height: 14px; }
body.split-left-full #splitRestorePill { display: inline-flex; }

/* The canvas toolbar adapts to a narrow canvas side: drop the label, then move under the logo. */
#networkTabContent .graph-main { container: canvasmain / inline-size; }
@container canvasmain (max-width: 820px) {
  #ambientToggleBtn > span { display: none; }
}
@container canvasmain (max-width: 600px) {
  .graph-main > .toolbar { top: 58px !important; }
}

/* Home tab close buttons only exist while split (see split-view.js) */
.sv-home-close { display: none !important; }
/* (Home's own × closes it; with nothing left on the left, the right side takes the whole screen: see newtab.js) */

/* Focus button before each side's tabs: that side goes full screen; pressed again = split. */
.sv-focus { display: none; }
html.split-bar .sv-focus {
  display: inline-flex; align-items: center; justify-content: center; align-self: center; flex-shrink: 0;
  width: 28px !important; height: 28px !important; min-width: 28px; padding: 0 !important; margin-right: 4px;
  border: 0 !important; border-radius: 6px !important; background: transparent !important; box-shadow: none !important; cursor: pointer;
  color: color-mix(in srgb, var(--console-fg, #fff) 60%, transparent) !important;
}
html.split-bar .sv-focus:hover { background: color-mix(in srgb, var(--console-fg, #fff) 8%, transparent) !important; color: var(--console-fg, #fff) !important; }
html.split-bar .sv-focus[aria-pressed="true"] { background: color-mix(in srgb, var(--console-fg, #fff) 14%, transparent) !important; color: var(--console-fg, #fff) !important; }
html.split-bar .sv-focus:focus-visible { outline: 2px solid var(--theme-accent-1, #8b9cff); outline-offset: 1px; }
.sv-focus svg { flex: none; width: 16px !important; height: 16px !important; min-width: 16px; }
.sv-focus .sv-eye-two { width: 20px !important; min-width: 20px; }
/* One eye in dual view (focus this side); two eyes on the focused side (back to dual view) */
/* both sides showing: two squares; one side focused: one eye */
.sv-focus .sv-eye-one, .sv-focus[aria-pressed="true"] .sv-eye-two { display: none; }
.sv-focus .sv-eye-two { display: block; }
.sv-focus[aria-pressed="true"] .sv-eye-one { display: block; }
html.split-bar #tabBar .sv-focus { background: transparent !important; color: color-mix(in srgb, var(--console-fg, #fff) 60%, transparent) !important; border: 0 !important; }
html.split-bar #tabBar .sv-focus:hover { background: color-mix(in srgb, var(--console-fg, #fff) 8%, transparent) !important; color: var(--console-fg, #fff) !important; }
html.split-bar #tabBar .sv-focus[aria-pressed="true"] { background: color-mix(in srgb, var(--console-fg, #fff) 14%, transparent) !important; color: var(--console-fg, #fff) !important; }

/* ---------- the two halves are containers ---------- */
/* views that fill the window (fixed to its edges) stay inside the left half while split view is open */
body.split-open :is(.nt-view, .paper-view, .lb-view, .an-view, #researchView .shop-home.shop-tabview) { right: calc(100% - var(--split-left)) !important; }
/* dragging (or hovering) the divider: blue, like the trading section's panel edges */
#globalSplitDivider:hover, body.split-dragging #globalSplitDivider { background: color-mix(in srgb, #3b82f6 40%, transparent); }
body.split-dragging #globalSplitDivider::after { background: #3b82f6; }

/* hovering the focus button previews what it does: the other icon */
.sv-focus:hover .sv-eye-two, .sv-focus[aria-pressed="true"]:hover .sv-eye-one { display: none !important; }
.sv-focus:hover .sv-eye-one, .sv-focus[aria-pressed="true"]:hover .sv-eye-two { display: block !important; }
/* duo: tabs can be dragged to the other side (grab cursor), except on their × and the + */
html.split-bar body.split-open #tabBar .tab-item[draggable="true"], html.split-bar body.split-open #splitBarRight .sv-tab[draggable="true"] { cursor: grab !important; }
html.split-bar body.split-open #tabBar .tab-item .tab-close, html.split-bar body.split-open #splitBarRight .sv-tab-close,
html.split-bar body.split-open #tabBar .tab-add, html.split-bar body.split-open #splitBarRight .sv-tab-add { cursor: pointer !important; }
/* the right side's + is quiet like the left side's: hovering only brightens it a little (no white fill) */
html #splitBarRight .sv-tab-add.sv-tab-add.sv-tab-add { background: transparent !important; border: 0 !important; box-shadow: none !important; color: color-mix(in srgb, var(--console-fg, #fff) 55%, transparent) !important; font-weight: 400; transition: color .15s, background .15s; }
html #splitBarRight .sv-tab-add.sv-tab-add.sv-tab-add:hover { background: color-mix(in srgb, var(--console-fg, #fff) 7%, transparent) !important; color: color-mix(in srgb, var(--console-fg, #fff) 92%, transparent) !important; font-weight: 700; }
