/* ai-cli Web UI — Custom styles (DaisyUI handles base theme) */

/* ── Auth Screen ───────────────────────────────────── */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(var(--b3));
  backdrop-filter: blur(8px);
}
.auth-card {
  background: oklch(var(--b1));
  border: 1px solid oklch(var(--bc) / 0.1);
  border-radius: var(--rounded-box, 1rem);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

/* ── Scrollbar ──────────────────────────────────────── */
#chat-area::-webkit-scrollbar { width: 6px; }
#chat-area::-webkit-scrollbar-track { background: transparent; }
#chat-area::-webkit-scrollbar-thumb {
  background: oklch(var(--bc) / 0.2);
  border-radius: 3px;
}

/* ── Chat bubbles ───────────────────────────────────── */
.chat-bubble-user {
  white-space: pre-wrap;
}

/* ── Assistant message (markdown rendered) ──────────── */
.msg-assistant {
  background: oklch(var(--b2));
  border-radius: var(--rounded-box, 1rem);
  padding: 1rem 1.25rem;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
  border-left: 3px solid oklch(var(--su));
}

.msg-assistant h1,
.msg-assistant h2,
.msg-assistant h3 {
  color: oklch(var(--p));
  margin: 1rem 0 0.5rem;
  font-weight: 700;
}
.msg-assistant h1 { font-size: 1.3em; }
.msg-assistant h2 { font-size: 1.15em; }
.msg-assistant h3 { font-size: 1.05em; }

.msg-assistant code {
  background: oklch(var(--b3));
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.88em;
}

.msg-assistant pre {
  background: oklch(var(--b3));
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  position: relative;
}

.msg-assistant pre code {
  display: block;
  padding: 1rem;
  background: transparent;
  font-size: 0.85em;
  line-height: 1.5;
}

.msg-assistant ul, .msg-assistant ol {
  padding-left: 1.25rem;
  margin: 0.5rem 0;
}

.msg-assistant li { margin: 0.25rem 0; }

.msg-assistant blockquote {
  border-left: 3px solid oklch(var(--p) / 0.5);
  padding-left: 0.75rem;
  opacity: 0.85;
  margin: 0.5rem 0;
}

.msg-assistant table {
  border-collapse: collapse;
  margin: 0.5rem 0;
  width: 100%;
  font-size: 0.9em;
}
.msg-assistant th,
.msg-assistant td {
  border: 1px solid oklch(var(--bc) / 0.15);
  padding: 0.4rem 0.75rem;
  text-align: left;
}
.msg-assistant th {
  background: oklch(var(--b3));
  font-weight: 600;
}

.msg-assistant a {
  color: oklch(var(--p));
  text-decoration: underline;
}

.msg-assistant p {
  margin: 0.4rem 0;
}

