.app-root {
  --app-titlebar-height: 23px;
  display: grid;
  grid-template-rows: var(--app-titlebar-height) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--app-bg);
}

/* macOS renders the native traffic-light controls over an overlay title bar.
   They need the standard ~28px of vertical room minimum, otherwise the buttons
   are clipped by the top edge of the window. A little extra height lets the icon
   and title sit vertically centered alongside the traffic-light controls. */
.app-root[data-platform="macos"] {
  --app-titlebar-height: 32px;
}

.app-titlebar {
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  height: var(--app-titlebar-height);
  padding-right: 202px;
  background: var(--titlebar-bg);
  color: var(--titlebar-text);
  border-bottom: 1px solid var(--titlebar-border);
  user-select: none;
  -webkit-user-select: none;
  app-region: drag;
  -webkit-app-region: drag;
}

/* macOS overlay title bar: the native traffic-light controls sit at the top-left
   and the custom minimize/maximize/close buttons are not rendered, so reserve
   space on the left for the controls and shrink the right reservation to the
   remaining panel-toggle buttons. */
.app-titlebar-native-controls {
  padding-right: 92px;
}

.app-titlebar-native-controls .app-titlebar-label {
  padding-left: 78px;
}

.app-titlebar-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  app-region: drag;
  -webkit-app-region: drag;
}

.app-titlebar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.app-titlebar-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--titlebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.82;
}

.app-titlebar-controls {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex: 0 0 auto;
  height: var(--app-titlebar-height);
  app-region: no-drag;
  -webkit-app-region: no-drag;
}

.app-titlebar-button {
  flex: 0 0 46px;
  width: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--titlebar-text);
  cursor: pointer;
  padding: 0;
  border-radius: 0;
  transition: background 120ms ease;
  app-region: no-drag;
  -webkit-app-region: no-drag;
}

.app-titlebar-button:hover {
  background: var(--titlebar-hover-bg);
}

.app-titlebar-panel-button {
  flex-basis: 32px;
  width: 32px;
  opacity: 0.58;
}

.app-titlebar-panel-button.active {
  opacity: 0.9;
}

.app-titlebar-close:hover {
  background: var(--red);
  color: #ffffff;
}

.app-shell {
  display: grid;
  grid-template-columns:
    48px var(--connection-panel-width, 292px) var(
      --connection-resize-width,
      3px
    )
    minmax(0, 1fr) var(--ai-resize-width, 3px)
    var(--ai-panel-width, 334px);
  grid-template-rows: minmax(0, 1fr) 28px;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--app-ui-font-family);
  background: var(--app-bg);
  border-top: 1px solid var(--border);
}

/* macOS: the title bar already renders its own bottom border, so the shell's
   top border shows up as a stray 1px light line above the rail. Drop it. */
.app-root[data-platform="macos"] .app-shell {
  border-top: 0;
}

.app-shell.status-bar-hidden {
  grid-template-rows: minmax(0, 1fr);
}

.app-shell.panel-animating {
  transition: none;
}

.workspace-page {
  display: contents;
}

.workspace-page[aria-hidden="true"] > * {
  visibility: hidden;
  pointer-events: none;
}

.activity-rail {
  display: flex;
  position: relative;
  grid-row: 1;
  z-index: 120;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 10px 7px;
  overflow: visible;
  background: var(--nav-toolbar-bg);
  color: var(--nav-toolbar-text);
}

.rail-button,
.icon-button,
.new-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: inherit;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
}

.rail-button {
  position: relative;
}

.rail-connected-connections {
  display: grid;
  position: relative;
  gap: 6px;
  justify-items: center;
  width: 100%;
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px solid var(--nav-toolbar-tooltip-border);
}

.rail-connected-connections-spacer {
  order: -1;
  width: 100%;
}

.rail-button-connection .connection-icon-image {
  border-radius: 4px;
}

.rail-button-connection .connection-icon-shell.has-background {
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.22);
}

.rail-button-connection.dragging {
  opacity: 0.48;
}

.rail-button-connection {
  touch-action: none;
}

.rail-button-connection.connected::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 3.5px;
  height: 3.5px;
  pointer-events: none;
  background: #32ff6a;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--nav-toolbar-bg);
}

.rail-button-connection.rail-drop-before::before,
.rail-button-connection.rail-drop-after::after,
.rail-connected-connections.rail-drop-end::after {
  content: "";
  display: block;
  justify-self: center;
  width: 24px;
  height: 2px;
  pointer-events: none;
  background: rgb(245 193 80 / 72%);
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 18%);
}

.rail-button-connection.rail-drop-before::before,
.rail-button-connection.rail-drop-after::after {
  position: absolute;
  left: 4px;
}

.rail-button-connection.rail-drop-before::before {
  top: -4px;
}

.rail-button-connection.rail-drop-after::after {
  bottom: -4px;
}

.rail-button-dont-sleep {
  margin-top: auto;
}

.rail-button-settings {
  margin-top: auto;
}

.rail-button-dont-sleep ~ .rail-button-settings {
  margin-top: 0;
}

