/* ============================================================
   Forest Canopy — Light, warm, natural theme
   ============================================================ */

:root {
  /* Forest Canopy palette */
  --forest-green: #2d4a2b;
  --sage: #7d8471;
  --olive: #a4ac86;
  --ivory: #faf9f6;
  --ivory-warm: #f5f3ee;
  --white: #ffffff;

  /* Semantic tokens */
  --bg-main: var(--ivory);
  --bg-card: var(--ivory-warm);
  --bg-sidebar: var(--white);
  --bg-header: var(--white);
  --bg-input: var(--ivory-warm);
  --bg-input-focus: var(--white);

  --text-primary: #1a1a1a;
  --text-secondary: var(--sage);
  --text-muted: #a0a0a0;
  --text-on-accent: var(--white);

  --accent: var(--forest-green);
  --accent-light: var(--olive);
  --accent-hover: #234021;
  --accent-red: #c0392b;
  --accent-red-light: #fdf0ef;

  /* Typography */
  --font-heading: Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  /* Sizes */
  --sidebar-width: 280px;
  --content-max-width: 720px;
  --input-max-width: 720px;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-input: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* ===== Reset ===== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-main);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

a {
  color: var(--accent);
}

/* ===== App layout ===== */

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */

#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid #e8e6e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid #e8e6e1;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.sidebar-header .logo {
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--accent);
  font-weight: 600;
  margin: 0;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(134, 149, 118, 0.12);
  border: 1px solid rgba(134, 149, 118, 0.28);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.beta-badge-inline {
  flex-shrink: 0;
}

#new-chat-btn {
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--text-on-accent);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

#new-chat-btn:hover {
  background: var(--accent-hover);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
}

.conversation-item:hover {
  background: var(--bg-card);
}

.conversation-item.active {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

.conv-info {
  flex: 1;
  min-width: 0;
}

.conv-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.delete-btn {
  color: var(--text-muted);
  font-size: 18px;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}

.conversation-item:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  color: var(--accent-red);
  background: var(--accent-red-light);
}

/* ===== Chat area ===== */

#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg-main);
}

/* ===== Chat header ===== */

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-header);
  border-bottom: 1px solid #e8e6e1;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#chat-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-indicator.connected {
  background: #4caf50;
}

.status-indicator.connecting {
  background: #ffc107;
  animation: pulse 1.2s infinite;
}

.status-indicator.disconnected {
  background: #ccc;
}

/* ===== Messages ===== */

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 140px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== Welcome screen ===== */

#welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 20px;
}

.welcome-icon {
  margin-bottom: 20px;
}

.welcome-icon svg {
  width: 56px;
  height: 56px;
  color: var(--olive);
}

#welcome h2 {
  font-family: var(--font-heading);
  font-size: 24px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 24px;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 480px;
}

.prompt-chip {
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid #e0ddd6;
  border-radius: var(--radius-pill);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.prompt-chip:hover {
  background: var(--white);
  border-color: var(--olive);
  color: var(--accent);
}

/* ===== User messages ===== */

.message-group.user {
  display: flex;
  justify-content: flex-end;
  max-width: var(--content-max-width);
  width: 100%;
  align-self: center;
}

.user-bubble {
  background: var(--accent);
  color: var(--text-on-accent);
  padding: 12px 18px;
  border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
  max-width: 85%;
  font-size: 15px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* ===== Assistant messages ===== */

.message-group.assistant {
  max-width: var(--content-max-width);
  width: 100%;
  align-self: center;
}

.assistant-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
}

.assistant-content p {
  margin-bottom: 12px;
}

.assistant-content p:last-child {
  margin-bottom: 0;
}

.assistant-content h1,
.assistant-content h2,
.assistant-content h3,
.assistant-content h4 {
  font-family: var(--font-heading);
  color: var(--accent);
  margin: 20px 0 8px;
}

.assistant-content h1 { font-size: 22px; }
.assistant-content h2 { font-size: 19px; }
.assistant-content h3 { font-size: 16px; }

.assistant-content ul,
.assistant-content ol {
  margin: 8px 0 12px 24px;
}

.assistant-content li {
  margin-bottom: 4px;
}

.assistant-content code {
  font-family: var(--font-mono);
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.assistant-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.5;
}

.assistant-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.assistant-content blockquote {
  border-left: 3px solid var(--olive);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text-secondary);
}

