:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --ink-muted: #4b4b4b;
  --accent: #005baa;
  --accent-weak: #e6f0fa;
  --danger: #e45865;
  --danger-weak: #ffe4e8;
  --success: #2e7d32;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --font: "Open Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --history-checkbox-slot: 2.2rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: #f7fbff;
  color: var(--ink);
}

.ls-ribbon {
  height: 10px;
  width: 100%;
  background: linear-gradient(
    to right,
    #243447 0 12.5%,
    #7b4fa3 12.5% 25%,
    #d4145a 25% 37.5%,
    #d97b0d 37.5% 50%,
    #ffcc4d 50% 62.5%,
    #2e7d32 62.5% 75%,
    #12a6a3 75% 87.5%,
    #0b88d9 87.5% 100%
  );
}

.ls-header {
  background: var(--accent);
  color: #fff;
  padding: 2.4rem 1.5rem 2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ls-title {
  margin: 0.2rem 0;
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 800;
}

.eyebrow {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.subtitle {
  margin: 0;
  color: #e6f0fa;
  font-size: 1.02rem;
}

.ls-pill,
.pill,
.chip {
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
}

.ls-pill {
  background: #fff;
  color: var(--accent);
  padding: 0.45rem 1.1rem;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0.5rem;
  max-width: 1400px;
  margin: 1.4rem auto 2rem;
  padding: 0 1rem 1rem;
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  align-items: flex-start;
}

.layout > aside.sidebar {
  grid-column: 1;
}

.layout > .history-content {
  grid-column: 2;
}

.sidebar {
  background: #fff;
  border: 1px solid var(--accent-weak);
  border-radius: 16px;
  padding: 0.6rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
  min-width: 0;
  position: relative;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--accent-weak);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.4rem 0.6rem;
  border-bottom: 1px solid var(--accent-weak);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  margin-top: -4px;
  margin-bottom: -4px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-header .cta {
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  min-height: 42px;
  border: 1px solid var(--accent-weak);
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}

.sidebar-link:hover {
  border-color: var(--accent);
  background: #f5f7fa;
  box-shadow: 0 4px 10px rgba(0, 91, 170, 0.08);
}

.sidebar-link:active {
  transform: translateY(1px);
}

.sidebar-link-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 6px;
  background: #f5f7fa;
  padding: 3px;
  border: 1px solid var(--accent-weak);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.sidebar-link-label {
  font-size: 0.9rem;
}

.sidebar-action {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 0.5rem;
  padding-right: 0.7rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  cursor: pointer;
  transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 40px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-action-label {
  display: inline-block;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 200px;
  padding-left: 0.55rem;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-weak);
  color: var(--accent);
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-action:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0, 91, 170, 0.18);
}

.sidebar-action:hover .sidebar-icon {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.sidebar-action svg {
  display: block;
}

.history-block {
  margin-top: 0.5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 500px;
  overflow: visible;
  transform: translateX(0);
}

.sidebar-toggle {
  background: #f5f7fa;
  border: 1px solid var(--accent-weak);
  border-radius: 8px;
  padding: 0.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  transition: all 0.2s ease;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
}

.sidebar-toggle:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sidebar-expand {
  background: #f5f7fa;
  border: 1px solid var(--accent-weak);
  border-radius: 8px;
  padding: 0.35rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-top: 0.35rem;
}

.sidebar-expand:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Collapsed sidebar state */
.layout.sidebar-collapsed {
  grid-template-columns: 56px 1fr;
}

.layout.sidebar-collapsed .sidebar {
  padding: 0.6rem;
  align-items: center;
}

/* Hide brand (logo + toggle) with horizontal collapse */
.layout.sidebar-collapsed .sidebar-brand {
  max-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
}

/* Nav section - remove border, center items */
.layout.sidebar-collapsed .sidebar-nav {
  border: none;
  padding: 0.3rem 0;
  align-items: center;
}

/* Action buttons - icon only */
.layout.sidebar-collapsed .sidebar-action {
  padding: 0.5rem;
  min-height: 36px;
  border-radius: 8px;
  background: #f5f7fa;
  border: 1px solid var(--accent-weak);
}

/* Hide text labels with horizontal collapse */
.layout.sidebar-collapsed .sidebar-action-label {
  max-width: 0;
  padding-left: 0;
  opacity: 0;
}

.layout.sidebar-collapsed .sidebar-action .sidebar-icon {
  background: transparent;
}

.layout.sidebar-collapsed .sidebar-action:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.layout.sidebar-collapsed .sidebar-action:hover .sidebar-icon {
  color: #fff;
}

/* Hide history/recents with horizontal collapse */
.layout.sidebar-collapsed .history-block {
  max-height: 0;
  padding: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-100%);
}

.layout.sidebar-collapsed .sidebar-expand {
  display: flex;
}

.layout.sidebar-collapsed .chat-shell {
  margin-left: 0;
}

.block {
  background: #f9fbff;
  border: 1px solid var(--accent-weak);
  border-radius: 12px;
  padding: 0.9rem;
}

#recents-list {
  background: transparent;
  border: none;
  box-shadow: none;
  text-align: left;
}

