/* Adapt Claude's labelled chrome zones to the existing Classic and Studio controllers. */
:root { --shell-height: 5.75rem; --project-journey-height: 0px; }
:root[data-ui="studio"] { --studio-bar-h: 3.25rem; --shell-height: var(--studio-bar-h); }
html[data-ui] #appShell:not([data-state-only="true"]) { height: var(--shell-height); min-height: var(--shell-height); }
html[data-ui] #appShell > .global-shell[data-shell-chrome] {
  --wc-ink: var(--wb-text); --wc-ink-3: var(--wb-muted); --wc-rule: var(--wb-border);
  --wc-rule-2: var(--wb-border-strong); --wc-bg: var(--wb-shell); --wc-plate: var(--wb-surface-1);
  --wc-field: var(--wb-surface-1); --wc-ring: var(--wb-focus); --wc-lift: var(--wb-shadow);
  --wc-ui: var(--st-font, "Segoe UI", system-ui, sans-serif);
  display: grid; grid-template-columns: minmax(0, 12rem) minmax(10rem, 1fr) auto auto auto;
  grid-template-rows: 3.25rem 2.5rem;
  grid-template-areas: "brand context tools display style" "flow flow flow flow flow";
  height: var(--shell-height); min-height: 0; gap: 0 .75rem; padding: 0 1rem;
  align-items: center; flex-wrap: nowrap; overflow: visible;
  border-bottom: 1px solid var(--wc-rule); background: var(--wc-bg); color: var(--wc-ink);
}
html[data-ui] #appShell > [data-shell-chrome] > .shell-brand { grid-area: brand; max-width: none; }
html[data-ui] #appShell > [data-shell-chrome] > .shell-context {
  grid-area: context; position: relative; display: grid; align-content: center;
  width: min(100%, 24rem); min-width: 0; max-width: none; height: 2.75rem;
  margin: 0; padding: .25rem 1.75rem .25rem .625rem; overflow: hidden;
  border: 1px solid var(--wc-rule-2); border-radius: var(--wc-r);
  background: var(--wc-field); color: inherit; text-align: start; cursor: pointer;
  clip-path: none; white-space: normal;
}
html[data-ui] #appShell > [data-shell-chrome] > .shell-context:disabled { opacity: 1; cursor: default; }
/* This project control is a two-row button, not the overlaid select that
   .wc-project normally labels. Keep both lines in the same grid flow. */