.assistant-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 14px;
}

.assistant-content th,
.assistant-content td {
  border: 1px solid #e0ddd6;
  padding: 8px 12px;
  text-align: left;
}

.assistant-content th {
  background: var(--bg-card);
  font-weight: 600;
}

.assistant-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--olive);
  text-underline-offset: 2px;
}

.assistant-content a:hover {
  text-decoration-color: var(--accent);
}

.assistant-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

/* ===== Streaming cursor ===== */

.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ===== Inline thinking indicator ===== */

.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 2px;
  animation: fadeIn 0.2s ease;
}

.thinking-dot {
  width: 6px;
  height: 6px;
  background: var(--olive);
  border-radius: 50%;
  animation: activityPulse 1.4s infinite;
}

.thinking-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.thinking-text {
  font-size: 14px;
  color: var(--sage);
  margin-left: 4px;
}

@keyframes activityPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

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

/* ===== File cards ===== */

.file-card {
  max-width: var(--content-max-width);
  width: 100%;
  align-self: center;
  background: var(--bg-card);
  border: 1px solid #e0ddd6;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.file-card-header {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid #e0ddd6;
}

.file-card-list {
  display: flex;
  flex-direction: column;
}

.file-card-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.12s;
  border-bottom: 1px solid #f0ede8;
}

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

.file-card-item:hover {
  background: var(--white);
}

.file-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
}

.file-download-icon {
  color: var(--text-muted);
  font-size: 16px;
  flex-shrink: 0;
}

/* ===== Error card ===== */

.error-card {
  max-width: var(--content-max-width);
  width: 100%;
  align-self: center;
  background: var(--accent-red-light);
  border: 1px solid #e8c4c0;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--accent-red);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.error-card-icon {
  font-size: 18px;
  flex-shrink: 0;
}

/* ===== Interrupt notice ===== */

.interrupt-notice {
  max-width: var(--content-max-width);
  width: 100%;
  align-self: center;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
}

/* ===== Tool approval dialog ===== */

.approval-dialog {
  max-width: var(--content-max-width);
  width: 100%;
  align-self: center;
  background: var(--bg-card);
  border: 1px solid #e0ddd6;
  border-radius: var(--radius-sm);
  padding: 18px;
}

.approval-dialog-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.approval-dialog-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.approval-dialog-actions {
  display: flex;
  gap: 10px;
}

.approval-btn {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.approval-btn.allow {
  background: var(--accent);
  color: var(--text-on-accent);
}

.approval-btn.allow:hover {
  background: var(--accent-hover);
}

.approval-btn.skip {
  background: var(--bg-main);
  color: var(--text-secondary);
  border: 1px solid #e0ddd6;
}

.approval-btn.skip:hover {
  background: var(--white);
  border-color: var(--sage);
}

.approval-resolved {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== Plan overlay ===== */

.plan-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.plan-overlay.hidden {
  display: none !important;
}

.plan-overlay-modal {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s ease;
}

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

.plan-overlay-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  padding: 20px 24px 0;
  flex-shrink: 0;
}

.plan-overlay-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
}

.plan-overlay-content h1,
.plan-overlay-content h2,
.plan-overlay-content h3 {
  font-family: var(--font-heading);
  color: var(--accent);
  margin: 16px 0 6px;
}

.plan-overlay-content h1 { font-size: 20px; }
.plan-overlay-content h2 { font-size: 17px; }
.plan-overlay-content h3 { font-size: 15px; }

.plan-overlay-content p {
  margin-bottom: 10px;
}

.plan-overlay-content p:last-child {
  margin-bottom: 0;
}

.plan-overlay-content ul,
.plan-overlay-content ol {
  margin: 6px 0 10px 22px;
}

.plan-overlay-content li {
  margin-bottom: 4px;
}

.plan-overlay-content code {
  font-family: var(--font-mono);
  background: var(--bg-card);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 13px;
}

