/* The only shared addition is the layout switch. Legacy geometry stays intact. */
#workspace-layout-toggle {
  display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;
  min-height:36px;padding:6px 10px;border:1px solid var(--b1x-border);
  border-radius:8px;background:var(--b1x-control);color:var(--b1x-text);
  font:600 12px/1.3 var(--sans);white-space:nowrap;cursor:pointer;
}
#workspace-layout-toggle:focus-visible {outline:2px solid var(--b1x-focus,var(--cyan));outline-offset:2px}
/* This second-line switch occupies only its own space on the constrained Legacy
   phone toolbar: existing controls are neither hidden nor compressed. */
@media(max-width:700px) {
  [data-workspace-layout=legacy] #workspace-layout-toggle {
    position:absolute;inset-inline-end:8px;top:calc(100% + 4px);z-index:31;
    min-height:32px;padding:5px 10px;
  }
}
.modern-workspace-commandbar[hidden] {display:none!important}

/* Six appearances inherit the same semantic palette. Reading/document/code
   fonts deliberately remain under the existing preference controllers. */
:root[data-workspace-layout=modern] #shell.unified-shell {
  --sidebar:232px;--modern-radius:12px;--modern-control-radius:8px;
  --modern-border:color-mix(in srgb,var(--b1x-text) 14%,transparent);
  grid-template-rows:auto auto minmax(0,1fr)!important;
  gap:8px;padding:10px;padding-top:max(10px,env(safe-area-inset-top,0px));box-shadow:none!important;
}
:root[data-workspace-layout=modern] #shell.unified-shell.no-sidebar {--sidebar:0px}
:root[data-workspace-layout=modern] #shell.unified-shell .topbar {
  grid-row:1;grid-column:2/-1;height:auto!important;min-height:52px;
  flex-wrap:wrap;justify-content:flex-start;gap:6px!important;padding:6px 8px!important;
  background:var(--b1x-bg)!important;box-shadow:none!important;
}
:root[data-workspace-layout=modern] #shell.unified-shell .workspace-mode-control {margin:0;max-width:160px}
:root[data-workspace-layout=modern] #shell.unified-shell .workspace-project-picker {max-width:150px}
:root[data-workspace-layout=modern] #shell.unified-shell .topbar :is(select,.mobile-select-trigger,.workspace-project-picker,.launch-signin) {border-radius:var(--modern-control-radius)!important}
:root[data-workspace-layout=modern] #workspace-layout-toggle {border-color:var(--b1x-accent);background:var(--b1x-selection)}
:root[data-workspace-layout=modern] #shell.unified-shell #main {grid-row:3;min-height:0;min-width:0;border-radius:var(--modern-radius);background:var(--b1x-solid)!important}
:root[data-workspace-layout=modern] #shell.unified-shell :is(.workspace-dock,.inspector,.canvas) {grid-row:3}
:root[data-workspace-layout=modern] #shell.unified-shell :is(.sidebar,.workspace-dock) {border-radius:var(--modern-radius);background:var(--b1x-solid-weak)!important}
:root[data-workspace-layout=modern] #shell.unified-shell .liquid-scene {display:none}

:root[data-workspace-layout=modern] #shell.unified-shell .modern-workspace-commandbar {
  display:flex;grid-column:2/-1;grid-row:2;align-items:center;justify-content:space-between;
  flex-wrap:wrap;gap:8px;min-width:0;padding:8px;
  background:var(--b1x-solid);border:1px solid var(--modern-border);border-radius:var(--modern-radius);
}
:root[data-workspace-layout=modern] .modern-workspace-navigation,
:root[data-workspace-layout=modern] .modern-workspace-panels {display:flex;flex-wrap:wrap;gap:4px;align-items:center;min-width:0}
:root[data-workspace-layout=modern] .modern-workspace-command {
  border:1px solid transparent;border-radius:var(--modern-control-radius);padding:7px 10px;
  min-height:36px;background:transparent;color:var(--b1x-muted);font:500 12px/1.4 var(--sans);white-space:nowrap;
}
:root[data-workspace-layout=modern] .modern-workspace-command:hover {background:var(--b1x-control);color:var(--b1x-text)}
:root[data-workspace-layout=modern] .modern-workspace-command:is([aria-current=page],[aria-pressed=true]) {
  color:var(--b1x-text);background:var(--b1x-selection);border-color:var(--modern-border);
  box-shadow:inset 0 -2px var(--b1x-accent);
}
:root[data-workspace-layout=modern] .modern-workspace-command:focus-visible {outline:2px solid var(--b1x-focus);outline-offset:1px}

