:root {
  --bg: #08080C;
  --bg-alt: #0D0D12;
  --surface: #111117;
  --surface-2: #13131A;
  --surface-3: #1A1A24;
  --accent-bg: #1E1A2E;

  --text: #F0F0F5;
  --text-muted: #9090A8;
  --text-dim: #606078;

  --primary: #FFFFFF;
  --violet: #7C3AED;
  --violet-soft: #A78BFA;
  --violet-deep: #6D28D9;
  --destructive: #EF4444;
  --success: #22C55E;
  --warning: #FBBF24;

  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --input-bg: rgba(255, 255, 255, 0.06);
  --hover-overlay: rgba(255, 255, 255, 0.02);

  --radius: 0.5rem;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.4);

  --t: 60ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; border-color: var(--border); }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

::selection { background: rgba(124, 58, 237, 0.3); color: var(--text); }

::-webkit-scrollbar { width: 8px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }

a { color: var(--violet-soft); text-decoration: none; transition: opacity var(--t); }
a:hover { opacity: 0.85; }

h1, h2, h3 { font-weight: 600; line-height: 1.2; }

/* ---------- header ---------- */
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

header .title { display: flex; gap: 0.875rem; align-items: baseline; }
header h1 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
header h1::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  background: var(--violet); border-radius: 50%;
  margin-right: 0.625rem; vertical-align: middle;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.6);
}
header .actions { display: flex; gap: 0.5rem; align-items: center; }
header .actions button,
header .actions select {
  padding: 0.28rem 0.5625rem;
  font-size: 0.6875rem;
}
header .actions select { padding-right: 1.25rem; background-position: right 0.4rem center; background-size: 8px; }

