:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #000);
  --hint: var(--tg-theme-hint-color, #888);
  --link: var(--tg-theme-link-color, #2a7);
  --btn: var(--tg-theme-button-color, #2a7);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --sec-bg: var(--tg-theme-secondary-bg-color, #f3f3f3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
}

#tabs {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--sec-bg);
  z-index: 10;
}

#tabs button {
  flex: 1;
  padding: 12px 4px;
  border: none;
  background: none;
  color: var(--hint);
  font-size: 14px;
  cursor: pointer;
}

#tabs button.active {
  color: var(--text);
  border-bottom: 2px solid var(--btn);
}

#view { padding: 12px; }

/* Tab swipe transition (see app.js shiftTab) */
@keyframes slide-in-right {
  from { transform: translateX(28px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes slide-in-left {
  from { transform: translateX(-28px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
#view.slide-next { animation: slide-in-right 0.18s ease; }
#view.slide-prev { animation: slide-in-left 0.18s ease; }

.card {
  background: var(--sec-bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.muted { color: var(--hint); font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

button.action {
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

button.action.secondary {
  background: transparent;
  color: var(--link);
  border: 1px solid var(--link);
}

pre.logs, pre.diff {
  background: #11151c;
  color: #d6deeb;
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  max-height: 60vh;
}

/* --- Git tab ------------------------------------------------------------- */

.git-head .branchline { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.git-head .branch { font-weight: 600; font-size: 14px; }
.git-head .refresh { padding: 4px 10px; font-size: 15px; line-height: 1; }
.git-head .headline { margin-top: 8px; word-break: break-word; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge.ahead { color: #3fb950; background: rgba(63, 185, 80, 0.15); }
.badge.behind { color: #f0883e; background: rgba(240, 136, 62, 0.15); }

.summary { margin: 4px 2px 10px; font-size: 13px; }

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  flex: none;
  background: rgba(127, 127, 127, 0.15);
}
.chip-add { color: #3fb950; }
.chip-mod { color: #d29922; }
.chip-del { color: #f85149; }
.chip-staged { color: #58a6ff; }
.chip-ren { color: #a371f7; }
.chip-untracked { color: var(--hint); }

.file-row { cursor: pointer; }
.fpath { margin-top: 6px; word-break: break-all; }
.fpath .fname { font-weight: 600; }

.add { color: #3fb950; }
.del { color: #f85149; }

.stat { display: flex; align-items: center; gap: 6px; flex: none; }
.stat-nums { font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: nowrap; }
.bar {
  display: inline-flex;
  width: 38px;
  height: 8px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.25);
}
.bar-add { background: #3fb950; }
.bar-del { background: #f85149; }

.clean { padding: 8px 2px; color: #3fb950; }

.section-title {
  margin: 16px 2px 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hint);
}
.commit .chash { color: var(--link); }
.commit .csubj { margin: 4px 0 2px; word-break: break-word; }
.commit .cauthor { font-size: 12px; }

/* diff syntax coloring (on the dark pre background) */
.d-line { display: block; }
.d-add { color: #3fb950; }
.d-del { color: #ff7b72; }
.d-hunk { color: #58a6ff; }
.d-meta { color: #8b949e; }

select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hint);
  border-radius: 6px;
  padding: 4px 6px;
  max-width: 60%;
}

.err { color: #e55; padding: 8px 0; }
.active-badge { color: var(--btn); font-weight: 600; }

/* --- Sessions: context usage ------------------------------------------- */

.ctx { margin: 10px 0 6px; }
.ctx-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.ctxbar {
  height: 6px;
  border-radius: 3px;
  background: rgba(127, 127, 127, 0.25);
  overflow: hidden;
}
.ctxbar > i {
  display: block;
  height: 100%;
  background: var(--btn);
  transition: width 0.3s ease;
}
.ctxbar > i.hot { background: #f0883e; }

/* --- Sessions: title editing + delete ---------------------------------- */

.title-area {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.title-area strong { word-break: break-word; }

.icon-btn {
  border: none;
  background: none;
  color: var(--hint);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  flex: none;
}
.icon-btn.ok { color: var(--btn); }

.rename-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hint);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 14px;
}

button.action.danger {
  background: transparent;
  color: #f85149;
  border: 1px solid #f85149;
}

.resolved { margin-top: 6px; word-break: break-all; }
.resolved-inline { color: var(--tg-theme-hint-color, #888); font-size: 0.82em; white-space: nowrap; flex-shrink: 0; }

/* --- CI tab ------------------------------------------------------------- */

.ci-run { cursor: pointer; }
.ci-title { margin: 6px 0 4px; word-break: break-word; }
.ci-meta { font-size: 12px; }

.ci-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.15);
  white-space: nowrap;
}
.ci-success { color: #3fb950; }
.ci-failure { color: #f85149; }
.ci-cancelled { color: #f0883e; }
.ci-skipped { color: var(--hint); }
.ci-queued { color: var(--hint); }
/* running: amber + a gentle pulse, matching the slide keyframes' house style */
.ci-running { color: #d29922; animation: ci-pulse 1.2s ease-in-out infinite; }
@keyframes ci-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.ci-detail-meta { margin: 4px 2px 12px; word-break: break-all; }

.ci-steps { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.ci-step { justify-content: flex-start; gap: 8px; }
.ci-step-name { font-size: 13px; word-break: break-word; }
.ci-dot { flex: none; width: 1.2em; text-align: center; font-weight: 700; }