/* ── Streaming cursor ───────────────────────────────── */
.streaming-cursor::after {
  content: '▌';
  animation: blink 0.8s infinite;
  color: oklch(var(--p));
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Tool call cards (collapsible <details>) ────────── */
.tool-card {
  background: oklch(var(--b2));
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
}
.tool-card summary {
  list-style: none;
}
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary::before {
  content: '▶';
  font-size: 0.65rem;
  margin-right: 0.4rem;
  transition: transform 0.15s;
  display: inline-block;
  opacity: 0.5;
}
.tool-card[open] summary::before {
  transform: rotate(90deg);
}
.tool-card .tool-details-body {
  padding-top: 0.25rem;
}
.tool-border-safe { border-left-color: oklch(var(--in)); }
.tool-border-write { border-left-color: oklch(var(--wa)); }
.tool-border-destructive { border-left-color: oklch(var(--er)); }

.tool-card .tool-args {
  white-space: pre-wrap;
  max-height: 100px;
  overflow-y: auto;
  font-size: 0.8rem;
  opacity: 0.65;
  line-height: 1.5;
}
.tool-card .tool-result-content {
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.8rem;
}

/* ── Confirm / ask-user card ────────────────────────── */
.confirm-card {
  background: oklch(var(--b2));
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid transparent;
}

.confirm-diff {
  background: oklch(var(--b3));
  color: oklch(var(--bc));
  padding: 0.5rem;
  border-radius: 0.375rem;
  font-family: 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

/* ── Error message ──────────────────────────────────── */
.error-message {
  background: oklch(var(--er) / 0.1);
  border-left: 3px solid oklch(var(--er));
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
}

/* ── Thinking block ─────────────────────────────────── */
.thinking-block summary {
  cursor: pointer;
  font-style: italic;
  opacity: 0.6;
  font-size: 0.85rem;
}
.thinking-block .thinking-content {
  padding: 0.5rem 0.75rem;
  border-left: 2px solid oklch(var(--bc) / 0.15);
  margin-top: 0.25rem;
  white-space: pre-wrap;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* ── Todo list ──────────────────────────────────────── */
.todo-item.completed { color: oklch(var(--su)); }
.todo-item.in_progress { color: oklch(var(--wa)); }
.todo-item.pending { opacity: 0.5; }

/* ── Copy button on code blocks ─────────────────────── */
.copy-code-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.msg-assistant pre:hover .copy-code-btn {
  opacity: 1;
}

/* ── Active toggle buttons ──────────────────────────── */
.btn-active-toggle {
  border: 1px solid oklch(var(--p)) !important;
  background: oklch(var(--p) / 0.15) !important;
  color: oklch(var(--p)) !important;
}

/* ── Batch confirm file list ────────────────────────── */
.file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.85rem;
}

/* ── Connection status ──────────────────────────────── */
.status-connected { color: oklch(var(--su)); }
.status-disconnected { color: oklch(var(--er)); }

/* ── Sidebar tabs ──────────────────────────────────── */
.sidebar-tab {
  cursor: pointer;
  opacity: 0.5;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}
.sidebar-tab:hover { opacity: 0.8; }
.sidebar-tab.active {
  opacity: 1;
  border-bottom-color: oklch(var(--p));
  color: oklch(var(--p));
}

/* ── Sidebar resize handle ─────────────────────────── */
.sidebar-resize-handle {
  width: 4px;
  cursor: col-resize;
  flex-shrink: 0;
  background: transparent;
  transition: background 0.15s;
  position: relative;
  z-index: 5;
}
.sidebar-resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  left: -3px;
  right: -3px;
  bottom: 0;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.resizing {
  background: oklch(var(--p) / 0.4);
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  width: 18rem;
  transition: width 0.2s ease;
}
.sidebar.no-transition {
  transition: none;
}
.sidebar .session-item {
  padding: 0.5rem 0.6rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 2px solid transparent;
}
.sidebar .session-item:hover {
  background: oklch(var(--b3));
}
.sidebar .session-item.active {
  background: oklch(var(--p) / 0.15);
  border-left-color: oklch(var(--p));
}
.sidebar .session-item .session-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
  cursor: text;
}
.sidebar .session-item .session-rename-input {
  height: 1.5rem;
  min-height: 1.5rem;
  padding: 0 0.4rem;
}
.sidebar .session-item .session-meta {
  font-size: 0.7rem;
  opacity: 0.5;
}
.sidebar .session-item:hover .session-delete-btn {
  opacity: 0.5;
}
.sidebar .session-item:hover .session-delete-btn:hover {
  opacity: 1;
}

/* ── Image upload preview ──────────────────────────── */
#image-preview {
  border-top: 1px dashed oklch(var(--bc) / 0.15);
  padding-top: 0.5rem;
}
.image-thumb {
  display: inline-block;
}

