body.ui-refresh-enabled .ide-header {
  min-height: var(--ui-header-height);
  height: auto;
  padding: var(--ui-space-2) var(--ui-space-4) 0;
  display: grid;
  grid-template-columns: minmax(210px, auto) minmax(160px, 1fr) minmax(0, auto);
  grid-template-areas:
    "title context actions"
    "nav nav nav";
  grid-auto-rows: auto;
  row-gap: var(--ui-space-2);
  column-gap: var(--ui-space-4);
  align-items: center;
  isolation: isolate;
  container-type: inline-size;
  border-bottom: 1px solid var(--border-color);
}

body.ui-refresh-enabled .ide-title {
  grid-area: title;
  gap: var(--ui-space-3);
  min-width: 0;
}

body.ui-refresh-enabled .ide-title > div {
  min-width: 0;
}

body.ui-refresh-enabled #brainStudioTitle {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

body.ui-refresh-enabled #modeDescription {
  font-size: 10px !important;
  margin-top: 1px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-refresh-enabled .ide-header > #brainPickerBtn {
  grid-area: context;
  justify-self: start;
  min-width: 0;
  max-width: min(360px, 100%);
}

body.ui-refresh-enabled .ide-header > nav {
  grid-area: nav;
  display: flex !important;
  align-items: stretch;
  gap: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  min-width: 0;
  overflow-x: auto;
  border-top: 1px solid var(--border-color);
}

body.ui-refresh-enabled .tab-btn {
  border-bottom: 3px solid transparent;
  padding: 0 var(--ui-space-4);
  height: 100%;
  min-height: 44px;
  font-size: 13px;
  gap: var(--ui-space-2);
  white-space: nowrap;
  flex: 0 0 auto;
  line-height: 1;
}

body.ui-refresh-enabled .tab-btn svg {
  width: 15px;
  height: 15px;
}

body.ui-refresh-enabled .tab-btn.active {
  border-bottom-color: var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
}

body.ui-refresh-enabled .runtime-context-shell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ui-space-3);
  padding: var(--ui-space-2) var(--ui-space-4);
  border-bottom: 1px solid var(--border-color);
  background: color-mix(in srgb, var(--bg-secondary) 88%, transparent);
}

body.ui-refresh-enabled .runtime-context-pills {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  min-width: 0;
  width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
}

body.ui-refresh-enabled .runtime-context-pills::-webkit-scrollbar {
  height: 6px;
}

body.ui-refresh-enabled .runtime-context-pill,
body.ui-refresh-enabled .runtime-context-row,
body.ui-refresh-enabled .runtime-context-summary {
  appearance: none;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 10px;
}

body.ui-refresh-enabled .runtime-context-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 0 auto;
  padding: 8px 10px;
  cursor: pointer;
}

body.ui-refresh-enabled .runtime-context-pill__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

body.ui-refresh-enabled .runtime-context-pill__value {
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
}

body.ui-refresh-enabled .runtime-context-pill--setup {
  border-style: dashed;
}

body.ui-refresh-enabled .runtime-context-pill[data-state="active"] {
  border-color: color-mix(in srgb, var(--accent-primary) 55%, var(--border-color));
  background: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-tertiary));
}

body.ui-refresh-enabled .runtime-context-pill[data-state="attention"] {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.12);
}

body.ui-refresh-enabled .runtime-context-pill[data-state="warning"] {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
}

body.ui-refresh-enabled .runtime-context-pill[data-state="success"] {
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.1);
}

body.ui-refresh-enabled .runtime-context-summary {
  display: none;
  width: 100%;
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

body.ui-refresh-enabled .runtime-context-summary__eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

body.ui-refresh-enabled .runtime-context-summary__text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

body.ui-refresh-enabled .runtime-context-sheet {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

body.ui-refresh-enabled .runtime-context-sheet.hidden {
  display: none;
}

body.ui-refresh-enabled .runtime-context-sheet__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(8, 12, 20, 0.56);
}

body.ui-refresh-enabled .runtime-context-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-3);
  padding: var(--ui-space-4);
  padding-bottom: calc(var(--ui-space-4) + env(safe-area-inset-bottom, 0px));
  background: var(--bg-secondary);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.35);
}

body.ui-refresh-enabled .runtime-context-sheet__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ui-space-3);
}

body.ui-refresh-enabled .runtime-context-sheet__eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

body.ui-refresh-enabled .runtime-context-sheet__title {
  margin: 2px 0 0;
  font-size: 16px;
}

body.ui-refresh-enabled .runtime-context-sheet__close {
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

body.ui-refresh-enabled .runtime-context-sheet__rows {
  display: grid;
  gap: var(--ui-space-2);
}

body.ui-refresh-enabled .runtime-context-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-3);
  width: 100%;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
}