html[data-ui] #appShell > [data-shell-chrome] .shell-context > .wc-cap { position: static; inset: auto; min-width: 0; }
html[data-ui] #appShell > [data-shell-chrome] .shell-context .wc-val { display: block; font-family: inherit; font-size: .875rem; font-weight: 600; line-height: 1.4; }
html[data-ui] #appShell > [data-shell-chrome] > .shell-tools {
  grid-area: tools; display: flex; flex-wrap: nowrap; align-items: center; gap: .25rem; min-width: 0;
}
html[data-ui] #appShell > [data-shell-chrome] .shell-tools > :is(a,button) {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  min-width: 2.75rem; height: 2.75rem; min-height: 2.75rem; gap: .375rem; margin: 0;
  padding: 0 .5rem; border: 1px solid var(--wc-rule); border-radius: var(--wc-r);
  background: transparent; color: inherit; font-family: inherit; font-size: .8125rem; font-weight: 600; line-height: 1.3; white-space: nowrap;
}
html[data-ui] #appShell > [data-shell-chrome] .shell-tools > [hidden] { display: none; }
html[data-ui] #appShell > [data-shell-chrome] .shell-tools .ui-icon { width: 1.125rem; height: 1.125rem; }
html[data-ui] #appShell > [data-shell-chrome] > .wc-display { grid-area: display; }
html[data-ui] #appShell > [data-shell-chrome] > .shell-style {
  grid-area: style; width: 9.25rem; max-width: 100%; min-width: 0; padding: .125rem .625rem;
}
html[data-ui] #appShell > [data-shell-chrome] .wc-cap { font: 600 .6875rem/1.2 var(--wc-ui); color: var(--wc-ink-3); }
html[data-ui] #appShell > [data-shell-chrome] .shell-style select {
  display: block; width: 100%; height: 1.5rem; min-height: 0; margin: 0; padding: 0;
  border: 0; background: transparent; color: inherit; font-family: inherit; font-size: .875rem; font-weight: 600; line-height: 1.3;
}
html[data-ui] #appShell > [data-shell-chrome] > .shell-utilities.wc-menu {
  position: absolute; top: calc(3.25rem + .375rem); right: 10.75rem; bottom: auto; left: auto;
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: stretch; justify-content: stretch;
  width: max-content; min-width: 17rem; max-width: calc(100vw - 1rem);
  height: auto; max-height: calc(100dvh - 4.25rem); gap: .25rem; margin: 0; padding: .5rem;
  overflow: auto; border: 1px solid var(--wc-rule-2); border-radius: var(--wc-r);
  background: var(--wc-plate); color: var(--wc-ink); box-shadow: var(--wc-lift);
}
html[data-ui] #appShell > [data-shell-chrome] > .shell-utilities:not([data-open]) { display: none; }
html[data-ui] #appShell > [data-shell-chrome] .shell-utilities > :is(button,label,.connection-pill) {
  position: relative; display: flex; align-items: center; justify-content: flex-start; gap: .625rem;
  width: 100%; height: auto; min-height: 2.75rem; margin: 0; padding: .375rem .5rem;
  border: 0; background: transparent; color: inherit; font-size: .875rem; line-height: 1.4;
}
/* Old compact toolbars hid these items; this scrollable menu has room for names. */
html[data-ui] #appShell > [data-shell-chrome] .shell-utilities :is(#shellResetDefaults, #shellConnection) { display: flex !important; }
html[data-ui] #appShell > [data-shell-chrome] .shell-utilities :is(#shellResetDefaults, #shellConnection) > span {
  display: inline; position: static; width: auto; height: auto; margin: 0; padding: 0;
  overflow: visible; clip: auto; clip-path: none; white-space: normal;
}
html[data-ui] #appShell > [data-shell-chrome] .shell-language select {
  width: auto; min-width: 4rem; min-height: 2.5rem; margin-left: auto; padding: .25rem .5rem;
  border: 1px solid var(--wc-rule-2); background: var(--wc-field); color: inherit;
}
html[data-ui] #appShell > [data-shell-chrome] .noise-settings-entry::after { display: block; content: attr(title); }
html:not([data-ui="studio"]) #appShell > [data-shell-chrome] > .shell-nav {
  grid-area: flow; position: static; display: flex; flex-wrap: nowrap; justify-content: flex-start;
  align-self: stretch; width: auto; height: 2.5rem; min-width: 0; gap: .25rem;
  margin: 0; padding: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  border: 0; border-top: 1px solid var(--wc-rule); background: transparent; box-shadow: none;
}
html:not([data-ui="studio"]) #appShell > [data-shell-chrome] .shell-nav-item {
  flex: 0 0 auto; width: auto; min-height: 2.5rem; height: 2.5rem; padding: 0 .75rem; font-size: .8125rem;
}
html:not([data-ui="studio"]) #appShell > [data-shell-chrome] .shell-nav-item span { display: block; font-size: .875rem; }
html:not([data-ui="studio"]) #appShell > [data-shell-chrome] .shell-nav-item.active::after { bottom: 0; }
html[data-ui] #appShell > [data-shell-chrome] ~ .project-journey {
  position: absolute; top: calc(var(--shell-height) + .375rem); left: 1rem; z-index: 110;
  display: none; width: min(38rem, calc(100vw - 2rem)); height: auto; min-height: 0;
  padding: .5rem; overflow: auto; max-height: calc(100dvh - var(--shell-height) - 1.5rem);
  border: 1px solid var(--wc-rule-2, var(--wb-border)); background: var(--wb-shell);
}
html[data-ui] #appShell > [data-shell-pipeline] ~ .project-journey:not([hidden]) { display: grid; }
html[data-ui] #appShell > [data-shell-chrome] ~ .project-journey .journey-stages {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0;
}
html[data-ui] #appShell > [data-shell-chrome] ~ .project-journey .journey-stage { min-width: 0; white-space: normal; }
/* Studio keeps its live context and existing vertical navigation, not a second row of tasks. */
html[data-ui="studio"] #appShell > .global-shell[data-shell-chrome] {
  --wc-ink: var(--st-text); --wc-ink-3: var(--st-muted); --wc-rule: var(--st-line);
  --wc-rule-2: var(--st-line-strong); --wc-bg: var(--st-bar); --wc-plate: var(--st-surface);
  --wc-field: var(--st-surface); --wc-ring: var(--st-focus);
  grid-template-columns: minmax(0, 1fr) auto auto auto; grid-template-rows: var(--shell-height);
  grid-template-areas: "context tools display style";
  background: var(--st-bar); box-shadow: none;
}
html[data-ui="studio"] #appShell > [data-shell-chrome] > .shell-context { display: none; }
html[data-ui="studio"] #appShell > [data-shell-chrome] > .studio-context {
  grid-area: context; display: flex; flex-wrap: nowrap; min-width: 0; width: auto; height: 100%; flex-basis: auto;
}
html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-crumb { max-width: 12rem; }
html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-project { max-width: 22rem; min-width: 0; }
html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-focus-toggle { flex: 0 0 auto; }
html[data-ui="studio"].studio-pipeline-open #appShell > [data-shell-chrome] ~ .project-journey:not([hidden]) {
  position: fixed; display: grid; top: calc(var(--studio-bar-h) + .375rem);
  left: var(--studio-pipeline-left, 1rem); width: var(--studio-pipeline-width, 22.5rem);
  background: var(--st-pop); color: var(--st-text); border-color: var(--st-line-strong);
}
@media (max-width: 75rem) {
  html[data-ui] #appShell > [data-shell-chrome] .shell-tools > :is(a,button) > span,
  html[data-ui] #appShell > [data-shell-chrome] .shell-tools #shellTaskProgress { display: none; }
  html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-crumb,
  html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-divider { display: none; }
}
@media (max-width: 51.25rem) {
  :root, :root[data-ui="studio"] { --shell-height: 6rem; --studio-bar-h: 6rem; }
  html[data-ui] #appShell > .global-shell[data-shell-chrome] {
    grid-template-columns: minmax(0, 1fr) auto auto; grid-template-rows: 3rem 3rem;
    grid-template-areas: "context context context" "tools display style"; gap: 0 .375rem; padding-inline: .5rem;
  }
  html[data-ui] #appShell > [data-shell-chrome] > .shell-brand { display: none; }
  html[data-ui] #appShell > [data-shell-chrome] > .shell-context { width: 100%; height: 2.75rem; }
  html[data-ui] #appShell > [data-shell-chrome] > .shell-tools { justify-self: start; gap: .125rem; }
  html[data-ui] #appShell > [data-shell-chrome] .shell-tools > :is(a,button) { padding-inline: .375rem; }
  html[data-ui] #appShell > [data-shell-chrome] .shell-tools > :is(a,button) > span,
  html[data-ui] #appShell > [data-shell-chrome] .shell-tools #shellTaskProgress { display: none; }
  html[data-ui] #appShell > [data-shell-chrome] > .shell-style { width: 7.5rem; }
  html[data-ui] #appShell > [data-shell-chrome] .wc-menu-btn { min-width: 2.75rem; width: 2.75rem; padding: 0; justify-content: center; }
  html[data-ui] #appShell > [data-shell-chrome] .wc-menu-btn::after { content: none; }
  html[data-ui] #appShell > [data-shell-chrome] .wc-menu-btn > .wc-cap,
  html[data-ui] #appShell > [data-shell-chrome] .wc-menu-btn .wc-val > span,
  html[data-ui] #appShell > [data-shell-chrome] > .shell-style > .wc-cap { display: none; }
  html[data-ui] #appShell > [data-shell-chrome] > .shell-utilities.wc-menu { top: calc(6rem + .375rem); right: .5rem; }
  html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-context { gap: .5rem; }
  html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-project { flex: 1 1 0; max-width: none; }
  html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-project-progress { display: none; }
  html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-project-name { position: static; width: auto; height: auto; clip-path: none; }
  html[data-ui="studio"] #appShell > [data-shell-chrome] .studio-chooser { max-width: 40%; }
}
@media (max-width: 51.25rem) and (min-width: 47.5625rem) {
  html:not([data-ui="studio"]) #appShell > .global-shell[data-shell-chrome] { height: 8.5rem; grid-template-rows: 3rem 3rem 2.5rem; grid-template-areas: "context context context" "tools display style" "flow flow flow"; }
  :root:not([data-ui="studio"]) { --shell-height: 8.5rem; }
}
@media (max-width: 47.5rem) {
  html:not([data-ui="studio"]) #appShell > [data-shell-chrome] > .shell-nav {
    position: fixed; inset: auto 0 0; z-index: 150; height: calc(3.75rem + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0;
    padding: .25rem .25rem env(safe-area-inset-bottom); border-top: 1px solid var(--wc-rule);
    background: var(--wc-bg); overflow: hidden;
  }
  html:not([data-ui="studio"]) #appShell > [data-shell-chrome] .shell-nav-item {
    flex-direction: column; justify-content: center; min-width: 0; height: 3.25rem; gap: .125rem; padding: .25rem .125rem; font-size: .5625rem;
  }
  html:not([data-ui="studio"]) #appShell > [data-shell-chrome] .shell-nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
}
/* Lab's host owns escape, style and tasks. The legacy iframe retains project and preferences. */
:root[data-lab-host] { --shell-height: calc(5.75rem + 1px); --studio-bar-h: var(--shell-height); }
html[data-lab-host] #appShell > .global-shell[data-shell-chrome] {
  grid-template-columns: minmax(0, 1fr) auto auto; grid-template-rows: var(--wc-row1) var(--wc-row2);
  grid-template-areas: "context tools display" "flow flow flow"; height: var(--shell-height);
}
html[data-lab-host] #appShell > [data-shell-chrome] > :is(.shell-brand,.shell-nav,.shell-style,.studio-context,.studio-rail-toggle) { display: none; }
html[data-lab-host] #appShell > [data-shell-chrome] > .shell-context { display: grid; }
html[data-lab-host] #appShell > [data-shell-chrome]::before { display: none; }
html[data-lab-host] #appShell > [data-shell-chrome] > .shell-utilities.wc-menu { top: calc(3.25rem + .375rem); right: .5rem; }
@media (pointer: coarse) {
  :root[data-lab-host] { --shell-height: calc(6.25rem + 1px); }
}
@media (max-height: 31.99rem) and (min-width: 40rem) {
  :root[data-lab-host] { --shell-height: calc(3rem + 1px); }
  html[data-lab-host] #appShell > .global-shell[data-shell-chrome] {
    grid-template-columns: minmax(0, 12rem) minmax(0, 1fr) auto auto;
    grid-template-rows: var(--wc-row1); grid-template-areas: "context flow tools display";
  }
  html[data-lab-host] #appShell > [data-shell-chrome] > .shell-utilities.wc-menu { top: calc(3rem + .375rem); }
}
/* Recovery only: enlarged personal text participates in flow rather than
   sharing ordinary fixed station rows. The adapter measures the real reserve. */