/* ── Diff syntax highlighting ─────────────────────── */
.confirm-diff .diff-add {
  color: oklch(var(--su));
  background: oklch(var(--su) / 0.1);
}
.confirm-diff .diff-del {
  color: oklch(var(--er));
  background: oklch(var(--er) / 0.1);
}
.confirm-diff .diff-hunk {
  color: oklch(var(--p));
  opacity: 0.8;
  font-weight: 600;
}
.confirm-diff .diff-ctx {
  opacity: 0.6;
}

/* ── Tools sidebar list ──────────────────────────── */
.tools-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.4;
  padding: 0.5rem 0.25rem 0.25rem;
}
.tool-item {
  padding: 0.3rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.tool-item:hover {
  background: oklch(var(--b3));
}
.tool-item .tool-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tool-dot-safe { background: oklch(var(--in)); }
.tool-dot-write { background: oklch(var(--wa)); }
.tool-dot-destructive { background: oklch(var(--er)); }
.tool-dot-connected { background: oklch(var(--su)); }
.tool-dot-disconnected { background: oklch(var(--er)); }
.tool-dot-active { background: oklch(var(--su)); }
.tool-dot-inactive { background: oklch(var(--bc) / 0.3); }

.mcp-server-item {
  padding: 0.3rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.mcp-server-item:hover {
  background: oklch(var(--b3));
}
.mcp-server-tools {
  padding-left: 1.25rem;
  font-size: 0.75rem;
  opacity: 0.6;
}

/* ── File tree ──────────────────────────────────────── */
.file-tree-item {
  user-select: none;
}
.file-tree-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.1s;
  min-width: 0;
}
.file-tree-row:hover {
  background: oklch(var(--b3));
}
.file-tree-row.file-tree-dir {
  font-weight: 500;
}
.file-tree-chevron {
  font-size: 0.55rem;
  opacity: 0.4;
  flex-shrink: 0;
  transition: transform 0.15s;
  display: inline-block;
  width: 0.75rem;
  text-align: center;
}
.file-tree-chevron.expanded {
  transform: rotate(90deg);
}
.file-tree-icon {
  font-size: 0.8rem;
  flex-shrink: 0;
  line-height: 1;
}
.file-tree-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.file-tree-insert-btn {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  color: oklch(var(--p));
  opacity: 0;
  background: oklch(var(--p) / 0.12);
  border: none;
  border-radius: 0.2rem;
  padding: 0 0.3rem;
  cursor: pointer;
  line-height: 1.4;
  transition: opacity 0.15s, background 0.15s;
}
.file-tree-row:hover .file-tree-insert-btn {
  opacity: 1;
}
.file-tree-insert-btn:hover {
  background: oklch(var(--p) / 0.25) !important;
}
.file-tree-children {
  padding-left: 1rem;
  border-left: 1px solid oklch(var(--bc) / 0.08);
  margin-left: 0.85rem;
}

/* file preview card in chat */
.file-preview-card {
  background: oklch(var(--b2));
  border-radius: var(--rounded-box, 1rem);
  padding: 0.75rem 1rem;
  border-left: 3px solid oklch(var(--in));
}
.file-preview-card pre {
  background: oklch(var(--b3));
  border-radius: 0.375rem;
  overflow-x: auto;
  margin: 0.5rem 0 0;
}
.file-preview-card pre code {
  display: block;
  padding: 0.75rem;
  font-size: 0.78rem;
  line-height: 1.5;
  font-family: 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

/* ── Session Tab Bar (P2-1: multi-tab in page) ──────── */
.session-tab-bar {
  display: flex;
  align-items: stretch;
  min-height: 2.25rem;
  padding: 0;
  gap: 0;
  overflow: hidden;
}
.session-tabs-scroll {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: oklch(var(--bc) / 0.15) transparent;
}
.session-tabs-scroll::-webkit-scrollbar { height: 3px; }
.session-tabs-scroll::-webkit-scrollbar-thumb { background: oklch(var(--bc) / 0.15); border-radius: 2px; }

.session-tab-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  white-space: nowrap;
  cursor: pointer;
  border-right: 1px solid oklch(var(--bc) / 0.08);
  transition: background 0.12s;
  min-width: 0;
  max-width: 12rem;
  flex-shrink: 0;
  position: relative;
  user-select: none;
}
.session-tab-item:hover {
  background: oklch(var(--b3));
}
.session-tab-item.active {
  background: oklch(var(--b1));
  border-bottom: 2px solid oklch(var(--p));
  color: oklch(var(--p));
  font-weight: 600;
}
.session-tab-item:not(.active) {
  border-bottom: 2px solid transparent;
}
.session-tab-item .tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.session-tab-item .tab-processing {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: oklch(var(--wa));
  flex-shrink: 0;
  animation: tab-pulse 1.2s infinite;
}
@keyframes tab-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.session-tab-item .tab-close {
  opacity: 0;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 0.15rem;
  border-radius: 0.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.12s, background 0.12s;
}
.session-tab-item:hover .tab-close,
.session-tab-item.active .tab-close {
  opacity: 0.5;
}
.session-tab-item .tab-close:hover {
  opacity: 1;
  background: oklch(var(--er) / 0.2);
  color: oklch(var(--er));
}
.session-tab-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  flex-shrink: 0;
  font-size: 1.1rem;
  font-weight: 300;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.12s, background 0.12s;
  border: none;
  background: transparent;
  color: inherit;
}
.session-tab-add:hover {
  opacity: 1;
  background: oklch(var(--b3));
}

