#app,
.app-shell {
  width: 100%;
  height: 100%;
}

.app-shell {
  --sidebar-current-width: var(--sidebar-width);
  --sidebar-layout-width: var(--sidebar-current-width);
  --sidebar-overlay-width: var(--sidebar-width);
  position: relative;
  overflow: hidden;
  background: var(--page);
}


.window-drag-region {
  position: fixed;
  z-index: var(--z-sticky);
  top: 0;
  right: 0;
  left: 0;
  height: var(--titlebar-height);
  pointer-events: none;
  -webkit-app-region: drag;
}

.sidebar {
  position: fixed;
  z-index: var(--z-sidebar);
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-current-width);
  min-width: var(--sidebar-current-width);
  flex-direction: column;
  overflow: hidden;
  border-right: 0;
  background-color: var(--page);
  background-image: var(--sidebar-wash);
  color: var(--text-primary);
  will-change: width, min-width, transform;
  transition:
    width 210ms var(--ease-dialog),
    min-width 210ms var(--ease-dialog),
    transform 150ms var(--ease-dialog),
    opacity 120ms var(--ease-standard),
    background-color 120ms var(--ease-standard),
    border-color 120ms var(--ease-standard),
    box-shadow 160ms var(--ease-standard);
}

.sidebar-resize-rail {
  position: fixed;
  z-index: var(--z-sidebar-trigger);
  top: 0;
  bottom: 0;
  left: var(--sidebar-layout-width);
  display: block;
  width: 12px;
  padding: 0;
  transform: translateX(-50%);
  border: 0;
  background: transparent;
  cursor: col-resize;
  outline: 0;
  touch-action: none;
  -webkit-app-region: no-drag;
  transition:
    left 210ms var(--ease-dialog),
    opacity 120ms var(--ease-standard);
}

.sidebar-resize-rail::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--border) 72%, transparent);
  content: "";
  opacity: .58;
  transition:
    width var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard),
    opacity var(--duration-fast) var(--ease-standard);
}

.sidebar-resize-rail::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 32px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: var(--border-strong);
  content: "";
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-standard);
}

.sidebar-resize-rail:hover::before,
.sidebar-resize-rail:focus-visible::before,
.app-shell[data-sidebar-resizing="true"] .sidebar-resize-rail::before {
  width: 2px;
  background: var(--border-strong);
  opacity: 1;
}

.sidebar-resize-rail:hover::after,
.sidebar-resize-rail:focus-visible::after,
.app-shell[data-sidebar-resizing="true"] .sidebar-resize-rail::after {
  opacity: 1;
}