.rail-button-dont-sleep.dont-sleep-enabled {
  color: var(--green);
}

.rail-button-dont-sleep.dont-sleep-enabled svg {
  color: var(--green);
  stroke: currentColor;
}

.rail-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.rail-button:hover,
.rail-button.active {
  background: var(--nav-toolbar-hover-bg);
}

.rail-button.connections-collapsed-indicator {
  color: var(--nav-toolbar-accent);
}

.rail-tooltip {
  position: absolute;
  left: calc(100% + 9px);
  top: 50%;
  z-index: 140;
  padding: 4px 10px;
  color: #111;
  white-space: nowrap;
  pointer-events: none;
  background: #fffdf6;
  border: 1px solid #111;
  border-radius: 0;
  box-shadow: none;
  opacity: 0;
  transform: translateY(-50%) translateX(-2px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
  font-size: 13px;
  font-weight: 400;
}

.rail-button:hover .rail-tooltip:not(.native-suppressed),
.rail-button:focus-visible .rail-tooltip:not(.native-suppressed) {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  transition-delay: 650ms;
}

.rail-tooltip.native-suppressed {
  opacity: 0;
}

.rail-context-menu {
  position: fixed;
  right: auto;
  z-index: 160;
}


.connection-panel-slot,
.assistant-panel-slot {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: visible;
}

.connection-panel-slot {
  grid-column: 2;
  grid-row: 1;
  z-index: 70;
}

.assistant-panel-slot {
  grid-column: 6;
  grid-row: 1;
}

.app-shell.panel-animating .connection-panel-slot,
.app-shell.panel-animating .assistant-panel-slot {
  overflow: clip;
}

@supports not (overflow: clip) {
  .app-shell.panel-animating .connection-panel-slot,
  .app-shell.panel-animating .assistant-panel-slot {
    overflow: hidden;
  }
}

.connection-sidebar,
.assistant-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--chrome);
  border-right: 1px solid var(--border);
  opacity: 1;
  contain: layout style;
  transition:
    opacity 120ms ease-out,
    transform 180ms cubic-bezier(0.2, 0, 0, 1);
  will-change: opacity, transform;
}

.connection-sidebar {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 70;
  min-height: 0;
  height: 100%;
  overflow: visible;
  padding: 0 14px 12px;
  transform: translateX(0);
}

.connection-sidebar .sidebar-header.module-header {
  justify-content: flex-start;
  min-height: 44px;
  margin: 0 -14px 10px;
}

.connection-sidebar .sidebar-title {
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
}

.connection-sidebar .sidebar-header .module-header__title {
  font-size: 15px;
  font-weight: 680;
}

.connection-sidebar .module-header__tile.sidebar-workspace-custom-icon-tile {
  background: transparent;
  box-shadow: none;
}

.connection-sidebar .sidebar-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.connection-sidebar .sidebar-actions .icon-button {
  width: 26px;
  height: 26px;
  color: var(--text-muted);
  border-radius: 7px;
}

.workspace {
  grid-column: 4;
}

.assistant-panel {
  overflow: hidden;
}

.connections-collapsed .connection-sidebar,
.ai-assist-collapsed .assistant-panel {
  opacity: 0;
  border-right: 0;
  pointer-events: none;
  transition: opacity 90ms ease-in;
}

.ai-assist-collapsed .assistant-panel {
  transform: translateX(100%);
  transition:
    opacity 90ms ease-in,
    transform 180ms cubic-bezier(0.2, 0, 0, 1);
}

.connections-collapsed .connection-sidebar {
  transform: translateX(-100%);
  transition:
    opacity 90ms ease-in,
    transform 180ms cubic-bezier(0.2, 0, 0, 1);
}

.panel-resize-handle {
  position: relative;
  grid-row: 1;
  z-index: 5;
  display: grid;
  place-items: center;
  min-width: 3px;
  width: 100%;
  height: 100%;
  padding: 0;
  color: var(--text-faint);
  background: linear-gradient(
    90deg,
    rgb(0 0 0 / 0.08),
    var(--border) 36%,
    var(--border) 64%,
    rgb(255 255 255 / 0.2)
  );
  box-shadow:
    inset 1px 0 rgb(255 255 255 / 0.16),
    inset -1px 0 rgb(0 0 0 / 0.12);
  cursor: col-resize;
}

.panel-resize-handle::after {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 3px;
  background: #2f80ff;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 120ms ease 500ms;
}

.panel-resize-handle-left,
.connection-collapsed-separator {
  grid-column: 3;
}

.panel-resize-handle-right {
  grid-column: 5;
}

.connection-collapsed-separator {
  grid-row: 1;
  width: 1px;
  height: 100%;
  background: var(--border);
}

.connections-collapsed .connection-collapsed-separator {
  display: none;
}

.panel-resize-handle:hover,
.panel-resize-handle:focus-visible {
  color: var(--text);
  outline: 0;
}

