@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg:        #09090b;
  --bg-card:   #111116;
  --bg-raised: #18181f;
  --bg-hover:  #1f1f29;
  --border:    #2a2a38;
  --border-hi: #3a3a52;
  --text:      #e4e4f0;
  --text-muted:#7e7e9a;
  --text-dim:  #4a4a62;
  --accent:    #7c6af7;
  --accent-hi: #9b8dff;
  --accent-glow: rgba(124,106,247,0.25);
  --green:     #22d3a0;
  --green-bg:  rgba(34,211,160,0.12);
  --red:       #f87171;
  --red-bg:    rgba(248,113,113,0.12);
  --blue:      #60a5fa;
  --blue-bg:   rgba(96,165,250,0.12);
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Links ── */
a { color: var(--accent-hi); text-decoration: none; transition: color 0.15s; }
a:hover { color: #fff; }

/* ── Nav ── */
nav.top {
  background: rgba(9,9,11,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 4px;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
}
nav.top .brand {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  padding-right: 20px;
  margin-right: 8px;
  border-right: 1px solid var(--border);
}
nav.top .brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  margin-right: 9px;
  flex-shrink: 0;
}
nav.top a {
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  margin: 8px 0;
}
nav.top a:hover { color: var(--text); background: var(--bg-raised); text-decoration: none; }
nav.top a.active { color: var(--accent-hi); background: rgba(124,106,247,0.1); }
nav.top a.nav-admin {
  color: var(--accent-hi);
  border: 1px solid rgba(124,106,247,0.3);
  margin: 8px 8px 8px 0;
}
nav.top a.nav-admin:hover { background: rgba(124,106,247,0.12); border-color: var(--accent); color: #fff; }
nav.top .nav-logout-form { display: flex; align-items: center; margin: 8px 0 8px 8px; }
nav.top .nav-logout { padding: 6px 14px; font-size: 13px; }

/* ── Quick actions on dashboard ── */
.quick-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-top: 4px;
}
.quick-actions .btn { justify-content: flex-start; padding: 10px 14px; }

/* Multi-button cells in tables */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.row-actions form.inline { display: inline-flex; }

/* ── Layout ── */
main { padding: 32px 28px; max-width: 1440px; margin: 0 auto; }

h1 { font-size: 22px; font-weight: 700; color: #fff; letter-spacing: -0.5px; margin-bottom: 24px; }
h2 { font-size: 18px; font-weight: 600; color: #fff; letter-spacing: -0.3px; margin-bottom: 16px; }
h3 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-hi); }

/* ── KPI strip ── */
.kpi { display: flex; gap: 12px; margin-bottom: 28px; flex-wrap: wrap; }
.kpi .item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  min-width: 130px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}
.kpi .item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.6;
}
.kpi .item:hover { border-color: var(--border-hi); transform: translateY(-1px); }
.kpi .item .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  margin-bottom: 6px;
}
.kpi .item .value { font-size: 26px; font-weight: 700; color: #fff; letter-spacing: -1px; }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
th {
  background: var(--bg-raised);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(42,42,56,0.7);
  vertical-align: middle;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover td { background: rgba(255,255,255,0.025); }

/* ── Buttons ── */
button, .btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  background: var(--bg-raised);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
button:hover, .btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-dim);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
button:active, .btn:active { transform: translateY(0); box-shadow: none; }

button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
button.primary:hover, .btn.primary:hover {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
  box-shadow: 0 4px 16px var(--accent-glow);
}
button.danger, .btn.danger {
  background: var(--red-bg);
  border-color: rgba(248,113,113,0.3);
  color: var(--red);
}
button.danger:hover, .btn.danger:hover {
  background: rgba(248,113,113,0.2);
  border-color: var(--red);
}
button.ghost, .btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--bg-raised);
  border-color: var(--border-hi);
  color: var(--text);
}

