.ai-rail {
  --ai-rail-bg: #f7f9fc;
  --ai-rail-panel: rgba(255, 255, 255, 0.76);
  --ai-rail-line: rgba(148, 163, 184, 0.14);
  --ai-rail-text: #162033;
  --ai-rail-muted: #738097;
  --ai-rail-accent: #2d72d9;
  --ai-rail-amber: #b76b16;
  --ai-rail-green: #2f8d7b;
  --ai-rail-ink-soft: #41506a;
  --ai-rail-accent-soft: rgba(45, 114, 217, 0.08);

  position: sticky;
  top: 0;
  width: 100%;
  height: var(--desktop-stage-height, 100dvh);
  min-height: var(--desktop-stage-height, 100dvh);
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 249, 252, 0.96) 62%, rgba(244, 247, 251, 0.98)),
    var(--ai-rail-bg);
  border-right: 1px solid rgba(203, 213, 225, 0.54);
  box-shadow:
    inset -1px 0 0 rgba(255, 255, 255, 0.64),
    1px 0 0 rgba(15, 23, 42, 0.02);
  color: var(--ai-rail-text);
  contain: layout paint;
}

.ai-rail::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.56), transparent 16%),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.12) 0,
      rgba(255, 255, 255, 0.12) 1px,
      transparent 1px,
      transparent 20px
    );
  opacity: 0.22;
}

.ai-rail > * {
  position: relative;
  z-index: 1;
}

.ai-rail-section {
  min-width: 0;
}

.ai-rail-brand {
  min-width: 0;
  min-height: 74px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 16px 18px 10px;
}

.ai-brand-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(45, 114, 217, 0.12);
  border-radius: 13px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(239, 246, 255, 0.7)),
    rgba(255, 255, 255, 0.72);
  color: var(--ai-rail-accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    0 8px 18px rgba(45, 114, 217, 0.055);
}

