/* Kepler Dynamix brand (brand-kit/README.txt): Navy #0a1524, Gold #e3a83f, Light #e9eef6,
   Muted #9fb0c6; Inter for text, Fraunces for headlines. */
:root {
  --bg: #0a1524;
  --panel: #111f33;
  --field: #0d1a2c;
  --accent: #e3a83f;
  --accent-ink: #0a1524;
  --text: #e9eef6;
  --muted: #9fb0c6;
  --border: #22344f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.topbar h1 { margin: 0; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; display: flex; align-items: center; gap: 0.6rem; }
.topbar h1 img { width: 32px; height: 32px; }
.auth-card h2 { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.6rem; }
.auth-card { border-radius: 16px; padding: 1.6rem 1.8rem; }
.stack input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

nav { display: flex; gap: 0.5rem; }

.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
}

.tab-btn.active { background: var(--accent); color: #0f172a; border-color: var(--accent); }

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #f87171;
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 700;
}

main { padding: 1.5rem; max-width: 900px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.show-misc { font-size: 0.85rem; color: var(--muted); display: flex; gap: 0.35rem; align-items: center; }

.test-panel { margin-bottom: 1.25rem; }
.test-panel h3 { margin: 0 0 0.6rem 0; font-size: 1rem; }
.test-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; flex-wrap: wrap; }

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

.bucket-controls { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.merge-control { display: flex; gap: 0.4rem; align-items: center; }
select { background: var(--field); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.3rem 0.5rem; }
textarea { background: var(--field); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.7rem; font-family: inherit; font-size: 0.9rem; }

/* Auth pages */
.auth-main { display: flex; justify-content: center; padding: 3rem 1rem; }
.auth-card { width: min(420px, 100%); }
.auth-card h2 { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 0.8rem; }
.stack label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
.stack label.remember { flex-direction: row; align-items: center; gap: 0.5rem; cursor: pointer; }
.stack label.remember input { width: auto; margin: 0; }
.stack input {
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
}
.inline-status { margin-top: 0.75rem; font-size: 0.9rem; min-height: 1.2rem; }
.inline-status.error { color: #f87171; }
.small-copy { font-size: 0.85rem; color: var(--muted); }
.small-copy a { color: var(--accent); }
.auth-bar { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; color: var(--muted); }

button {
  font-family: inherit;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.card-list { display: flex; flex-direction: column; gap: 0.75rem; }

.tagup-entry { padding-top: 0.6rem; margin-top: 0.6rem; border-top: 1px solid var(--border); }
.tagup-entry:first-of-type { padding-top: 0; margin-top: 0.4rem; border-top: none; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
}

.card h3 { margin: 0 0 0.35rem 0; }
.card .muted { color: var(--muted); font-size: 0.85rem; }
.card .goals { margin-top: 0.5rem; font-size: 0.9rem; }

.status-select { margin-top: 0.5rem; }

#chat-log {
  height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--panel);
}

.chat-msg { margin-bottom: 0.6rem; }
.chat-msg.user { color: var(--accent); }
.chat-msg .role { font-weight: 700; margin-right: 0.4rem; }

#chat-form { display: flex; gap: 0.5rem; }
#chat-input {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
}

/* Bucket wait badge + detail modal */
.wait-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-top: 0.4rem;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}
.wait-badge.overdue { background: rgba(248, 113, 113, 0.15); color: #f87171; border-color: rgba(248, 113, 113, 0.4); }

.narrative-blurb { margin-top: 0.5rem; font-size: 0.9rem; line-height: 1.4; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  z-index: 50;
}

.modal-overlay[hidden] { display: none; }

.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  width: min(680px, 100%);
}

.modal-close { float: right; }

