/* ============ base ============ */

:root {
  --bg: #0f1117;
  --bg-raised: #171a21;
  --bg-card: #1e222b;
  --bg-hover: #242935;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button { font-family: inherit; }

/* ============ top bar ============ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand strong { color: var(--text); }
.brand .bolt { margin-right: 6px; }

.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  cursor: text;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
}

.topbar h1:hover { border-color: var(--border); background: var(--bg-card); }

.topbar input.rename {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  outline: none;
}

.spacer { flex: 1; }

.pill {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.pill.live { color: var(--green); border-color: rgba(52, 211, 153, 0.35); }
.pill.warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.35); }

/* ============ buttons ============ */

.btn {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--bg-hover); border-color: #3a4150; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(248, 113, 113, 0.3); background: transparent; }
.btn.danger:hover { background: rgba(248, 113, 113, 0.1); }
.btn.wide { width: 100%; }

.btn.live {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.4);
}

body.time-traveling .btn.live {
  background: var(--green);
  color: #06281c;
  border-color: var(--green);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
}

/* ============ layout ============ */

#layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ============ board ============ */

.board {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  transition: filter 0.3s;
}

body.time-traveling .board {
  filter: sepia(0.25) saturate(0.75);
}

body.time-traveling .board .card { cursor: default; }

.column {
  width: 280px;
  min-width: 280px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 8px;
}

.column-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: default;
}

.column-title:hover { color: var(--text); }

.column-header input.rename {
  font-size: 13px;
  font-weight: 600;
  width: 100%;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 3px 8px;
  outline: none;
}

.column-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-card);
  border-radius: 999px;
  padding: 2px 8px;
}

.cards {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.cards:empty::after {
  content: "no cards";
  font-size: 12px;
  color: var(--muted);
  opacity: 0.5;
  text-align: center;
  padding: 14px 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}

.card:hover { border-color: #3a4150; }
.card.dragging { opacity: 0.45; transform: rotate(2deg); }

.card-title { font-size: 14px; font-weight: 500; line-height: 1.35; }

.card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* card accent colors */
.card.c-blue   { border-left-color: #60a5fa; }
.card.c-purple { border-left-color: #a78bfa; }
.card.c-teal   { border-left-color: #2dd4bf; }
.card.c-green  { border-left-color: #34d399; }
.card.c-amber  { border-left-color: #fbbf24; }
.card.c-pink   { border-left-color: #f472b6; }
.card.c-red    { border-left-color: #f87171; }

.column-footer { padding: 6px 10px 10px; }

.add-card-btn {
  width: 100%;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.add-card-btn:hover { background: var(--bg-card); color: var(--text); }

.composer textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 11px;
  resize: none;
  outline: none;
}

.composer-actions { display: flex; gap: 8px; margin-top: 6px; }

.add-column {
  min-width: 280px;
  width: 280px;
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  flex-shrink: 0;
}

.add-column:hover { color: var(--text); background: var(--bg-raised); }

.add-column input {
  width: 100%;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 10px;
  outline: none;
}

/* ============ under-the-hood panel ============ */

.panel {
  width: 340px;
  min-width: 340px;
  background: var(--bg-raised);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.panel.hidden { display: none; }

.panel-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-section.grow { flex: 1; }

.panel-section h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 8px 0; }
.hint-inline { font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.hint code, .snapshot-info code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-card);
  padding: 1px 5px;
  border-radius: 4px;
}

.stack { list-style: none; }

.stack li {
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  margin: 4px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  position: relative;
}

.stack li::after {
  content: "▼";
  position: absolute;
  left: 50%;
  bottom: -11px;
  font-size: 8px;
  color: var(--muted);
  z-index: 1;
}

.stack li:last-child::after { content: ""; }

.streams { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.streams .stream-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.streams .stream-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.streams .stream-version { color: var(--accent); font-weight: 600; flex-shrink: 0; }

.snapshot-info { font-size: 12px; color: var(--muted); line-height: 1.6; margin-bottom: 12px; }
.snapshot-info strong { color: var(--text); }

.activity { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.activity li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12.5px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.45;
}

.activity li:hover { background: var(--bg-card); }
.activity li.current { background: var(--accent-soft); }

.activity .v {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 30px;
}

.activity .when { font-size: 11px; color: var(--muted); margin-left: auto; flex-shrink: 0; }

/* ============ time bar ============ */

.timebar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.timebar input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.time-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  min-width: 110px;
  text-align: right;
  white-space: nowrap;
}

/* ============ banner, toasts, modal ============ */

.banner {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #2a2410;
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--amber);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-width: 80vw;
}

.banner.hidden { display: none; }

.banner button {
  font-size: 12px;
  font-weight: 600;
  color: #06281c;
  background: var(--green);
  border: none;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.toasts {
  position: fixed;
  bottom: 76px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
  max-width: 420px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow);
  animation: slide-in 0.25s ease-out;
}

.toast.error { border-color: rgba(248, 113, 113, 0.5); }
.toast.conflict { border-color: rgba(251, 191, 36, 0.5); }
.toast.snapshot { border-color: rgba(52, 211, 153, 0.5); }

.toast .toast-title { font-weight: 600; margin-bottom: 3px; }
.toast .toast-detail { color: var(--muted); font-size: 12px; }
.toast .toast-detail code { font-family: var(--mono); font-size: 11px; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal {
  margin: auto;
  width: 440px;
  max-width: 92vw;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal::backdrop { background: rgba(5, 7, 12, 0.6); backdrop-filter: blur(2px); }

.modal h3 { font-size: 15px; margin-bottom: 14px; }

.modal input, .modal textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  outline: none;
  resize: vertical;
}

.modal input:focus, .modal textarea:focus { border-color: var(--accent); }

.swatches { display: flex; gap: 8px; margin-bottom: 16px; }

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--sw, var(--bg-card));
}

.swatch.selected { border-color: var(--text); }

.modal-actions { display: flex; align-items: center; gap: 8px; }