html[data-ui] body.app-workbench:has(#appShell > [data-shell-chrome][data-wc-reading]) {
  height: auto; min-height: 100dvh; overflow: auto;
}
html[data-ui] #appShell > .global-shell[data-shell-chrome][data-wc-reading] {
  position: relative; display: flex; flex-wrap: wrap; align-items: center;
  grid-template: none; gap: .5rem; height: auto; min-height: 0; padding: .5rem;
}
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] > .shell-context {
  flex: 1 1 100%; width: auto; height: auto; min-height: 2.75rem; max-width: 100%;
}
html[data-ui="studio"] #appShell > [data-shell-chrome][data-wc-reading] > .shell-context { display: none; }
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] > .shell-tools {
  order: 1; flex: 1 1 100%; flex-wrap: wrap; max-width: 100%;
}
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] > .wc-display { order: 2; flex: 1 1 8rem; max-width: 100%; }
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] .wc-menu-btn {
  width: 100%; height: auto; min-height: 2.75rem; padding: .25rem .75rem; justify-content: start;
}
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] .wc-menu-btn > .wc-cap,
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] > .shell-style > .wc-cap { display: block; }
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] .wc-menu-btn .wc-val > span { display: inline; }
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] > .shell-style {
  order: 3; flex: 1 1 8rem; width: auto; height: auto; min-height: 2.75rem; max-width: 100%;
}
html[data-ui] #appShell > [data-shell-chrome][data-wc-reading] .shell-style select { height: auto; min-height: 2rem; }
html:not([data-ui="studio"]) #appShell > [data-shell-chrome][data-wc-reading] > .shell-nav {
  position: static; order: 4; flex: 1 1 100%; display: flex; flex-wrap: wrap;
  width: 100%; height: auto; max-height: none; min-height: 0; padding: .25rem 0;
  overflow: visible;
}
html:not([data-ui="studio"]) #appShell > [data-shell-chrome][data-wc-reading] .shell-nav-item {
  flex: 1 1 8rem; flex-direction: row; width: auto; height: auto; min-height: 2.75rem;
  padding: .375rem .5rem; gap: .375rem; font-size: .875rem;
}
html:not([data-ui="studio"]) #appShell > [data-shell-chrome][data-wc-reading] .shell-nav-item span { white-space: normal; }
html[data-ui="studio"] #appShell > [data-shell-chrome][data-wc-reading] > .studio-context {
  flex: 1 1 100%; flex-wrap: wrap; height: auto; width: 100%; max-width: 100%;
}
html[data-ui="studio"] #appShell > [data-shell-chrome][data-wc-reading] .studio-context > :is(.studio-chooser,.studio-project,.studio-focus-toggle) {
  width: auto; height: auto; min-width: 2.75rem; min-height: 2.75rem; max-width: 100%;
}
html[data-ui="studio"] #appShell > [data-shell-chrome][data-wc-reading] .studio-context > :is(.studio-chooser,.studio-project) { flex: 1 1 8rem; }
html[data-ui="studio"] #appShell > [data-shell-chrome][data-wc-reading] > .shell-nav {
  position: static; inset: auto; order: 4; flex: 1 1 100%; width: 100%; height: auto; max-height: none;
}
/* Enlarged text folds the navigation behind the chooser only where the chooser exists (narrow); on a desktop bar
   the navigation stays as its own wrapped row, since nothing else could reopen it. */
