/* ============================================================
   EnVision: Project Workspace + Dockable Window Manager
   ============================================================ */

.ws {
  position: fixed; inset: 0; display: grid; grid-template-columns: auto 1fr;
  background: var(--bg-2); overflow: hidden;
}

/* ---- Left icon rail + sidebar ---- */
.ws-rail { display: flex; height: 100vh; }
.rail {
  width: 60px; background: var(--charcoal); display: flex; flex-direction: column; align-items: center;
  padding: 10px 0; gap: 4px; flex: none;
}
[data-color-scheme="light"] .rail { background: #322d26; }
.rail .brand-mark { width: 40px; height: 40px; border-radius: var(--r-md); margin-bottom: 6px; }
.rail .brand-mark .brand-logo-wrap--mark { width: 40px; height: 40px; }
.rail .brand-logo-wrap .brand-logo--light { display: none; }
.rail .brand-logo-wrap .brand-logo--dark { display: block; }
.rail-btn {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #cdbfa3;
  position: relative; transition: all var(--dur-fast) var(--ease);
}
.rail-btn svg { width: 1.35em; height: 1.35em; }
.rail-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.rail-btn.is-active { background: var(--accent); color: #fff; }
.rail-btn.is-active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--accent); }
.rail-spacer { flex: 1; }

.ws-sidebar {
  width: 216px; background: var(--bg-2); border-right: 1.5px solid var(--line); flex: none;
  display: flex; flex-direction: column; overflow: hidden; transition: width var(--dur) var(--ease);
}
.ws-sidebar.collapsed { width: 0; }
.ws-side-head { padding: 12px 14px; border-bottom: 1.5px solid var(--line); }
.ws-side-head .proj-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.ws-side-head .proj-meta { font-size: 0.78rem; color: var(--text-3); }
.ws-nav { padding: 8px; overflow-y: auto; flex: 1; }
.ws-nav .side-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); font-weight: 700; padding: 12px 8px 4px; }
.ws-nav-link {
  display: flex; align-items: center; gap: 0.65em; padding: 0.5em 0.6em; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 600; font-size: 0.88rem; cursor: pointer; transition: all var(--dur-fast) var(--ease);
}
.ws-nav-link svg { width: 1.15em; height: 1.15em; color: var(--text-3); }
.ws-nav-link:hover { background: var(--surface-2); color: var(--text); }
.ws-nav-link.is-open { color: var(--accent-deep); }
.ws-nav-link.is-open svg { color: var(--accent); }
.ws-nav-link .open-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: 0; }
.ws-nav-link.is-open .open-dot { opacity: 1; }

/* ---- Main column ---- */
.ws-main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.ws-toolbar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 10px; padding-inline: 12px;
  background: var(--bg); border-bottom: 1.5px solid var(--line);
}
.ws-toolbar .tb-sep { width: 1.5px; height: 26px; background: var(--line); margin-inline: 2px; }
.ws-title-input {
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; color: var(--text);
  background: transparent; border: 1.5px solid transparent; border-radius: 8px; padding: 3px 8px; max-width: 240px;
}
.ws-title-input:hover { border-color: var(--line); }
.ws-title-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.preset-select { display: inline-flex; align-items: center; gap: 8px; }

/* ---- Dock area ---- */
.dock {
  --left-w: 250px; --right-w: 300px; --top-h: 0px; --bottom-h: 210px;
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column;
  background:
    linear-gradient(color-mix(in srgb, var(--line) 40%, transparent) 1px, transparent 1px) 0 0/26px 26px,
    linear-gradient(90deg, color-mix(in srgb, var(--line) 40%, transparent) 1px, transparent 1px) 0 0/26px 26px,
    var(--bg-3);
  overflow: hidden;
}
.dock-mid { flex: 1; display: flex; min-height: 0; }
.dock-col { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.dock-region { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); overflow: hidden; }
.region-left  { width: var(--left-w);  flex: none; border-right: 1.5px solid var(--line); }
.region-right { width: var(--right-w); flex: none; border-left: 1.5px solid var(--line); }
.region-top   { height: var(--top-h);  flex: none; border-bottom: 1.5px solid var(--line); }
.region-bottom{ height: var(--bottom-h);flex: none; border-top: 1.5px solid var(--line); }
.region-center{ flex: 1; background: transparent; }
.dock-region.is-empty { display: none; }
.dock-region.collapsed .region-body { display: none; }
.dock-region.collapsed.region-left, .dock-region.collapsed.region-right { width: 40px; }
.dock-region.collapsed.region-bottom, .dock-region.collapsed.region-top { height: 38px; }

/* Splitters */
.splitter { flex: none; background: transparent; position: relative; z-index: 5; }
.splitter::after { content: ""; position: absolute; background: transparent; transition: background var(--dur) var(--ease); }
.splitter.v { width: 6px; cursor: col-resize; margin-inline: -3px; }
.splitter.v::after { inset: 0 2px; }
.splitter.h { height: 6px; cursor: row-resize; margin-block: -3px; }
.splitter.h::after { inset: 2px 0; }
.splitter:hover::after, .splitter.dragging::after { background: var(--accent); }
.splitter.hidden { display: none; }

