:root {
  --bg:         #09090b;
  --surface:    #18181b;
  --surface-2:  #27272a;
  --border:     #3f3f46;
  --text:       #fafafa;
  --muted:      #a1a1aa;
  --accent:     #6366f1;
  --accent-dim: #4338ca;
  --ok:         #22c55e;
  --slow:       #f59e0b;
  --down:       #ef4444;
  --unknown:    #52525b;
  --dev:        #8b5cf6;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: 72px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.topbar-title {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  height: 64px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover, .nav-item.active { color: var(--accent); text-decoration: none; }

.nav-icon { font-size: 1.25rem; line-height: 1; }

/* ── Page content ── */
.page { max-width: 640px; margin: 0 auto; padding: 1rem; }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ── Service card ── */
.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  cursor: default;
  transition: border-color 0.15s;
}

.service-card:hover { border-color: var(--accent-dim); }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

.status-dot.ok       { background: var(--ok);      box-shadow: 0 0 6px var(--ok); }
.status-dot.slow     { background: var(--slow);     box-shadow: 0 0 6px var(--slow); }
.status-dot.down     { background: var(--down);     box-shadow: 0 0 6px var(--down); }
.status-dot.unknown,
.status-dot.no_endpoint { background: var(--unknown); }

.card-body { flex: 1; min-width: 0; }

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.15em 0.45em;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-prod { background: #14532d; color: #86efac; }
.badge-dev  { background: #2e1065; color: #c4b5fd; }

.card-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.card-status-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-status-label.ok    { color: var(--ok); }
.card-status-label.slow  { color: var(--slow); }
.card-status-label.down  { color: var(--down); }
.card-status-label.unknown, .card-status-label.no_endpoint { color: var(--unknown); }

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn:hover { background: var(--border); text-decoration: none; }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

.btn-danger { border-color: var(--down); color: var(--down); }
.btn-danger:hover { background: #450a0a; }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.7rem; }

/* ── Summary bar ── */
.summary-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.summary-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
}

.summary-pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
}

/* ── Log viewer ── */
.log-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.log-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
  flex-wrap: wrap;
}

.log-tab-group { display: flex; gap: 0.3rem; }

