/* Workspace tabs + split screen (assets/js/core/workspace.js). Loaded after modern.css. */
/* --wt = the room the tab bar takes (0 when hidden). Registered so it can animate when the bar slides away on phones. */
@property --wt { syntax: '<length>'; inherits: true; initial-value: 0px; }
:root { --wt: 0px; --wt-h: 42px; --split: 0.5; --sp-w: 0px; }
body.has-wtabs { --wt: var(--wt-h); }

/* ---- tab bar */
#wtabs { position: sticky; top: 0; z-index: 40; height: var(--wt-h); margin-bottom: calc(var(--wt) - var(--wt-h)); margin-left: var(--side);
  display: flex; align-items: center; gap: 6px; padding: 0 10px; background: var(--bg); border-bottom: 1px solid var(--line);
  transform: translateY(calc(var(--wt) - var(--wt-h))); transition: transform .2s ease; }
.wt-list { flex: 1; min-width: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; height: 100%; align-items: center;
  overscroll-behavior-x: contain; touch-action: pan-x; -webkit-overflow-scrolling: touch; }
.wt-list::-webkit-scrollbar { display: none; }
.wt-tab { --c: var(--accent); position: relative; flex: 0 1 auto; min-width: 62px; max-width: 210px; display: flex; align-items: center; gap: 7px; height: 30px;
  padding: 0 4px 0 10px; border-radius: var(--btn-r, 8px); color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; outline: none; transition: background .12s, color .12s; }