/* ── Round progress bar (sticky top of chat area) ──── */
.round-progress-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.4rem 1rem;
  background: oklch(var(--b2) / 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid oklch(var(--bc) / 0.1);
  max-width: 64rem;
  margin: -1rem auto 0.5rem;
}
.round-progress-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.round-progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.7;
  white-space: nowrap;
}

/* ── Tool duration & timer ─────────────────────────── */
.tool-timer {
  font-size: 0.7rem;
  font-family: 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  opacity: 0.5;
  white-space: nowrap;
}
.tool-timer.timing {
  color: oklch(var(--wa));
  opacity: 0.7;
}
.tool-duration {
  font-size: 0.7rem;
  font-family: 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  opacity: 0.6;
  white-space: nowrap;
}
.tool-duration.fast { color: oklch(var(--su)); }
.tool-duration.medium { color: oklch(var(--wa)); }
.tool-duration.slow { color: oklch(var(--er)); }

/* ── Prompt templates ──────────────────────────────── */
.template-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid oklch(var(--bc) / 0.08);
}
.template-item:hover {
  background: oklch(var(--b3));
  border-color: oklch(var(--p) / 0.3);
}
.template-item-body {
  flex: 1;
  min-width: 0;
}
.template-item-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.template-item-preview {
  font-size: 0.78rem;
  opacity: 0.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.template-item-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}
.template-item-tag {
  font-size: 0.65rem;
  padding: 0.05rem 0.35rem;
  border-radius: 0.25rem;
  background: oklch(var(--p) / 0.12);
  color: oklch(var(--p));
}
.template-item-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.template-item:hover .template-item-actions {
  opacity: 1;
}
.template-empty {
  text-align: center;
  padding: 2rem;
  opacity: 0.4;
  font-size: 0.85rem;
}

/* ── Sidebar toggle button ──────────────────────────── */
/* Visible on every width: on desktop it collapses the panel to give all
   space to the chat; on mobile (≤768px) it opens/closes the slide-over. */
.sidebar-toggle-btn { display: flex; }

/* Desktop collapse: scoped to ≥769px so it never fights the mobile
   slide-over rules (which use .sidebar-open). width:0 !important is needed
   to override the inline width set by the drag-resize handle. */