.log-tab {
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.log-tab:hover { color: var(--text); text-decoration: none; }
.log-tab.active { background: var(--surface-2); border-color: var(--border); color: var(--text); }

.log-lines {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.7rem;
  line-height: 1.6;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  white-space: pre;
  max-height: 70vh;
  overflow-y: auto;
  color: #d4d4d8;
  -webkit-overflow-scrolling: touch;
}

.log-lines .err-line { color: #fca5a5; }
.log-lines .warn-line { color: #fcd34d; }

/* ── Roadmap ── */
.roadmap-filters {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 0.25rem 0.65rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.filter-chip:hover { color: var(--text); text-decoration: none; }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.roadmap-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
}

.roadmap-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.roadmap-item-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
}

.roadmap-item-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.3rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  border-radius: 5px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.s-todo        { background: #1c1c1f; color: var(--muted); border: 1px solid var(--border); }
.s-in_progress { background: #1e3a5f; color: #93c5fd; }
.s-done        { background: #14532d; color: #86efac; }
.s-blocked     { background: #450a0a; color: #fca5a5; }
.s-deferred, .s-move_later, .s-skipped_today { background: #1c1917; color: #a8a29e; }

.priority-dot { font-size: 0.7rem; }
.p-critical { color: #ef4444; }
.p-high     { color: #f59e0b; }
.p-medium   { color: #6366f1; }
.p-low      { color: var(--muted); }

/* ── Login ── */
.login-wrap {
  display: flex;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
}

.login-logo {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.login-title {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1.75rem;
}

.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.form-input:focus { border-color: var(--accent); }

.error-msg {
  background: #450a0a;
  border: 1px solid #7f1d1d;
  color: #fca5a5;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

.btn-block { width: 100%; }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ── */
.text-muted { color: var(--muted); }
.text-small { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }

/* ── Checked at bar ── */
.checked-at {
  font-size: 0.65rem;
  color: var(--unknown);
  text-align: right;
  margin-bottom: 0.5rem;
}

/* ── Desktop centering ── */
@media (min-width: 641px) {
  .page { padding: 1.5rem; }
  .bottom-nav { max-width: 640px; left: 50%; transform: translateX(-50%); border-radius: 0; }
}

/* ── Work Terminal ── */

.work-console-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

/* Task card — clickable, used on /work list */
.work-task-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.work-task-card:hover { border-color: var(--accent-dim); text-decoration: none; color: var(--text); }
.work-task-card.is-active { border-color: #1e3a5f; }

.work-task-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.work-task-name {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
}

.work-session-hint {
  margin-top: 0.4rem;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 600;
}

/* Task header — used on /work/session page */
.work-task-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

.work-task-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  flex: 1;
}

.work-task-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.5rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Work section — grouped card block */
.work-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

/* Objective textarea */
.work-objective {
  width: 100%;
  min-height: 80px;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.work-objective:focus { border-color: var(--accent); }

/* Prompt package — monospace read-only box */
.prompt-box {
  width: 100%;
  min-height: 220px;
  max-height: 50vh;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: #d4d4d8;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.72rem;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Session status chips */
.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.status-chip {
  padding: 0.3rem 0.7rem;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.status-chip:hover { color: var(--text); border-color: var(--muted); }
.status-chip.active { color: #fff; }
.status-chip.active.s-drafted    { background: #27272a; border-color: var(--border); color: var(--text); }
.status-chip.active.s-copied     { background: #1e3a5f; border-color: #1e3a5f; color: #93c5fd; }
.status-chip.active.s-sent       { background: #14532d; border-color: #14532d; color: #86efac; }
.status-chip.active.s-completed  { background: #14532d; border-color: #14532d; color: #86efac; }
.status-chip.active.s-blocked    { background: #450a0a; border-color: #450a0a; color: #fca5a5; }

/* Notes textarea */
.notes-area {
  width: 100%;
  min-height: 90px;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.notes-area:focus { border-color: var(--accent); }

/* History rows */
.work-history-row {
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  margin-top: 0.6rem;
}
.work-history-row:first-child { border-top: none; margin-top: 0; padding-top: 0; }

.work-history-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Empty state */
.work-empty {
  text-align: center;
  padding: 2rem 1rem;
}

/* ── Change Tracking ── */

.tracking-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ok);
  letter-spacing: 0.04em;
  animation: tracking-pulse 2s ease-in-out infinite;
}
@keyframes tracking-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

.tracking-summary {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.7rem;
  line-height: 1.55;
  color: #d4d4d8;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  margin-top: 0.75rem;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.changes-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.change-row {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.68rem;
  color: var(--muted);
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.change-row:last-child { border-bottom: none; }
.change-row.log-err    { color: #fca5a5; background: #450a0a22; }

.text-danger { color: var(--down); }

/* ── Claude CLI Bridge ── */

.claude-idle        { font-size:0.65rem; font-weight:700; color:var(--muted); }
.claude-running     { font-size:0.65rem; font-weight:700; color:var(--slow);
                      animation: tracking-pulse 1.2s ease-in-out infinite; }
.claude-done        { font-size:0.65rem; font-weight:700; color:var(--ok); }
.claude-error       { font-size:0.65rem; font-weight:700; color:var(--down); }
.claude-unavailable { font-size:0.65rem; font-weight:700; color:var(--unknown); }

.claude-output-box {
  min-height: 200px;
  max-height: 60vh;
  background: #0d1117;
  color: #c9d1d9;
}

/* Project selector */
.form-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  cursor: pointer;
}
.form-select:focus { border-color: var(--accent); }