.block-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.6rem;
  font-size: 0.82rem;
}

#recents-list .block-title {
  color: #5a7597;
  font-weight: 600;
  text-align: left;
}

.history-container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem 2rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.history-list.claude-style {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  padding: 0;
}

.history-card {
  display: flex;
  align-items: flex-start;
  position: relative;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  margin: 0 -0.6rem 0 calc(-0.6rem - var(--history-checkbox-slot));
  padding: 1rem 0.6rem 1rem 37px;
  border-radius: 12px;
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    color 0.12s ease;
  gap: 0;
  overflow: visible;
}

.history-card:last-child {
  border-bottom: none;
}

.history-card:hover {
  background: rgba(0, 91, 170, 0.06);
  border-bottom-color: rgba(15, 23, 42, 0.18);
}

.history-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.history-card.selected {
  background: transparent;
  border-bottom-color: var(--accent);
  color: inherit;
  box-shadow: none;
}

.history-card.selected .history-title {
  color: var(--accent);
}

.history-card.selected .history-meta {
  color: var(--accent);
}

.history-select-control {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(-1 * var(--history-checkbox-slot));
  width: var(--history-checkbox-slot);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-0.25rem);
  transition:
    opacity 0.12s ease,
    transform 0.18s ease;
}

.history-card:hover .history-select-control,
.history-card:focus-within .history-select-control,
.history-list.selection-mode .history-select-control {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.history-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid #c6d5ea;
  background: #fff;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  appearance: none;
  position: relative;
}

.history-checkbox:focus-visible,
.history-checkbox:hover {
  border-color: #7eaeee;
  box-shadow: 0 0 0 3px rgba(126, 174, 238, 0.25);
}

.history-card:hover .history-checkbox,
.history-list.selection-mode .history-checkbox {
  opacity: 1;
}

.history-checkbox::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: translate(-50%, -50%) rotate(45deg) scale(0);
  transform-origin: center;
  transition: transform 0.15s ease;
  top: 45%;
  left: 50%;
}

.history-checkbox:checked {
  background: linear-gradient(135deg, #0a7be7, #0a5fc7);
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(10, 95, 199, 0.35);
}

.history-checkbox:checked::after {
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
}

.history-row-body {
  flex: 1;
}

.history-row-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
}

.history-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-row-details {
  flex: 1;
  min-width: 0;
}

.history-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2a44;
}