.sidebar-resize-rail:focus-visible::after {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.app-shell[data-sidebar-resizing="true"] .sidebar-resize-rail,
.app-shell[data-sidebar-resizing="true"] .main-shell,
.app-shell[data-sidebar-resizing="true"] .sidebar {
  transition: none;
}


.sidebar-header {
  position: relative;
  height: 40px;
  min-height: 40px;
  -webkit-app-region: drag;
}

.sidebar-wordmark {
  position: absolute;
  top: 12px;
  left: 18px;
  width: 80px;
  height: 16px;
  background: currentColor;
  color: #0b0b0b;
  -webkit-mask: var(--kalamos-wordmark-mask) center / contain no-repeat;
  mask: var(--kalamos-wordmark-mask) center / contain no-repeat;
  pointer-events: none;
  -webkit-app-region: no-drag;
  transition: opacity 150ms var(--ease-standard), visibility 0s linear 150ms;
}

html[data-theme="dark"] .sidebar-wordmark { color: #f0efec; }

.sidebar-header-actions {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sidebar-header-actions > * {
  position: absolute;
  top: 9px;
  pointer-events: auto;
  -webkit-app-region: no-drag;
}

.sidebar .sidebar-header-icon-button {
  --sidebar-header-button-size: 22px;
  --sidebar-header-icon-size: 15px;
  width: var(--sidebar-header-button-size);
  height: var(--sidebar-header-button-size);
  color: var(--text-faint);
}

.sidebar .sidebar-header-icon-button .icon {
  width: var(--sidebar-header-icon-size);
  height: var(--sidebar-header-icon-size);
  font-size: var(--sidebar-header-icon-size);
}

.sidebar .sidebar-header-icon-button svg {
  width: var(--sidebar-header-icon-size);
  height: var(--sidebar-header-icon-size);
}

.sidebar .sidebar-header-icon-button:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

#sidebar-toggle {
  right: 16px;
  transition:
    color var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

#sidebar-search-trigger {
  right: 42px;
  transition:
    color var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard),
    opacity 160ms var(--ease-standard),
    transform 210ms var(--ease-dialog),
    visibility 0s linear 160ms;
}

/* Native window controls and the fold button keep one location on every page.
   Collapsed pages reserve the same lane before their title. */
html[data-kalamos-desktop-app="true"] .app-shell {
  --desktop-collapsed-titlebar-height: 40px;
  --desktop-collapsed-board-inset: 8px;
  --desktop-collapsed-board-pad-x: 7px;
  --desktop-traffic-lights-end: 68px;
  --desktop-chrome-gap: 12px;
  --desktop-toggle-size: 22px;
  --desktop-toggle-top: calc((var(--desktop-collapsed-titlebar-height) - var(--desktop-toggle-size)) / 2);
  --desktop-toggle-left: calc(var(--desktop-traffic-lights-end) + var(--desktop-chrome-gap));
  --desktop-chrome-duration: 180ms;
  --desktop-chrome-ease: var(--ease-dialog);
  /* Header padding is inside the 7px workbench pad, so subtract it or the
     fold-to-title gap is 7px wider than the lights-to-fold gap. */
  --desktop-collapsed-chrome-left: calc(
    var(--desktop-toggle-left)
    + var(--desktop-toggle-size)
    + var(--desktop-chrome-gap)
    - var(--desktop-collapsed-board-pad-x)
  );
}

html[data-kalamos-desktop-app="true"] {
  --desktop-chrome-duration: 180ms;
  --desktop-chrome-ease: var(--ease-dialog);
}

html[data-kalamos-desktop-app="true"] #sidebar-toggle,
html[data-kalamos-desktop-app="true"] #compact-sidebar-trigger {
  position: absolute;
  top: var(--desktop-toggle-top);
  left: var(--desktop-toggle-left);
  right: auto;
  width: var(--desktop-toggle-size);
  height: var(--desktop-toggle-size);
  transition: color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard);
}
html[data-kalamos-desktop-app="true"] #compact-sidebar-trigger .icon { width: 15px; height: 15px; }
html[data-kalamos-desktop-app="true"] #sidebar-search-trigger { top: var(--desktop-toggle-top); right: 16px; }
html[data-kalamos-desktop-app="true"] .sidebar-header { height: 76px; min-height: 76px; }
html[data-kalamos-desktop-app="true"] .sidebar-wordmark { top: 44px; }

.product-mode-switch {
  display: flex;
  gap: 3px;
  margin: 0 12px 12px;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-2);
}
.product-mode-switch button {
  flex: 1;
  min-width: 0;
  height: 30px;
  border: 0;
  border-radius: 6px;
  color: var(--text-secondary);
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 120ms var(--ease-standard), color 120ms var(--ease-standard);
}
.product-mode-switch button[aria-pressed="true"] { background: var(--surface-1); color: var(--text-primary); box-shadow: 0 1px 3px rgb(0 0 0 / 8%); }
.product-mode-switch button:focus-visible { outline: 2px solid var(--text-secondary); outline-offset: 2px; }
.app-shell[data-sidebar-rail="true"] .product-mode-switch { display: none; }
.history-search-filters { padding: 0 16px 8px; border-bottom: 1px solid var(--border); }
@media (prefers-reduced-motion: reduce) { .product-mode-switch button { transition: none; } }


html[data-kalamos-desktop-app="true"] .sidebar {
  will-change: auto;
  transition:
    width var(--desktop-chrome-duration) var(--desktop-chrome-ease),
    min-width var(--desktop-chrome-duration) var(--desktop-chrome-ease),
    transform var(--desktop-chrome-duration) var(--desktop-chrome-ease),
    opacity 180ms var(--desktop-chrome-ease),
    background-color 160ms var(--desktop-chrome-ease),
    border-color 160ms var(--desktop-chrome-ease);
}