/* Tab strip */
.region-tabs {
  display: flex; align-items: stretch; height: 38px; flex: none; background: var(--surface-2);
  border-bottom: 1.5px solid var(--line); padding-left: 4px; overflow: hidden;
}
.region-tablist { display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none; }
.region-tablist::-webkit-scrollbar { display: none; }
.dock-tab {
  display: inline-flex; align-items: center; gap: 0.5em; padding: 0 12px; height: 100%; cursor: pointer;
  color: var(--text-2); font-size: 0.82rem; font-weight: 600; border-right: 1.5px solid var(--line);
  max-width: 190px; white-space: nowrap; position: relative; transition: background var(--dur-fast) var(--ease);
  user-select: none;
}
.dock-tab svg.tab-ic { width: 1.05em; height: 1.05em; color: var(--text-3); flex: none; }
.dock-tab .tab-label { overflow: hidden; text-overflow: ellipsis; }
.dock-tab:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.dock-tab.is-active { background: var(--surface); color: var(--accent-deep); }
.dock-tab.is-active svg.tab-ic { color: var(--accent); }
.dock-tab.is-active::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2.5px; background: var(--accent); }
.dock-tab .tab-close { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; opacity: 0; margin-right: -4px; }
.dock-tab .tab-close svg { width: 0.85em; height: 0.85em; }
.dock-tab:hover .tab-close, .dock-tab.is-active .tab-close { opacity: 0.6; }
.dock-tab .tab-close:hover { opacity: 1; background: color-mix(in srgb, var(--danger) 25%, transparent); }
.dock-tab.dragging { opacity: 0.4; }

.region-tabtools { margin-left: auto; display: flex; align-items: center; gap: 1px; padding-inline: 4px; }
.region-tabtools .mini {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--text-3);
}
.region-tabtools .mini svg { width: 1em; height: 1em; }
.region-tabtools .mini:hover { background: var(--surface-3); color: var(--text); }

.region-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
.panel-view { position: absolute; inset: 0; overflow: auto; display: none; }
.panel-view.is-active { display: block; }

/* When region is collapsed, show vertical label */
.region-collapsed-label {
  display: none; writing-mode: vertical-rl; text-orientation: mixed; padding: 10px 0; font-weight: 700;
  font-size: 0.8rem; color: var(--text-2); cursor: pointer; text-align: center;
}
.dock-region.collapsed .region-tabs { display: none; }
.dock-region.collapsed .region-collapsed-label { display: block; }

/* ---- Floating panels ---- */
.dock-floats { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.float-panel {
  position: absolute; pointer-events: auto; display: flex; flex-direction: column;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-4); overflow: hidden; min-width: 220px; min-height: 120px;
}
.float-panel.dragging, .float-panel.resizing { user-select: none; box-shadow: var(--shadow-4), 0 0 0 2px var(--accent); }
.float-panel.focused { border-color: var(--line-strong); }
.panel-head {
  display: flex; align-items: center; gap: 0.5em; height: 36px; flex: none; padding: 0 6px 0 12px;
  background: var(--surface-2); border-bottom: 1.5px solid var(--line); cursor: grab;
}
.panel-head.grabbing { cursor: grabbing; }
.panel-head .ph-ic { width: 1.05em; height: 1.05em; color: var(--accent); flex: none; }
.panel-head .ph-title { font-size: 0.82rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head .ph-tools { margin-left: auto; display: flex; gap: 1px; }
.panel-head .ph-tools .mini { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--text-3); }
.panel-head .ph-tools .mini svg { width: 1em; height: 1em; }
.panel-head .ph-tools .mini:hover { background: var(--surface-3); color: var(--text); }
.float-panel .panel-body { flex: 1; min-height: 0; overflow: auto; }
.float-panel.collapsed { height: 36px !important; min-height: 0; }
.float-panel.collapsed .panel-body { display: none; }
.float-resize { position: absolute; width: 16px; height: 16px; right: 0; bottom: 0; cursor: nwse-resize; }
.float-resize::after { content: ""; position: absolute; right: 3px; bottom: 3px; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); border-radius: 0 0 3px 0; }

/* ---- Drop zones (while dragging a panel) ---- */
.dock-dropzones { position: absolute; inset: 0; z-index: 40; pointer-events: none; display: none; }
.dock-dropzones.active { display: block; }
.dz {
  position: absolute; border: 2.5px dashed var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: var(--r-md); transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  display: grid; place-items: center; color: var(--accent-deep); font-weight: 700; font-size: 0.85rem;
}
.dz.hot { background: color-mix(in srgb, var(--accent) 30%, transparent); transform: scale(1.02); }
.dz-left   { left: 8px;  top: 8px; bottom: 8px; width: 22%; }
.dz-right  { right: 8px; top: 8px; bottom: 8px; width: 22%; }
.dz-top    { left: 27%; right: 27%; top: 8px; height: 22%; }
.dz-bottom { left: 27%; right: 27%; bottom: 8px; height: 22%; }
.dz-center { left: 27%; right: 27%; top: calc(22% + 16px); bottom: calc(22% + 16px); }

/* ---- Panel content shared styling ---- */
.p-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1.5px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent); position: sticky; top: 0; z-index: 3; flex-wrap: wrap;
}
.p-scroll { padding: 14px; }
.p-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.p-sub { font-size: 0.8rem; color: var(--text-3); }

/* status bar */
.ws-status {
  height: 26px; flex: none; display: flex; align-items: center; gap: 16px; padding-inline: 12px;
  background: var(--charcoal); color: #cdbfa3; font-size: 0.75rem; font-weight: 500;
}
[data-color-scheme="light"] .ws-status { background: #322d26; }
.ws-status .st { display: inline-flex; align-items: center; gap: 5px; }
.ws-status .st svg { width: 0.95em; height: 0.95em; }
.ws-status .st.push { margin-left: auto; }

/* preset menu popover */
.popover { position: absolute; z-index: 120; }

@media (max-width: 860px) {
  .ws-sidebar { position: absolute; z-index: 30; height: 100%; box-shadow: var(--shadow-3); }
  .region-left, .region-right { position: absolute; z-index: 15; height: 100%; }
}