@media (max-width: 51.25rem) {
  html[data-ui="studio"]:not(.studio-nav-open) #appShell > [data-shell-chrome][data-wc-reading] > .shell-nav { display: none; }
}
html[data-lab-host] #appShell > [data-shell-chrome][data-wc-reading] > :is(.shell-nav,.studio-context) { display: none; }
/* Ordinary text: the tool buttons keep their own width and the interface-style picker takes what is left, so the
   guide, home and task tools never lie under Display. Narrow: two rows; 820-1200 px: one row with a compact Display. */
@media (max-width: 51.25rem) {
  html[data-ui]:not([data-lab-host]) body #appShell > .global-shell[data-shell-chrome]:not([data-wc-reading]) { grid-template-columns: auto auto minmax(0, 1fr); }
  html[data-ui]:not([data-lab-host]) body #appShell > [data-shell-chrome]:not([data-wc-reading]) > .shell-style { width: auto; min-width: 0; max-width: 7.5rem; justify-self: end; }
}
@media (min-width: 51.3125rem) and (max-width: 75rem) {
  html[data-ui]:not([data-ui="studio"]):not([data-lab-host]) body #appShell > .global-shell[data-shell-chrome]:not([data-wc-reading]) { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
  html[data-ui]:not([data-lab-host]) body #appShell > [data-shell-chrome]:not([data-wc-reading]) .wc-menu-btn > .wc-cap { display: none; }
}
