/* Story #0 | 2026-09-07 | George | Refine the authenticated workspace shell and Codex chat into a compact professional operating surface. */

/* Story #0 | 2026-09-07 | George | Establish a restrained, route-safe shell foundation without changing global page styles. */
.shell {
  --workspace-canvas: #f7f9fc;
  --workspace-surface: #ffffff;
  --workspace-surface-subtle: #f2f5f9;
  --workspace-text: #172033;
  --workspace-muted: #667085;
  --workspace-line: #e3e8ef;
  --workspace-line-strong: #cfd8e5;
  --workspace-blue: #2563eb;
  --workspace-blue-soft: #eef4ff;
  --workspace-danger: #b42318;
  --workspace-danger-soft: #fff4f2;
  --workspace-shadow: 0 10px 30px rgba(16, 24, 40, .06);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  background: var(--workspace-canvas);
  color: var(--workspace-text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  transition: grid-template-columns .18s ease;
}

.shell *,
.shell *::before,
.shell *::after {
  box-sizing: border-box;
}

.shell.nav-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.shell .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell :is(button, a, input, textarea, summary):focus-visible {
  outline: 2px solid var(--workspace-blue);
  outline-offset: 2px;
}

/* Story #0 | 2026-09-07 | George | Make navigation calm, compact, and independently scrollable on desktop. */
.shell .rail {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 232px;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px 10px 10px;
  overflow: hidden;
  background: var(--workspace-surface);
  border-right: 1px solid var(--workspace-line);
  transition: width .18s ease, transform .18s ease;
}

.shell .rail-brand {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 2px 4px 12px;
  border-bottom: 1px solid var(--workspace-line);
}

.shell .rail-brand .brand-logo {
  width: 128px;
  max-width: calc(100% - 34px);
  height: auto;
}

.shell .rail-collapse,
.shell .shell-menu,
.shell .user-row,
.shell .rail-user [data-sign-out] {
  -webkit-tap-highlight-color: transparent;
}

.shell .rail-collapse,
.shell .shell-menu {
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--workspace-muted);
  cursor: pointer;
}

.shell .rail-collapse {
  position: absolute;
  top: 0;
  right: 0;
}

.shell .rail-collapse svg,
.shell .shell-menu svg,
.shell .nav-icon svg,
.shell .rail-user [data-sign-out] svg,
.shell .codex-chat-composer button svg,
.shell .chat-symbol svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.shell .rail-collapse:hover,
.shell .shell-menu:hover,
.shell .rail-user [data-sign-out]:hover {
  background: var(--workspace-surface-subtle);
  color: var(--workspace-text);
}

.shell .tenant-switcher {
  /* Story #0 | 2026-09-07 | George | Present the fixed tenant as context rather than an unavailable switch action. */
  cursor: default;
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 7px;
  border: 1px solid var(--workspace-line);
  border-radius: 7px;
  background: #fbfcfe;
  color: var(--workspace-text);
}

.shell .tenant-avatar {
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: var(--workspace-blue-soft);
  color: var(--workspace-blue);
  font-size: 11px;
  font-weight: 700;
}