.ai-brand-logo img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.ai-brand-logo svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.ai-brand-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.ai-brand-copy strong {
  overflow: hidden;
  color: #162033;
  font-size: 14px;
  font-weight: 820;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-brand-copy small {
  overflow: hidden;
  color: var(--ai-rail-muted);
  font-size: 12px;
  font-weight: 560;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-rail-quick {
  display: grid;
  gap: 6px;
  padding: 8px 18px 12px;
}

.ai-quick-btn,
.ai-nav-btn,
.ai-recent-item,
.ai-user-action {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition:
    background 180ms var(--ease),
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    color 180ms var(--ease),
    transform 180ms var(--ease);
}

.ai-quick-btn {
  min-height: 48px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  color: #111827;
  font-size: 14px;
  font-weight: 780;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.ai-quick-icon {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  color: #536277;
}

.ai-sidebar-tabler-icon {
  width: 20px;
  height: 20px;
  display: block;
  overflow: visible;
  flex: none;
  stroke-width: 1.85;
}

.ai-quick-btn.primary {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.ai-quick-btn.primary .ai-quick-icon {
  color: var(--ai-rail-amber);
}

.ai-recent-item:hover,
.ai-user-action:hover {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(148, 163, 184, 0.28);
  box-shadow: 0 8px 18px rgba(31, 48, 68, 0.045);
  transform: translateY(-1px);
}

.ai-quick-btn:hover,
.ai-quick-btn.active,
.ai-nav-btn:hover,
.ai-nav-btn.active {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.035);
  border-color: transparent;
  box-shadow: none;
  transform: translateX(2px);
}

.ai-quick-btn:hover .ai-quick-icon,
.ai-quick-btn.active .ai-quick-icon,
.ai-nav-btn:hover .ai-nav-icon,
.ai-nav-btn.active .ai-nav-icon {
  color: var(--ai-rail-accent);
}

.ai-quick-btn.primary:hover .ai-quick-icon {
  color: var(--ai-rail-amber);
}

.ai-conversation-search {
  min-width: 0;
  min-height: 48px;
  height: 48px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 10px;
  border: 1px solid rgba(45, 114, 217, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 8px 18px rgba(45, 114, 217, 0.035);
}

.ai-conversation-search > i {
  color: #64748b;
  font-size: 17px;
  line-height: 1;
}

.ai-conversation-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #162033;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0;
}

.ai-conversation-search input::placeholder {
  color: rgba(115, 128, 151, 0.78);
}

.ai-conversation-search button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.ai-conversation-search button:hover {
  background: rgba(15, 23, 42, 0.055);
  color: #173d78;
}

.ai-rail-divider {
  height: 1px;
  margin: 0 18px;
  background: var(--ai-rail-line);
}

.ai-section-heading {
  margin: 0;
  padding: 0 10px 8px;
  color: #7d8796;
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
}

.ai-rail-nav {
  display: grid;
  padding: 18px 18px 20px;
}

.ai-nav-list {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 2px 0;
}

.ai-nav-btn {
  position: relative;
  min-height: 48px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  color: var(--ai-rail-ink-soft);
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
}

.ai-nav-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  transition:
    background 180ms var(--ease),
    color 180ms var(--ease),
    box-shadow 180ms var(--ease);
}

.ai-nav-icon .ai-sidebar-tabler-icon {
  width: 19px;
  height: 19px;
}

.ai-nav-copy {
  min-width: 0;
}

.ai-nav-copy strong,
.ai-recent-title {
  min-width: 0;
  overflow: hidden;
  color: currentColor;
  font-size: 14px;
  font-weight: 780;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-recent-desc {
  min-width: 0;
  overflow: hidden;
  color: var(--ai-rail-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-rail-recents {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
  padding: 18px 12px 12px;
}

.ai-recents-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 5px;
  overflow-y: auto;
  padding: 1px 4px 1px 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.ai-recents-list::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.ai-recents-empty {
  margin: 10px 8px 0 12px;
  padding: 14px 12px;
  border: 1px dashed rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  color: rgba(115, 128, 151, 0.84);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.5;
}

.ai-recent-item {
  min-height: 56px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 8px 10px 8px 18px;
}

.ai-recent-item:focus-visible {
  outline: 2px solid rgba(45, 114, 217, 0.32);
  outline-offset: 2px;
}

.ai-recent-item::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 16px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(115, 128, 151, 0.38);
}

.ai-recent-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ai-recent-item:hover .ai-recent-title,
.ai-recent-item.active .ai-recent-title {
  color: #173d78;
}

.ai-recent-item:hover::before,
.ai-recent-item.active::before {
  background: var(--ai-rail-accent);
}

.ai-recent-item.active {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(183, 107, 22, 0.1);
  box-shadow:
    0 10px 22px rgba(31, 48, 68, 0.055),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ai-recent-time {
  color: rgba(107, 114, 128, 0.82);
  font-size: 11px;
  font-weight: 680;
  line-height: 1.35;
}

.ai-recent-title-input {
  width: 100%;
  min-width: 0;
  height: 24px;
  padding: 0 6px;
  border: 1px solid rgba(45, 114, 217, 0.22);
  border-radius: 7px;
  outline: 0;
  background: rgba(255, 255, 255, 0.86);
  color: #173d78;
  font-size: 14px;
  font-weight: 780;
  line-height: 1.2;
  letter-spacing: 0;
  box-shadow: 0 0 0 3px rgba(45, 114, 217, 0.06);
}

.ai-rail-user {
  box-sizing: border-box;
  min-width: 0;
  height: 72px;
  min-height: 72px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 12px 14px 12px 18px;
  border-top: 1px solid rgba(203, 213, 225, 0.55);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(247, 250, 252, 0.9)),
    rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.ai-user-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.22), transparent 32%),
    linear-gradient(135deg, #1f4f96, #2f8d7b);
  color: #fff;
  font-size: 15px;
  font-weight: 820;
  box-shadow:
    0 8px 16px rgba(45, 114, 217, 0.13),
    inset 0 -1px 0 rgba(15, 23, 42, 0.08);
}

.ai-user-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ai-user-copy strong {
  overflow: hidden;
  color: #182237;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-user-copy span {
  overflow: hidden;
  color: var(--ai-rail-muted);
  font-size: 12px;
  font-weight: 520;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-user-actions {
  display: grid;
  grid-template-columns: 44px;
  justify-content: end;
}

.ai-user-action {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #708096;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.ai-user-action i {
  font-size: 19px;
}

.ai-rail.rail-collapsed {
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
}

.ai-rail.rail-collapsed .ai-rail-brand {
  grid-template-columns: 1fr;
  justify-items: center;
  min-height: 70px;
  padding: 14px 10px 8px;
}

.ai-rail.rail-collapsed .ai-rail-quick {
  padding: 4px 10px 16px;
}

.ai-rail.rail-collapsed .ai-nav-list {
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.ai-rail.rail-collapsed .ai-nav-list::before {
  display: none;
}

.ai-rail.rail-collapsed .ai-quick-btn,
.ai-rail.rail-collapsed .ai-nav-btn {
  min-height: 44px;
  grid-template-rows: auto;
  justify-content: center;
  grid-template-columns: 1fr;
  align-content: center;
  padding: 8px;
}

.ai-rail.rail-collapsed .ai-quick-btn span,
.ai-rail.rail-collapsed .ai-conversation-search,
.ai-rail.rail-collapsed .ai-brand-copy,
.ai-rail.rail-collapsed .ai-section-heading,
.ai-rail.rail-collapsed .ai-nav-copy,
.ai-rail.rail-collapsed .ai-rail-recents,
.ai-rail.rail-collapsed .ai-user-copy,
.ai-rail.rail-collapsed .ai-user-actions {
  display: none;
}

.ai-rail.rail-collapsed .ai-quick-icon,
.ai-rail.rail-collapsed .ai-brand-logo,
.ai-rail.rail-collapsed .ai-nav-icon,
.ai-rail.rail-collapsed .ai-user-avatar {
  margin: 0 auto;
}

.ai-rail.rail-collapsed .ai-rail-user {
  grid-template-columns: 1fr;
  padding: 12px 10px 14px;
}

@media (max-width: 760px) {
  .ai-rail {
    max-width: min(320px, 82vw);
  }

  .ai-rail-quick {
    padding-top: 18px;
  }
}