.wt-tab .wt-name { flex: 1 1 auto; min-width: 2.6ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wt-ic { position: relative; flex: none; display: grid; place-items: center; }
.wt-ic svg { color: var(--c); }
.wt-tab:hover { background: var(--soft-2); color: var(--text); }
.wt-tab:focus-visible { box-shadow: 0 0 0 2px var(--accent-solid); }
.wt-tab.on { flex-shrink: 0; min-width: 0; background: var(--surface); color: var(--text); border-color: var(--line-2); box-shadow: inset 0 -2px 0 var(--c); }
.wt-tab.on:focus-visible { box-shadow: inset 0 -2px 0 var(--c), 0 0 0 2px var(--accent-solid); }
.wt-tab button { flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; color: var(--dim); opacity: 0; }
.wt-tab:hover button, .wt-tab.on .wt-x, .wt-tab:focus-within button { opacity: 1; }
.wt-tab button:hover { background: var(--soft-3); color: var(--text); }
/* inactive tabs: ✕ / ⫿ float over the end of the name on hover, so a shrunk tab still shows its first letters */
.wt-tab:not(.on) button { position: absolute; top: 3px; inset-inline-end: 3px; pointer-events: none;
  background: linear-gradient(var(--soft-2), var(--soft-2)), var(--bg); }
.wt-tab:not(.on) .wt-side { inset-inline-end: 27px; }
.wt-tab:not(.on):hover button, .wt-tab:not(.on):focus-within button { pointer-events: auto; }
.wt-tab:not(.on) button:hover { background: linear-gradient(var(--soft-3), var(--soft-3)), var(--bg); }
.wt-tab:not(.on):not(.pin) { padding-inline-end: 8px; }
.wt-side { font-size: 14px !important; }
/* pinned: icon only, never closes by accident */
.wt-tab.pin { flex: none; min-width: 0; width: auto; padding: 0 9px; justify-content: center; gap: 4px; }
.wt-tab.pin-end { margin-inline-end: 6px; }
.wt-tab.pin-end::after { content: ''; position: absolute; inset-inline-end: -6px; top: 7px; bottom: 7px; width: 1px; background: var(--line-2); }
/* live indicators (setTabState) */
.wt-dot { position: absolute; top: -3px; inset-inline-end: -4px; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--bg); background: var(--ok); }
.wt-dot.rec { background: #e5484d; animation: wt-blink 1.2s ease-in-out infinite; }
@keyframes wt-blink { 50% { opacity: .35; } }
.wt-snd { flex: none; display: grid; place-items: center; color: var(--accent); }
.wt-badge { flex: none; min-width: 17px; height: 17px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: #e5484d; color: #fff; font: 700 10.5px/17px var(--font); text-align: center; }
.wt-tab.pin .wt-badge { position: absolute; top: 1px; inset-inline-end: 0; min-width: 15px; height: 15px; padding: 0 3px; font-size: 9.5px; line-height: 15px; }
/* very many tabs: the inactive ones become icon-only before the list starts to scroll */
.wt-list.tight .wt-tab:not(.on):not(.pin) { flex: none; min-width: 0; padding: 0 9px; gap: 4px; }
.wt-list.tight .wt-tab:not(.on):not(.pin) :is(.wt-name, button) { display: none; }
/* dragging */
.wt-list.wt-dragging .wt-tab { transition: none; }
.wt-tab.wt-drag { z-index: 2; background: var(--surface); color: var(--text); border-color: var(--line-2); box-shadow: var(--shadow), 0 6px 18px -6px rgba(0, 0, 0, .35); cursor: grabbing; opacity: .96; }
.wt-tab.wt-held { background: var(--soft-3); }
body:has(.wt-dragging) { cursor: grabbing; }
/* ＋ / ⌄ / split */
.wt-new, .wt-more { flex: none; height: 30px; min-width: 30px; border-radius: var(--btn-r, 8px); display: grid; place-items: center; color: var(--muted); }
.wt-new:hover, .wt-more:hover, .wt-more[aria-expanded="true"] { color: var(--text); background: var(--soft-2); }
.wt-more { display: flex; align-items: center; gap: 3px; padding: 0 7px; border: 1px solid var(--line-2); font-size: 16px; line-height: 1; }
.wt-more span { transform: translateY(-3px); }
.wt-more small { font-size: 11.5px; font-weight: 600; }
.wt-split { flex: none; height: 30px; padding: 0 10px; border-radius: var(--btn-r, 8px); border: 1px solid var(--line-2); color: var(--muted); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.wt-split:hover, .wt-split.on { color: var(--text); background: var(--soft-2); }
.wt-split.on { border-color: var(--accent); }
/* menus */
#wt-menu { position: fixed; z-index: 90; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); max-height: min(70vh, 560px); overflow: auto; padding: 6px; border-radius: 12px;
  display: flex; flex-direction: column; background: var(--panel, var(--surface)); font-size: 13.5px; }
#wt-menu .wt-mh { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--dim); padding: 6px 8px 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#wt-menu .wt-mh small { margin-inline-start: auto; font-size: 11px; }
#wt-menu .wt-mi { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border-radius: 7px; text-align: start; font-size: 13.5px; color: var(--text); }
#wt-menu .wt-mi:hover:not([disabled]), #wt-menu .wt-mi:focus-visible { background: var(--soft-2); outline: none; }
#wt-menu .wt-mi[disabled] { color: var(--dim); opacity: .6; cursor: default; }
#wt-menu .wt-mg { flex: none; width: 18px; display: grid; place-items: center; text-align: center; font-size: 13px; color: var(--muted); }
#wt-menu .wt-ml { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#wt-menu kbd { font: 500 11px var(--font); color: var(--dim); }
#wt-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
#wt-menu .wt-find { margin: 2px 2px 6px; height: 34px; padding: 0 10px; border-radius: var(--btn-r, 8px); border: 1px solid var(--line-2); background: var(--field, var(--surface)); color: var(--text); font-size: 13.5px; }
#wt-menu .wt-find:focus { outline: none; border-color: var(--accent); }
.wt-orow { --c: var(--accent); display: flex; align-items: center; border-radius: 7px; }
.wt-orow .wt-mg svg { color: var(--c); }
.wt-orow.on .wt-mi { background: var(--soft-2); font-weight: 600; }
.wt-orow.gone .wt-mi { color: var(--muted); }
.wt-ox { flex: none; width: 26px; height: 26px; border-radius: 6px; color: var(--dim); font-size: 11px; opacity: .7; }
.wt-ox:hover { background: var(--soft-3); color: var(--text); opacity: 1; }
.wt-none { padding: 10px 8px; color: var(--dim); }
/* the eviction toast has an Undo button (the toast stack itself ignores the pointer) */
.wt-toast { display: inline-flex; align-items: center; gap: 10px; }
.wt-undo { pointer-events: auto; padding: 4px 10px; border-radius: 7px; background: var(--accent-solid); color: #fff; font-weight: 600; font-size: 13px; }
/* tab-limit notice lives inside the bar (never over the page) */
.wt-note { flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 6px; margin: 0 4px; padding: 3px 4px 3px 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 12.5px; white-space: nowrap; animation: wt-note-in .2s ease; }
.wt-note > span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wt-note .wt-undo { padding: 3px 9px; font-size: 12.5px; }
.wt-nx { flex: none; width: 24px; height: 24px; border-radius: 6px; color: var(--muted); font-size: 15px; line-height: 1; }
.wt-nx:hover { background: var(--soft-3); color: var(--text); }
@keyframes wt-note-in { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .wt-note { animation: none; } }

/* full-screen modules leave room for the tab bar (and the view must not make the window scroll by the bar's height) */
body.has-wtabs #view { min-height: calc(100vh - var(--wt)); }
body.has-wtabs .page.tool-page { height: calc(100vh - var(--wt)); }

/* ---- split screen (desktop: side by side) */
body.split { --sp-w: calc((100vw - var(--side)) * var(--split)); }
body.split #view, body.split #wtabs { margin-right: var(--sp-w); }
#split-pane { position: fixed; z-index: 45; top: 0; right: 0; bottom: 0; width: var(--sp-w); display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line-2); }
#split-frame { flex: 1; width: 100%; border: 0; background: var(--bg); }
.sp-head { height: var(--wt, 42px); min-height: 38px; display: flex; align-items: center; gap: 4px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.sp-title { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sp-sp { flex: 1; }
.sp-head button { width: 30px; height: 30px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.sp-head button:hover { background: var(--soft-2); color: var(--text); }
.sp-grip { position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 2; touch-action: none; }
.sp-grip:hover, .sp-grip:focus-visible, body.sp-dragging .sp-grip { background: linear-gradient(90deg, transparent 4px, var(--accent) 4px 6px, transparent 6px); outline: none; }
body.sp-dragging { user-select: none; cursor: col-resize; }
body.sp-dragging iframe { pointer-events: none; }
body.split .playerbar { right: calc(var(--sp-w) + 12px); }

/* ---- phones: the pane sits below the main view */
@media (max-width: 760px) {
  #wtabs { margin-left: 0; padding: 0 6px; gap: 4px; }
  body { transition: --wt .2s ease; }
  body.wt-away.wt-in { --wt: 0px; }                                    /* page scroller: the page grows into the room */
  body.wt-away:not(.wt-in) #wtabs { transform: translateY(-100%); }    /* window scroll: the sticky bar slides out */
  .wt-list { scroll-behavior: smooth; }
  .wt-list.wt-dragging { scroll-behavior: auto; }
  /* the active tab shows icon + name, the others only their icon */
  .wt-tab { max-width: 160px; }
  .wt-tab:not(.on) { flex: none; min-width: 0; padding: 0 10px; gap: 4px; }
  .wt-tab:not(.on) :is(.wt-name, button) { display: none; }
  .wt-tab.on { flex: none; }
  .wt-tab.on .wt-name { max-width: 96px; }
  .wt-tab button { opacity: 1; }
  .wt-tab .wt-side, .wt-split span { display: none; }
  .wt-split { padding: 0 9px; }
  body.has-wtabs .page.tool-page { height: calc(100dvh - 78px - var(--wt)); }
  body.split { --sp-h: calc((100dvh - 78px) * var(--split)); --sp-w: 0px; }
  body.split #view, body.split #wtabs { margin-right: 0; }
  body.split #view { padding-bottom: var(--sp-h); }
  body.split .page.tool-page { height: calc(100dvh - 78px - var(--wt) - var(--sp-h)); }
  #split-pane { top: auto; left: 0; width: auto; bottom: 78px; height: var(--sp-h); border-left: 0; border-top: 1px solid var(--line-2); }
  .sp-grip { left: 0; right: 0; top: -6px; bottom: auto; width: auto; height: 12px; cursor: row-resize; }
  .sp-grip:hover, .sp-grip:focus-visible, body.sp-dragging .sp-grip { background: linear-gradient(180deg, transparent 5px, var(--accent) 5px 7px, transparent 7px); }
  body.split .playerbar { right: 8px; }
}

/* ---- inside the pane (embedded copy of the site): no menu, tabs or bottom bar */
body.pane #rail, body.pane #tabbar, body.pane #wtabs, body.pane #splash { display: none !important; }
body.pane #view { margin: 0 !important; }
body.pane .page.tool-page { height: 100vh !important; }
body.pane .page { padding-bottom: calc(24px + var(--player, 0px)); }
body.pane .playerbar { left: 8px !important; right: 8px !important; bottom: 8px !important; }

[dir="rtl"] #wtabs { margin-left: 0; margin-right: var(--side); }
[dir="rtl"] body.split #view, [dir="rtl"] body.split #wtabs { margin-right: var(--side); margin-left: var(--sp-w); }
[dir="rtl"] #split-pane { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--line-2); }

/* ---- voice control (assets/js/core/voice.js) */
.sb-find { display: flex; gap: 6px; }
.sb-find .sb-search { flex: 1; min-width: 0; }
.sb-mic { flex: none; width: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--soft); border: 1px solid var(--line); color: var(--muted); }
.sb-mic:hover { color: var(--text); border-color: var(--line-2); }
body.voice-on .sb-mic { color: #fff; background: #e5484d; border-color: transparent; }
body.side-mini .sb-find { flex-direction: column; }
body.side-mini .sb-mic { width: auto; height: 34px; }
#voice { position: fixed; z-index: 120; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 24px));
  padding: 10px 10px 10px 12px; border-radius: 14px; box-shadow: var(--shadow); font-size: 14px; }
#voice .vc-dot { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; background: #e5484d; animation: vc-pulse 1.2s ease-in-out infinite; }
#voice.ok .vc-dot { background: var(--ok); animation: none; } #voice.err .vc-dot { background: var(--dim); animation: none; }
#voice .vc-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#voice button { width: 28px; height: 28px; border-radius: 8px; color: var(--muted); } #voice button:hover { background: var(--soft-2); }
@keyframes vc-pulse { 50% { box-shadow: 0 0 0 8px rgba(229, 72, 77, .18); } }
#voice-help { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 10, .5); }
.vh-card { width: min(460px, 100%); padding: 20px; border-radius: 16px; }
.vh-card h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 6px; } .vh-card p { color: var(--muted); margin: 0 0 12px; }
.vh-card ul { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; } .vh-card li { display: flex; gap: 10px; } .vh-card li span { width: 22px; flex: none; text-align: center; }
.vh-card > button { padding: 8px 14px; border-radius: 8px; background: var(--accent-solid); color: #fff; font-weight: 600; }
@media (max-width: 760px) { #voice { bottom: 92px; } }