.timeline { list-style: none; margin: 0.5rem 0 0; padding: 0; border-left: 2px solid var(--border); }
.timeline li {
  padding: 0.5rem 0 0.5rem 1rem;
  margin-left: 0.1rem;
  font-size: 0.88rem;
  position: relative;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.7rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline .layer-raw::before { background: var(--muted); }
.timeline .layer-ai::before { background: var(--accent); }
.timeline .layer-user::before { background: #34d399; }
.timeline-meta { color: var(--muted); font-size: 0.78rem; }

/* Status badges + task list (bucket detail) */
.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-badge.active { color: var(--accent); border-color: rgba(56, 189, 248, 0.4); }
.status-badge.done { color: #34d399; border-color: rgba(52, 211, 153, 0.4); }
.status-badge.cancelled { color: var(--muted); }

.task-item { border: 1px solid var(--border); border-radius: 6px; padding: 0.65rem 0.8rem; margin-bottom: 0.5rem; }
.task-item .task-title { font-weight: 600; }
.task-item .task-next-action { font-size: 0.85rem; color: var(--muted); margin-top: 0.2rem; }

.data-question-candidates { font-size: 0.82rem; color: var(--muted); margin-top: 0.3rem; }

/* Bucket grid (dense grid + group-by / sort-by toolbar) */
.bucket-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.bucket-filters { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.bucket-controls-row { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; }
.chip-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}
.chip.active { border-color: var(--accent); color: var(--accent); background: rgba(56, 189, 248, 0.12); }
.search { min-width: 180px; }
.field-group { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.control-select { font-size: 0.82rem; }

.bucket-summary { display: flex; gap: 1.4rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 0.1rem; }
.stat .num { font-weight: 800; font-size: 1.3rem; }
.stat .lbl { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat.attn .num { color: #f87171; }

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 0.75rem;
}
.bucket-card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.bucket-card:hover { border-color: var(--accent); }
.bucket-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.bucket-card-top-left { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.bucket-card-title { font-weight: 700; font-size: 0.92rem; line-height: 1.3; cursor: pointer; }
.bucket-card-title:hover { color: var(--accent); }
.bucket-card-snip {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bucket-card-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.bucket-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-top: auto; }

.domain-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
}
.tag-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.meta-chip {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.16rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}
.meta-chip.priority { background: rgba(56, 189, 248, 0.15); color: var(--accent); }
.meta-chip.due-neutral { background: var(--field); color: var(--muted); }
.meta-chip.due-soon { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.meta-chip.due-overdue { background: rgba(248, 113, 113, 0.15); color: #f87171; }

.bucket-group-section { margin-bottom: 1.6rem; }
.bucket-group-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.bucket-group-head h3 { font-size: 0.95rem; font-weight: 800; margin: 0; }
.bucket-group-head .count { font-size: 0.76rem; color: var(--muted); }

.task-meta-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.35rem; }
.task-fields-form { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.4rem; }
.task-fields-form input { max-width: 140px; }

.new-bucket-btn {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  font-weight: 700;
}

.manage-categories { display: flex; gap: 2rem; flex-wrap: wrap; margin-top: 0.5rem; }
.manage-category-col { min-width: 180px; }
.manage-category-col h4 { margin: 0 0 0.4rem; font-size: 0.85rem; }
.chip-row-list { list-style: none; margin: 0 0 0.5rem; padding: 0; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.chip-row-list li {
  font-size: 0.76rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--field);
  border: 1px solid var(--border);
  color: var(--muted);
}

.style-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.style-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
}
.style-checkbox-item:has(input:checked) { border-color: var(--accent); background: rgba(56, 189, 248, 0.08); }
.style-checkbox-item input { margin-top: 0.2rem; }
.style-checkbox-item .style-title { font-weight: 700; font-size: 0.85rem; }
.style-checkbox-item .style-tagline { font-size: 0.76rem; color: var(--muted); }

.table-scroll { overflow-x: auto; margin-top: 0.75rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .data-table td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table td.timesheet-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table td.timesheet-bucket { white-space: nowrap; }