.history-meta {
  color: var(--ink-muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  margin: 0.2rem 0 0;
}

.history-preview {
  margin: 0;
  color: #4a5872;
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-session {
  margin-bottom: 0;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.history-session .history-meta {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.history-card-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-right: 0.35rem;
}

.history-card .session-menu-btn {
  opacity: 0;
  transition: opacity 0.12s ease;
}

.history-card:hover .session-menu-btn,
.history-card .session-menu-btn.active {
  opacity: 1;
}

.history-list.selection-mode .history-card {
  cursor: default;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  background: var(--accent-weak);
  color: var(--accent);
  border: 1px solid var(--accent-weak);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: var(--accent);
  color: #fff;
}

.chip.ghost {
  background: #fff;
  border-color: var(--accent-weak);
  color: var(--accent);
}

.session-card {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0.4rem 0.1rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  margin: 0 0 0.35rem 0;
  cursor: pointer;
  transition: color 0.15s ease;
}

.session-card.recents-placeholder {
  justify-content: center;
  min-height: 34px;
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.84rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  box-shadow: none;
  pointer-events: none;
}

.session-card.recents-placeholder::after {
  content: none;
}

.session-card:hover {
  color: var(--accent);
}

.session-card.active {
  color: var(--accent);
  font-weight: 700;
}

.session-card.starred .session-title::before {
  content: "★";
  color: #f2b01e;
  margin-right: 0.35rem;
}

.session-title {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.84rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.session-menu-btn {
  background: transparent;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--ink-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s ease;
}

.session-card:hover .session-menu-btn,
.session-card .session-menu-btn.active {
  opacity: 1;
}

.session-menu-btn:hover {
  background: var(--accent-weak);
  color: var(--accent);
}

.topbar-actions .session-menu-btn {
  opacity: 1; /* always visible in top bar */
  padding: 0.25rem;
  border: 1px solid var(--accent-weak);
  border-radius: 6px;
  background: #f7f9fc;
}

.chat-shell.claude-mode .topbar-actions .session-menu-btn {
  padding: 0.2rem;
}

.topbar-actions .session-menu-btn:hover {
  background: var(--accent-weak);
}

.session-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.35rem;
  background: #fff;
  border: 1px solid var(--accent-weak);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 91, 170, 0.15);
  min-width: 160px;
  padding: 0.4rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: all 0.15s ease;
}

.session-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.pinned-container {
  margin-bottom: 0.6rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--accent-weak);
  display: none;
}

.pinned-container.visible {
  display: block;
}

.pinned-label {
  font-weight: 700;
  font-size: 0.78rem;
  color: #5a7597;
  margin: 0 0 0.1rem 0;
}

.pinned-cards,
.recents-container {
  display: flex;
  flex-direction: column;
}

#recents-list .session-card {
  text-align: left;
  justify-content: flex-start;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--accent-weak);
  color: var(--accent);
}

.dropdown-item.danger {
  color: #c0392b;
}

.dropdown-item.danger:hover {
  background: #fdf2f2;
  color: #c0392b;
}

.dropdown-divider {
  height: 1px;
  background: var(--accent-weak);
  margin: 0.35rem 0;
}

.pinned-list {
  margin: 0;
  padding-left: 1rem;
  color: var(--ink-muted);
  line-height: 1.5;
  font-size: 0.82rem;
}

.cta {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.5rem 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.cta.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cta.primary:hover {
  background: #0b88d9;
  border-color: #0b88d9;
}

.chat-shell {
  background: #fff;
  border: 1px solid var(--accent-weak);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 80vh;
}

.chat-topbar {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--accent-weak);
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(180deg, #fdfefe 0%, #f7fbff 100%);
}

.chat-topbar-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.chat-label {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.chat-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.15rem 0.4rem;
  outline: none;
  transition: all 0.15s ease;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}

.chat-title:hover {
  background: #f5f7fa;
  border-color: var(--accent-weak);
}

.chat-title:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 91, 170, 0.12);
}

.rename-btn {
  background: transparent;
  border: none;
  padding: 0.3rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink-muted);
  opacity: 0.5;
  transition: all 0.15s ease;
  border-radius: 4px;
}

.rename-btn:hover {
  opacity: 1;
  color: var(--accent);
  background: var(--accent-weak);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--ink-muted);
}

.status-dot.online {
  background: var(--success);
}

.status-label {
  font-size: 0.82rem;
}

.pill {
  padding: 0.1rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid var(--accent-weak);
  background: #fff;
  color: var(--ink-muted);
}

.pill.neutral {
  background: var(--accent-weak);
  color: var(--accent);
}

.pill.subtle {
  background: #fff;
}

.pill.success {
  background: #e8f5e9;
  color: var(--success);
  border-color: #d4edda;
}

.chat-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f7f9fc;
  color: var(--ink);
  border: 1px solid var(--accent-weak);
  border-radius: 12px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(0, 91, 170, 0.06);
}

.topbar-btn svg {
  width: 16px;
  height: 16px;
}

.topbar-btn.ghost:hover {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 6px 16px rgba(0, 91, 170, 0.14);
}

.topbar-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 91, 170, 0.24);
}

.topbar-btn.primary:hover {
  background: #0b88d9;
  border-color: #0b88d9;
}

.topbar-divider {
  width: 1px;
  height: 26px;
  background: var(--accent-weak);
}