.shell .tenant-switcher strong {
  min-width: 0;
  overflow: hidden;
  color: var(--workspace-text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell .rail nav {
  min-height: 0;
  display: block;
  padding: 0 2px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.shell .rail-section {
  display: grid;
  gap: 2px;
  margin: 0 0 16px;
}

.shell .rail-title {
  margin: 0;
  padding: 0 8px 5px;
  color: var(--workspace-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.shell .nav-link {
  min-width: 0;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  color: #4b5565;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.shell .nav-link:hover {
  background: var(--workspace-surface-subtle);
  color: var(--workspace-text);
}

.shell .nav-link.is-active {
  background: var(--workspace-blue-soft);
  color: #1d4ed8;
  font-weight: 600;
}

.shell .nav-main {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.shell .nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-grid;
  place-items: center;
  color: #667085;
}

.shell .nav-link.is-active .nav-icon {
  color: var(--workspace-blue);
}

.shell .nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell .nav-count {
  min-width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: #f0f3f7;
  color: #667085;
  font-size: 11px;
  font-weight: 600;
}

.shell .rail-user {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 4px 0;
  border-top: 1px solid var(--workspace-line);
}

.shell .user-row {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.shell .avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #eaf2ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
}

.shell .user-meta {
  min-width: 0;
}

.shell .user-meta strong,
.shell .user-meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell .user-meta strong {
  color: var(--workspace-text);
  font-size: 11px;
  font-weight: 600;
}

.shell .user-meta small {
  margin-top: 1px;
  color: var(--workspace-muted);
  font-size: 10px;
}

.shell .rail-user [data-sign-out] {
  width: 30px;
  height: 30px;
  min-height: 30px;
  flex: 0 0 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--workspace-muted);
  cursor: pointer;
}

/* Story #0 | 2026-09-07 | George | Preserve all shell routes while making the collapsed rail scan as icons rather than clipped text. */
.shell.nav-collapsed .rail {
  width: 72px;
  padding-right: 10px;
  padding-left: 10px;
}

.shell.nav-collapsed .rail-brand {
  justify-items: center;
}

.shell.nav-collapsed .rail-brand .brand-logo {
  width: 35px;
  max-width: 35px;
  object-fit: cover;
  object-position: left;
}

.shell.nav-collapsed .rail-collapse {
  position: static;
}

.shell.nav-collapsed .tenant-switcher,
.shell.nav-collapsed .rail-title,
.shell.nav-collapsed .nav-label,
.shell.nav-collapsed .nav-count,
.shell.nav-collapsed .user-meta {
  display: none;
}

.shell.nav-collapsed .rail nav {
  padding: 0;
}

.shell.nav-collapsed .rail-section {
  justify-items: center;
}

.shell.nav-collapsed .nav-link {
  width: 36px;
  justify-content: center;
  padding: 7px;
}

.shell.nav-collapsed .nav-main {
  gap: 0;
}

.shell.nav-collapsed .rail-user,
.shell.nav-collapsed .user-row {
  justify-content: center;
}

.shell.nav-collapsed .rail-user [data-sign-out] {
  display: none;
}

/* Story #0 | 2026-09-07 | George | Give the application header a lean command-bar rhythm while preserving normal page content widths. */
.shell .main {
  min-width: 0;
}

.shell .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 56px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 28px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--workspace-line);
  backdrop-filter: blur(10px);
}

.shell .topbar-leading,
.shell .topbar-right {
  min-width: 0;
  display: flex;
  align-items: center;
}

.shell .topbar-leading {
  gap: 10px;
}

.shell .shell-menu {
  display: none;
}

.shell .topbar .shell-menu {
  display: none;
}

.shell .topbar-breadcrumbs {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--workspace-muted);
  font-size: 13px;
  font-weight: 500;
}

.shell .topbar-breadcrumbs a {
  min-height: 0;
  color: inherit;
  text-decoration: none;
}

.shell .topbar-breadcrumbs a:hover {
  color: var(--workspace-blue);
}

.shell .topbar-breadcrumbs strong {
  min-width: 0;
  overflow: hidden;
  color: var(--workspace-text);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell .topbar-right {
  justify-content: flex-end;
  gap: 8px;
}

.shell .topbar-search {
  position: relative;
  width: min(330px, 28vw);
  z-index: 30;
}

/* Story #0 | 2026-09-07 | George | Keep the workspace search result list readable and reachable from the keyboard. */
.shell .topbar-search-label {
  position: relative;
  display: block;
}

.shell .workspace-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(420px, calc(100vw - 32px));
  max-height: min(60vh, 360px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--workspace-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(16, 24, 40, .16);
}

.shell .workspace-search-result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--workspace-text);
  text-align: left;
  cursor: pointer;
}

.shell .workspace-search-result:hover,
.shell .workspace-search-result[aria-selected="true"] {
  background: #eef4ff;
}

