* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1115;
  color: #e6e7eb;
}
main { max-width: 1100px; margin: 0 auto; padding: 24px; }
h1 { margin: 0 0 16px; font-size: 20px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }

#login-view { max-width: 360px; margin: 80px auto; }
#login-view form { display: grid; gap: 12px; }
.brandline { text-align: center; margin: 0 0 24px; font-size: 14px; color: #9aa0aa; }
.brandline a { color: #9aa0aa; text-decoration: none; font-weight: 600; }
.brandline a:hover { color: #e6e7eb; }
.brandlink { color: inherit; text-decoration: none; }
.brandlink:hover { color: #60a5fa; }
label { display: grid; gap: 6px; font-size: 13px; color: #9aa0aa; }
input, select, button {
  font: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #2a2f3a;
  background: #161a22;
  color: #e6e7eb;
}
button {
  cursor: pointer;
  background: #2b6cb0;
  border-color: #2b6cb0;
  color: white;
}
button:hover { background: #2c5d96; }

header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.controls { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }

canvas { background: #161a22; border: 1px solid #2a2f3a; border-radius: 8px; padding: 12px; }

.panel { margin-top: 24px; background: #161a22; border: 1px solid #2a2f3a; border-radius: 8px; padding: 16px; }
.muted { color: #9aa0aa; font-weight: normal; font-size: 13px; }
.small { font-size: 12px; }
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #1f2630;
  border: 1px solid #2a2f3a;
  color: #c5cad3;
  font-size: 12px;
  margin-right: 6px;
}

.sessions-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.session-card {
  display: block;
  background: #1a1f29;
  border: 1px solid #2a2f3a;
  border-radius: 8px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 120ms ease, background 120ms ease;
}
.session-card:hover { border-color: #60a5fa; background: #1d2330; }
.session-title { font-weight: 600; margin-bottom: 6px; word-break: break-word; }
.session-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }

.keystrokes-list {
  max-height: 560px;
  overflow-y: auto;
  background: #0f1320;
  border: 1px solid #1d2230;
  border-radius: 6px;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
}
.ks-group {
  border: 1px solid #1d2230;
  border-radius: 6px;
  margin-bottom: 6px;
  background: #11151c;
}
.ks-group[open] { background: #131822; }
.ks-group > summary {
  cursor: pointer;
  padding: 6px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  list-style: none;
}
.ks-group > summary::-webkit-details-marker { display: none; }
.ks-group > summary::before {
  content: "▸";
  color: #9aa0aa;
  margin-right: 6px;
  transition: transform 120ms ease;
  display: inline-block;
}
.ks-group[open] > summary::before { transform: rotate(90deg); }
.ks-group-rows { padding: 4px 10px 8px 28px; }
.keystroke-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid #1a1f29;
}
.keystroke-row:last-child { border-bottom: none; }
.ks-time { color: #9aa0aa; }
.ks-file { color: #c5cad3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ks-text { white-space: pre-wrap; word-break: break-word; color: #e6e7eb; }
#keystrokes-more { margin-top: 8px; }

.git-summary { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.git-row-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.git-list {
  max-height: 560px;
  overflow-y: auto;
  background: #0f1320;
  border: 1px solid #1d2230;
  border-radius: 6px;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
}
.git-group {
  border: 1px solid #1d2230;
  border-radius: 6px;
  margin-bottom: 6px;
  background: #11151c;
}
.git-group[open] { background: #131822; }
.git-group > summary {
  cursor: pointer;
  padding: 6px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  list-style: none;
}
.git-group > summary::-webkit-details-marker { display: none; }
.git-group > summary::before {
  content: "▸";
  color: #9aa0aa;
  margin-right: 6px;
  transition: transform 120ms ease;
  display: inline-block;
}
.git-group[open] > summary::before { transform: rotate(90deg); }
.git-group-rows { padding: 4px 10px 8px 28px; }
.git-repo { color: #22d3ee; font-weight: 600; }
.git-row {
  display: grid;
  grid-template-columns: 56px 84px 1fr;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid #1a1f29;
  align-items: baseline;
}
.git-row:last-child { border-bottom: none; }
.git-time { color: #9aa0aa; }
.git-action {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #1f2630;
  border: 1px solid #2a2f3a;
  color: #c5cad3;
  font-size: 11px;
  text-transform: lowercase;
  text-align: center;
}
.git-action-commit       { color: #22d3ee; border-color: #155e75; }
.git-action-checkout     { color: #34d399; border-color: #14532d; }
.git-action-merge        { color: #a78bfa; border-color: #4c1d95; }
.git-action-rebase       { color: #fbbf24; border-color: #78350f; }
.git-action-reset        { color: #f87171; border-color: #7f1d1d; }
.git-action-pull         { color: #60a5fa; border-color: #1e3a8a; }
.git-action-fetch        { color: #93c5fd; border-color: #1e3a8a; }
.git-action-push         { color: #f472b6; border-color: #831843; }
.git-action-cherry-pick  { color: #fde047; border-color: #713f12; }
.git-action-stash        { color: #c084fc; border-color: #581c87; }
.git-action-other        { color: #9aa0aa; border-color: #2a2f3a; }
.git-subject {
  white-space: pre-wrap;
  word-break: break-word;
  color: #e6e7eb;
}
.git-meta-inline { grid-column: 2 / -1; }

#users-panel { margin-top: 32px; background: #161a22; border: 1px solid #2a2f3a; border-radius: 8px; padding: 16px; }
#users-panel summary { cursor: pointer; font-weight: 600; }
#create-user-form { display: flex; gap: 8px; margin: 12px 0; }
#new-token-display { background: #1e2a1e; border: 1px solid #2f4a2f; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
#new-token-value { word-break: break-all; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #2a2f3a; }
th { color: #9aa0aa; font-weight: 500; }
.error { color: #f87171; font-size: 13px; }
button.danger { background: #8a2c2c; border-color: #8a2c2c; }
button.danger:hover { background: #6f2323; }

/* Session detail view */
.session-meta { margin-bottom: 16px; }
.session-meta h2 { font-size: 18px; margin-bottom: 4px; }
.session-transcript { display: flex; flex-direction: column; gap: 12px; }

.bubble {
  background: #161a22;
  border: 1px solid #2a2f3a;
  border-left: 3px solid #2a2f3a;
  border-radius: 8px;
  padding: 10px 14px;
}
.bubble-user { border-left-color: #34d399; }
.bubble-assistant { border-left-color: #60a5fa; }
.bubble header { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; margin-right: 0; }
.bubble .role {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #c5cad3;
  font-weight: 600;
}
.bubble-body { font-size: 14px; line-height: 1.5; }
.bubble-body .md p { margin: 0 0 8px; }
.bubble-body .md p:last-child { margin-bottom: 0; }
.bubble-body .md pre {
  background: #0f1320;
  border: 1px solid #1d2230;
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
  font-size: 12px;
}
.bubble-body .md code {
  background: #1d2230;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}
.bubble-body .md pre code { background: transparent; padding: 0; }
.bubble-body .md a { color: #60a5fa; }
.bubble-body .md ul, .bubble-body .md ol { padding-left: 22px; margin: 4px 0 8px; }
.bubble-body .md table { font-size: 12px; }

.tool-block {
  margin: 6px 0;
  background: #11151c;
  border: 1px solid #1f2630;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}
.tool-block summary { cursor: pointer; color: #c5cad3; font-weight: 500; }
.tool-block.tool-use summary { color: #a78bfa; }
.tool-block.tool-result summary { color: #34d399; }
.tool-block.thinking summary { color: #9aa0aa; font-style: italic; }
.tool-block .raw-json {
  background: transparent;
  border: none;
  padding: 6px 0 0;
  margin: 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c5cad3;
}

.summary-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 4px 8px;
  border-left: 2px solid #2a2f3a;
  color: #9aa0aa;
  font-size: 12px;
}
.summary-row .rt { color: #c5cad3; font-weight: 600; }

.raw-json {
  background: #0f1320;
  border: 1px solid #1d2230;
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