.icon-btn {
  background: #f5f7fa;
  border: 1px solid var(--accent-weak);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Welcome Screen Styles */
.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(180deg, #f0f6fb 0%, #ffffff 60%, #f9fbff 100%);
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 680px;
  width: 100%;
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-icon {
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.welcome-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.welcome-title {
  margin: 0 0 0.5rem;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.5px;
}

.welcome-subtitle {
  margin: 0 0 2rem;
  font-size: 1.1rem;
  color: var(--ink-muted);
}

.welcome-composer {
  width: 100%;
  margin-bottom: 1.5rem;
}

.welcome-input-wrapper {
  background: #fff;
  border: 2px solid var(--accent-weak);
  border-radius: 16px;
  padding: 0.5rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 8px 32px rgba(0, 91, 170, 0.08);
  transition: all 0.2s ease;
}

.welcome-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(0, 91, 170, 0.15), 0 0 0 4px rgba(0, 91, 170, 0.08);
}

.welcome-input-wrapper textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  min-height: 28px;
  max-height: 120px;
  line-height: 1.5;
}

.welcome-input-wrapper textarea::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}

.welcome-input-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.welcome-icon-btn {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--ink-muted);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.welcome-icon-btn:hover {
  background: var(--accent-weak);
  color: var(--accent);
}

.welcome-send-btn {
  background: var(--accent);
  border: none;
  padding: 0.6rem;
  cursor: pointer;
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.welcome-send-btn:hover {
  background: #0b88d9;
  transform: translateY(-1px);
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.welcome-action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: #fff;
  border: 1px solid var(--accent-weak);
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.welcome-action-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 91, 170, 0.2);
}

.welcome-action-btn svg {
  opacity: 0.8;
}

.welcome-action-btn:hover svg {
  opacity: 1;
}

/* Hidden state */
.hidden {
  display: none !important;
}

.chat-window {
  padding: 1.1rem 1.3rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(180deg, #f9fbff 0%, #fff 100%);
}

/* Claude-inspired chat treatment */
.chat-shell.claude-mode {
  /* Keep the original shell look; claude-mode now only tweaks message layout */
  background: #fff;
  border-color: var(--accent-weak);
  box-shadow: var(--shadow);
}

.chat-shell.claude-mode .chat-topbar {
  background: transparent;
  border-color: transparent;
}

.chat-shell.claude-mode .chat-title {
  color: var(--ink);
  border-color: transparent;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
}

.chat-shell.claude-mode .chat-title:hover {
  background: #f5f7fa;
  border-color: var(--accent-weak);
}

.chat-shell.claude-mode .chat-window {
  background: linear-gradient(180deg, #f9fbff 0%, #fff 100%);
  color: var(--ink);
  padding: 1.1rem 1.3rem;
  gap: 1rem;
  align-items: flex-start;
}

.chat-shell.claude-mode .message {
  width: 100%;
  padding: 0;
  gap: 0.4rem;
}

.chat-shell.claude-mode .message .avatar {
  display: none;
}

.chat-shell.claude-mode .message.bot .avatar {
  display: none;
}

.chat-shell.claude-mode .message.user {
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 0.65rem;
  justify-content: flex-end;
  padding-right: 6rem;
}

.chat-shell.claude-mode .bubble {
  width: auto;
  max-width: 880px;
}

.chat-shell.claude-mode .message.bot .bubble {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  padding-right: 6rem;
  padding-left: 6rem
}

.chat-shell.claude-mode .message.bot .msg-header {
  display: none;
}

.chat-shell.claude-mode .message.user .bubble {
  background: #fff;
  border: 1px solid var(--accent-weak);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  margin-left: auto;
}

.chat-shell.claude-mode .message.user .pill.subtle {
  display: none;
}

.chat-shell.claude-mode .message.user .msg-header,
.chat-shell.claude-mode .message.user .role {
  display: none;
}

.chat-shell.claude-mode .prompt-row,
.chat-shell.claude-mode .composer,
.chat-shell.claude-mode .composer-inner {
  background: transparent;
  border-color: var(--accent-weak);
  box-shadow: var(--shadow);
}

.chat-shell.claude-mode .composer textarea {
  background: #fff;
  color: var(--ink);
}

.chat-shell.claude-mode .composer textarea::placeholder {
  color: var(--ink-muted);
}

.chat-shell.claude-mode #composer-attach-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 33px;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
}

.chat-shell.claude-mode #composer-attach-btn:hover {
  background: #0b88d9;
  border-color: #0b88d9;
}

.chat-shell.claude-mode #composer-attach-btn svg {
  display: block;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.82rem;
  box-shadow: 0 2px 8px rgba(0, 91, 170, 0.2);
}

.avatar.user-avatar {
  background: #243447;
}

.bubble {
  background: #fff;
  border: 1px solid var(--accent-weak);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  max-width: 880px;
  font-size: 0.88rem;
}