body.ui-refresh-enabled .runtime-context-row__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

body.ui-refresh-enabled .runtime-context-row__value {
  min-width: 0;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

body.ui-refresh-enabled .header-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-self: end;
  justify-content: flex-end;
  gap: var(--ui-space-2);
  flex-wrap: nowrap;
  min-width: 0;
  max-width: min(46vw, 520px);
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

body.ui-refresh-enabled .header-actions::-webkit-scrollbar {
  height: 6px;
}

body.ui-refresh-enabled .header-group {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
  height: auto;
  border-right: none;
  padding: 0;
  gap: var(--ui-space-1);
  white-space: nowrap;
}

body.ui-refresh-enabled .header-group:not(:last-child) {
  padding-right: var(--ui-space-1);
  margin-right: var(--ui-space-1);
  border-right: 1px solid color-mix(in srgb, var(--border-color) 82%, transparent);
}

body.ui-refresh-enabled .header-group-label {
  display: none;
}

body.ui-refresh-enabled .btn,
body.ui-refresh-enabled .btn-icon,
body.ui-refresh-enabled #brainPickerBtn {
  min-height: var(--ui-control-height);
  border-radius: var(--ui-radius-sm);
  flex: 0 0 auto;
}

body.ui-refresh-enabled .btn-icon {
  width: var(--ui-control-height);
  height: var(--ui-control-height);
}

body.ui-refresh-enabled .btn-icon svg {
  width: var(--ui-icon-size);
  height: var(--ui-icon-size);
  stroke-width: 2;
}

body.ui-refresh-enabled #brainPickerBtn {
  margin-left: 0 !important;
  padding: 0 var(--ui-space-3) !important;
  display: inline-flex !important;
  align-items: center;
  gap: var(--ui-space-2);
  line-height: 1;
}

body.ui-refresh-enabled #brainPickerLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-refresh-enabled .btn svg {
  flex: 0 0 auto;
}

body.ui-refresh-enabled #ai-btn {
  background: color-mix(in srgb, var(--accent-primary) 18%, var(--bg-tertiary)) !important;
  border: 1px solid color-mix(in srgb, var(--accent-primary) 38%, var(--border-color));
  min-width: auto;
  padding: 0 var(--ui-space-3) !important;
}

body.ui-refresh-enabled .header-ai-label {
  display: inline;
}

body.ui-refresh-enabled #ai-btn:not(.active) {
  background: var(--bg-tertiary) !important;
}

body.ui-refresh-enabled #save-btn {
  min-width: auto;
}

body.ui-refresh-enabled .header-overflow {
  position: relative;
}

body.ui-refresh-enabled .header-overflow-menu {
  position: absolute;
  top: calc(100% + var(--ui-space-2));
  right: 0;
  min-width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--ui-radius-md);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  display: none;
  flex-direction: column;
  padding: var(--ui-space-2);
  z-index: 1200;
}

body.ui-refresh-enabled .header-overflow-menu.open {
  display: flex;
}

body.ui-refresh-enabled .overflow-item {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  padding: var(--ui-space-2) var(--ui-space-3);
  border-radius: var(--ui-radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 12px;
}

body.ui-refresh-enabled .overflow-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

body.ui-refresh-enabled .overflow-item svg {
  width: 14px;
  height: 14px;
}

body.ui-refresh-enabled .overflow-divider {
  height: 1px;
  margin: var(--ui-space-1) 0;
  background: var(--border-color);
  opacity: 0.7;
}

body.ui-refresh-enabled .header-group .low-frequency-action {
  display: none !important;
}

body.ui-refresh-enabled .sidebar {
  container-type: inline-size;
}

body.ui-refresh-enabled .sidebar-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--ui-space-2);
  padding: var(--ui-space-3) var(--ui-space-4);
}

body.ui-refresh-enabled .sidebar-header span:first-child {
  letter-spacing: 0.06em;
  min-width: 0;
}