.plan-overlay-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  margin: 10px 0;
}

.plan-overlay-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.plan-overlay-actions {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #e8e6e1;
  flex-shrink: 0;
}

.plan-overlay-feedback {
  padding: 0 24px 18px;
  flex-shrink: 0;
}

.plan-overlay-feedback textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0ddd6;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  resize: vertical;
  background: var(--white);
  color: var(--text-primary);
  min-height: 60px;
}

.plan-overlay-feedback textarea:focus {
  outline: none;
  border-color: var(--olive);
}

.plan-overlay-feedback button {
  margin-top: 8px;
}

/* ===== Plan summary card (in chat stream) ===== */

.plan-summary-card {
  max-width: var(--content-max-width);
  width: 100%;
  align-self: center;
  background: var(--bg-card);
  border: 1px solid #e0ddd6;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.plan-summary-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: default;
}

.plan-summary-check {
  color: #4caf50;
  font-size: 16px;
  font-weight: 700;
}

.plan-summary-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.plan-summary-toggle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}

.plan-summary-toggle:hover {
  background: var(--ivory-warm);
  color: var(--accent);
}

.plan-summary-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.plan-summary-body.open {
  max-height: 600px;
  overflow-y: auto;
  padding: 0 16px 14px;
  border-top: 1px solid #e8e6e1;
}

.plan-summary-body h1,
.plan-summary-body h2,
.plan-summary-body h3 {
  font-family: var(--font-heading);
  color: var(--accent);
}

.plan-summary-body code {
  font-family: var(--font-mono);
  background: #eee;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 13px;
}

.plan-summary-body pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
}

.plan-summary-body pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ===== Input bar ===== */

#input-bar {
  position: fixed;
  bottom: 24px;
  left: calc(var(--sidebar-width) + 24px);
  right: 24px;
  max-width: var(--input-max-width);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--white);
  border: 1px solid #e0ddd6;
  border-radius: var(--radius-lg);
  padding: 8px 12px 8px 18px;
  box-shadow: var(--shadow-input);
  transition: border-color 0.15s, box-shadow 0.15s;
  z-index: 100;
}

#input-bar:focus-within {
  border-color: var(--olive);
  box-shadow: var(--shadow-input), 0 0 0 3px rgba(45, 74, 43, 0.08);
}

#message-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  resize: none;
  max-height: 200px;
  line-height: 1.5;
  padding: 6px 0;
  outline: none;
}

#message-input::placeholder {
  color: var(--text-muted);
}

#send-btn,
#cancel-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

#send-btn {
  background: var(--accent);
  color: var(--text-on-accent);
}

#send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#send-btn:disabled {
  background: #ddd;
  color: #aaa;
  cursor: not-allowed;
}

#cancel-btn {
  background: var(--accent-red);
  color: var(--text-on-accent);
}

#cancel-btn:hover {
  background: #a93226;
}

.hidden {
  display: none !important;
}

/* ===== Mobile sidebar toggle ===== */

.mobile-only {
  display: none;
}

/* ===== Scrollbar ===== */

#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-track {
  background: transparent;
}

#messages::-webkit-scrollbar-thumb {
  background: #d5d2cc;
  border-radius: 3px;
}

#messages::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

.conversation-list::-webkit-scrollbar {
  width: 4px;
}

.conversation-list::-webkit-scrollbar-thumb {
  background: #e0ddd6;
  border-radius: 2px;
}

/* ===== Pulse / spin animations ===== */

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

/* ===== Files toggle button ===== */

.files-toggle-btn {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid #e0ddd6;
  transition: all 0.15s;
}

.files-toggle-btn:hover {
  background: var(--bg-card);
  border-color: var(--olive);
  color: var(--accent);
}

.files-toggle-btn.active {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

/* ===== File panel ===== */

.file-panel {
  width: 380px;
  background: var(--bg-sidebar);
  border-left: 1px solid #e8e6e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.file-panel.collapsed {
  width: 0;
  border-left: none;
  overflow: hidden;
}

.fp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e8e6e1;
  flex-shrink: 0;
}

