/* ── Layout ── */
:root {
  --sidebar-w: 420px;
  --accent: #d97706;
  --accent-bg: #fffbeb;
  --transition: 0.3s ease;
}

body {
  font-family: 'Georgia', serif;
  margin: 0;
  overflow-x: hidden;
}
h1, h2, h3, .sans { font-family: 'Inter', sans-serif; }
code, pre, .mono  { font-family: 'JetBrains Mono', monospace; }

/* ── Left sidebar (tree) ── */
#sidebar-left {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: #fafafa;
  border-right: 1px solid #e5e7eb;
  transform: translateX(-100%);
  transition: transform var(--transition);
  z-index: 50;
  display: flex;
  flex-direction: column;
}
#sidebar-left.open {
  transform: translateX(0);
}

/* ── Right sidebar (chat) ── */
#sidebar-right {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: #fafafa;
  border-left: 1px solid #e5e7eb;
  transform: translateX(100%);
  transition: transform var(--transition);
  z-index: 50;
  display: flex;
  flex-direction: column;
}
#sidebar-right.open {
  transform: translateX(0);
}

/* ── Shared sidebar header ── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: white;
  flex-shrink: 0;
}
.sidebar-header .icon {
  font-size: 16px;
  opacity: 0.5;
}
.sidebar-header .title {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #9ca3af;
  padding: 4px 8px;
  border-radius: 4px;
}
.sidebar-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Main content shift */
#page-wrap {
  transition: margin-left var(--transition), margin-right var(--transition);
}
body.left-open #page-wrap {
  margin-left: var(--sidebar-w);
}
body.right-open #page-wrap {
  margin-right: var(--sidebar-w);
}

/* ── Active link indicator ── */
a[data-sidebar] {
  cursor: pointer;
  text-decoration: none;
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  transition: all 0.2s;
}
a[data-sidebar]:hover {
  color: #b45309;
  border-bottom-style: solid;
}
a[data-sidebar].active {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  padding-left: 4px;
  margin-left: -7px;
  border-bottom: none;
}

/* ── File tree ── */
.tree-item {
  display: flex;
  align-items: center;
  padding: 3px 8px 3px 0;
  cursor: default;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #374151;
  border-radius: 4px;
  user-select: none;
}
.tree-item:hover {
  background: #f3f4f6;
}
.tree-item.tree-clickable {
  cursor: pointer;
  color: var(--accent);
}
.tree-item.tree-clickable:hover {
  text-decoration: underline;
}
.tree-item.highlighted {
  background: var(--accent-bg);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tree-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 12px;
  opacity: 0.5;
}
.tree-toggle {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 10px;
  opacity: 0.4;
  transition: transform 0.15s;
}
.tree-toggle.expanded {
  transform: rotate(90deg);
}
.tree-children {
  padding-left: 16px;
  overflow: hidden;
}
.tree-children.collapsed {
  display: none;
}

/* ── Chat viewer ── */
.chat-msg {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  line-height: 1.6;
}
.chat-msg.highlighted {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
}
.chat-role {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.chat-role.user {
  color: #92400e;
}
.chat-role.assistant {
  color: #1e40af;
}
.chat-text {
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-text code {
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}
.chat-text pre {
  background: #1f2937;
  color: #e5e7eb;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}
.chat-truncated {
  max-height: 200px;
  overflow: hidden;
  position: relative;
}
.chat-truncated::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, #fafafa);
  pointer-events: none;
}
.chat-truncated.highlighted::after {
  background: linear-gradient(transparent, var(--accent-bg));
}
.chat-show-more {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 16px 8px;
  display: block;
}
.chat-show-more:hover {
  color: #b45309;
}

/* ── Convo sidebar button (eye icon) ── */
.convo-sidebar-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #d97706;
  opacity: 0.3;
  text-decoration: none;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  cursor: pointer;
}
.convo-sidebar-btn:hover {
  opacity: 1;
  background: rgba(217, 119, 6, 0.1);
}
.convo-sidebar-btn.active {
  opacity: 1;
  background: rgba(217, 119, 6, 0.15);
  border-left: none;
  padding-left: 0;
  margin-left: 0;
}
.convo-sidebar-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Existing report styles ── */
.claude-convo {
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
}
.claude-convo .human {
  color: #92400e;
  font-weight: 600;
}
.claude-convo .assistant {
  color: #1e40af;
  font-weight: 600;
}
.figure-caption {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #6b7280;
  font-style: italic;
}
