/* NDWS.dock: fullscreen shell, side panel with tabs, splitter, floating windows, drop zones.
   Colors and radii come from the variables of style.css (--panel, --panel-2, --line, --line-2, --accent, --accent-soft, --muted, --faint,
   --text, --bg, --bad), so both themes work. Everything is prefixed ws-. */

.ws-dock [hidden] { display: none !important; }

.ws-dock {
  --ws-title-h: 36px;
  position: relative; display: flex; flex: 1 1 0%; width: 100%; height: 100%; min-width: 0; min-height: 240px;
  overflow: hidden; isolation: isolate; background: var(--bg); color: var(--text);
  font: 13px/1.4 var(--sans, system-ui, sans-serif);
}
.ws-dock *, .ws-dock *::before, .ws-dock *::after { box-sizing: border-box; }
.ws-dock[data-side="right"] { flex-direction: row; }
.ws-dock[data-side="left"] { flex-direction: row-reverse; }
.ws-dock[data-side="bottom"] { flex-direction: column; }
.ws-dock[data-side="top"] { flex-direction: column-reverse; }
.ws-dock.ws-dragging { user-select: none; -webkit-user-select: none; }
.ws-dock.ws-dragging, .ws-dock.ws-dragging * { cursor: grabbing !important; }

.ws-dock-main { position: relative; flex: 1 1 0%; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
/* the workspace element fills the main slot unless its own stylesheet says otherwise (:where keeps this rule at zero specificity) */
:where(.ws-dock-main) > :where(:only-child) { width: 100%; height: 100%; }

/* splitter: out of flow (so main + panel always add up to the container), 8 px hit area centred on the panel edge
   (the dock sets left/right/top/bottom in px from the panel size), 2 px line inside */
.ws-dock { --ws-split: 8px; }
.ws-dock-split { position: absolute; z-index: 6; touch-action: none; outline: none; background: transparent; }
.ws-dock[data-side="left"] .ws-dock-split, .ws-dock[data-side="right"] .ws-dock-split { top: 0; bottom: 0; width: var(--ws-split); cursor: col-resize; }
.ws-dock[data-side="top"] .ws-dock-split, .ws-dock[data-side="bottom"] .ws-dock-split { left: 0; right: 0; height: var(--ws-split); cursor: row-resize; }
.ws-dock-split::after { content: ""; position: absolute; background: var(--line-2); transition: background .1s; }
/* the splitter starts 4 px inside the panel (set by the dock) and reaches --ws-split - 4 px into the main area; the 2 px line sits on the panel edge */
.ws-dock[data-side="left"] .ws-dock-split::after { top: 0; bottom: 0; left: 3px; width: 2px; }
.ws-dock[data-side="right"] .ws-dock-split::after { top: 0; bottom: 0; left: calc(100% - 5px); width: 2px; }
.ws-dock[data-side="top"] .ws-dock-split::after { left: 0; right: 0; top: 3px; height: 2px; }
.ws-dock[data-side="bottom"] .ws-dock-split::after { left: 0; right: 0; top: calc(100% - 5px); height: 2px; }
@media (pointer: coarse) { .ws-dock { --ws-split: 24px; } } /* touch: a real finger target (24 px, mostly on the main side so the panel header buttons stay free) */
.ws-dock-split:hover::after, .ws-dock-split.is-drag::after { background: var(--accent); }
.ws-dock-split:focus-visible::after { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 3px var(--accent); }
.ws-dock[data-hidden="true"] .ws-dock-split { display: none; }

/* panel */
.ws-dock-panel { position: relative; flex: 0 0 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); overflow: hidden; }
.ws-dock[data-side="left"] .ws-dock-panel, .ws-dock[data-side="right"] .ws-dock-panel { min-width: 0; max-width: 80%; }
.ws-dock[data-side="top"] .ws-dock-panel, .ws-dock[data-side="bottom"] .ws-dock-panel { max-height: 80%; }
/* hidden panel: kept laid out (scroll offsets survive) but out of flow and invisible */
.ws-dock[data-hidden="true"] .ws-dock-panel { position: absolute; visibility: hidden; pointer-events: none; }
.ws-dock[data-hidden="true"][data-side="left"] .ws-dock-panel, .ws-dock[data-hidden="true"][data-side="right"] .ws-dock-panel { top: 0; bottom: 0; left: 0; }
.ws-dock[data-hidden="true"][data-side="top"] .ws-dock-panel, .ws-dock[data-hidden="true"][data-side="bottom"] .ws-dock-panel { left: 0; right: 0; top: 0; }

.ws-btn {
  flex: 0 0 auto; width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; touch-action: manipulation;
}
.ws-btn:hover:not(:disabled) { background: var(--panel); color: var(--text); }
.ws-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ws-btn:disabled { opacity: .4; cursor: default; }
.ws-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.ws-grip svg { stroke-width: 2.4; }
.ws-grip { cursor: grab; touch-action: none; }