/* ── Forms ── */
input, textarea, select {
  font-family: inherit;
  font-size: 13px;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { width: 100%; min-height: 70px; resize: vertical; line-height: 1.5; }
input[type=text], input[type=number] { width: 100%; }
select { cursor: pointer; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge.ok {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(34,211,160,0.2);
}
.badge.ok::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
}
.badge.fail {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
}
.badge.run {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid rgba(96,165,250,0.2);
}
.badge.run::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 1.2s infinite;
}
.badge.muted {
  background: rgba(42,42,56,0.6);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ── Images ── */
.thumb { width: 80px; height: 60px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.imgs-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-padding: 4px;
  padding-bottom: 4px;
}
.imgs-strip > img {
  flex: 0 0 auto;
  scroll-snap-align: start;
}
.imgs-strip img {
  width: 110px; height: 82px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: zoom-in;
}
.imgs-strip.imgs-large { gap: 12px; }
.imgs-strip.imgs-large img {
  width: 80%;
  max-width: 560px;
  min-width: 320px;
  height: auto;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.imgs-strip img:hover {
  transform: scale(1.04);
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(124,106,247,0.3);
  z-index: 1;
  position: relative;
}

/* ── Code / Pre ── */
pre.tail, pre, code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
pre.tail {
  background: #07070a;
  border: 1px solid var(--border);
  color: #c9cfe0;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  overflow: auto;
  max-height: 520px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
}

/* ── Layout helpers ── */
.row { display: flex; gap: 16px; align-items: flex-start; }
.col { flex: 1; }
.right { text-align: right; }
.muted { color: var(--text-muted); }
.empty-state {
  padding: 60px 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state::before {
  content: '◌';
  display: block;
  font-size: 32px;
  margin-bottom: 12px;
  color: var(--text-dim);
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar h1 { margin-bottom: 0; }
.toolbar .spacer { flex: 1; }
.toolbar .btn + .btn,
.toolbar button + button,
.toolbar .btn + button,
.toolbar button + .btn { margin-left: 4px; }
.toolbar form.inline { display: inline-flex; gap: 8px; align-items: center; }

/* ── Misc ── */
.score-input { width: 64px; }
form.inline { display: inline; }
.flash-saved { color: var(--green); font-size: 11px; font-weight: 600; margin-left: 8px; letter-spacing: 0.3px; }
.tag {
  display: inline-block;
  background: rgba(124,106,247,0.1);
  border: 1px solid rgba(124,106,247,0.2);
  color: var(--accent-hi);
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 4px;
}

/* ── Score panel ── */
#score-panel .card {
  position: sticky;
  top: 68px;
}
.dim-block {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.dim-block:last-of-type { border-bottom: none; }
.dim-block .score-input { margin-top: 6px; }
.dim-block .dim-note {
  width: 100%;
  margin-top: 6px;
  min-height: 44px;
  font-size: 12px;
}
.dim-block .dim-text-score {
  width: 100%;
  margin-top: 6px;
  min-height: 56px;
  font-size: 13px;
}

/* ── Goal Breakdown card ── */
.goal-card {
  border-left: 3px solid var(--accent);
}
.goal-header {
  margin-bottom: 20px;
}
.goal-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.goal-text {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.5;
  letter-spacing: -0.2px;
}
.goal-step-intents {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.goal-intents-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.intent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.intent-item {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.15s;
}
.intent-item:hover { border-color: var(--border-hi); }
.intent-item.for-response {
  background: rgba(124,106,247,0.06);
  border-color: rgba(124,106,247,0.3);
}
.intent-item.for-response:hover { border-color: var(--accent); }
.intent-step-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.intent-step-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}
.intent-item.for-response .intent-step-name { color: var(--accent-hi); }
.intent-focus {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Suggestions ── */
.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.suggestion-item {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color 0.15s;
}
.suggestion-item:hover { border-color: var(--border-hi); }
.suggestion-chip { border-left: 2px solid var(--text-dim); }
.suggestion-input { border-left: 2px solid var(--blue); background: var(--blue-bg); }
.suggestion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.suggestion-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.suggestion-action {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Experiment list suggestion chips */
.exp-suggestion-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(42,42,56,0.8);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}
.exp-suggestion-chip.exp-suggestion-input {
  background: var(--blue-bg);
  border-color: rgba(96,165,250,0.25);
  color: var(--blue);
}

/* ── Progress / run ── */
.progress-bar-wrap {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  border-radius: 20px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ── Section separators ── */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  main { padding: 20px 16px; }
  .row { flex-direction: column; }
  nav.top { padding: 0 16px; gap: 2px; }
  nav.top a { padding: 0 8px; font-size: 13px; }
  .kpi .item { min-width: 100px; padding: 14px 16px; }
  .kpi .item .value { font-size: 22px; }
}