/* A quiet rail with a reserved, independently scrollable footer. No settings or
   companion actions disappear, even in short landscape windows. */
:root[data-workspace-layout=modern] #shell.unified-shell #sidebar {
  display:flex;flex-direction:column;min-height:0;padding:16px 12px 12px;
  overflow:hidden;box-shadow:none!important;border:1px solid var(--modern-border)!important;
}
:root[data-workspace-layout=modern] #shell.unified-shell.no-sidebar #sidebar {display:none}
:root[data-workspace-layout=modern] #shell.unified-shell.no-sidebar :is(.topbar,.modern-workspace-commandbar) {grid-column:1/-1}
:root[data-workspace-layout=modern] #shell.unified-shell #sidebar .brand.identity {flex:none;padding:4px 0 12px;margin:0 0 8px;min-height:0}
:root[data-workspace-layout=modern] #shell.unified-shell #sidebar .sidebar-scroll {flex:1 1 0;min-height:60px;padding-inline-end:4px}
:root[data-workspace-layout=modern] #shell.unified-shell #sidebar .sidebar-foot {
  flex:0 1 auto;max-height:42%;min-height:48px;overflow:auto;overscroll-behavior:contain;
  margin-top:10px;padding-top:8px;padding-bottom:env(safe-area-inset-bottom,0px);border-top:1px solid var(--modern-border);
}
:root[data-workspace-layout=modern] #shell.unified-shell #sidebar :is(.nav,#new-chat) {
  border-radius:var(--modern-control-radius)!important;min-height:36px;padding:8px 10px;gap:9px;
  font:500 13px/1.4 var(--sans);letter-spacing:normal;box-shadow:none!important;
}
:root[data-workspace-layout=modern] #shell.unified-shell #sidebar #new-chat {flex:none;margin-bottom:12px;background:var(--b1x-control);color:var(--b1x-text);border:1px solid var(--modern-border)}
:root[data-workspace-layout=modern] #shell.unified-shell #sidebar .nav.active {background:var(--b1x-selection);box-shadow:inset 2px 0 var(--b1x-accent)!important}
/* Studios and file actions have a persistent home in the command bar. The rail
   retains projects, history, plugins, operational tools and the existing footer. */
:root[data-workspace-layout=modern] #sidebar .unified-feature-nav [data-workspace-mode]:is([data-workspace-mode=visual],[data-workspace-mode=studio],[data-workspace-mode=arena],[data-workspace-mode=ledger],[data-workspace-mode=codingteam],[data-workspace-mode=files]),
:root[data-workspace-layout=modern] #sidebar .saved-files-shortcut {display:none!important}
:root[data-workspace-layout=modern] #shell.unified-shell #sidebar .section-label {font-size:10px;letter-spacing:.08em;margin:14px 10px 6px}
:root[data-workspace-layout=modern] #shell.unified-shell .project-list-row {background:var(--b1x-control)!important;border-color:var(--modern-border)!important}
:root[data-workspace-layout=modern] #shell.unified-shell .project-list-row.active-project {background:var(--b1x-selection)!important;border-color:var(--b1x-accent)!important}
:root[data-workspace-layout=modern] #shell.unified-shell .project-folder-badge {color:var(--b1x-accent)!important}

/* Home is the real current conversation and saved work, not another dashboard. */
:root[data-workspace-layout=modern] #shell.unified-shell .launch-home {max-width:960px;padding:32px 28px 24px!important}
:root[data-workspace-layout=modern] #shell.unified-shell .launch-home h1 {font-size:clamp(26px,2.6vw,36px)!important;letter-spacing:-.035em;line-height:1.2!important;margin:0 0 12px!important}
:root[data-workspace-layout=modern] #shell.unified-shell .launch-subtitle {font-size:14px;margin-bottom:16px}
:root[data-workspace-layout=modern] #shell.unified-shell .launch-home .composer-area {margin-top:24px}
:root[data-workspace-layout=modern] #shell.unified-shell .recent-work {margin-top:24px}
:root[data-workspace-layout=modern] #shell.unified-shell .recent-work h2 {font-size:15px}
:root[data-workspace-layout=modern] #shell.unified-shell .recent-work-list>button {padding:13px 8px}
:root[data-workspace-layout=modern] #shell.unified-shell .launch-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:12px}
:root[data-workspace-layout=modern] #shell.unified-shell .launch-tool {width:100%;justify-content:flex-start;min-height:48px!important;border:1px solid var(--modern-border)!important;border-radius:var(--modern-control-radius);background:var(--b1x-solid-weak)}