.ws-dock-phead {
  flex: 0 0 auto; display: flex; align-items: center; gap: 2px; min-height: 36px; padding: 2px 4px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.ws-dock-ptitle { flex: 1 1 auto; min-width: 0; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 650; color: var(--muted); }
.ws-dock-phead.is-drag { background: var(--accent-soft); }
.ws-dock-phead .ws-btn:hover:not(:disabled) { background: var(--panel-2); filter: brightness(.94); }
/* hide-button chevron points away from the main area */
.ws-dock[data-side="right"] .ws-hide svg { transform: none; }
.ws-dock[data-side="left"] .ws-hide svg { transform: rotate(180deg); }
.ws-dock[data-side="bottom"] .ws-hide svg { transform: rotate(90deg); }
.ws-dock[data-side="top"] .ws-hide svg { transform: rotate(-90deg); }

/* tabs */
.ws-tabs { position: relative; flex: 0 0 auto; display: flex; align-items: stretch; min-height: 36px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.ws-tablist { position: relative; flex: 1 1 auto; min-width: 0; display: flex; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.ws-tablist::-webkit-scrollbar { display: none; }
.ws-tabscroll { width: 32px; height: auto; border-radius: 0; background: var(--panel-2); border-left: 1px solid var(--line); }
.ws-tabs > .ws-tabscroll:first-child { border-left: 0; border-right: 1px solid var(--line); }
.ws-tabadd { width: 36px; height: auto; border-radius: 0; background: var(--panel-2); border-left: 1px solid var(--line); }
.ws-addmenu {
  position: absolute; right: 4px; top: calc(100% + 2px); z-index: 20; min-width: 190px; max-width: calc(100% - 8px); max-height: min(260px, 60vh); overflow: auto; display: flex; flex-direction: column; padding: 4px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}
.ws-addmenu[hidden] { display: none; }
.ws-addmenu-i { flex: 0 0 auto; min-height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-addmenu-i:hover { background: var(--panel-2); }
.ws-addmenu-i:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ws-tab {
  position: relative; flex: 0 0 auto; display: flex; align-items: center; gap: 2px; max-width: 220px; min-height: 36px; padding: 0 2px 0 12px;
  border-right: 1px solid var(--line); color: var(--muted); cursor: pointer; user-select: none; -webkit-user-select: none; white-space: nowrap; touch-action: none;
}
.ws-tab:hover { color: var(--text); background: var(--panel); }
.ws-tab[aria-selected="true"] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: inset 0 2px 0 var(--accent); }
.ws-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ws-tab.is-drag { opacity: .45; }
.ws-tab-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ws-tab-x { width: 32px; height: 32px; opacity: .85; } /* .65 gave 2.6:1 in the light theme (WCAG 1.4.11 asks 3:1) */
.ws-tab-x svg { width: 12px; height: 12px; }
.ws-tab:hover .ws-tab-x, .ws-tab[aria-selected="true"] .ws-tab-x, .ws-tab-x:focus-visible { opacity: 1; }
.ws-tab-x:hover:not(:disabled) { background: var(--bad-soft, var(--panel-2)); color: var(--bad); }
.ws-tab-ins { position: absolute; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--accent); pointer-events: none; z-index: 3; }

/* panel body and views */
.ws-dock-pbody { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; overflow: hidden; }
.ws-dock-empty { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 4px; padding: 16px; text-align: center; color: var(--muted); }
.ws-dock-empty-t { font-weight: 650; color: var(--text); }
.ws-dock-empty-h { font-size: 12px; }
.ws-view { position: absolute; inset: 0; overflow: auto; background: var(--panel); color: var(--text); }
.ws-view.is-off { visibility: hidden; pointer-events: none; }
.ws-float-body > .ws-view { position: absolute; inset: 0; }

/* edge handle shown while the panel is hidden */
.ws-dock-handle { position: absolute; z-index: 6; display: none; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.2)); }
.ws-dock[data-hidden="true"] .ws-dock-handle { display: flex; }
.ws-dock[data-side="right"] .ws-dock-handle { right: 0; top: 50%; transform: translateY(-50%); flex-direction: column; border-right: 0; border-radius: 8px 0 0 8px; }
.ws-dock[data-side="left"] .ws-dock-handle { left: 0; top: 50%; transform: translateY(-50%); flex-direction: column; border-left: 0; border-radius: 0 8px 8px 0; }
.ws-dock[data-side="top"] .ws-dock-handle { top: 0; left: 50%; transform: translateX(-50%); flex-direction: row; border-top: 0; border-radius: 0 0 8px 8px; }
.ws-dock[data-side="bottom"] .ws-dock-handle { bottom: 0; left: 50%; transform: translateX(-50%); flex-direction: row; border-bottom: 0; border-radius: 8px 8px 0 0; }
.ws-dock[data-side="left"] .ws-show svg { transform: rotate(180deg); }
.ws-dock[data-side="bottom"] .ws-show svg { transform: rotate(90deg); }
.ws-dock[data-side="top"] .ws-show svg { transform: rotate(-90deg); }
.ws-dock[data-side="right"] .ws-show svg { transform: none; }