.shell .workspace-search-result-label {
  max-width: 100%;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell .workspace-search-result small,
.shell .workspace-search-empty {
  color: var(--workspace-muted);
  font-size: 11px;
  font-weight: 500;
}

.shell .workspace-search-empty {
  padding: 12px 10px;
}

/* Story #0 | 2026-09-07 | George | Keep the search glyph attached to its labelled input after adding results. */
.shell .topbar-search-label > span {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 14px;
  height: 14px;
  border: 1.7px solid #98a2b3;
  border-radius: 999px;
  transform: translateY(-50%);
  pointer-events: none;
}

.shell .topbar-search-label > span::after {
  content: "";
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 6px;
  height: 1.7px;
  border-radius: 999px;
  background: #98a2b3;
  transform: rotate(45deg);
}

.shell .search-box {
  width: 100%;
  min-height: 34px;
  padding: 7px 11px 7px 33px;
  border: 1px solid var(--workspace-line);
  border-radius: 6px;
  background: #fbfcfe;
  color: var(--workspace-text);
  font-size: 12px;
  outline: none;
}

.shell .search-box::placeholder {
  color: var(--workspace-muted);
}

.shell .search-box:focus {
  border-color: #84adff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.shell .topbar-icon,
.shell .topbar .icon-btn,
.shell .topbar-avatar {
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--workspace-muted);
  text-decoration: none;
}

.shell .topbar .icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.shell .topbar-icon:hover,
.shell .topbar-avatar:hover {
  background: var(--workspace-surface-subtle);
  color: var(--workspace-text);
}

.shell .topbar-avatar {
  border-radius: 999px;
  background: #eaf2ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
}

.shell .content {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.shell .shell-backdrop {
  display: none;
}

/* Story #0 | 2026-09-07 | George | Make the chat route a focused conversation workspace with evidence in a subordinate inspector. */
.shell.shell-chat .content {
  width: min(1440px, calc(100% - 48px));
  min-height: calc(100dvh - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding-bottom: 20px;
}

.shell .codex-chat-head {
  align-items: center;
  margin: 0 0 16px;
}

.shell .page-kicker {
  margin: 0 0 4px;
  color: var(--workspace-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.shell .page-head h1 {
  color: var(--workspace-text);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
}

.shell .page-head p {
  max-width: 720px;
  margin-top: 5px;
  color: var(--workspace-muted);
  font-size: 13px;
}

.shell .codex-chat-actions .badge,
.shell .codex-chat-run-card .badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid #bfd5ff;
  border-radius: 999px;
  background: var(--workspace-blue-soft);
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 600;
}

.shell .codex-chat-run-card .badge.success {
  border-color: #abefc6;
  background: #ecfdf3;
  color: #067647;
}

.shell .codex-chat-run-card .badge.warning,
.shell .codex-chat-actions .badge.warning {
  border-color: #fedf89;
  background: #fffaeb;
  color: #b54708;
}

.shell .codex-chat-run-card .badge.info,
.shell .codex-chat-actions .badge.info {
  border-color: #bfd5ff;
  background: var(--workspace-blue-soft);
  color: #1d4ed8;
}

.shell .codex-chat-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 282px;
  gap: 18px;
  align-items: stretch;
}

.shell .codex-chat-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--workspace-line);
  border-radius: 10px;
  background: var(--workspace-surface);
  box-shadow: var(--workspace-shadow);
}

.shell .codex-chat-transcript {
  min-height: 0;
  max-height: none;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 28px clamp(20px, 4vw, 52px);
  overflow-y: auto;
  background: var(--workspace-surface);
  border: 0;
  border-radius: 0;
  scrollbar-width: thin;
}

.shell .codex-chat-empty {
  width: min(540px, 100%);
  align-self: center;
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 20px 0;
  text-align: center;
}

.shell .chat-symbol {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: var(--workspace-blue-soft);
  color: var(--workspace-blue);
}

.shell .chat-symbol svg {
  width: 20px;
  height: 20px;
}

.shell .codex-chat-empty h2 {
  margin: 2px 0 0;
  color: var(--workspace-text);
  font-size: 18px;
  font-weight: 600;
}

.shell .codex-chat-empty p {
  max-width: 430px;
  margin: 0;
  color: var(--workspace-muted);
  font-size: 13px;
}

.shell .chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 4px;
}