.message.bot .bubble {
  background: #f0f6fb;
}

.message.typing .bubble {
  background: #fff;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.role {
  font-weight: 700;
  color: var(--accent);
}

.lo-list {
  padding-left: 1rem;
  margin: 0.35rem 0;
  color: var(--ink);
  font-size: 0.88rem;
}

.note {
  margin-top: 0.5rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.composer {
  padding: 0.9rem 6rem 1rem;
  background: transparent;
  border-top: none;
}

.composer-inner {
  border: 1px solid var(--accent-weak);
  border-radius: 14px;
  background: #fff;
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem;
  align-items: flex-end;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.04);
}

.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: vertical;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--ink);
  min-height: 64px;
  background: #fff;
}

.composer-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.helper {
  margin: 0.4rem 0 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.typing-dots {
  display: inline-flex;
  gap: 6px;
  margin: 0.35rem 0 0.1rem;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: blink 1.2s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 220px 1fr;
    gap: 0.75rem;
  }

  .sidebar {
    order: 1;
    padding: 0.6rem;
  }

  .chat-shell {
    order: 1;
  }

  .sidebar-toggle {
    display: flex;
  }

  .layout.sidebar-collapsed {
    grid-template-columns: 56px 1fr;
  }

  .layout.sidebar-collapsed .sidebar {
    padding: 0.6rem;
  }

  .layout.sidebar-collapsed .chat-shell {
    margin-left: 0;
  }

  .layout > .history-content {
    order: 2;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 72px 1fr;
    gap: 0.5rem;
  }

  .sidebar {
    padding: 0.5rem 0.35rem;
    gap: 0.4rem;
    width: 72px;
    border-radius: 16px;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--accent-weak);
    box-shadow: 0 10px 28px rgba(0, 91, 170, 0.08);
  }

  .sidebar-header .cta {
    font-size: 0;
    padding: 0.7rem;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    border-color: var(--accent);
  }

  .sidebar-header .cta::after {
    content: "+";
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
  }

  .sidebar-toggle {
    padding: 0.45rem;
    width: 44px;
    height: 44px;
  }

  .block-title,
  .session-title,
  .session-actions {
    display: none;
  }

  .block {
    padding: 0.35rem 0;
    background: transparent;
    border: none;
    box-shadow: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
  }

  .session-card {
    padding: 0;
    margin: 0;
    width: 44px;
    height: 44px;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid transparent;
    background: #f5f7fa;
    position: relative;
  }

  .session-card::after {
    content: attr(data-short);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #f0f6fb;
    color: var(--ink);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.2px;
  }

  .session-card.active::after {
    background: rgba(0, 91, 170, 0.14);
    color: var(--accent);
    border: 1px solid var(--accent-weak);
  }

  .session-card:hover::after {
    background: #eaf3fb;
  }

  .session-card:hover {
    border-color: transparent;
    box-shadow: none;
  }

  .layout.sidebar-collapsed {
    grid-template-columns: 56px 1fr;
  }

  .layout.sidebar-collapsed .sidebar {
    padding: 0.5rem 0.35rem;
  }

  .layout > .history-content {
    order: 2;
  }

  .category-label-full {
    display: none;
  }

  .category-label-short {
    display: inline;
  }
}

@media (max-width: 720px) {
  .chat-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .chat-topbar-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .topbar-divider {
    display: none;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .welcome-title {
    font-size: 1.6rem;
  }

  .welcome-subtitle {
    font-size: 1rem;
  }

  .welcome-actions {
    gap: 0.5rem;
  }

  .welcome-action-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.82rem;
  }

  .welcome-icon {
    width: 72px;
    height: 72px;
  }
}

/* Delete confirmation modal */
.confirm-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(7, 20, 38, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.confirm-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.confirm-modal {
  position: relative;
  width: min(520px, 100%);
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--accent-weak);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(17, 34, 68, 0.18);
  padding: 1.4rem 1.7rem 1.2rem;
  animation: cardPop 0.22s cubic-bezier(0.34, 1.5, 0.64, 1) forwards;
}