html[data-kalamos-desktop-app="true"] .main-shell,
html[data-kalamos-desktop-app="true"] .sidebar-resize-rail {
  transition:
    left var(--desktop-chrome-duration) var(--desktop-chrome-ease),
    opacity 160ms var(--desktop-chrome-ease);
}

html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] #sidebar-toggle {
  position: absolute;
  top: var(--desktop-toggle-top);
  right: auto;
  left: var(--desktop-toggle-left);
  z-index: var(--z-sidebar-trigger);
  pointer-events: auto;
}

html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] #sidebar-toggle {
  top: var(--desktop-toggle-top);
}

html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] .sidebar {
  width: 0;
  min-width: 0;
  overflow: visible;
  background-color: transparent;
  background-image: none;
  pointer-events: none;
}

html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] .main-shell {
  left: 0;
}

html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] .sidebar-wordmark,
html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] .sidebar-groups,
html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] .sidebar-footer,
html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] #sidebar-search-trigger,
html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] .sidebar-resize-rail {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
  transition:
    opacity 160ms var(--desktop-chrome-ease),
    transform var(--desktop-chrome-duration) var(--desktop-chrome-ease),
    visibility 0s linear 160ms;
}

.desktop-rail-open-hint {
  display: none;
}

html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] .desktop-rail-open-hint {
  display: block;
  position: absolute;
  top: calc(var(--desktop-collapsed-board-inset) + var(--desktop-collapsed-titlebar-height) + 6px);
  left: 12px;
  z-index: var(--z-sidebar-trigger);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgb(16 16 16 / 14%);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-8px);
  transition:
    opacity 80ms var(--ease-standard),
    transform 80ms var(--ease-standard);
}

html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .desktop-rail-open-hint {
  top: calc(var(--desktop-collapsed-board-inset) + var(--desktop-collapsed-titlebar-height) + 6px);
}

html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] #sidebar-toggle:hover ~ .desktop-rail-open-hint,
html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] #sidebar-toggle:focus-visible ~ .desktop-rail-open-hint {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-rail="true"] .desktop-rail-open-hint {
    transition-duration: .001ms;
    transform: none;
  }
}

/* Content toolbar spacing is independent of the native window controls.
   Native control coordinates are published by AppDelegate in desktop-refinement.css. */
html[data-kalamos-desktop-app="true"] .content-pane-grid .pane-header,
html[data-kalamos-desktop-app="true"] .page-toolbar-shell.page-header {
  box-sizing: border-box;
  height: var(--desktop-collapsed-titlebar-height);
  min-height: var(--desktop-collapsed-titlebar-height);
  padding-top: 0;
  padding-bottom: 0;
  align-items: center;
}

html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .content-input-pane .pane-header,
html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .page-toolbar-shell.page-header,
html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .copylibrary-toolbar,
html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .knowledge-toolbar,
html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .profile-toolbar,
html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .analysis-toolbar,
html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .access-toolbar,
html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .admin-header-toolbar,
html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .main-header {
  box-sizing: border-box;
  height: var(--desktop-collapsed-titlebar-height);
  min-height: var(--desktop-collapsed-titlebar-height);
  align-items: center;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: var(--desktop-collapsed-chrome-left);
  transition: padding-left var(--desktop-chrome-duration) var(--desktop-chrome-ease);
}

html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .content-input-pane > .pane-content {
  height: calc(100% - var(--desktop-collapsed-titlebar-height));
}

@media (prefers-reduced-motion: reduce) {
  html[data-kalamos-desktop-app="true"] #sidebar-toggle,
  html[data-kalamos-desktop-app="true"] .sidebar,
  html[data-kalamos-desktop-app="true"] .main-shell,
  html[data-kalamos-desktop-app="true"] .sidebar-resize-rail,
  html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .content-input-pane .pane-header,
  html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .page-toolbar-shell.page-header,
  html[data-kalamos-desktop-app="true"] .app-shell[data-desktop-title-chrome="true"] .copylibrary-toolbar {
    transition-duration: .001ms;
  }
}