.shell .chat-suggestions button {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--workspace-line);
  border-radius: 6px;
  background: #fff;
  color: #475467;
  font-size: 12px;
  cursor: pointer;
}

.shell .chat-suggestions button:hover,
.shell .chat-suggestions button:focus-visible {
  border-color: #a9c5ff;
  background: var(--workspace-blue-soft);
  color: #1d4ed8;
}

.shell .story-chat-message.codex-chat-message {
  width: fit-content;
  max-width: min(760px, 88%);
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f5f7fa;
  color: var(--workspace-text);
}

.shell .story-chat-message.codex-chat-message.user {
  justify-self: end;
  background: var(--workspace-blue-soft);
  border-color: #d6e4ff;
}

.shell .story-chat-message.codex-chat-message.assistant {
  justify-self: start;
}

.shell .story-chat-message.codex-chat-message.system {
  justify-self: start;
  background: #f8fafc;
  color: #475467;
}

.shell .story-chat-message.codex-chat-message strong {
  color: inherit;
  font-size: 11px;
  font-weight: 600;
}

.shell .story-chat-message.codex-chat-message p {
  margin: 0;
  color: inherit;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.shell .story-chat-message.codex-chat-message.is-busy {
  background: #f8fafc;
  border-color: var(--workspace-line);
}

.shell .codex-chat-error {
  width: min(760px, 100%);
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #fecdc7;
  border-radius: 7px;
  background: var(--workspace-danger-soft);
  color: var(--workspace-danger);
}

.shell .codex-chat-error strong {
  font-size: 12px;
  font-weight: 600;
}

.shell .codex-chat-error p {
  margin: 0;
  color: inherit;
  font-size: 12px;
}

.shell .codex-chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  padding: 14px 16px 10px;
  border-top: 1px solid var(--workspace-line);
  background: var(--workspace-surface);
}

.shell .codex-chat-composer .field {
  min-width: 0;
}

.shell .codex-chat-composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 150px;
  display: block;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--workspace-line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--workspace-text);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
}

.shell .codex-chat-composer textarea:focus {
  border-color: #84adff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.shell .codex-chat-composer-actions {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.shell .chat-composer-hint {
  flex: 1 1 auto;
  color: var(--workspace-muted);
  font-size: 11px;
  white-space: nowrap;
}

.shell .codex-chat-composer .btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.shell .codex-chat-composer .btn.primary {
  border: 1px solid var(--workspace-blue);
  background: var(--workspace-blue);
  color: #fff;
}

.shell .codex-chat-composer .btn.primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.shell .codex-chat-composer .btn.secondary {
  border: 1px solid var(--workspace-line-strong);
  background: #fff;
  color: #475467;
}

.shell .codex-chat-composer .btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.shell .chat-policy-note {
  margin: 0;
  padding: 0 16px 12px;
  color: var(--workspace-muted);
  font-size: 11px;
}

.shell .codex-chat-side {
  min-width: 0;
  align-self: start;
  display: grid;
  gap: 12px;
}

.shell .codex-chat-run-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--workspace-line);
  border-radius: 9px;
  background: var(--workspace-surface);
}

.shell .codex-chat-run-card .panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.shell .codex-chat-run-card .panel-head h2 {
  margin: 0;
  color: var(--workspace-text);
  font-size: 14px;
  font-weight: 600;
}

.shell .codex-chat-run-card .panel-head p,
.shell .codex-chat-run-card > p {
  margin: 3px 0 0;
  color: var(--workspace-muted);
  font-size: 12px;
}

.shell .codex-chat-facts {
  display: grid;
  gap: 0;
  margin: 0;
}

.shell .codex-chat-facts div {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-top: 1px solid var(--workspace-line);
}

.shell .codex-chat-facts div:first-child {
  padding-top: 0;
  border-top: 0;
}