/* drop zones while dragging a panel header or a float title */
.ws-zones { position: absolute; inset: 0; z-index: 40; pointer-events: none; display: none; }
.ws-dock.ws-zoning .ws-zones { display: block; }
.ws-zone { position: absolute; display: grid; place-items: center; }
.ws-zone::before { content: ""; position: absolute; inset: 0; background: var(--accent); opacity: .14; border: 2px dashed var(--accent); border-radius: 4px; transition: opacity .1s; }
.ws-zone.on::before { opacity: .3; border-style: solid; }
.ws-zone-l { position: relative; padding: 2px 10px; border-radius: 999px; background: var(--panel); color: var(--accent); font-weight: 650; font-size: 12px; box-shadow: var(--shadow, none); }

/* floating windows */
.ws-floats { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.ws-float {
  position: absolute; display: flex; flex-direction: column; pointer-events: auto; overflow: hidden; background: var(--panel); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}
.ws-float.on { border-color: var(--accent); }
.ws-float.is-drag { opacity: .92; }
.ws-float-title {
  flex: 0 0 calc(var(--ws-title-h) - 2px); height: calc(var(--ws-title-h) - 2px); display: flex; align-items: center; gap: 2px; padding: 0 8px 0 10px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.ws-float.on .ws-float-title { background: var(--accent-soft); color: var(--accent); }
.ws-float-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; font-size: 12px; }
.ws-fb { width: 32px; height: 32px; } /* 32 px touch target on every pointer (title bar is 36 px) */
.ws-float-body { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.ws-float.is-min { height: calc(var(--ws-title-h) + 2px) !important; }
.ws-float.is-min .ws-float-title { border-bottom: 0; }
.ws-float.is-min .ws-float-body { position: absolute; left: 0; right: 0; top: var(--ws-title-h); height: var(--ws-body-h); visibility: hidden; pointer-events: none; }
.ws-float.is-max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; border-width: 0; }
.ws-float.is-max .ws-float-title { cursor: default; }
.ws-float.is-max .ws-rz, .ws-float.is-min .ws-rz { display: none; }
.ws-rz { position: absolute; z-index: 2; touch-action: none; }
.ws-rz[data-h="n"] { left: 10px; right: 10px; top: 0; height: 6px; cursor: ns-resize; }
.ws-rz[data-h="s"] { left: 10px; right: 10px; bottom: 0; height: 6px; cursor: ns-resize; }
.ws-rz[data-h="e"] { top: 10px; bottom: 10px; right: 0; width: 6px; cursor: ew-resize; }
.ws-rz[data-h="w"] { top: 10px; bottom: 10px; left: 0; width: 6px; cursor: ew-resize; }
.ws-rz[data-h="ne"] { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.ws-rz[data-h="nw"] { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.ws-rz[data-h="se"] { bottom: 0; right: 0; width: 14px; height: 14px; cursor: nwse-resize; }
.ws-rz[data-h="sw"] { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
@media (pointer: coarse) {
  /* edge handles start where the 20 px corner handles end, so a corner is never half covered by an edge handle (QA fix) */
  .ws-rz[data-h="n"], .ws-rz[data-h="s"] { height: 12px; left: 20px; right: 20px; }
  .ws-rz[data-h="e"], .ws-rz[data-h="w"] { width: 12px; top: 20px; bottom: 20px; }
  .ws-rz[data-h="ne"], .ws-rz[data-h="nw"], .ws-rz[data-h="se"], .ws-rz[data-h="sw"] { width: 20px; height: 20px; }
  .ws-fb { width: 32px; height: 32px; }
}

/* drag ghost (tab being dragged: label pill inside the strip, mini window outside of it) */
.ws-ghost {
  position: absolute; z-index: 60; pointer-events: none; max-width: 220px; padding: 5px 12px; border-radius: 999px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--accent); color: var(--on-accent, #fff); font-weight: 650; font-size: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.ws-ghost.is-win { width: 220px; height: 120px; padding: 6px 10px; border-radius: 8px; background: var(--panel); color: var(--accent); border: 2px solid var(--accent); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); opacity: .92; white-space: normal; }

/* the integrator's toggle button (dock.fullscreenButton) */
.ws-fsbtn { width: 32px; height: 32px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); }
.ws-fsbtn.has-text { width: auto; padding: 0 12px; gap: 6px; display: inline-flex; align-items: center; font-weight: 600; }

/* fullscreen: native :fullscreen gets a real background, the fallback is fixed, above modals (50) and below the toast (60) */
.ws-fs { background: var(--bg); color: var(--text); }
.ws-fs-fallback { position: fixed !important; inset: 0 !important; width: auto !important; height: auto !important; min-height: 0 !important; max-width: none !important; max-height: none !important; margin: 0 !important; z-index: 58 !important; border-radius: 0 !important; }
html.ws-fs-lock, body.ws-fs-lock { overflow: hidden !important; }

/* narrow screens: the dock already switches the panel to the bottom under 700 px; keep controls usable */
@media (max-width: 520px) {
  .ws-tab { max-width: 160px; }
  .ws-dock-ptitle { display: none; }
  .ws-dock-phead { justify-content: flex-end; }
  .ws-dock-phead .ws-grip { margin-right: auto; }
}
@media (prefers-reduced-motion: reduce) { .ws-zone::before { transition: none; } }