.session-badge,
.connects-badge {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.1875rem 0.625rem; font-size: 0.6875rem; font-weight: 500;
  border-radius: var(--radius-pill); border: 1px solid;
}
.connects-badge {
  color: var(--violet-soft);
  border-color: rgba(124, 58, 237, 0.3);
  background: var(--accent-bg);
}
.connects-badge::before {
  content: '◆';
  font-size: 0.625rem;
  color: var(--violet-soft);
}
.connects-badge.low { color: #FCD34D; border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.08); }
.connects-badge.low::before { color: #FCD34D; }
.session-badge.ok { color: #86EFAC; border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.1); }
.session-badge.expired { color: #FCA5A5; border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.12); }
.session-badge.connecting { color: var(--violet-soft); border-color: rgba(124, 58, 237, 0.4); background: var(--accent-bg); }
.session-badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.session-badge.connecting::before { animation: pulse 1.2s ease-in-out infinite; }

.muted { color: var(--text-muted); font-size: 0.75rem; }
.dim { color: var(--text-dim); font-size: 0.75rem; }

/* ---------- buttons ---------- */
button, .btn {
  background: var(--primary);
  color: #08080C;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 500;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: opacity var(--t), box-shadow var(--t), background-color var(--t), border-color var(--t), transform var(--t);
}
button:hover:not(:disabled) { opacity: 0.9; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.ghost, .btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
  box-shadow: none; opacity: 1;
}

/* ---------- inputs / selects ---------- */
input, textarea, select {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font: inherit; font-size: 0.8125rem;
  transition: border-color var(--t), box-shadow var(--t);
}
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
select { appearance: none; -webkit-appearance: none; padding-right: 2rem; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%239090A8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 0.625rem center; }

/* ---------- layout ---------- */
main {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  display: flex; flex-direction: column;
  gap: 1.75rem;
}

.section-head {
  display: flex; align-items: baseline; gap: 0.625rem;
  margin-bottom: 0.75rem;
}
.section-head h2 {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ---------- table / card surface ---------- */
table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

thead { background: var(--surface-3); }
th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 150ms ease; }
tbody tr:hover { background: var(--hover-overlay); }

.col-score { width: 76px; }
.col-title { min-width: 320px; }
.col-meta  { width: 130px; color: var(--text-muted); font-size: 0.75rem; }
.col-status { width: 150px; }
.col-draft  { width: 110px; }

.draft-preview-btn {
  display: inline-flex; align-items: center; gap: 0.25rem;
  background: var(--accent-bg); color: var(--violet-soft);
  border: 1px solid rgba(124, 58, 237, 0.3);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius);
  font: inherit; font-size: 0.6875rem; font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t), border-color var(--t), transform var(--t);
}
.draft-preview-btn:hover { background: rgba(124, 58, 237, 0.22); border-color: rgba(124, 58, 237, 0.5); }
.draft-preview-btn:active { transform: scale(0.97); }
.draft-preview-btn .arrow { opacity: 0.7; }

/* ---------- score badges ---------- */
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; padding: 0.25rem 0.625rem;
  border-radius: var(--radius-pill);
  font-weight: 600; font-size: 0.75rem;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}
.score-high { background: rgba(34, 197, 94, 0.12); color: #86EFAC; border-color: rgba(34, 197, 94, 0.28); }
.score-mid  { background: rgba(251, 191, 36, 0.12); color: #FCD34D; border-color: rgba(251, 191, 36, 0.28); }
.score-low  { background: rgba(239, 68, 68, 0.12); color: #FCA5A5; border-color: rgba(239, 68, 68, 0.28); }

/* ---------- title cell ---------- */
.title-cell a {
  color: var(--text); font-weight: 500;
  display: inline-block; line-height: 1.35;
}
.title-cell a:hover { color: var(--violet-soft); opacity: 1; }
.title-cell .desc {
  color: var(--text-muted); font-size: 0.75rem; line-height: 1.5;
  margin-top: 0.3125rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.status-select { width: 100%; font-size: 0.75rem; padding: 0.375rem 1.75rem 0.375rem 0.625rem; }

/* ---------- rules / runs ---------- */
.rules {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  white-space: pre-wrap;
  font: 0.75rem/1.6 ui-monospace, 'Cascadia Code', 'Geist Mono', monospace;
  color: var(--text);
  max-height: 320px; overflow: auto;
}

#runs-list {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
#runs-list li {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  display: flex; align-items: center; gap: 0.75rem;
  transition: background-color 150ms ease;
}
#runs-list li:last-child { border-bottom: none; }
#runs-list li:hover { background: var(--hover-overlay); }
#runs-list .run-time { font-weight: 500; min-width: 100px; }
#runs-list .run-meta { color: var(--text-muted); font-size: 0.75rem; }

/* ---------- run state dot ---------- */
.dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  margin-right: 0.5rem; vertical-align: middle;
}
.dot.running { background: var(--violet); box-shadow: 0 0 8px rgba(124, 58, 237, 0.7); animation: pulse 1.4s ease-in-out infinite; }
.dot.idle    { background: #4ADE80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.5); }
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ---------- empty state ---------- */
.empty {
  text-align: center; padding: 2.5rem 1rem;
  color: var(--text-muted); font-size: 0.8125rem;
}

/* ---------- live activity ---------- */
.live-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.125rem 1rem;
}
.live-head { margin-bottom: 0.625rem; align-items: center; gap: 0.5rem; }
.live-actions { margin-left: auto; display: flex; gap: 0.4rem; }
.sched-modes { display: flex; flex-direction: column; gap: 0.5rem; }
.sched-mode-row { display: flex; align-items: center; gap: 0.5rem; }
.sched-mode-row label { display: flex; align-items: center; gap: 0.4rem; }
.sched-mode-row input[type="number"] { width: 4rem; }
.sched-mode-row input[type="time"] { width: 7rem; }
.live-current + .live-actions { margin-left: 0.5rem; }
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.7);
  animation: pulse 1.4s ease-in-out infinite;
}
.live-section.idle .live-dot { background: var(--good, #4ADE80); animation: none; box-shadow: 0 0 6px rgba(74, 222, 128, 0.5); }
.live-section.error .live-dot { background: var(--bad, #f85149); animation: none; }
.live-current {
  margin-left: auto;
  color: var(--text); font-size: 0.8125rem; font-weight: 500;
  max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.live-timeline {
  list-style: none;
  position: relative;
  padding-left: 1.125rem;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.8125rem;
}
.live-timeline::before {
  content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.live-timeline li {
  position: relative;
  padding: 0.3125rem 0 0.3125rem 0.625rem;
  color: var(--text);
}
.live-timeline li::before {
  content: ''; position: absolute; left: -10px; top: 12px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--border-strong);
}
.live-timeline li.last::before {
  background: var(--violet); border-color: var(--violet);
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.7);
  animation: pulse 1.2s ease-in-out infinite;
}
.live-timeline li.error::before { background: var(--bad, #f85149); border-color: var(--bad, #f85149); animation: none; }
.live-timeline li.done::before  { background: var(--good, #4ADE80); border-color: var(--good, #4ADE80); animation: none; }
.live-timeline .ts {
  color: var(--text-dim); font-variant-numeric: tabular-nums;
  margin-right: 0.5rem; font-size: 0.6875rem;
}
.live-timeline .stage {
  color: var(--text-muted); font-size: 0.6875rem; text-transform: uppercase;
  letter-spacing: 0.05em; margin-right: 0.5rem;
}

/* ---------- runs list (clickable) ---------- */
#runs-list li { cursor: pointer; }
#runs-list li:hover .run-time { color: var(--violet-soft); }

/* ---------- side panel ---------- */
.side-panel {
  position: fixed; top: 0; right: -560px; width: 540px; max-width: 92vw; height: 100vh;
  background: var(--panel, var(--surface)); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  display: flex; flex-direction: column;
  transition: right 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 50;
}
.side-panel.open { right: 0; }
.side-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.side-panel-head h3 { font-size: 0.9375rem; font-weight: 600; }
#side-panel-body {
  padding: 1.125rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}
.side-panel-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  opacity: 0; pointer-events: none; transition: opacity 220ms ease;
  z-index: 40;
}
.side-panel-backdrop.open { opacity: 1; pointer-events: auto; }

.run-stat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}
.run-stat-label { color: var(--text-muted); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; }
.run-stat-value { font-size: 0.9375rem; font-variant-numeric: tabular-nums; margin-top: 0.125rem; }

.run-jobs-list { list-style: none; }
.run-jobs-list li {
  padding: 0.625rem 0; border-bottom: 1px solid var(--border);
  display: flex; gap: 0.625rem; align-items: flex-start;
}
.run-jobs-list li:last-child { border-bottom: none; }
.run-jobs-list .meta { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.25rem; }

/* ---------- settings form ---------- */
.settings-form { display: flex; flex-direction: column; gap: 1.125rem; }
.settings-row { display: flex; flex-direction: column; gap: 0.375rem; }
.settings-row label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.settings-row .desc { font-size: 0.75rem; color: var(--text-dim); }
.settings-radio-group { display: flex; gap: 0.5rem; }
.settings-radio { flex: 1; }
.settings-radio input { display: none; }
.settings-radio label {
  display: block; cursor: pointer; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  text-align: center; font-size: 0.8125rem; text-transform: none; letter-spacing: 0;
  transition: all var(--t);
}
.settings-radio input:checked + label {
  background: var(--accent-bg); color: var(--violet-soft);
  border-color: rgba(124, 58, 237, 0.5);
}
.settings-checkbox { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.settings-checkbox input { margin: 0; }
.settings-actions { display: flex; gap: 0.5rem; justify-content: flex-end; padding-top: 0.5rem; border-top: 1px solid var(--border); }

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 0.25rem; flex-wrap: wrap;
  margin-bottom: 0.875rem;
}
.tab {
  padding: 0.4375rem 0.875rem;
  background: transparent; color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer; font: inherit; font-size: 0.8125rem; font-weight: 500;
  transition: background-color var(--t), color var(--t), border-color var(--t);
  display: inline-flex; align-items: center; gap: 0.4375rem;
}
.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.tab.active {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--border);
}
.tab .tab-count {
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  padding: 0.0625rem 0.5rem;
  font-size: 0.6875rem; font-weight: 600;
  color: var(--text-muted);
}
.tab.active .tab-count { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.tab-filter-bar {
  display: flex; gap: 0.5rem; align-items: center;
  margin-bottom: 0.875rem;
  font-size: 0.75rem;
}
.tab-filter-bar label { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.tab-filter-bar input { width: 76px; padding: 0.25rem 0.5rem; font-size: 0.75rem; }

.tab-content { min-height: 220px; }
.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 0.75rem;
}
.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  display: flex; flex-direction: column; gap: 0.875rem;
  transition: border-color var(--t);
}
.job-card-section { display: flex; flex-direction: column; gap: 0.3rem; }
.job-card-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.job-card-desc-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.625rem 0.75rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.75rem; font-weight: 500;
  color: var(--text);
  transition: background var(--t), border-color var(--t);
  text-align: left;
}
.job-card-desc-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.job-card-desc-btn .muted { font-size: 0.6875rem; }

/* Job description side-panel body */
.job-desc-panel { display: flex; flex-direction: column; gap: 0.75rem; }
.job-desc-meta {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.job-desc-link {
  font-size: 0.75rem;
  color: var(--violet-soft);
}
.job-desc-body {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-alt);
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.job-card:hover { border-color: var(--border-strong); }
.job-card-head { display: flex; gap: 0.5rem; align-items: flex-start; }
.job-card-head .score-badge { flex-shrink: 0; }
.job-card-title {
  font-weight: 500; font-size: 0.875rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  flex: 1;
}
.job-card-title a { color: var(--text); }
.job-card-title a:hover { color: var(--violet-soft); }
.job-card-meta {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.875rem;
  color: var(--text-muted); font-size: 0.6875rem;
}
.job-card-meta span { white-space: nowrap; }
.job-card-cover {
  position: relative;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.625rem;
  font-size: 0.75rem; line-height: 1.45;
  color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap;
  cursor: default;
}
.copy-cover-btn {
  position: absolute;
  top: 0.375rem; right: 0.375rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.625rem;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 0.3rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t), background var(--t);
}
.job-card-cover:hover .copy-cover-btn { opacity: 1; }
.copy-cover-btn:hover { background: var(--violet-deep); color: white; }
.copy-cover-btn.copied { background: var(--success); color: white; opacity: 1; }
.job-card-ai {
  border-left: 2px solid var(--violet);
  background: var(--surface-2);
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.75rem; color: var(--text); line-height: 1.55;
  white-space: pre-wrap;
}
.job-card-summary {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem; line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}
.job-card-summary-label {
  display: block;
  font-size: 0.625rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.job-card-actions {
  display: flex; gap: 0.375rem; flex-wrap: wrap;
  padding-top: 0.5rem; margin-top: auto;
  border-top: 1px solid var(--border);
}
.job-card-actions button,
.job-card-actions select {
  padding: 0.3125rem 0.625rem; font-size: 0.6875rem;
}
.job-card-actions .spacer { flex: 1; }

/* ---------- kanban (legacy — kept for any leftover usage) ---------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  min-height: 180px;
}
.kanban-col-head {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 600;
  position: sticky; top: 0;
  background: var(--surface-3);
  border-top-left-radius: var(--radius); border-top-right-radius: var(--radius);
}
.kanban-col-head .count {
  color: var(--text-dim); font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill); padding: 0.0625rem 0.5rem;
  font-size: 0.6875rem;
}
.kanban-col[data-status="drafted"]   .kanban-col-head .accent { color: var(--violet-soft); }
.kanban-col-body {
  padding: 0.625rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  flex: 1;
}
.kanban-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  transition: border-color var(--t), background var(--t), transform var(--t);
}
.kanban-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.kanban-card:active { transform: scale(0.98); }
.kanban-card .title {
  font-weight: 500; font-size: 0.8125rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kanban-card .row {
  display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem;
}
.kanban-card .meta {
  color: var(--text-muted); font-size: 0.6875rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kanban-empty {
  color: var(--text-dim); font-size: 0.75rem; text-align: center;
  padding: 1rem 0.5rem;
}

/* ---------- proposal detail ---------- */
.proposal-meta {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.625rem 1rem;
  margin-bottom: 1rem;
}
.proposal-cover {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  font: 0.8125rem/1.55 inherit;
  white-space: pre-wrap;
  resize: vertical;
  width: 100%;
  min-height: 320px;
  color: var(--text);
}
.query-tags { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.25rem; }
.query-tag {
  background: var(--accent-bg); color: var(--violet-soft);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-pill); padding: 0.1875rem 0.625rem;
  font-size: 0.6875rem;
}

/* ---------- chat panel ---------- */
.chat-panel {
  position: fixed; top: 0; right: -480px; width: 460px; max-width: 92vw; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  display: flex; flex-direction: column;
  transition: right 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 60;
}
.chat-panel.open { right: 0; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-head h3 { font-size: 0.9375rem; font-weight: 600; }
.chat-head h3::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  background: var(--violet); border-radius: 50%;
  margin-right: 0.5rem; vertical-align: middle;
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.6);
}
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 1rem 1.125rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.chat-msg {
  max-width: 92%; padding: 0.625rem 0.875rem;
  border-radius: 0.75rem; font-size: 0.875rem; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--violet); color: #fff;
  border-bottom-right-radius: 0.25rem;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0.25rem;
}
.chat-msg.tool {
  align-self: flex-start;
  background: transparent; color: var(--text-muted);
  border: 1px dashed var(--border);
  font-size: 0.75rem; padding: 0.375rem 0.625rem;
  font-family: ui-monospace, 'Cascadia Code', monospace;
}
.chat-msg.tool.error { color: #FCA5A5; border-color: rgba(239, 68, 68, 0.3); }
.chat-form {
  border-top: 1px solid var(--border); padding: 0.75rem 1rem;
  display: flex; gap: 0.5rem; align-items: flex-end;
  flex-shrink: 0;
}
.chat-form textarea {
  flex: 1; resize: none; min-height: 38px; max-height: 200px;
  font-family: inherit;
}
.chat-form button { flex-shrink: 0; }
.chat-empty {
  color: var(--text-dim); text-align: center; padding: 2rem 0;
  font-size: 0.8125rem;
}
.chat-msg .typing::after {
  content: '▍'; opacity: 0.6;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* === Settings tabs (search / presets) === */

.settings-tabs {
  display: flex; gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1rem;
}
.settings-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.5rem 0.875rem;
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent, #6c8eff);
}
.settings-tab-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-header {
  display: flex; align-items: end; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.search-header label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.75rem; color: var(--muted);
}
.search-header select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  min-width: 14rem;
  font: inherit;
  font-size: 0.8125rem;
}
.search-header-actions { display: flex; align-items: center; gap: 0.5rem; }

.search-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem;
  background: var(--surface-2);
}
.search-card h4 { margin: 0 0 0.625rem; font-size: 0.8125rem; font-weight: 600; }
.search-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.625rem;
}
.search-card-head h4 { margin: 0; }