.confirm-modal::before {
  content: "";
  position: absolute;
  top: 0.4rem;
  left: 1.4rem;
  right: 1.4rem;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(120deg, #005baa, #12a6a3);
  pointer-events: none;
}

.confirm-header {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--danger-weak);
  color: var(--danger);
  border: 1px solid rgba(228, 88, 101, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 6px 18px rgba(228, 88, 101, 0.15);
}

.confirm-eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.confirm-title {
  margin: 0.2rem 0 0.35rem;
  font-size: clamp(1.15rem, 2.6vw, 1.35rem);
  font-weight: 800;
  color: var(--ink);
}

.confirm-description {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.confirm-description strong {
  color: var(--ink);
  font-weight: 800;
}

.confirm-actions {
  margin-top: 1.4rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.65rem 1.2rem;
  font-weight: 700;
  font-size: 0.93rem;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-ghost {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent-weak);
  box-shadow: 0 4px 12px rgba(0, 91, 170, 0.08);
}

.btn-ghost:hover {
  background: var(--accent-weak);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 8px 18px rgba(0, 91, 170, 0.14);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 12px 26px rgba(228, 88, 101, 0.3);
}

.btn-danger:hover {
  background: #f56b75;
  border-color: #f56b75;
  box-shadow: 0 16px 34px rgba(245, 107, 117, 0.35);
}

@keyframes cardPop {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Toast */
.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem 0.75rem 0.8rem;
  border-radius: 999px;
  background: rgba(17, 26, 36, 0.9);
  color: #f3f6fb;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2100;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
}

.toast-text {
  font-weight: 700;
  font-size: 0.95rem;
}

.toast-close {
  background: transparent;
  border: none;
  color: #f3f6fb;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* =====================================================
   HISTORY PAGE - Claude-inspired minimalist design
   ===================================================== */

.history-page {
  background: #f8fafc;
  min-height: 100vh;
}

.history-page .ls-header {
  padding: 2.4rem 1.5rem 2rem;
}

.history-page .ls-title {
  font-size: 2rem;
}

.history-page .subtitle {
  font-size: 0.95rem;
  opacity: 0.85;
}

.history-page .cta.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.history-page .cta.ghost:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
}

.history-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
}

/* Sidebar */
.history-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-section {
  background: #fff;
  border: 1px solid #e5eaf0;
  border-radius: 12px;
  padding: 1rem;
}

.sidebar-label {
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7a8a9e;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-chip {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid #e5eaf0;
  border-radius: 6px;
  background: #fff;
  color: #5a6b7d;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.category-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.category-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  text-decoration: none;
  color: #4a5568;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.category-link:hover {
  background: #f5f7fa;
  color: var(--accent);
}

.category-link.active {
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
}

.category-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: inherit;
  opacity: 0.7;
}

.category-link:hover .category-icon,
.category-link.active .category-icon {
  opacity: 1;
}

.category-count {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  color: #9ca3af;
  background: #f0f3f7;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.category-link.active .category-count {
  background: rgba(0, 91, 170, 0.15);
  color: var(--accent);
}

/* Main content */
.history-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-shell {
  background: #fff;
  border: 1px solid var(--accent-weak);
  border-radius: 18px;
  padding: 1.25rem clamp(2.1rem, 5vw, 4rem) 1.8rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
}

@media (max-width: 640px) {
  .history-shell {
    padding: 1.2rem 1.5rem 1.4rem;
  }
}

.history-shell > * + * {
  margin-top: 1rem;
}

#history-conversations-list {
  margin-top: 0;
  padding: 0 0.6rem;
}

.content-header + #history-conversations-list {
  margin-top: 1rem;
}

.history-bar {
  border: 1px solid var(--accent-weak);
  background: #fff;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: var(--shadow);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    max-height 0.18s ease,
    margin 0.18s ease,
    padding 0.18s ease,
    border-width 0.18s ease,
    box-shadow 0.18s ease;
  min-height: 57px;
}

.history-bar.is-hidden {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  visibility: hidden;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  margin-bottom: 0;
  border-width: 0;
  box-shadow: none;
}

.history-summary-row {
  margin-top: 0.3rem;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0.45rem 0.6rem;
  min-height: 0;
  justify-content: flex-start;
  gap: 0.6rem;
}

.history-count {
  margin: 0;
  font-size: 0.85rem;
}

.history-summary-row .history-bulk-info {
  color: inherit;
  font-weight: 600;
  order: 0;
}

.history-summary-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  order: 1;
  margin-right: 0;
  margin-left: 0.4rem;
}

.history-select-btn {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: 0;
  font-size: 0.85rem;
  font-weight: inherit;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.15s ease;
  line-height: 1.2;
}

.history-select-btn:hover:enabled {
  color: #003f7c;
  text-decoration-thickness: 2px;
}