body.ui-refresh-enabled .sidebar-header .sidebar-actions {
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 4px !important;
  min-width: 0;
  max-width: 220px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

body.ui-refresh-enabled .sidebar-header .sidebar-actions::-webkit-scrollbar {
  display: none;
}

@container (max-width: 320px) {
  body.ui-refresh-enabled .sidebar-header {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    row-gap: var(--ui-space-1);
  }

  body.ui-refresh-enabled .sidebar-header .sidebar-actions {
    justify-content: flex-start;
    max-width: 100%;
  }

  body.ui-refresh-enabled .sidebar-header .sidebar-actions #auto-refresh-btn,
  body.ui-refresh-enabled .sidebar-header .sidebar-actions [data-action="toggleSidebar()"] {
    display: none !important;
  }
}

@container (max-width: 560px) {
  body.ui-refresh-enabled .header-actions [data-action="createNewFolder()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="downloadCurrentFile()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="toggleSnapshotHistory()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions #save-all-btn {
    display: none !important;
  }
}

@container (max-width: 460px) {
  body.ui-refresh-enabled .header-actions [data-action="createNewFile()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="toggleSearch()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="togglePreview()"]:not(.overflow-item) {
    display: none !important;
  }
}

@container (max-width: 340px) {
  body.ui-refresh-enabled .header-actions [data-action="createNewFile()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="createNewFolder()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="downloadCurrentFile()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="toggleSearch()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="togglePreview()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions [data-action="toggleSnapshotHistory()"]:not(.overflow-item),
  body.ui-refresh-enabled .header-actions #save-all-btn {
    display: none !important;
  }
}

@container (max-width: 280px) {
  body.ui-refresh-enabled .sidebar-header .sidebar-actions #auto-refresh-btn {
    display: none !important;
  }
}

@container (max-width: 220px) {
  body.ui-refresh-enabled .sidebar-header .sidebar-actions #go-up-btn {
    display: none !important;
  }
}

@container (max-width: 200px) {
  body.ui-refresh-enabled .sidebar-header .sidebar-actions [data-action="refreshFileTree()"] {
    display: none !important;
  }
}

@container (max-width: 180px) {
  body.ui-refresh-enabled .sidebar-header .sidebar-actions #go-home-btn {
    display: none !important;
  }
}

@container (max-width: 170px) {
  body.ui-refresh-enabled .sidebar-header .sidebar-actions #brain-folder-btn {
    display: none !important;
  }
}

body.ui-refresh-enabled .sidebar-path {
  min-height: 26px;
  display: flex;
  align-items: center;
  padding: 0 var(--ui-space-4) !important;
}

body.ui-refresh-enabled .file-item,
body.ui-refresh-enabled .folder-item,
body.ui-refresh-enabled .tab {
  min-height: 32px;
}

body.ui-refresh-enabled .ai-header {
  min-height: 46px;
  padding: var(--ui-space-2) var(--ui-space-3);
}

body.ui-refresh-enabled .ai-input-container {
  padding: var(--ui-space-2) var(--ui-space-3);
}

body.ui-refresh-enabled .browse-meta,
body.ui-refresh-enabled .browse-empty,
body.ui-refresh-enabled .browse-error {
  font-size: 11px;
  padding: var(--ui-space-2) var(--ui-space-3);
  border-bottom: 1px solid var(--border-color);
}

body.ui-refresh-enabled .browse-meta {
  color: var(--warning-color);
  background: color-mix(in srgb, var(--warning-color) 10%, transparent);
}

body.ui-refresh-enabled .browse-error {
  color: var(--error-color);
  background: color-mix(in srgb, var(--error-color) 10%, transparent);
}

body.ui-refresh-enabled .onboarding-empty-state {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, color-mix(in srgb, var(--bg-primary) 88%, var(--accent-primary) 12%), var(--bg-primary));
  z-index: 5;
}

body.ui-refresh-enabled .onboarding-empty-state.visible {
  display: flex;
}

body.ui-refresh-enabled .onboarding-card {
  width: min(580px, 92%);
  padding: var(--ui-space-5);
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: color-mix(in srgb, var(--bg-secondary) 92%, var(--accent-primary) 8%);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

body.ui-refresh-enabled .onboarding-card h2 {
  font-size: 22px;
  margin-bottom: var(--ui-space-2);
}

body.ui-refresh-enabled .onboarding-card p {
  color: var(--text-secondary);
  margin-bottom: var(--ui-space-4);
  line-height: 1.55;
}

body.ui-refresh-enabled .onboarding-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--ui-space-2);
}

body.ui-refresh-enabled .onboarding-action {
  min-height: 40px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
}

body.ui-refresh-enabled .onboarding-action.primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

body.ui-refresh-enabled .readiness-disabled {
  opacity: 0.48 !important;
  cursor: not-allowed !important;
}

body.ui-refresh-enabled .overflow-item:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

body.ui-refresh-enabled .overflow-item:disabled:hover {
  background: transparent;
  border-color: transparent;
}

body.ui-refresh-enabled.agent-ide-no-folder .sidebar-path {
  color: var(--text-secondary);
  font-style: italic;
}

body.ui-refresh-enabled.agent-ide-no-folder .sidebar-header {
  background: color-mix(in srgb, var(--bg-secondary) 92%, var(--accent-primary) 8%);
}