.app-shell[data-sidebar-phase="collapsing"] #sidebar-toggle,
.app-shell[data-sidebar-phase="expanding"] #sidebar-toggle {
  background: var(--surface-pressed);
  color: var(--text-primary);
  transform: scale(.96);
}

html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-phase="collapsing"] #sidebar-toggle,
html[data-kalamos-desktop-app="true"] .app-shell[data-sidebar-phase="expanding"] #sidebar-toggle {
  background: transparent;
  transform: none;
}

.sidebar-nav {
  padding: 2px 8px 4px;
}

.sidebar-nav > li + li,
.sidebar-history li + li {
  margin-top: 3px;
}

.sidebar-groups {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 0 8px;
}

.sidebar-nav-group + .sidebar-nav-group {
  margin-top: 6px;
}

.sidebar-section-label {
  display: flex;
  height: 28px;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
}

.sidebar-item {
  display: flex;
  width: 100%;
  height: 34px;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 0 10px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-align: left;
  transition:
    color var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard);
}

.sidebar-item .icon {
  color: color-mix(in srgb, currentColor 76%, var(--text-faint));
}

.sidebar-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sidebar-item:active {
  background: var(--surface-pressed);
}

.sidebar-nav .sidebar-item[aria-current="page"] {
  background: color-mix(in srgb, var(--surface-selected) 92%, var(--text-primary) 8%);
  color: var(--text-primary);
  font-weight: 500;
}

.sidebar-nav .sidebar-item[aria-current="page"] .icon {
  color: var(--text-primary);
}

.sidebar-item .item-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: var(--ui-control-label-line-height);
  transform: translateY(var(--ui-control-label-optical-shift-y));
}

.sidebar-item .item-meta {
  color: var(--text-faint);
  font-size: 11px;
}

.sidebar-history {
  min-height: 80px;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px 8px 12px;
  overscroll-behavior: contain;
}

.sidebar-section-toggle {
  display: inline-flex;
  width: 100%;
  height: 28px;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  transition: color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard);
}

.sidebar-section-toggle:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.sidebar-section-toggle:focus-visible {
  box-shadow: var(--focus);
}

/* 三箭头统一：sidebar-section-toggle 的 chevron 使用 caret-down + 旋转；
   更多按钮的 caret-right 保持方向不动。 */
.sidebar-section-toggle .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  transition:
    transform 320ms cubic-bezier(.22, 1, .36, 1) 48ms,
    color var(--duration-fast) var(--ease-standard);
}

/* aria-expanded=false 时（折叠态）旋转到 -90deg；收起略快一点，保持同向缓动 */
.sidebar-section-toggle[aria-expanded="false"] .icon {
  transform: rotate(-90deg);
  transition-duration: 260ms;
  transition-delay: 16ms;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-section-toggle .icon {
    transition: none;
  }
}

.sidebar-history .sidebar-item {
  height: 32px;
  padding-left: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}

.sidebar-history .sidebar-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sidebar-history .sidebar-item:hover .icon {
  color: var(--text-primary);
}

.sidebar-history .sidebar-item[aria-current="page"] {
  background: var(--surface-hover);
  color: var(--text-primary);
  font-weight: 430;
}

.sidebar-history .sidebar-item[aria-current="page"] .icon {
  color: var(--text-primary);
}

.sidebar-history-more-row {
  padding: 3px 10px 0;
}

.sidebar-history-more {
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.sidebar-history-more:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.sidebar-history-more:disabled {
  cursor: default;
  opacity: .64;
}

.sidebar-footer {
  padding: 6px 8px 10px;
  border-top: .5px solid color-mix(in srgb, var(--border) 62%, transparent);
}

.sidebar-footer-actions {
  padding-bottom: 5px;
}

.profile-button {
  height: 44px;
}

.profile-label {
  min-width: 0;
}

.profile-name {
  display: block;
  overflow: hidden;
  color: var(--text-secondary);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-caret {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--text-faint);
}

.avatar {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #d9c6a3;
  color: #513f27;
  font-size: 11px;
  font-weight: 600;
}

.main-shell {
  position: absolute;
  z-index: var(--z-content);
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--sidebar-layout-width);
  min-width: 0;
  overflow: hidden;
  background: var(--page);
  transition:
    left 210ms var(--ease-dialog),
    background-color var(--duration-surface) var(--ease-standard);
}