.history-select-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  text-decoration: none;
}

.history-bulk-bar {
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: linear-gradient(135deg, #0c1424 0%, #101b31 100%);
  border-radius: 999px;
  box-shadow:
    0 12px 24px rgba(5, 9, 18, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  padding: 0.35rem 0.55rem;
  min-height: auto;
  justify-content: flex-start;
  gap: 0.45rem;
  color: #f1f5f9;
}

.history-selected-count {
  font-weight: 600;
  font-size: 0.92rem;
  color: inherit;
  letter-spacing: 0.01em;
}

.history-bulk-gap {
  flex: 1;
}

.history-bulk-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.history-bulk-icon svg {
  width: 16px;
  height: 16px;
}

.history-bulk-icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.history-bulk-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.history-bulk-icon.history-bulk-cancel {
  background: rgba(255, 255, 255, 0.06);
}

.history-bulk-icon.history-bulk-star {
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.25);
  background: rgba(252, 211, 77, 0.15);
}

.history-bulk-icon.history-bulk-star.is-active {
  background: rgba(252, 211, 77, 0.35);
  border-color: rgba(252, 211, 77, 0.7);
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.35);
}

.history-bulk-icon.danger {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.32);
  color: #fecaca;
}

.history-bulk-icon.danger:hover:not(:disabled) {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

.history-bulk-info {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.history-bulk-bar .history-bulk-info {
  color: var(--ink-muted);
  font-weight: 600;
}

.history-bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-bulk-bar .history-bulk-actions {
  order: -1;
  margin-right: 0.4rem;
}

.history-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-controls .sidebar-section {
  background: #fff;
  border: 1px solid var(--accent-weak);
  border-radius: 12px;
  padding: 1rem;
}

.content-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.9rem;
}

.content-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.history-inline-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}

.history-new-chat-btn {
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.45rem 1.35rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 91, 170, 0.25);
  transition: background 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.history-new-chat-btn::first-letter {
  font-size: 1.2rem;
  font-weight: 700;
}

.history-new-chat-btn:hover {
  background: #004c95;
  box-shadow: 0 10px 24px rgba(0, 76, 149, 0.35);
}

.search-wrapper {
  position: relative;
  flex: 1;
  width: min(100%, 540px);
  transition: width 0.25s ease;
}

.search-wrapper:focus-within {
  width: min(100%, 680px);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.65rem 0.9rem 0.65rem 2.6rem;
  font-size: 0.88rem;
  font-family: var(--font);
  border: 1px solid #cdd5e0;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.search-input::placeholder {
  color: #a0aec0;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 91, 170, 0.1);
}

.history-empty-state {
  padding: 2rem;
  border-radius: 16px;
  background: #ffffff;
  text-align: center;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.08);
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.history-empty-state h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1f2a44;
}