@media (min-width: 769px) {
  .sidebar.sidebar-collapsed {
    width: 0 !important;
    min-width: 0;
    border-right-width: 0;
    overflow: hidden;
  }
  .sidebar.sidebar-collapsed + .sidebar-resize-handle { display: none; }
}

/* ── Sidebar backdrop (mobile overlay) ───────────────── */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  top: 3.5rem;
  background: rgba(0, 0, 0, 0.5);
  z-index: 19;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* ── Touch optimization ──────────────────────────────── */
button, a, .session-item, .file-tree-row, .template-item, .tool-item, .mcp-server-item {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Input footer safe area (iPhone notch) ───────────── */
.input-footer {
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

/* ── Responsive: Tablet ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-toggle-btn { display: flex; }
  .sidebar-resize-handle { display: none; }
  .sidebar {
    width: 0;
    padding: 0;
    border: none;
    position: fixed;
    z-index: 20;
    top: 3.5rem;
    left: 0;
    height: calc(100vh - 3.5rem);
    height: calc(100dvh - 3.5rem);
    transition: width 0.2s ease, padding 0.2s ease;
  }
  .sidebar.sidebar-open {
    width: 18rem;
    border-right: 1px solid oklch(var(--bc) / 0.1);
    overflow: hidden;
  }
  /* Provider/model selects: narrower on tablet */
  .navbar-select { width: 7rem; font-size: 0.8rem; }
  /* Navbar end buttons: hide text labels */
  #btn-think, #btn-plan { font-size: 0.8rem; padding: 0 0.4rem; }
}

/* ── Responsive: Phone ──────────────────────────────── */
@media (max-width: 640px) {
  /* Navbar: compact layout */
  .navbar { padding: 0 0.5rem; min-height: 3rem; }
  .navbar-start { gap: 0.25rem; }
  .navbar-end { gap: 0; }
  .brand-text { display: none; }
  .navbar-select { width: 5.5rem; font-size: 0.72rem; height: 2rem; min-height: 2rem; }
  /* Navbar end: icon-only for action buttons */
  #btn-think, #btn-plan { font-size: 0.75rem; padding: 0 0.3rem; min-height: 2rem; height: 2rem; }
  .divider-horizontal { display: none; }
  #btn-clear, #btn-compact { min-height: 2rem; height: 2rem; padding: 0 0.3rem; }

  /* Sidebar: full width on small phones */
  .sidebar.sidebar-open { width: min(85vw, 20rem); }

  /* Tab bar: smaller on phone */
  .session-tab-item { padding: 0 0.5rem; font-size: 0.72rem; max-width: 9rem; }
  .session-tab-bar { min-height: 2rem; }
  .session-tab-item .tab-close { opacity: 0.4; } /* always visible on mobile (no hover) */

  /* Chat area */
  #chat-area { padding: 0.75rem 0.5rem; }
  .msg-assistant { padding: 0.75rem; font-size: 0.92rem; }
  .msg-assistant pre code { font-size: 0.78rem; padding: 0.75rem; }
  .msg-assistant table { font-size: 0.8rem; }
  .msg-assistant th, .msg-assistant td { padding: 0.3rem 0.5rem; }

  /* Input area */
  .input-footer { padding: 0.5rem; padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)); }
  .input-footer .max-w-4xl { gap: 0.35rem; }
  #user-input { font-size: 16px; /* Prevents iOS zoom on focus */ min-height: 2.5rem; }
  #btn-send, #btn-stop { width: 2.5rem; height: 2.5rem; min-height: 2.5rem; }
  #btn-templates { width: 2rem; height: 2rem; min-height: 2rem; }
  #btn-templates .text-lg { font-size: 1rem; }

  /* Status bar: hide or compact */
  .input-footer .text-xs { font-size: 0.65rem; gap: 0.25rem; }

  /* Tool cards */
  .tool-card { padding: 0.4rem 0.65rem; font-size: 0.8rem; }
  .confirm-diff { font-size: 0.72rem; max-height: 150px; }

  /* Copy button always visible on mobile (no hover) */
  .copy-code-btn { opacity: 0.6; }

  /* Modals: near full-width on phone */
  .modal-box { max-width: 95vw; margin: 0.5rem; }
  #templates-modal .modal-box { max-height: 85vh; }
}

