/* ═══════════════════════════════════════════
   Honcho Memory Browser — Styles
   Design: warm green, garden-vitality
   ═══════════════════════════════════════════ */

/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #F5F0E8;
  --cream-dark: #EDE7DB;
  --cream-card: #FAF7F0;
  --sage: #5B7B5B;
  --sage-light: #7CA07C;
  --sage-lighter: #B5CCB5;
  --sage-dark: #3D5A3D;
  --gold: #C49A6C;
  --gold-light: #D4A76A;
  --gold-pale: #E8D5B8;
  --text: #2C2C2C;
  --text-muted: #8A8A7A;
  --text-dim: #B0A898;
  --border: #E0D8C8;
  --border-light: #EDE8DB;
  --shadow: rgba(60, 50, 40, 0.06);
  --shadow-strong: rgba(60, 50, 40, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-w: 280px;
  --detail-w: 380px;
  --header-h: 64px;
  --transition: 0.2s ease;
  --font: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--sage); text-decoration: none; }
a:hover { color: var(--sage-dark); }

/* ── App Layout ── */
.app {
  display: flex;
  height: 100vh;
}

/* ── Loader ── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 240, 232, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.loader-overlay.visible { opacity: 1; pointer-events: auto; }

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--cream-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

.sidebar-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-header .brand {
  font-size: 18px;
  font-weight: 600;
  color: var(--sage-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .brand-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--sage), var(--sage-dark));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
}

.sidebar-header .subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
  padding-left: 40px;
}

.sidebar-search {
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream-card);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  font-family: var(--font);
}
.sidebar-search input:focus { border-color: var(--sage-light); }
.sidebar-search input::placeholder { color: var(--text-dim); }
.sidebar-search-wrap { position: relative; }
.sidebar-search-wrap .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 13px;
  pointer-events: none;
}

.peers-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 16px;
}
.peers-list::-webkit-scrollbar { width: 4px; }
.peers-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.peer-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 16px 12px 6px;
}

.peer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 1px;
  position: relative;
}
.peer-item:hover { background: rgba(91, 123, 91, 0.08); }
.peer-item.active {
  background: rgba(91, 123, 91, 0.14);
  box-shadow: inset 3px 0 0 var(--sage);
}
.peer-item.active .peer-name { color: var(--sage-dark); font-weight: 600; }

.peer-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  position: relative;
}
.peer-avatar.status-online::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--sage);
  border: 2px solid var(--cream-dark);
}

.peer-avatar.color-sage { background: linear-gradient(135deg, var(--sage), var(--sage-dark)); }
.peer-avatar.color-gold { background: linear-gradient(135deg, var(--gold), #B8895E); }
.peer-avatar.color-sage-light { background: linear-gradient(135deg, var(--sage-lighter), var(--sage-light)); }
.peer-avatar.color-forest { background: linear-gradient(135deg, #6B8F6B, #4A6B4A); }
.peer-avatar.color-terra { background: linear-gradient(135deg, #A8B8A0, var(--sage-light)); }

.peer-info { flex: 1; min-width: 0; }
.peer-name { font-size: 14px; font-weight: 500; color: var(--text); }
.peer-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.peer-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  flex-shrink: 0;
  line-height: 1.4;
}
.peer-badge.ai { background: rgba(91,123,91,0.15); color: var(--sage-dark); }
.peer-badge.user { background: rgba(196,154,108,0.15); color: var(--gold); }
.peer-badge.bot { background: rgba(160,160,140,0.15); color: var(--text-muted); }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-footer .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--sage);
  margin-right: 6px;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Main Content ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-header {
  height: var(--header-h);
  padding: 0 28px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--cream);
}

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

.main-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.main-header h2 .peer-indicator {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.main-header .stats-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--cream-card);
  padding: 3px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

.header-actions button {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--cream-card);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  white-space: nowrap;
}
.header-actions button:hover {
  border-color: var(--sage-light);
  color: var(--sage-dark);
}
.header-actions button.primary {
  background: var(--sage);
  border-color: var(--sage);
  color: white;
}
.header-actions button.primary:hover { background: var(--sage-dark); border-color: var(--sage-dark); }

/* ── Content Area ── */
.content-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Timeline Panel ── */
.timeline-panel {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--cream);
}
.timeline-panel::-webkit-scrollbar { width: 4px; }
.timeline-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.timeline-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  text-align: center;
  padding: 60px 40px;
}
.timeline-empty .icon { font-size: 56px; margin-bottom: 16px; opacity: 0.5; }
.timeline-empty h3 { font-size: 16px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.timeline-empty p { font-size: 13px; max-width: 260px; }

.timeline-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.filter-chip {
  padding: 4px 14px;
  border-radius: 14px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--cream-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.filter-chip:hover { border-color: var(--sage-lighter); }
.filter-chip.active { background: var(--sage); border-color: var(--sage); color: white; }

.timeline-list { position: relative; min-height: 100px; }

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 10px 0 10px 0;
  position: relative;
  cursor: pointer;
  transition: all var(--transition);
  border-radius: var(--radius-sm);
  margin: 0 -8px;
  padding: 10px 8px;
}
.timeline-item:hover { background: rgba(91, 123, 91, 0.04); }
.timeline-item.active { background: rgba(91, 123, 91, 0.08); }

.timeline-connector {
  position: absolute;
  left: 8px;
  top: 34px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child .timeline-connector { display: none; }

.timeline-dot {
  width: 17px; height: 17px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
  position: relative;
  z-index: 1;
  border: 3px solid var(--cream);
  transition: all var(--transition);
}
.timeline-dot.observation { background: var(--sage-light); }
.timeline-dot.conclusion { background: var(--gold); }
.timeline-dot.summary { background: var(--sage-dark); }
.timeline-item.active .timeline-dot { box-shadow: 0 0 0 4px rgba(91,123,91,0.15); }

.timeline-content {
  flex: 1;
  min-width: 0;
}

.tl-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}
.tl-time { font-size: 11px; color: var(--text-dim); }
.tl-tag {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 8px;
  font-weight: 500;
}
.tl-tag.observation { background: rgba(91,123,91,0.12); color: var(--sage); }
.tl-tag.conclusion { background: rgba(196,154,108,0.12); color: var(--gold); }
.tl-tag.summary { background: rgba(61,90,61,0.12); color: var(--sage-dark); }

.tl-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  transition: color var(--transition);
}
.tl-text .hl { background: rgba(196,154,108,0.2); padding: 0 3px; border-radius: 2px; }
.timeline-item:hover .tl-text { color: var(--sage-dark); }
.timeline-item.active .tl-text { font-weight: 500; color: var(--sage-dark); }