.history-empty-state p {
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.results-count {
  font-size: 0.82rem;
  color: #7a8a9e;
  font-weight: 500;
}

/* Conversations list */
.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.conversation-item {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid #e5eaf0;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}

.conversation-item:hover {
  border-color: #cdd5e0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

.conversation-item.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, #f8fbff 0%, #fff 100%);
  box-shadow: 0 4px 16px rgba(0, 91, 170, 0.08);
}

.conversation-body {
  flex: 1;
  min-width: 0;
}

.conversation-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.3rem;
}

.conversation-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.conversation-item:hover .conversation-title,
.conversation-item.active .conversation-title {
  color: var(--accent);
}

.conversation-time {
  font-size: 0.75rem;
  color: #9ca3af;
  white-space: nowrap;
  flex-shrink: 0;
}

.conversation-preview {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: #6b7280;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.conversation-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: #f0f4f8;
  color: #5a6b7d;
  border-radius: 4px;
}

.conversation-item.active .tag {
  background: var(--accent-weak);
  color: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
  .history-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .history-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .sidebar-section {
    flex: 1;
    min-width: 200px;
  }

  .content-header {
    flex-direction: column;
    align-items: stretch;
  }

  .search-wrapper,
  .search-wrapper:focus-within {
    width: 100%;
    max-width: none;
  }

  .results-count {
    text-align: right;
  }

  .conversation-item {
    padding: 0.85rem 0.9rem;
  }

  .conversation-header {
    flex-direction: column;
    gap: 0.25rem;
  }

  .conversation-time {
    order: -1;
  }
}

/* ============================================
   Chat Message Markdown Styles
   ============================================ */

.msg-body {
  line-height: 1.6;
}

.msg-body p {
  margin: 0 0 0.5em 0;
}

.msg-body p:last-child {
  margin-bottom: 0;
}

.msg-body br {
  display: block;
  content: "";
  margin: 0.25em 0;
}

.msg-body strong {
  font-weight: 600;
  color: var(--text-primary, #1a1a2e);
}

.msg-body em {
  font-style: italic;
}

.msg-body .chat-heading {
  font-weight: 600;
  margin: 1em 0 0.5em 0;
  color: var(--text-primary, #1a1a2e);
}

.msg-body h3.chat-heading {
  font-size: 1.05em;
}

.msg-body h4.chat-heading {
  font-size: 0.95em;
}

.msg-body .chat-list {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.msg-body ul.chat-list {
  list-style-type: disc;
}

.msg-body ol.chat-list {
  list-style-type: decimal;
}

.msg-body .chat-list li {
  margin: 0.35em 0;
  line-height: 1.5;
}

.msg-body .chat-list li strong {
  color: var(--accent-primary, #4361ee);
}

/* ============================================
   Tool Calls UI (Claude-inspired expandable sections)
   ============================================ */

.tool-calls-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tool-call-container {
  border: 1px solid #e5eaf0;
  border-radius: 10px;
  background: #f8fafc;
  overflow: hidden;
  transition: all 0.2s ease;
}

.tool-call-container:hover {
  border-color: #d0d8e0;
}

.tool-call-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.tool-call-header:hover {
  background: #f0f4f8;
}

.tool-call-expand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #7a8a9e;
  transition: transform 0.2s ease;
}

.tool-call-container.expanded .tool-call-expand-icon {
  transform: rotate(90deg);
}

.tool-call-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--accent-weak, #e6f0fa);
  color: var(--accent, #005baa);
}

.tool-call-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink, #1a1a1a);
  font-family: "SF Mono", "Fira Code", "Monaco", monospace;
}

.tool-call-content {
  display: none;
  border-top: 1px solid #e5eaf0;
  background: #fff;
}

.tool-call-container.expanded .tool-call-content {
  display: block;
}

.tool-call-section {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid #f0f4f8;
}

.tool-call-section:last-child {
  border-bottom: none;
}

.tool-call-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7a8a9e;
  margin-bottom: 0.5rem;
}

.tool-call-json {
  margin: 0;
  padding: 0.65rem 0.75rem;
  background: #f5f7fa;
  border-radius: 6px;
  font-size: 0.78rem;
  font-family: "SF Mono", "Fira Code", "Monaco", monospace;
  color: var(--ink, #1a1a1a);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.5;
}

/* Scrollbar styling for tool call content */
.tool-call-json::-webkit-scrollbar {
  width: 6px;
}

.tool-call-json::-webkit-scrollbar-track {
  background: #f0f4f8;
  border-radius: 3px;
}

.tool-call-json::-webkit-scrollbar-thumb {
  background: #c4cdd8;
  border-radius: 3px;
}

.tool-call-json::-webkit-scrollbar-thumb:hover {
  background: #a8b5c4;
}

/* Claude mode adjustments for tool calls */
.chat-shell.claude-mode .tool-calls-section {
  margin-bottom: 0.75rem;
}

.chat-shell.claude-mode .tool-call-container {
  background: #fff;
  border-color: #e8ecf2;
}

.chat-shell.claude-mode .tool-call-header:hover {
  background: #f5f8fb;
}

.chat-shell.claude-mode .tool-call-content {
  background: #fafbfc;
}

.chat-shell.claude-mode .tool-call-json {
  background: #f0f3f7;
}

/* Animation for expand/collapse */
@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 500px;
  }
}

.tool-call-container.expanded .tool-call-content {
  animation: slideDown 0.2s ease-out;
}

/* Loading state for real-time tool calls */
.tool-call-container.loading {
  background: linear-gradient(90deg, #f8fafc 0%, #f0f4f8 50%, #f8fafc 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.tool-call-container.loading .tool-call-header {
  cursor: default;
}

.tool-call-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent, #005baa);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.tool-call-status {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--accent, #005baa);
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  background: var(--accent-weak, #e6f0fa);
  border-radius: 4px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Smooth transition when loading completes */
.tool-call-container {
  transition: background 0.3s ease;
}

.tool-call-container.loading .tool-call-name {
  color: var(--accent, #005baa);
}