.panel-resize-handle:not(.panel-resize-handle-collapsed):hover::after,
.panel-resize-handle:not(.panel-resize-handle-collapsed):focus-visible::after {
  opacity: 1;
}

.panel-resize-handle-collapsed {
  color: var(--text);
  background: #bfd0ea;
  box-shadow: none;
  cursor: pointer;
}

.panel-resize-handle-collapsed::after {
  content: none;
}

.panel-collapsed-tab {
  display: grid;
  gap: 8px;
  align-content: start;
  justify-items: center;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 12px 0 8px;
}

.panel-collapsed-tab span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.panel-resize-handle-left .panel-collapsed-tab span:empty {
  display: none;
}

.is-resizing-layout,
.is-resizing-layout * {
  cursor: col-resize !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}


.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 160;
  pointer-events: none;
}

.tutorial-overlay-dim {
  position: absolute;
  inset: 0;
}

.tutorial-highlight {
  position: absolute;
  box-sizing: border-box;
  background: transparent;
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow:
    0 0 0 9999px rgb(12 16 24 / 52%),
    0 0 0 4px var(--accent-soft),
    var(--shadow);
}

.tutorial-balloon {
  position: absolute;
  display: grid;
  gap: 8px;
  width: 280px;
  max-width: calc(100vw - 32px);
  min-height: 104px;
  padding: 12px 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tutorial-balloon strong {
  font-size: 13px;
  font-weight: 800;
}

.tutorial-balloon p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

/* Workspace switcher (Activity Rail) */
.rail-workspaces {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding-bottom: 8px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
}

.rail-button-add-workspace {
  opacity: 0.7;
}

.rail-button-add-workspace:hover {
  opacity: 1;
}

.workspace-icon-shell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--workspace-icon-shell-size);
  height: var(--workspace-icon-shell-size);
  color: var(--workspace-icon-color);
  background: var(--workspace-icon-bg);
  /* Rounded-rectangle fill to match the connection icons, not a circle. */
  border-radius: 6px;
  vertical-align: middle;
}

.workspace-icon-shell.has-background {
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.38), 0 1px 2px rgb(15 23 42 / 0.16);
}

.workspace-icon-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--workspace-icon-size);
  height: var(--workspace-icon-size);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

/* New / Edit / Delete Workspace dialogs */
.new-workspace-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
}

.connection-dialog-backdrop .new-workspace-dialog {
  overflow: visible;
}

.new-workspace-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.new-workspace-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.required-marker {
  color: var(--red);
  margin-left: 2px;
}

.new-workspace-group {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  margin: 0;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.new-workspace-group > legend {
  padding: 0 2px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.new-workspace-summary {
  grid-template-columns: auto auto;
  justify-content: start;
  gap: 12px;
  padding: 8px 10px;
  background: var(--surface);
}

.new-workspace-icon-editor {
  position: relative;
  display: inline-flex;
}

.new-workspace-icon-edit-button {
  color: var(--text);
}

.connection-type-summary .new-workspace-icon-edit-button {
  width: 52px;
  height: 52px;
  background: transparent;
  border: 0;
  border-radius: 10px;
}

.connection-type-summary .new-workspace-icon-edit-button:hover {
  border-color: transparent;
}

.connection-type-summary .new-workspace-icon-edit-button .workspace-icon-shell {
  max-width: 52px;
  max-height: 52px;
  border-radius: 10px;
}

.new-workspace-icon-popover {
  width: min(520px, calc(100vw - 48px));
}

.workspace-material-icon {
  width: var(--workspace-icon-size);
  height: var(--workspace-icon-size);
  object-fit: contain;
}

.new-workspace-import-tools {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(150px, 190px);
  gap: 8px;
  align-items: end;
  margin-bottom: 4px;
}

.connection-dialog .new-workspace-import-search {
  display: flex;
  align-items: center;
  margin: 0;
}

.connection-dialog .new-workspace-import-search input[type="search"] {
  height: auto;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.new-workspace-selection-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.new-workspace-selection-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
}

.new-workspace-type-filter {
  display: grid;
  gap: 4px;
}

.new-workspace-type-filter > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.new-workspace-import-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.new-workspace-import-row {
  display: grid;
  grid-template-columns: 16px auto minmax(0, 1fr) minmax(112px, 150px);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 6px;
  cursor: pointer;
  border-radius: 6px;
}

.new-workspace-import-row:hover {
  background: var(--surface-muted);
}

.connection-dialog .new-workspace-import-row input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
}

.new-workspace-import-row strong,
.new-workspace-import-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-workspace-import-row strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.new-workspace-import-row small,
.new-workspace-import-empty {
  color: var(--text-muted);
  font-size: 12px;
}

.new-workspace-import-empty {
  margin: 0;
  padding: 8px;
}

@media (max-width: 760px) {
  .new-workspace-import-tools {
    grid-template-columns: 1fr;
  }

  .new-workspace-selection-actions {
    justify-content: flex-start;
  }

  .new-workspace-import-row {
    grid-template-columns: 16px auto minmax(0, 1fr) minmax(96px, 120px);
  }
}