/* ── Detail Panel ── */
.detail-panel {
  width: var(--detail-w);
  min-width: var(--detail-w);
  background: var(--cream-card);
  border-left: 1px solid var(--border-light);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-align: center;
  padding: 60px 30px;
}
.detail-empty .icon { font-size: 42px; margin-bottom: 12px; opacity: 0.4; }
.detail-empty h3 { font-size: 15px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.detail-empty p { font-size: 12px; }

.detail-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.detail-header h3 { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.4; }
.detail-header .detail-time { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.detail-body { padding: 20px 24px; flex: 1; }

.detail-section { margin-bottom: 24px; }
.detail-section:last-child { margin-bottom: 0; }

.detail-section h4 {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.detail-section p, .detail-section .text-content {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

.detail-card {
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
}
.detail-card:last-child { margin-bottom: 0; }

.dc-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.dc-value { font-size: 13px; color: var(--text); line-height: 1.6; word-break: break-all; }
.dc-value code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--sage-dark);
  background: rgba(91,123,91,0.08);
  padding: 1px 6px;
  border-radius: 3px;
}
.dc-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.relation-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  background: rgba(91,123,91,0.1);
  color: var(--sage);
  margin: 2px 4px 2px 0;
  cursor: pointer;
  transition: background var(--transition);
}
.relation-tag:hover { background: rgba(91,123,91,0.2); }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .detail-panel { display: none; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
}