/* ── Responsive: Very small phones (320px) ───────────── */
@media (max-width: 380px) {
  .navbar-select { width: 4.5rem; font-size: 0.68rem; }
  .sidebar.sidebar-open { width: 90vw; }
  .msg-assistant { padding: 0.5rem 0.6rem; font-size: 0.88rem; }
}

/* ── Landscape phone: reduce vertical space ──────────── */
@media (max-height: 500px) and (max-width: 900px) {
  .navbar { min-height: 2.5rem; }
  .input-footer { padding-top: 0.35rem; padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px)); }
  #chat-area { padding-top: 0.5rem; padding-bottom: 0.5rem; }
}

/* ── PWA standalone mode: extra top padding for status bar ── */
@media (display-mode: standalone) {
  .navbar { padding-top: env(safe-area-inset-top, 0px); }
}

/* ── Session Replay (B1) ───────────────────────────── */
.replay-step {
  border-left: 3px solid hsl(var(--b3));
  padding: 0.5rem 0.6rem;
  background: hsl(var(--b1));
  border-radius: 0 0.35rem 0.35rem 0;
  font-size: 0.85rem;
}
.replay-step.role-user { border-left-color: #3b82f6; }
.replay-step.role-assistant { border-left-color: #10b981; }
.replay-step.role-tool { border-left-color: #f59e0b; }
.replay-step.role-tool.error { border-left-color: #ef4444; }
.replay-step-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.72rem;
  opacity: 0.75;
  margin-bottom: 0.25rem;
}
.replay-step-header .role-tag {
  font-weight: 600;
  padding: 0 0.35rem;
  border-radius: 0.25rem;
  background: hsl(var(--b3));
}
.replay-step-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  max-height: 18rem;
  overflow-y: auto;
}
.replay-step-body.text-body {
  font-family: inherit;
  font-size: 0.85rem;
}
.replay-tool-block {
  margin-top: 0.3rem;
  padding: 0.4rem;
  background: hsl(var(--b2));
  border-radius: 0.3rem;
  font-size: 0.78rem;
}
.replay-tool-block .tool-name {
  font-weight: 600;
  color: #f59e0b;
}
.replay-tool-block pre {
  margin: 0.2rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.72rem;
  max-height: 12rem;
  overflow-y: auto;
}

/* ── B2 Branch picker (sidebar) ─────────────────────────── */
.branch-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.35rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
  font-size: 0.78rem;
  line-height: 1.25;
  position: relative;
}
.branch-item:hover {
  background: rgba(128, 128, 128, 0.12);
}
.branch-item.active {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.45);
}
.branch-item .branch-marker {
  flex-shrink: 0;
  width: 0.8rem;
  color: rgb(34, 197, 94);
}
.branch-item .branch-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.branch-item .branch-id {
  flex-shrink: 0;
  opacity: 0.5;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.7rem;
}
.branch-item .branch-count {
  flex-shrink: 0;
  opacity: 0.55;
  font-size: 0.7rem;
}
.branch-item .branch-actions {
  display: none;
  gap: 0.15rem;
  flex-shrink: 0;
}
.branch-item:hover .branch-actions {
  display: flex;
}
.branch-item .branch-actions button {
  background: transparent;
  border: none;
  padding: 0 0.2rem;
  font-size: 0.72rem;
  cursor: pointer;
  opacity: 0.7;
}
.branch-item .branch-actions button:hover {
  opacity: 1;
}
.branch-item .branch-indent {
  flex-shrink: 0;
  color: rgba(128, 128, 128, 0.5);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.72rem;
  white-space: pre;
}
