:root {
  --bg-0: #f4f9f7;
  --bg-1: #e5f1ec;
  --bg-2: #ecf4fb;
  --panel: #fdfdfb;
  --sidebar-bg: #f8faf9;
  --ink: #102124;
  --ink-soft: #4f6368;
  --ink-muted: #7a8b8f;
  --line: #c9d8d5;
  --accent: #0b7285;
  --accent-light: #e3f4f6;
  --user-a: #e1f4ff;
  --user-b: #f3fbff;
  --assistant-a: #eef8e6;
  --assistant-b: #f8fff2;
  --shadow: 0 8px 24px rgba(13, 38, 33, 0.08);
  --shadow-sm: 0 2px 8px rgba(13, 38, 33, 0.06);
  
  --tool-bg: #f5f5f5;
  --tool-border: #e0e0e0;
  --success: #4caf50;
  --error: #f44336;
  --warning: #ff9800;
}

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

body {
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 45%, var(--bg-2) 100%);
  min-height: 100vh;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.back-link:hover {
  text-decoration: underline;
}

.header-stats {
  display: flex;
  gap: 12px;
  font-size: 13px;
}

.stat {
  background: var(--bg-0);
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
}

/* Main Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 80px 20px 40px;
}

/* Session List Page */
.session-list {
  display: grid;
  gap: 16px;
}

.session-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.session-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.session-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}

.session-card-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.session-card-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
}

.stat-tag {
  background: var(--bg-0);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

/* Session Detail Page */
.session-header-detail {
  margin-bottom: 24px;
}

.session-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.3;
}

.session-meta {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

.session-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-stats-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message Cards */
.msg {
  width: fit-content;
  max-width: min(85%, 85ch);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.msg.user {
  margin-left: auto;
  background: linear-gradient(170deg, var(--user-a) 0%, var(--user-b) 100%);
}

.msg.assistant {
  margin-right: auto;
  background: linear-gradient(170deg, var(--assistant-a) 0%, var(--assistant-b) 100%);
}

.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  border: 1px solid #bdd0cb;
  background: rgba(255, 255, 255, 0.84);
  font-size: 12px;
}

.badge.role {
  font-weight: 600;
}

.badge.role.user {
  background: var(--user-a);
  border-color: #9fc8db;
  color: #1a5276;
}

.badge.role.assistant {
  background: var(--assistant-a);
  border-color: #9fbdb7;
  color: #26454d;
}

.badge.agent {
  background: #fff3e0;
  border-color: #ffb74d;
  color: #e65100;
}

.badge.model {
  background: #f3e5f5;
  border-color: #ce93d8;
  color: #7b1fa2;
}

/* Provider and Agent Icons */
.provider-icon,
.agent-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  margin-right: 4px;
  display: inline-block;
}

.time {
  font-size: 12px;
  color: var(--ink-soft);
  margin-left: auto;
}

.msg-content {
  font-size: 14px;
  line-height: 1.7;
}

.msg-content pre {
  font-family: "Berkeley Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0, 0, 0, 0.04);
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
  overflow-x: auto;
}

.msg-content p {
  margin: 8px 0;
}

.msg-content p:first-child {
  margin-top: 0;
}

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

.msg-content code {
  font-family: "Berkeley Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.msg-content pre code {
  padding: 0;
  background: none;
}

.msg-stats {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* Tool Section */
.tools-section {
  margin-top: 12px;
  padding: 12px;
  background: var(--tool-bg);
  border-radius: 8px;
  border: 1px solid var(--tool-border);
}

.tools-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.tool-item {
  margin-bottom: 8px;
}

.tool-item:last-child {
  margin-bottom: 0;
}

.tool-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--tool-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: all 0.2s;
}

.tool-header:hover {
  background: var(--bg-0);
}

.tool-icon {
  font-size: 14px;
}

.tool-name {
  flex: 1;
  font-weight: 500;
}

.tool-status {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.tool-status.completed {
  background: #e8f5e9;
  color: var(--success);
}

.tool-status.error {
  background: #ffebee;
  color: var(--error);
}

.tool-status.running {
  background: #fff3e0;
  color: var(--warning);
}

.tool-toggle {
  font-size: 10px;
  color: var(--ink-muted);
  transition: transform 0.2s;
}

.tool-item.expanded .tool-toggle {
  transform: rotate(180deg);
}

.tool-content {
  display: none;
  margin-top: 8px;
  padding: 14px;
  background: white;
  border: 1px solid var(--tool-border);
  border-radius: 8px;
}

.tool-item.expanded .tool-content {
  display: block;
}

.tool-section {
  margin-bottom: 14px;
}

.tool-section:last-child {
  margin-bottom: 0;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.tool-code {
  font-family: "Berkeley Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  background: #f8f9fa;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid #e9ecef;
}

/* Reasoning Section */
.reasoning-section {
  margin-top: 12px;
  padding: 12px 14px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 8px;
}

.reasoning-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.reasoning-title {
  font-size: 12px;
  font-weight: 600;
  color: #f57c00;
  display: flex;
  align-items: center;
  gap: 6px;
}

.reasoning-toggle {
  font-size: 11px;
  color: #f57c00;
}

.reasoning-content {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #ffe082;
}

.reasoning-section.expanded .reasoning-content {
  display: block;
}

.reasoning-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

/* Search */
.search-container {
  margin-bottom: 24px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  background: var(--panel);
  outline: none;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--accent);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 0 16px;
    height: 56px;
  }
  
  .header h1 {
    font-size: 16px;
  }
  
  .container {
    padding: 72px 16px 32px;
  }
  
  .msg {
    max-width: 95%;
  }
  
  .session-title {
    font-size: 20px;
  }
  
  .session-meta {
    font-size: 13px;
  }
}