/* The native output canvas stays central. These rules never move the shared
   composer/thread or replace editor and studio controllers. */
:root[data-workspace-layout=modern] #shell.unified-shell :is(.pw-card,.cs-layout,.ds-center,.ds-library,.ds-inspector,.ds-lower,.arena-card,.coding-team-form,.coding-team-detail,.coding-team-notice) {
  border-color:var(--modern-border);border-radius:var(--modern-radius);box-shadow:none;background:var(--b1x-solid);
}
:root[data-workspace-layout=modern] #shell.unified-shell .coding-team button[type=submit] {color:var(--b1x-on-accent)}
:root[data-workspace-layout=modern] #shell.unified-shell :is(.pw-header,.cs-heading,.ds-top) {padding-bottom:10px;border-bottom:1px solid var(--modern-border)}
:root[data-workspace-layout=modern] #shell.unified-shell :is(.cs-toolbar,.ds-toolbar,.dock-head) {background:var(--b1x-solid-weak);box-shadow:none}
:root[data-workspace-layout=modern] #shell.unified-shell :is(.pw-actions,.cs-heading-actions,.ds-toolbar) :is(button,select) {border-radius:var(--modern-control-radius)}
:root[data-workspace-layout=modern] #shell.unified-shell :is(.code-studio button.primary,.pw-primary) {background:var(--b1x-accent);color:var(--b1x-on-accent)}
:root[data-workspace-layout=modern] #shell.unified-shell .workspace-tool-screen {min-width:0;overflow:auto}
:root[data-workspace-layout=modern] #shell.unified-shell .workspace-tool-screen>header {padding:12px 16px}
:root[data-workspace-layout=modern] #shell.unified-shell .workspace-tool-screen iframe {min-height:240px;border-radius:var(--modern-radius)}
:root[data-workspace-layout=modern] #shell.unified-shell .shared-composer {animation:none!important;box-shadow:none!important}
:root[data-workspace-layout=modern] #shell.unified-shell .shared-composer::after,
:root[data-workspace-layout=modern] #shell.unified-shell #composer-live-audio::before {display:none!important}
:root[data-workspace-layout=modern] #shell.unified-shell #composer-live-audio svg {filter:none}
:root[data-workspace-layout=modern] body #shell.unified-shell #composer .composer-toolbar #send {
  background:var(--b1x-accent)!important;color:var(--b1x-on-accent)!important;border-radius:10px!important;
}
:root[data-workspace-layout=modern] body #shell.unified-shell #composer#composer #stop:not([hidden]) {background:var(--b1x-control)!important;color:var(--b1x-text)!important;border-radius:10px!important}