.main-header {
  position: absolute;
  z-index: var(--z-sticky);
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--header-transition-idle-surface, transparent);
  border-bottom: var(--header-transition-border, 0 solid transparent);
  box-shadow: var(--header-transition-shadow, none);
  isolation: isolate;
  transition:
    background-color var(--duration-surface) var(--ease-standard),
    border-color var(--duration-surface) var(--ease-standard),
    box-shadow var(--duration-surface) var(--ease-standard);
  -webkit-app-region: drag;
}

.main-header::after {
  position: absolute;
  z-index: 0;
  top: 100%;
  right: 0;
  left: 0;
  height: var(--header-transition-height, 36px);
  background: var(--header-transition-background, transparent);
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-surface) var(--ease-standard), background var(--duration-surface) var(--ease-standard);
}

.main-header[data-scrolled="true"]::after {
  opacity: var(--header-transition-overlay-opacity, 1);
}

.main-header[data-scrolled="true"] {
  background: var(--header-transition-scrolled-surface, transparent);
  border-bottom-color: var(--header-transition-border-color, transparent);
  box-shadow: var(--header-transition-shadow, none);
}

.main-header[data-transition="opaque-mist"],
.header-transition-preview[data-transition="opaque-mist"] {
  /* Keep the approved 08 surface genuinely opaque in file:// WebKit/Chromium. */
  --header-transition-scrolled-surface: var(--page);
  --header-transition-border: .5px solid var(--border);
  --header-transition-border-color: var(--border);
  --header-transition-shadow: none;
  --header-transition-height: 0px;
  --header-transition-overlay-opacity: 0;
}

.main-header > * {
  position: relative;
  z-index: 1;
  -webkit-app-region: no-drag;
}

.main-header-title {
  position: absolute;
  left: 50%;
  max-width: 48%;
  transform: translateX(-50%);
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-viewport {
  position: absolute;
  inset: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--page);
}

.icon-button.compact-sidebar-trigger {
  position: fixed;
  z-index: var(--z-sidebar-trigger);
  top: 8px;
  left: 8px;
  display: none;
}

.sidebar-scrim {
  position: fixed;
  z-index: calc(var(--z-sidebar) - 1);
  inset: 0;
  display: none;
  background: rgb(11 11 11 / 8%);
  opacity: 0;
  transition: opacity 120ms var(--ease-standard);
}

/* Desktop rail state: retain the semantic navigation and icon column while
   fading secondary copy. The controller owns timing; CSS only animates the
   visual properties so width, Main layout and content begin together. */
.sidebar .item-label,
.sidebar .item-meta,
.sidebar .pro-badge,
.sidebar .profile-name,
.sidebar .profile-caret,
.sidebar .sidebar-section-toggle span:not(.icon),
.sidebar-history,
#sidebar-more-trigger > .icon:last-child {
  transition:
    opacity 160ms var(--ease-standard),
    transform 210ms var(--ease-dialog),
    visibility 0s linear 160ms;
}

.app-shell[data-sidebar-rail="true"] .sidebar .item-label,
.app-shell[data-sidebar-rail="true"] .sidebar .item-meta,
.app-shell[data-sidebar-rail="true"] .sidebar .pro-badge,
.app-shell[data-sidebar-rail="true"] .sidebar .profile-name,
.app-shell[data-sidebar-rail="true"] .sidebar .profile-caret,
.app-shell[data-sidebar-rail="true"] .sidebar .sidebar-section-toggle span:not(.icon),
.app-shell[data-sidebar-rail="true"] #sidebar-more-trigger > .icon:last-child {
  visibility: hidden;
  transform: translateX(-3px);
  opacity: 0;
  pointer-events: none;
}

.app-shell[data-sidebar-rail="true"] .sidebar-history {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.app-shell[data-sidebar-rail="true"] #sidebar-search-trigger {
  visibility: hidden;
  transform: translateX(-4px);
  opacity: 0;
  pointer-events: none;
}

.app-shell[data-sidebar-rail="true"] .sidebar-wordmark {
  visibility: hidden;
  opacity: 0;
}