.fp-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.fp-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

.fp-header-right {
  display: flex;
  gap: 4px;
}

.fp-header-right button,
.fp-back-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 16px;
  transition: background 0.12s, color 0.12s;
}

.fp-header-right button:hover,
.fp-back-btn:hover {
  background: var(--bg-card);
  color: var(--accent);
}

.fp-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.fp-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* File list items */

.fp-list {
  display: flex;
  flex-direction: column;
}

.fp-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #f0ede8;
  cursor: pointer;
  transition: background 0.12s;
}

.fp-file-item:last-child {
  border-bottom: none;
}

.fp-file-item:hover {
  background: var(--bg-card);
}

.fp-file-icon {
  font-size: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.fp-file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.fp-file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fp-file-size {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.fp-file-download {
  color: var(--text-muted);
  font-size: 16px;
  text-decoration: none;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}

.fp-file-download:hover {
  background: var(--bg-card);
  color: var(--accent);
}

/* File preview */

.fp-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid #f0ede8;
  font-size: 12px;
  color: var(--text-muted);
}

.fp-meta-download {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.fp-meta-download:hover {
  text-decoration: underline;
}

.fp-preview-content {
  padding: 16px;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
}

.fp-preview-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.fp-preview-content pre code {
  font-family: var(--font-mono);
}

.fp-loading,
.fp-error,
.fp-binary-notice {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.fp-error {
  color: var(--accent-red);
}

.fp-body::-webkit-scrollbar {
  width: 4px;
}

.fp-body::-webkit-scrollbar-thumb {
  background: #e0ddd6;
  border-radius: 2px;
}

/* ===== File panel drag-over highlight ===== */

.fp-body.fp-dragover {
  background: rgba(45, 74, 43, 0.06);
  outline: 2px dashed var(--olive);
  outline-offset: -4px;
}

/* ===== Mobile backdrop ===== */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 199;
}

.sidebar-backdrop.visible {
  display: block;
}

/* ===== Responsive: Mobile ===== */

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-only {
    display: inline-flex;
  }

  #input-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    border-radius: var(--radius-md);
    padding: 6px 10px 6px 14px;
  }

  #messages {
    padding: 16px 16px 120px;
  }

  .user-bubble {
    max-width: 92%;
  }

  .file-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }

  .file-panel:not(.collapsed) {
    transform: translateX(0);
  }

  .file-panel.collapsed {
    width: 100% !important;
    border-left: none;
  }

}

/* ===== Floating Todo Panel ===== */
.todo-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 300px;
  max-height: 400px;
  background: var(--white);
  border: 1px solid #e0ddd6;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: todoFadeIn 0.2s ease;
}

.todo-panel.hidden {
  display: none;
}

.todo-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 8px;
}

.todo-panel-label {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--forest-green);
  flex: 1;
}

.todo-panel-progress {
  font-size: 12px;
  color: var(--sage);
}

.todo-panel-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.todo-panel-header button:hover {
  color: var(--text-primary);
}

.todo-panel-bar {
  height: 3px;
  background: #e8e6e1;
  margin: 0 14px 4px;
  border-radius: 2px;
  overflow: hidden;
}

.todo-panel-bar-fill {
  height: 100%;
  background: var(--forest-green);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.todo-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px 12px;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #e8e6e1;
}

.todo-item:last-child {
  border-bottom: none;
}

.todo-status {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}

.todo-status.pending {
  border-color: var(--text-muted);
}

.todo-status.in_progress {
  border-color: var(--olive);
  animation: todoPulse 1.5s infinite;
}

.todo-status.in_progress::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--olive);
}

.todo-status.completed {
  border-color: var(--forest-green);
  background: var(--forest-green);
  color: var(--white);
}

.todo-status.completed::after {
  content: '\2713';
}

.todo-content {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
}

.todo-item.completed .todo-content {
  color: var(--text-muted);
  text-decoration: line-through;
}

.todo-active-form {
  font-size: 11px;
  color: var(--olive);
  margin-top: 2px;
}

@keyframes todoPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

@media (max-width: 768px) {
  .todo-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 80px;
  }
}
