:root {
  --bg: #0f1115;
  --surface: #1a1d23;
  --surface-hover: #21252c;
  --text: #eaecef;
  --text-muted: #9aa0a8;
  --border: #2a2e35;
  --accent: #5b9dff;
  --accent-claude: #d97757;
  --accent-cursor: #7c6cf0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-hover: #f0f1f3;
    --text: #1a1d23;
    --text-muted: #6b7280;
    --border: #e2e4e8;
    --accent: #2563eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  }
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

header {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
}
header a { color: var(--text); text-decoration: none; }

main {
  padding: 1rem 1rem 3rem;
  max-width: 720px;
  margin: 0 auto;
}

@media (min-width: 800px) {
  main { max-width: 800px; padding: 1.5rem 1.5rem 3rem; }
}

.staleness {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

input, select, button {
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: default; }

.combobox { position: relative; flex: 1 1 200px; }
.combobox input { width: 100%; }
.combobox-listbox {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.combobox-listbox li {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  word-break: break-all;
}
.combobox-listbox li:hover,
.combobox-listbox li.active { background: var(--surface-hover); }

.session-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.session-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background 0.15s;
}
.session-list li:hover { background: var(--surface-hover); }
.session-list li:not(:has(a)) { padding: 0.9rem 1rem; }
.session-list a { color: inherit; text-decoration: none; display: block; padding: 0.9rem 1rem; }
.session-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.session-list strong { font-size: 1rem; min-width: 0; }
.session-list p { margin: 0.4rem 0; color: var(--text-muted); font-size: 0.85rem; }

.tool-badge {
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  background: var(--text-muted);
}
.tool-badge-claude-code { background: var(--accent-claude); }
.tool-badge-cursor { background: var(--accent-cursor); }

.project, time { display: block; font-size: 0.75rem; color: var(--text-muted); }
.session-dates { margin-top: 0.35rem; }
.session-dates .updated { color: var(--text); font-weight: 600; }
.session-dates .created { margin-top: 0.1rem; }
.error { color: #ef4444; }

.messages { display: flex; flex-direction: column; gap: 0.75rem; }
.message {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.message-user { border-left: 3px solid var(--accent); }
.message time { margin-bottom: 0.35rem; }

.history-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