.shell .codex-chat-facts dt {
  color: var(--workspace-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.shell .codex-chat-facts dd {
  min-width: 0;
  margin: 0;
  color: var(--workspace-text);
  font-size: 12px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.shell .codex-chat-facts code {
  display: inline;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: 11px/1.45 Consolas, "Liberation Mono", monospace;
}

.shell .codex-chat-run-card details {
  margin-top: 10px;
  border-top: 1px solid var(--workspace-line);
}

.shell .codex-chat-run-card summary {
  padding: 9px 0 0;
  color: #475467;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.shell .codex-chat-run-card details .codex-chat-facts {
  margin-top: 8px;
}

/* Story #0 | 2026-09-07 | George | Keep the shell usable at narrow widths with a true drawer and no horizontal chat overflow. */
@media (min-width: 861px) and (max-width: 1180px) {
  .shell.shell-chat .content {
    width: min(980px, calc(100% - 40px));
    display: block;
    min-height: 0;
  }

  .shell .codex-chat-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .shell .codex-chat-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shell .codex-chat-panel {
    height: min(620px, calc(100dvh - 156px));
  }
}

@media (min-width: 1181px) {
  /* Story #0 | 2026-09-07 | George | Bound both conversation and inspector independently when receipt details expand. */
  .shell.shell-chat .main {
    height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .shell.shell-chat {
    height: 100dvh;
    overflow: hidden;
  }

  .shell.shell-chat .content {
    height: calc(100dvh - 56px);
    min-height: 0;
  }

  .shell.shell-chat .codex-chat-layout,
  .shell.shell-chat .codex-chat-panel {
    min-height: 0;
  }

  .shell.shell-chat .codex-chat-side {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    scrollbar-width: thin;
  }
}

@media (max-width: 860px) {
  .shell,
  .shell.nav-collapsed {
    display: block;
  }

  .shell .rail,
  .shell.nav-collapsed .rail {
    position: fixed;
    left: 0;
    width: min(292px, calc(100vw - 48px));
    transform: translateX(-102%);
    box-shadow: none;
  }

  .shell.nav-open .rail {
    transform: translateX(0);
    box-shadow: 10px 0 30px rgba(16, 24, 40, .16);
  }

  .shell.nav-collapsed .rail-brand {
    justify-items: initial;
  }

  .shell.nav-collapsed .rail-brand .brand-logo {
    width: 128px;
    max-width: calc(100% - 34px);
    object-fit: initial;
  }

  .shell.nav-collapsed .rail-collapse {
    position: absolute;
  }

  .shell.nav-collapsed .tenant-switcher,
  .shell.nav-collapsed .rail-title,
  .shell.nav-collapsed .nav-label,
  .shell.nav-collapsed .nav-count,
  .shell.nav-collapsed .user-meta,
  .shell.nav-collapsed .rail-user [data-sign-out] {
    display: flex;
  }

  .shell.nav-collapsed .rail-title,
  .shell.nav-collapsed .nav-label,
  .shell.nav-collapsed .user-meta {
    display: block;
  }

  .shell.nav-collapsed .nav-count,
  .shell.nav-collapsed .rail-user [data-sign-out] {
    display: inline-grid;
  }

  .shell.nav-collapsed .rail-section,
  .shell.nav-collapsed .rail-user,
  .shell.nav-collapsed .user-row {
    justify-items: initial;
    justify-content: initial;
  }

  .shell.nav-collapsed .nav-link {
    width: auto;
    justify-content: space-between;
    padding: 7px 8px;
  }

  .shell.nav-collapsed .nav-main {
    gap: 9px;
  }

  .shell .topbar {
    min-height: 52px;
    display: flex;
    flex-direction: row;
    padding: 8px 16px;
    /* Story #0 | 2026-09-07 | George | Let the mobile search popup escape the legacy overflow-clipped header. */
    overflow: visible;
    backdrop-filter: none;
  }

  .shell .topbar-leading {
    min-width: 0;
    flex: 1 1 auto;
  }

  /* Story #0 | 2026-09-07 | George | Show the current section on phones so long project breadcrumbs cannot cover search. */
  .shell .topbar-breadcrumbs {
    overflow: hidden;
    white-space: nowrap;
  }

  .shell .topbar-breadcrumbs > :not(strong) { display: none; }

  .shell .topbar-right {
    min-width: max-content;
    /* Story #0 | 2026-09-07 | George | Keep the legacy full-width toolbar from hiding the mobile breadcrumb. */
    width: auto;
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .shell .topbar .shell-menu {
    display: inline-grid;
  }

  /* Story #0 | 2026-09-07 | George | Keep workspace search available on mobile while preserving the compact navigation rail. */
  .shell .topbar-search {
    display: block;
    width: min(145px, 40vw);
    flex-shrink: 0;
  }

  .shell .search-box {
    font-size: 16px;
  }

  .shell .workspace-search-results {
    position: fixed;
    top: 58px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: min(60vh, 360px);
  }

  .shell .content,
  .shell.shell-chat .content {
    width: min(100% - 28px, 680px);
    min-height: calc(100dvh - 52px);
    padding-top: 18px;
  }

  .shell.shell-chat .content {
    /* Story #0 | 2026-09-07 | George | Let context follow the mobile conversation without consuming its reading space. */
    height: auto;
    min-height: 0;
    display: block;
    padding-bottom: 16px;
  }

  .shell .shell-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    border: 0;
    background: rgba(16, 24, 40, .32);
  }

  .shell.nav-open .shell-backdrop:not([hidden]) {
    display: block;
  }

  .shell .codex-chat-head {
    align-items: flex-start;
  }

  .shell .page-head h1 {
    font-size: 23px;
  }

  .shell .codex-chat-layout {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .shell.shell-chat .codex-chat-panel {
    width: 100%;
    height: calc(100dvh - 154px);
    min-height: 340px;
  }

  .shell .codex-chat-transcript {
    padding: 20px 16px;
  }

  .shell .story-chat-message.codex-chat-message,
  .shell .codex-chat-error {
    max-width: 100%;
  }

  .shell .codex-chat-composer {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  /* Story #0 | 2026-09-07 | George | Keep the mobile composer readable without automatic browser input zoom. */
  .shell .codex-chat-composer textarea { font-size: 16px; }

  .shell .codex-chat-composer-actions {
    justify-content: space-between;
  }

  .shell .chat-composer-hint {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .shell .codex-chat-side {
    grid-template-columns: 1fr;
  }
}

/* Story #0 | 2026-09-07 | George | Override the generic icon control display so desktop has one navigation toggle. */
@media (min-width: 861px) {
  .shell .topbar .shell-menu { display: none; }
}

@media (max-width: 440px) {
  .shell .topbar-leading {
    max-width: 120px;
  }

  .shell .topbar-right {
    gap: 3px;
  }

  .shell .topbar-breadcrumbs {
    max-width: 100px;
  }

  .shell .topbar-search {
    /* Story #0 | 2026-09-07 | George | Reserve enough width for a short query and its native clear button. */
    width: min(130px, 34vw);
  }

  .shell .codex-chat-head .codex-chat-actions {
    display: none;
  }

  .shell .chat-composer-hint {
    display: none;
  }
}

/* Story #0 | 2026-09-07 | George | Keep local draft recovery legible in the existing editor at desktop and phone widths. */
.work-item-drafts {
  min-width: 0;
  padding: 12px;
  border: 1px solid #e0bd68;
  border-radius: 6px;
  background: #fffbef;
  overflow-wrap: anywhere;
}

.work-item-drafts summary {
  cursor: pointer;
  font-weight: 600;
}

.work-item-drafts p { margin: 10px 0; }
.work-item-draft { margin-top: 12px; }
.work-item-draft-field { margin: 12px 0; }
.work-item-draft-value {
  margin-top: 4px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e3e8ef;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .shell,
  .shell .rail {
    transition: none;
  }
}

/* Story #0 | 2026-11-06 | George | Keep the explicit legacy project import choices readable on narrow screens. */
.project-import-list { display: grid; gap: .75rem; margin: 1rem 0; }
.project-import-list label { display: flex; align-items: center; gap: .5rem; overflow-wrap: anywhere; }
.project-import-list input { flex: 0 0 auto; }
.project-import-panel .btn { white-space: normal; }