.search-globals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.5rem 0.875rem;
}
.search-row {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.75rem; color: var(--muted);
}
.search-row.search-row-bool {
  flex-direction: row; align-items: center; gap: 0.5rem;
  color: var(--text); font-size: 0.8125rem;
}
.search-row input[type="text"],
.search-row input[type="number"],
.search-row select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
}

.search-queries { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.query-row {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 0.375rem 0.5rem;
}
.query-row-head { display: flex; align-items: center; gap: 0.5rem; }
.query-expand {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.875rem; padding: 0 0.25rem;
}
.query-text {
  flex: 1;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.45rem;
  font: inherit;
  font-size: 0.8125rem;
}
.query-delete { padding: 0.25rem 0.5rem; }
.query-overrides {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 0.375rem;
}
.ov-row {
  display: grid; grid-template-columns: 12rem 1fr auto; gap: 0.5rem;
  align-items: center;
}
.ov-label { font-size: 0.75rem; color: var(--muted); }
.ov-input {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.3rem 0.45rem; font: inherit; font-size: 0.8125rem;
}
.ov-remove { padding: 0.2rem 0.45rem; }
.query-add-override .query-override-picker {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 0.3rem 0.45rem; font: inherit; font-size: 0.75rem;
}

.presets-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.preset-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 0.625rem 0.75rem;
}
.preset-head { display: flex; align-items: center; gap: 0.5rem; }
.preset-default {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 1rem; padding: 0;
}
.preset-default:hover { color: gold; }
.preset-desc {
  margin: 0.25rem 0 0.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.preset-actions {
  display: flex; gap: 0.375rem; flex-wrap: wrap;
  margin-top: 0.375rem;
}
.preset-actions button { padding: 0.3rem 0.625rem; font-size: 0.75rem; }
.preset-actions button[disabled] { opacity: 0.4; cursor: not-allowed; }

/* =========================================================================
   App shell: sticky header + nav-style left sidebar + main content
   Overrides earlier `main` rule (max-width centered column).
   ========================================================================= */
main { max-width: none; margin: 0; padding: 0; gap: 0; display: block; }

.app-shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 60px);
}