.app-shell[data-sidebar-rail="false"] .sidebar .item-label,
.app-shell[data-sidebar-rail="false"] .sidebar .item-meta,
.app-shell[data-sidebar-rail="false"] .sidebar .pro-badge,
.app-shell[data-sidebar-rail="false"] .sidebar .profile-name,
.app-shell[data-sidebar-rail="false"] .sidebar .profile-caret,
.app-shell[data-sidebar-rail="false"] .sidebar .sidebar-section-toggle span:not(.icon),
.app-shell[data-sidebar-rail="false"] .sidebar-history,
.app-shell[data-sidebar-rail="false"] #sidebar-more-trigger > .icon:last-child,
.app-shell[data-sidebar-rail="false"] #sidebar-search-trigger {
  transition-delay: 0ms;
}

.profile-button .profile-avatar {
  transition: transform 210ms var(--ease-dialog);
}

.app-shell[data-sidebar-rail="true"] .profile-button .profile-avatar {
  transform: translateX(-5px);
}

/* Sidebar icons use a stable 18px optical size in both expanded and rail modes.
   Exception: disclosure chevrons (.icon--xxs) stay at 11px. */
.sidebar .icon {
  width: 18px;
  height: 18px;
  font-size: 18px;
}

/* 三箭头 token：更多 + 最近折叠箭头均强制 11px，覆盖上方 18px 全局规则 */
.sidebar-section-toggle .icon--xxs,
#sidebar-more-trigger .icon--xxs {
  width: 11px;
  height: 11px;
  font-size: 11px;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .main-shell,
  .sidebar-resize-rail,
  .sidebar .item-label,
  .sidebar .item-meta,
  .sidebar .pro-badge,
  .sidebar .profile-name,
  .sidebar .profile-caret,
  .sidebar .sidebar-section-toggle span:not(.icon),
  .sidebar .sidebar-section-toggle .icon,
  .sidebar-history,
  #sidebar-search-trigger,
  #sidebar-more-trigger > .icon:last-child,
  .profile-button .profile-avatar {
    transition-duration: .001ms !important;
    transition-delay: 0ms !important;
  }
}

/* Keep the native fold control stationary while the compact overlay appears. */
@media (max-width: 1023px) {
  html[data-kalamos-desktop-app="true"] .app-shell .sidebar { transform: none; transition: opacity 120ms var(--ease-standard), box-shadow 120ms var(--ease-standard); }
}

/* Shared compact desktop controls. */
.composer-workspace { max-width: 220px; min-width: 0; }
.composer-workspace span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-save-notice { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 0; color: var(--text-secondary); font-size: 13px; }
.image-service-notice { padding: 12px 14px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 12px; font-size: 13px; color: var(--text-secondary); }
.image-service-notice p { margin: 0 0 6px; }
.image-service-notice input { width: 100%; margin: 8px 0; }
.thread-load-earlier { display: block; margin: 0 auto 24px; }
.library-image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 16px 0; }
.library-image-grid figure { margin: 0; }
.library-image-grid img { width: 100%; max-height: 380px; object-fit: contain; border-radius: 10px; }
.composer-profile-select { max-width: 175px; background: transparent; color: var(--text-secondary); border: 0; padding: 6px 8px; font: inherit; font-size: 13px; text-overflow: ellipsis; border-radius: 8px; }
.composer-profile-chip { display: inline-flex; align-items: center; gap: 6px; margin: 4px 8px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-secondary); font-size: 13px; }

::highlight(conversation-find) { background: #f3d98b; color: #292720; }
.message.find-current { outline: 1px solid var(--border); outline-offset: 6px; border-radius: 10px; }

.models-empty-sources { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.workflow-failed-output { width: min(100%, 640px); text-align: left; }
.workflow-failed-output pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; }

.workflow-failure-notice { padding: 16px 20px; font-size: 13px; border-bottom: 1px solid var(--border); }
.workflow-failure-notice p { color: var(--text-secondary); }

.message-attachment { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; opacity: .7; }

.app-shell[data-runtime-mode="desktop-packaged"] .inspector-actions { flex-wrap: wrap; gap: 6px; }