@media(max-width:1100px) {
  :root[data-workspace-layout=modern] #shell.unified-shell,
  :root[data-workspace-layout=modern] #shell.unified-shell.dock-open {--sidebar:0px;grid-template-columns:minmax(0,1fr)!important}
  :root[data-workspace-layout=modern] #shell.unified-shell :is(.topbar,#main,.modern-workspace-commandbar) {grid-column:1/-1}
  :root[data-workspace-layout=modern] #shell.unified-shell #sidebar {
    position:fixed!important;inset:0 auto 0 0;width:240px!important;max-width:calc(100vw - 40px)!important;
    z-index:100!important;transform:translateX(-100%)!important;visibility:hidden;
    background:var(--b1x-solid)!important;border-radius:0 var(--modern-radius) var(--modern-radius) 0!important;
  }
  :root[data-workspace-layout=modern] #shell.unified-shell #sidebar[aria-modal=true] {display:flex!important;transform:none!important;visibility:visible}
  :root[data-workspace-layout=modern] #shell.unified-shell .workspace-dock:not(.dock-fullscreen) {
    position:fixed;right:12px;top:140px;bottom:calc(var(--dock-composer-height,58px) + 24px);
    width:min(520px,calc(100vw - 24px));max-width:calc(100vw - 24px);grid-column:auto;min-height:0;
  }
}
@media(max-width:700px) {
  :root[data-workspace-layout=modern] #shell.unified-shell {padding:max(6px,env(safe-area-inset-top,0px)) max(6px,env(safe-area-inset-right,0px)) max(6px,env(safe-area-inset-bottom,0px)) max(6px,env(safe-area-inset-left,0px));gap:6px}
  :root[data-workspace-layout=modern] body #shell.unified-shell .topbar {gap:4px!important;padding:4px!important;min-height:48px}
  :root[data-workspace-layout=modern] body #shell.unified-shell .topbar .workspace-mode-control {order:0;flex:0 1 76px!important;position:relative}
  :root[data-workspace-layout=modern] body #shell.unified-shell .topbar #workspace-mode.mobile-select-native {width:1px!important;max-width:1px!important;min-width:0!important;height:1px!important;min-height:0!important;padding:0!important}
  :root[data-workspace-layout=modern] body #shell.unified-shell #workspace-layout-toggle {min-height:40px;font-size:11px;padding:6px 8px}
  :root[data-workspace-layout=modern] body #shell.unified-shell .topbar .workspace-panel-controls:not([hidden]) {display:flex}
  :root[data-workspace-layout=modern] #shell.unified-shell .modern-workspace-commandbar {gap:5px;padding:5px}
  :root[data-workspace-layout=modern] .modern-workspace-navigation {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));width:100%;gap:2px}
  :root[data-workspace-layout=modern] .modern-workspace-panels {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));width:100%;border-top:1px solid var(--modern-border);padding-top:4px;gap:2px}
  :root[data-workspace-layout=modern] .modern-workspace-command {min-height:40px;padding:6px 4px;font-size:12px}
  :root[data-workspace-layout=modern] #shell.unified-shell .launch-home {padding:22px 14px 16px!important}
  :root[data-workspace-layout=modern] #shell.unified-shell .launch-grid {grid-template-columns:repeat(2,minmax(0,1fr))}
  :root[data-workspace-layout=modern] #shell.unified-shell #main {border-radius:10px}
  :root[data-workspace-layout=modern] #shell.unified-shell .dock-head {padding:8px;min-width:0}
  :root[data-workspace-layout=modern] #shell.unified-shell .dock-head>button {min-height:40px!important;min-width:32px;padding:6px}
  :root[data-workspace-layout=modern] #shell.unified-shell .dock-panel {padding:14px}
  :root[data-workspace-layout=modern] #shell.unified-shell .dock-panel[aria-label=Files] {grid-template-columns:minmax(0,1fr)}
}
@media(max-height:550px) {
  :root[data-workspace-layout=modern] #shell.unified-shell #sidebar .brand.identity {padding:0;margin-bottom:6px}
  :root[data-workspace-layout=modern] #shell.unified-shell #sidebar .sidebar-foot {max-height:36%;min-height:44px}
  :root[data-workspace-layout=modern] #shell.unified-shell .launch-home {padding-top:16px!important}
  :root[data-workspace-layout=modern] #shell.unified-shell .modern-workspace-commandbar {gap:4px;padding:4px}
  :root[data-workspace-layout=modern] .modern-workspace-command {min-height:32px;padding-block:4px}
  :root[data-workspace-layout=modern] #shell.unified-shell .workspace-dock:not(.dock-fullscreen) {top:100px}
}
@media(prefers-reduced-motion:reduce) {
  :root[data-workspace-layout=modern] #shell.unified-shell *,
  :root[data-workspace-layout=modern] #shell.unified-shell *::before,
  :root[data-workspace-layout=modern] #shell.unified-shell *::after {animation:none!important;transition:none!important;scroll-behavior:auto!important}
}
@media(forced-colors:active) {
  :root[data-workspace-layout=modern] #shell.unified-shell {--modern-border:CanvasText;--b1x-solid:Canvas;--b1x-solid-weak:Canvas;--b1x-control:ButtonFace;--b1x-accent:Highlight;--b1x-on-accent:HighlightText;--b1x-text:CanvasText;--b1x-muted:CanvasText;--b1x-selection:Canvas;--b1x-focus:Highlight}
  :root[data-workspace-layout=modern] .modern-workspace-command:is([aria-current=page],[aria-pressed=true]) {outline:1px solid Highlight;border-color:Highlight}
}