.left-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 0.625rem 0.5rem;
  display: flex; flex-direction: column;
  gap: 0.375rem;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  position: sticky; top: 60px;
}

.left-sidebar .primary-action {
  width: 100%;
  padding: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
}
.run-cancel-side, .run-pause-side { width: 100%; padding: 0.3rem; font-size: 0.65rem; }

.sidebar-nav {
  display: flex; flex-direction: column; gap: 0.0625rem;
  margin-top: 0.375rem;
}
.sidebar-nav .nav-section {
  padding: 0.625rem 0.5rem 0.2rem;
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.sidebar-nav .nav-item {
  width: 100%;
  text-align: left;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.sidebar-nav .nav-item:hover {
  background: var(--hover-overlay);
  color: var(--text);
}
.sidebar-nav .nav-item.active {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}

.main-content {
  padding: 1.5rem;
  overflow-x: hidden;
  display: flex; flex-direction: column; gap: 1.25rem;
}

.page { display: block; }
.page[hidden] { display: none; }
.page-head {
  display: flex; align-items: baseline; gap: 0.625rem;
  margin-bottom: 1rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
}
.page-head h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.runs-list-full { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.runs-list-full li {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t);
}
.runs-list-full li:hover { background: var(--surface-2); }

/* Per-job rating widget (used in side-panel & elsewhere) */
.rating-widget {
  margin-top: 0.875rem;
  padding: 0.75rem 0.875rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.rating-widget-row { display: flex; align-items: center; gap: 0.5rem; }
.rating-widget label { font-size: 0.6875rem; font-weight: 500; color: var(--text-muted); }
.rating-input { width: 5rem; }
.rating-reason { width: 100%; resize: vertical; min-height: 2.25rem; font-size: 0.75rem; }
.rating-actions { display: flex; align-items: center; gap: 0.5rem; }
.rating-actions button { font-size: 0.7rem; padding: 0.35rem 0.75rem; }
.rating-status { font-size: 0.7rem; }

/* Inline ★ rating badge on cards */
.user-rating-badge {
  display: inline-flex; align-items: center; gap: 0.2rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.6875rem; font-weight: 600;
  background: var(--accent-bg);
  color: var(--violet-soft);
  border: 1px solid var(--violet-deep);
  border-radius: 9999px;
}
.rate-btn { font-size: 0.6875rem; }

/* Recent ratings list (scoring page) */
.ratings-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.ratings-list li {
  display: flex; gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ratings-list-body { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.ratings-list-title { font-size: 0.8125rem; font-weight: 500; color: var(--text); }
.ratings-list-reason { font-size: 0.75rem; color: var(--text-muted); }
.ratings-list-meta { font-size: 0.6875rem; color: var(--text-dim); }

.main-content {
  padding: 1.5rem;
  overflow-x: hidden;
}

/* =========================================================================
   Chat as full-area view (replaces slide-out)
   ========================================================================= */
.chat-view {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: calc(100vh - 60px - 3rem);
  gap: 1rem;
}
.chat-view-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.chat-view-sidebar .section-head { justify-content: space-between; margin-bottom: 0.5rem; }
.chat-view-sidebar .section-head button { font-size: 0.6875rem; padding: 0.2rem 0.5rem; }
.chat-conversations {
  list-style: none;
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.75rem;
  overflow-y: auto;
}
.chat-conversations li {
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  cursor: pointer;
  border: 1px solid transparent;
}
.chat-conversations li:hover { background: var(--hover-overlay); }
.chat-conversations li.active {
  background: var(--accent-bg);
  border-color: var(--violet-deep);
  color: var(--text);
}
.chat-conversations .conv-title { font-weight: 500; display: block; margin-bottom: 0.125rem; }
.chat-conversations .conv-meta { color: var(--text-dim); font-size: 0.6875rem; }
.chat-conversations .empty { color: var(--text-dim); padding: 0.5rem; font-style: italic; }

.chat-view-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem 0.875rem;
  display: flex; flex-direction: column;
  overflow: hidden;
  font-size: 0.75rem;
}
.chat-view-main .chat-head {
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.4rem;
}
.chat-view-main .chat-head h3 { font-size: 0.75rem; font-weight: 500; }
.chat-view-main .chat-messages { flex: 1; overflow-y: auto; padding: 0.375rem 0; font-size: 0.75rem; }
.chat-view-main .chat-messages .chat-msg { font-size: 0.75rem; line-height: 1.45; }
.chat-view-main .chat-form { display: flex; gap: 0.4rem; align-items: flex-end; }
.chat-view-main .chat-form textarea {
  flex: 1; resize: vertical; min-height: 2.25rem; font-size: 0.75rem;
}
.chat-view-main .chat-form button { font-size: 0.7rem; padding: 0.4rem 0.75rem; }

/* Sidebar runs-list compact override */
.sidebar-card #runs-list { display: flex; flex-direction: column; gap: 0.25rem; list-style: none; }
.sidebar-card #runs-list li {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
}
.sidebar-card #runs-list li:hover { background: var(--hover-overlay); }
.sidebar-card #runs-list .run-meta { display: none; }

/* On small screens collapse sidebar */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .left-sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--border); }
}
