:root {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --link: #58a6ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --orange: #d18616;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Menlo, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --radius: 6px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

/* Layout */
.nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  text-decoration: none;
}

.nav-brand:hover {
  text-decoration: none;
  color: var(--text);
}

.nav-logo {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  background-image: url("/assets/logo-f6cc59c8.png");
  background-size: 135%;
  background-position: center 45%;
  background-repeat: no-repeat;
}

/* User menu */
.nav-user-menu {
  margin-left: auto;
  position: relative;
}

.nav-user-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.nav-user-trigger:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.nav-user-icon {
  width: 20px;
  height: 20px;
}

.nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  overflow: hidden;
}

.nav-dropdown-header {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-all;
}

.nav-dropdown-divider {
  height: 1px;
  background: var(--border);
}

.nav-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-sans);
}

.nav-dropdown-item:hover {
  background: var(--bg-tertiary);
  text-decoration: none;
  color: var(--text);
}

.nav-dropdown-item-danger {
  color: var(--red);
}

.nav-dropdown-item-danger:hover {
  color: var(--red);
}

main { max-width: 960px; margin: 0 auto; padding: 24px; padding-bottom: 70px; }

/* Flash messages */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: #238636; border-color: #238636; color: #fff; }
.btn-primary:hover { background: #2ea043; border-color: #2ea043; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--red) 40%, var(--border)); color: var(--red); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 14%, transparent); border-color: var(--red); color: var(--red); }

/* Refined "New" action — neutral chrome, a green + to signal create. */
.btn-new { gap: 5px; padding: 6px 12px 6px 10px; background: var(--bg-tertiary); }
.btn-new svg { color: var(--green); }
.btn-new:hover { background: var(--border); }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-created { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-queued { background: #1f2937; color: var(--blue); }
.badge-running { background: #0c2d1a; color: var(--green); }
.badge-waiting_for_input { background: #2d2000; color: var(--yellow); }
.badge-evaluating { background: #1c1340; color: var(--purple); }
.badge-completed { background: #0c2d1a; color: var(--green); }
.badge-failed { background: #2d0c0c; color: var(--red); }
.badge-cancelled { background: var(--bg-tertiary); color: var(--text-muted); }
.badge-pending_onboarding { background: #2d2000; color: var(--orange); }
.badge-api_qa_running { background: #1c1340; color: var(--purple); }

/* Page headers */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 24px; font-weight: 600; }

/* Breadcrumbs */
.breadcrumbs {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.breadcrumb-sep {
  margin: 0 6px;
  color: var(--text-muted);
}

.breadcrumb-current {
  color: var(--text);
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab-bar-right {
  margin-left: auto;
  display: flex;
  gap: 0;
}

.tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab-active {
  color: var(--text);
  border-bottom-color: var(--blue);
}

/* Task table */
.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.task-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.task-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.task-table tr:hover td { background: var(--bg-secondary); }

.task-title { font-weight: 500; }
.task-meta { color: var(--text-muted); font-size: 12px; }

/* Task detail */
.task-header {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.task-header h1 { font-size: 20px; margin-bottom: 8px; }

.task-metadata {
  margin-top: 16px;
  font-size: 13px;
}

.meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
}

.task-metadata dt { color: var(--text-muted); width: 72px; flex-shrink: 0; }
.task-metadata dd { font-weight: 500; min-width: 0; }
.task-metadata dd code { word-break: break-all; }

/* Copy button */
.copy-btn {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
}
.copy-btn:hover { color: var(--text); background: var(--border); }

/* Copyable CLI snippet for continuing a project's agent session locally */
.session-resume { margin-top: 12px; max-width: 640px; }
.session-resume-cmd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 6px 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.session-resume-cmd code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow-x: auto;
}
.session-resume-cmd .copy-btn { margin-left: 0; padding: 3px 10px; flex-shrink: 0; }
.session-resume-prompt { color: var(--text-muted); user-select: none; }
.session-resume-hint {
  margin: 6px 0 0 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.task-prompt {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  font-size: 14px;
}

.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* Inline action cluster for table-row buttons (Edit + Delete, etc.).
   `button_to` wraps its button in a <form>, which is block-level by default
   and would push the next button to a new line — flex fixes the layout. */
.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}
.row-actions form { display: inline-block; margin: 0; }
.link-danger {
  background: none;
  border: none;
  color: #848d97;
  cursor: pointer;
  font-size: 0.85em;
  padding: 0;
}
.link-danger:hover { color: #f85149; }

/* Message log */
.message-log {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.message-log-header {
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
}

#task_messages {
  padding: 8px;
}

.message {
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 4px;
  font-size: 13px;
}

.message + .message { margin-top: 2px; }

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 4px;
}

.message-role-system { background: var(--bg-tertiary); color: var(--text-muted); }
.message-role-worker { background: #0c2d1a; color: var(--green); }
.message-role-supervisor { background: #1c1340; color: var(--purple); }
.message-role-human { background: #1a2332; color: var(--blue); }
.message-role-qa_agent { background: #2d1a0e; color: #f97316; }

/* QA scenario divider — separates streamed screenshots by scenario */
.message-scenario-header {
  display: flex;
  align-items: center;
  gap: 10px;
  /* Match .message-status's 12px side margins so the header aligns with the
     screenshot messages below it. */
  margin: 18px 12px 6px;
  padding: 8px 12px;
  border: none;
  border-top: 2px solid #f97316;
  background: #2d1a0e;
}
.scenario-header-label {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #f97316;
  background: rgba(249, 115, 22, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
}
.scenario-header-name { font-weight: 600; color: var(--text); }

.message-time { color: var(--text-muted); font-size: 11px; }

.message-copy-btn {
  margin-left: auto;
  margin-right: 2px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.message-copy-btn:hover { color: var(--text); background: var(--border); }

.toggle-group {
  margin-left: auto;
  display: flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.toggle-btn {
  padding: 1px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1.6;
}

.toggle-btn + .toggle-btn {
  border-left: 1px solid var(--border);
}

.toggle-btn:hover { color: var(--text); }

.toggle-btn-active {
  background: var(--bg-tertiary);
  color: var(--text);
}

.message-content { line-height: 1.6; }
.message-content pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 4px;
}

.message-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-tertiary);
  padding: 2px 4px;
  border-radius: 3px;
}

/* Rendered markdown in worker messages */
.markdown-body {
  font-size: 14px;
  line-height: 1.6;
}

.markdown-body-bordered {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 4px;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 600;
}

.markdown-body h1 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown-body h2 { font-size: 17px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body h3:first-child { margin-top: 0; }

.markdown-body p { margin-bottom: 10px; }
.markdown-body p:last-child { margin-bottom: 0; }

.markdown-body ul, .markdown-body ol {
  margin-bottom: 10px;
  padding-left: 24px;
}

.markdown-body li { margin-bottom: 4px; }

.markdown-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: 10px;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-tertiary);
  padding: 2px 5px;
  border-radius: 3px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  font-size: 13px;
}

.markdown-body th, .markdown-body td {
  padding: 6px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-body th {
  background: var(--bg-tertiary);
  font-weight: 600;
}

.markdown-body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.markdown-body strong { font-weight: 600; }

/* Embedded images (e.g. screenshots in a Linear issue description) render at
   native resolution otherwise — a phone screenshot can be 1500px+ tall and
   shove the rest of the turn off-screen. Constrain to a thumbnail; the
   markdown controller wraps each in a lightbox link, so cursor:zoom-in and a
   click open the full-size viewer. */
.markdown-body img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  width: auto;
  height: auto;
  margin: 8px 0;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}
.markdown-body a[data-lightbox] { display: inline-block; line-height: 0; }

.message-error { background: #2d0c0c; border-left: 3px solid var(--red); }
.message-status { background: var(--bg-secondary); color: var(--text-muted); font-style: italic; margin-left: 12px; margin-right: 12px; }
.message-status-link { color: var(--link); font-style: italic; text-decoration: none; }
.message-status-link:hover { text-decoration: underline; }

/* Worker status line (transient) */
.worker-status {
  padding: 8px 12px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.worker-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  animation: status-pulse 1.5s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.worker-status-summary {
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 0.8em;
  font-style: italic;
}

/* Human input form */
.human-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.human-input h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--yellow);
}

.human-input textarea {
  width: 100%;
  min-height: 100px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  resize: vertical;
}

.human-input textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.human-input .btn { margin-top: 8px; }

/* Steer/interrupt bar — pinned to the bottom of the viewport while the agent runs */
.steer-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.35);
}

.steer-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex: 1;
}

.steer-form textarea {
  flex: 1;
  min-height: 36px;
  max-height: 240px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  resize: none;
  overflow-y: auto;
}

.steer-form textarea:focus {
  outline: none;
  border-color: var(--blue);
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.form-group small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.form-group textarea { min-height: 120px; resize: vertical; }

.form-group input[type="number"] { width: 120px; }

/* Replace the native select chrome so text padding matches the text inputs and
   the dropdown caret sits inset from the right edge. */
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-group select:focus {
  outline: none;
  border-color: var(--blue);
}

/* Action fields Turbo frame: dim + spinner while it reloads. Turbo sets the
   `busy` attribute on the frame for the duration of the request. */
turbo-frame.action-frame {
  display: block;
  position: relative;
}

turbo-frame.action-frame[busy] {
  opacity: 0.55;
  transition: opacity 0.1s ease-in;
}

turbo-frame.action-frame[busy]::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.form-errors {
  background: #2d0c0c;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

.form-errors h3 { font-size: 14px; margin-bottom: 4px; }
.form-errors ul { margin-left: 16px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state p { margin-bottom: 16px; }

/* Iteration counter */
.iteration-count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

/* Profile / Account Settings */
.profile-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.profile-section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.profile-section-header h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.profile-section-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.profile-section-body {
  padding: 16px 20px;
}

.profile-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Connected apps (curated MCP providers) */
.profile-connected-apps {
  padding-top: 4px;
  padding-bottom: 4px;
}

.profile-connected-app {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.profile-connected-app + .profile-connected-app {
  border-top: 1px solid var(--border);
}

.profile-connected-app-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.profile-connected-app-name {
  font-size: 14px;
  font-weight: 500;
}

.profile-connected-app-info .badge {
  align-self: flex-start;
}

.profile-connected-app-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.profile-connected-app-action {
  flex-shrink: 0;
}

.profile-readonly {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-muted);
}

.profile-pending {
  font-size: 13px;
  color: var(--yellow);
  margin-top: -8px;
  margin-bottom: 8px;
}

.profile-section-danger {
  border-color: #f8514933;
}

.profile-section-danger .profile-section-header {
  border-bottom-color: #f8514933;
}

.profile-section-danger .profile-section-header h2 {
  color: var(--red);
}

/* Auth pages (login, signup, forgot password) */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
}

.auth-logo {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  background-image: url("/assets/logo-f6cc59c8.png");
  background-size: 135%;
  background-position: center 45%;
  background-repeat: no-repeat;
}

.auth-brand-name {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.auth-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.auth-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
  text-align: center;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 8px;
}

.auth-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg-elevated, #1e1e2e);
  color: var(--text-primary, #cdd6f4);
  border: 1px solid var(--border-color, #45475a);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  margin-bottom: 12px;
}

.auth-hint-icon {
  flex-shrink: 0;
  margin-top: 1px;
  opacity: 0.7;
}

.auth-submit {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 10px 16px;
  font-size: 15px;
}

.auth-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.form-label-link {
  font-size: 13px;
}

.form-group-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.form-group-inline input[type="checkbox"] {
  width: auto;
  accent-color: var(--green);
}

.form-group-inline label {
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--green);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

/* Title skeleton placeholder */
.title-placeholder {
  display: inline-block;
  height: 20px;
  width: 240px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  vertical-align: middle;
}

.title-placeholder-sm {
  height: 13px;
  width: 160px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Pagination */
.series-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  padding: 12px 0;
}

.series-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.series-nav a:hover {
  color: var(--text);
  border-color: var(--text-muted);
  text-decoration: none;
}

.series-nav a[aria-current="page"] {
  background: var(--bg-tertiary);
  color: var(--text);
  border-color: var(--blue);
  cursor: default;
}

.series-nav a[aria-disabled="true"]:not([aria-current]) {
  color: var(--text-muted);
  opacity: 0.4;
  cursor: default;
}

.series-nav a[aria-disabled="true"]:not([aria-current]):hover {
  border-color: var(--border);
  color: var(--text-muted);
}

/* Onboarding */
.onboarding-step {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.onboarding-step-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.onboarding-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.onboarding-check-done {
  background: #0d3117;
  border-color: var(--green);
  color: var(--green);
}

.onboarding-step-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.onboarding-step-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.onboarding-step-action {
  flex-shrink: 0;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .nav { padding: 10px 16px; gap: 16px; }
  main { padding: 16px; }
  .page-header { gap: 12px; }
  .page-header h1 { font-size: 20px; }
  .task-table .col-iteration,
  .task-table .col-created { display: none; }
  .task-table td,
  .task-table th { padding: 10px 8px; }
  .modal-content { max-width: calc(100% - 32px); }
  .onboarding-step { flex-direction: column; align-items: flex-start; }
  .onboarding-step-action { align-self: stretch; }
  .onboarding-step-action .btn,
  .onboarding-step-action button { width: 100%; }
}

/* QA Results — desktop table */
.qa-scenarios-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.qa-scenarios-table th { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.qa-scenarios-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-subtle, var(--border)); vertical-align: top; }
.qa-reasoning { color: var(--text-secondary); font-size: 13px; }
.qa-expand-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; padding: 0 2px; text-decoration: underline; }
.qa-expand-btn:hover { color: var(--text-primary); }
.qa-video { margin-top: 8px; }
.qa-video video { border-radius: 4px; border: 1px solid var(--border); display: block; max-width: 320px; }
.message-attachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.message-attachment-video { display: block; max-width: 640px; width: 100%; border-radius: 4px; border: 1px solid var(--border); }
@media (max-width: 768px) {
  .message-attachment-video { max-width: 100%; }
}

/* Task attachments — strip on the task show page + picker file list in forms */
.task-attachments { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.attachment-thumb {
  display: block;
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: border-color 0.15s;
}
.attachment-thumb:hover { border-color: var(--text-muted); }
.message-attachments a[data-lightbox], .task-attachments a[data-lightbox] { line-height: 0; }

/* Attachment lightbox — full-screen viewer for attachment thumbnails */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(1, 4, 9, 0.85);
}
/* display:flex above would defeat the hidden attribute's UA display:none */
.lightbox-overlay[hidden] { display: none; }
.lightbox-content { max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lightbox-content img {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
}
.lightbox-caption { font-size: 13px; color: var(--text-muted); font-family: var(--font-mono); }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { color: var(--text); }
.attachment-file-link { display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-tertiary); font-size: 13px; font-family: var(--font-mono); }
/* Attach affordance tucked into the prompt box's bottom-right corner (mirrors
   the chat composer's paperclip). The corner is where the resize grip would be,
   so this field doesn't resize; text is padded clear of the icon. */
.prompt-field { position: relative; }
.prompt-field textarea { resize: none; padding-right: 40px; }
/* Scoped under .prompt-field to outrank `.form-group label { display: block }`,
   which would otherwise kill the flex centering and pin the icon top-left. */
.prompt-field .prompt-attach {
  position: absolute; right: 8px; bottom: 8px;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
}
.prompt-field .prompt-attach:hover { color: var(--text); background: var(--bg-tertiary); }

.attachment-picker-list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted); }
.attachment-picker-item-invalid { color: var(--red); }
.attachment-picker-clear { align-self: flex-start; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; padding: 0; text-decoration: underline; }
.attachment-picker-clear:hover { color: var(--text); }

/* Collapsible optional form sections (e.g. the QA test plan) */
.form-details { margin-bottom: 16px; }
.form-details summary { font-size: 13px; color: var(--text-muted); cursor: pointer; }
.form-details summary:hover { color: var(--text); }
.form-details .form-group { margin-top: 10px; }
.test-plan-input { font-family: var(--font-mono); font-size: 12px; }

/* QA Results — mobile cards (hidden on desktop) */
.qa-scenarios-cards { display: none; }

@media (max-width: 768px) {
  .qa-scenarios-table { display: none; }
  .qa-scenarios-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
  .qa-card { border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-size: 13px; }
  .qa-card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
  .qa-card-name { font-weight: 500; flex: 1; }
  .qa-card-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
  .qa-video video { max-width: 100%; width: 100%; }
}

/* ---------- Tom Select (dark theme overrides) ---------- */

.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.single.full .ts-control,
.ts-wrapper.multi .ts-control {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 12px;
  box-shadow: none;
  min-height: 0;
  cursor: pointer;
}
.ts-wrapper.single .ts-control:hover { border-color: var(--text-muted); }
.ts-wrapper.focus .ts-control,
.ts-wrapper.single.dropdown-active .ts-control {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.18);
}
.ts-wrapper.single .ts-control > input,
.ts-wrapper.single .ts-control .item { color: var(--text); }
.ts-wrapper .ts-control > input::placeholder { color: var(--text-muted); }

/* Dropdown is portalled to <body> via dropdownParent: "body" — these styles
   apply globally, not scoped to a parent. z-index must exceed the modal
   backdrop (200) so it renders above it. */
.ts-dropdown,
.ts-dropdown.single,
.ts-dropdown.multi {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  margin-top: 4px;
  padding: 4px;
  z-index: 300;
}
.ts-dropdown .ts-dropdown-content { background: transparent; }
.ts-dropdown .dropdown-input-wrap {
  padding: 4px;
}
.ts-dropdown .dropdown-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 10px;
}
.ts-dropdown .dropdown-input:focus {
  outline: none;
  border-color: var(--blue);
}
.ts-dropdown .option {
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text);
}
.ts-dropdown .option.active,
.ts-dropdown .active {
  background: var(--bg-tertiary);
  color: var(--text);
}
.ts-dropdown .option.selected {
  box-shadow: inset 2px 0 0 var(--blue);
}
.ts-dropdown .no-results,
.ts-dropdown .optgroup-header {
  color: var(--text-muted);
  padding: 6px 10px;
}

/* ===== Clicky agent chat ===== */
/* Linear "Skills"-style: a subtle inline icon + label + chevron, no box. */
.chat-model { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.chat-model:hover, .chat-model:hover .chat-model-select { color: var(--text); }
.chat-model svg { flex: none; }
.chat-model-select {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: none; color: var(--text-muted);
  font-family: var(--font-sans); font-size: 12.5px; cursor: pointer;
  padding: 2px 16px 2px 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' stroke='%238b949e' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center;
}
.chat-model-select:focus { outline: none; }

.chat-new-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-msg-model {
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
}

.chat-stream { white-space: pre-wrap; }

.chat-stream:empty::before { content: "…"; color: var(--text-muted); }

.chat-stream::after {
  content: "▋";
  color: var(--text-muted);
  animation: status-pulse 1s ease-in-out infinite;
}

#typing_indicator .worker-status { padding: 10px 16px; }

.chat-tool-calls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chat-tool-chip {
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  cursor: default;
}

.chat-msg-event { padding: 4px 0; }

.chat-event-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  color: var(--text-muted);
  font-size: 13px;
}

.chat-event-summary::-webkit-details-marker { display: none; }

.chat-event-summary::after {
  content: "▸";
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.chat-event[open] .chat-event-summary::after { transform: rotate(90deg); }

.chat-event-label { flex: 0 1 auto; }

.chat-event-body {
  margin: 8px 0 4px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* ===== Chat layout (Claude-app style: no cards, bubbles for the human,
   plain flowing text for Clicky, rounded sticky composer) ===== */
/* Full-viewport column: the composer sits at the bottom even for short
   conversations. dvh tracks the iOS keyboard / collapsing URL bar. */
.chat-screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
  min-height: calc(100dvh - 140px);
}

.chat-log { margin-top: 12px; flex: 1 1 auto; }

#chat_messages {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

#chat_messages .chat-msg {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.6;
}

/* The #chat_messages prefix is REQUIRED: the base rule above carries an ID
   selector, so an unprefixed .chat-msg-user (lower specificity) is silently
   ignored regardless of source order — which kept the bubble invisible. */
/* No chat bubble — a flat, full-width block with a faint tint distinguishes the
   human's turn from Clicky's plain flowing reply (Linear-style). */
#chat_messages .chat-msg-user {
  align-self: stretch;
  max-width: 100%;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border: none;
  border-radius: 6px;
  padding: 10px 12px;
}

#chat_messages .chat-msg-user .message-header { display: none; }

.chat-msg-assistant { width: 100%; }

.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
}

.chat-msg-copy {
  margin-left: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}

.chat-msg-copy:hover { color: var(--text); }

.chat-msg-event { align-self: stretch; }

.chat-composer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 12px 0 16px;
  margin-top: 8px;
}

.chat-composer form {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px 8px;
}

.chat-composer textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  overflow-y: auto; /* scrolls internally once autogrow hits its cap */
  padding: 2px 4px;
  font: inherit;
  /* 16px minimum: anything smaller makes iOS Safari zoom in on focus */
  font-size: 16px;
  color: var(--text);
}

.chat-composer textarea:focus {
  outline: none;
  border: none;
  box-shadow: none;
}

.chat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}

.chat-composer-right { display: inline-flex; align-items: center; gap: 4px; }
.chat-attach-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; color: var(--text-muted); cursor: pointer;
}
.chat-attach-btn:hover { color: var(--text); background: var(--bg-tertiary); }
.chat-attach-list { margin-bottom: 8px; }
.chat-attach-list:empty { display: none; }

/* Subtle send (Linear-style) — not a bright accent. */
.chat-send-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--border); color: var(--text); }

/* Index-page variant: same composer, not pinned */
.chat-composer--inline {
  position: static;
  padding: 8px 0 0;
  margin-top: 8px;
}

/* Recent chats: quiet rows, no table chrome */
.chat-list {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
}

.chat-list-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.chat-list-item:hover { background: var(--bg-secondary); text-decoration: none; }

.chat-list-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-time {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 768px) {
  .chat-msg-user { max-width: 92%; }
  .chat-composer { padding: 8px 0 calc(12px + env(safe-area-inset-bottom)); }
  /* selects below 16px also trigger the iOS focus zoom */
  .chat-model-select { font-size: 16px; }
}

/* ============================================================
   Projects UI — conversation-first project view + timeline spine
   ============================================================ */

/* --- Projects index --- */
.projects-toolbar {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap;
}
.toolbar-search { position: relative; flex: 1; min-width: 200px; display: flex; align-items: center; }
.toolbar-search-icon {
  position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.toolbar-search-input {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: var(--font-sans); font-size: 14px;
}
.toolbar-search-input::placeholder { color: var(--text-muted); }
.toolbar-search-input:focus { outline: none; border-color: var(--link); }
.toolbar-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.toolbar-select { display: inline-flex; align-items: center; gap: 7px; }
.toolbar-select-label {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
}
.toolbar-select select {
  height: 36px; padding: 0 30px 0 11px; border-radius: 8px;
  background: var(--bg-secondary); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-sans); font-size: 13.5px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' stroke='%238b949e' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.toolbar-select select:focus { outline: none; border-color: var(--link); }
@media (max-width: 640px) {
  /* Search takes its own full-width row; the two dropdowns share the next. */
  .toolbar-search { flex-basis: 100%; }
  .toolbar-select { flex: 1; }
  .toolbar-select select { flex: 1; width: 100%; min-width: 0; }
}

.project-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.project-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.project-card:hover { border-color: var(--text-muted); background: var(--bg-tertiary); }
.project-card-live { border-color: color-mix(in srgb, var(--green) 45%, var(--border)); }
.project-card-link { display: flex; align-items: center; gap: 14px; padding: 14px 16px; color: inherit; }
.project-card-link:hover { text-decoration: none; }
.project-card-dot { position: relative; width: 14px; height: 14px; flex: none; }
.project-card-body { flex: 1; min-width: 0; }
.project-card-head { display: flex; align-items: center; gap: 10px; }
.project-card-name { font-size: 15px; font-weight: 600; color: var(--text); }
.project-card-live-tag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 40%, transparent);
  border-radius: 999px; padding: 1px 7px;
}
.project-card-sub {
  margin-top: 3px; font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}

.empty-state { text-align: center; padding: 64px 24px; color: var(--text-muted); }
.empty-state-title { font-size: 16px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.empty-state-hint { font-size: 14px; margin-bottom: 20px; }

/* --- Project conversation view --- */
.project-view { max-width: 820px; margin: 0 auto; }
.breadcrumb-back { font-size: 13px; color: var(--text-muted); }
.breadcrumb-back:hover { color: var(--text); text-decoration: none; }

.project-head { padding: 8px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.project-head-top { display: flex; align-items: center; gap: 12px; }
.project-head-actions { margin-left: auto; }
.project-head-actions form { margin: 0; }
.project-name { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.project-status {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted);
}
.project-status-active { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.project-sub {
  margin-top: 8px; font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; max-width: 100%;
}
/* Repo slug (e.g. "clickfunnels2/clicky@main") is a single unbroken token; allow it to
   shrink and wrap inside the flex row instead of forcing horizontal overflow on mobile. */
.project-sub-item { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.project-sub-branch { color: var(--purple); }
.project-sub-sep { opacity: 0.5; flex-shrink: 0; }

.session-strip {
  margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-secondary); flex-wrap: wrap;
}
.session-strip-main { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 12px; }
.session-strip-label { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; }
.session-strip-id { color: var(--text); background: var(--bg-tertiary); padding: 2px 8px; border-radius: 4px; }
.session-strip-tag { color: var(--green); }

/* --- Timeline spine --- */
.timeline { position: relative; margin-top: 24px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 10px; bottom: 10px; width: 2px; background: var(--border); }
.timeline-empty { color: var(--text-muted); padding: 32px 0; font-size: 14px; }

.turn { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 20px; padding-bottom: 28px; }
.turn-rail { position: relative; }
.turn-dot {
  position: absolute; top: 4px; left: 0; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--text-muted);
  box-shadow: 0 0 0 4px var(--bg);
}
/* status → dot color, reusing the badge palette. The status class lives on the
   dot itself so a Turbo replace can recolor it live as the task transitions. */
.turn-dot-completed { border-color: var(--green); background: var(--green); }
.turn-dot-failed { border-color: var(--red); background: var(--red); }
.turn-dot-cancelled { border-color: var(--text-muted); background: var(--bg); }
.turn-dot-waiting_for_input { border-color: var(--yellow); background: var(--yellow); }
.turn-dot-waiting_for_turn { border-color: var(--text-muted); background: var(--bg); }
.turn-dot-queued, .turn-dot-created, .turn-dot-evaluating,
.turn-dot-qa_planning, .turn-dot-qa_running { border-color: var(--blue); background: var(--blue); }
.turn-dot-running {
  border-color: var(--green); background: var(--green);
  animation: turn-pulse 1.6s ease-in-out infinite;
}
@keyframes turn-pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px color-mix(in srgb, var(--green) 55%, transparent); }
  50% { box-shadow: 0 0 0 4px var(--bg), 0 0 0 9px color-mix(in srgb, var(--green) 0%, transparent); }
}

.turn-body { min-width: 0; }
.turn-head { display: flex; align-items: center; gap: 10px; }
.turn-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.turn-meta {
  margin-top: 5px; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted);
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.turn-meta-link { color: var(--text-muted); }
.turn-meta-link:hover { color: var(--link); }
.turn-meta-sep { opacity: 0.5; }

.turn-actions { margin-top: 12px; }
.turn-actions form { margin: 0; }
.turn-actions .composer-cancel { border-color: color-mix(in srgb, var(--red) 25%, transparent); }

.turn-prompt {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg-secondary); border-left: 2px solid var(--border);
  font-size: 14px;
}
.turn-summary {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg-secondary); border-left: 2px solid var(--green);
}
.turn-summary-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.turn-summary-label { font-size: 12px; font-weight: 600; color: var(--green); text-transform: uppercase; letter-spacing: 0.05em; }
.turn-messages { margin-top: 12px; }

/* Completed-task transcript: collapsed behind a toggle, summary leads. */
.turn-transcript { margin-top: 14px; }
.turn-transcript-toggle {
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
  list-style: none; user-select: none; padding: 4px 0;
}
.turn-transcript-toggle::-webkit-details-marker { display: none; }
.turn-transcript-toggle::before {
  content: "▸"; font-size: 10px; transition: transform 0.12s ease; display: inline-block;
}
.turn-transcript[open] .turn-transcript-toggle::before { transform: rotate(90deg); }
.turn-transcript-toggle:hover { color: var(--text); }
.turn-transcript-label-hide { display: none; }
.turn-transcript[open] .turn-transcript-label-show { display: none; }
.turn-transcript[open] .turn-transcript-label-hide { display: inline; }
.turn-transcript .turn-messages { margin-top: 8px; }

/* --- Composer (sticky bottom, state-aware) --- */
.composer {
  position: sticky; bottom: 46px; margin-top: 8px;
  padding: 12px 0 16px;
  background: linear-gradient(to bottom, transparent, var(--bg) 26%);
}
.composer-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px; padding: 0 2px;
}
.composer-tools form { margin: 0; }
.composer-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted);
}
.composer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: turn-pulse 1.6s ease-in-out infinite; }
.composer-dot-wait { background: var(--yellow); animation: none; }
.composer-dot-busy { background: var(--blue); animation: none; }
.composer-cancel {
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  font-family: var(--font-sans); font-size: 12.5px; padding: 4px 10px; border-radius: 6px;
  cursor: pointer; transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.composer-cancel:hover {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
  background: color-mix(in srgb, var(--red) 12%, transparent);
}

.composer-form {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-secondary);
  transition: border-color 0.12s ease;
}
.composer-form:focus-within { border-color: var(--link); }
.composer-input {
  flex: 1; resize: none; border: none; background: transparent; color: var(--text);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.5;
  padding: 6px 0; max-height: 200px; min-height: 20px;
}
.composer-input:focus { outline: none; }
.composer-input::placeholder { color: var(--text-muted); }
.composer-send {
  flex: none; align-self: flex-end; background: #238636; color: #fff; border: none;
  border-radius: 8px; padding: 8px 18px; font-size: 13.5px; font-weight: 600;
  line-height: 1.2; cursor: pointer; transition: background 0.12s ease;
}
.composer-send:hover { background: #2ea043; }
.composer-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 640px) {
  .turn { gap: 14px; grid-template-columns: 12px 1fr; }
  .project-name { font-size: 20px; }
}

/* ============================================================
   Clicky dock — global agent-chat launcher + floating panel
   ============================================================ */
.dock { font-family: var(--font-sans); }

/* --- bottom bar: a full-width taskbar (pills left, history + launcher right) --- */
.dock-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 12px;
  background: var(--bg-secondary); border-top: 1px solid var(--border);
}
.dock-pills { display: flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; overflow-x: auto; overflow-y: hidden; }
.dock-pill {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; flex: none;
  padding: 0 4px 0 12px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); font-size: 12.5px; max-width: 190px;
}
.dock-pill:hover { color: var(--text); background: var(--bg-tertiary); }
/* Subtle active state (no accent outline) — a filled chip, like Linear. */
.dock-pill--active { color: var(--text); background: var(--bg-tertiary); border-color: var(--border); }
.dock-pill-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-pill-close { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; font-size: 15px; line-height: 1; color: var(--text-muted); }
.dock-pill-close:hover { color: var(--text); }

.dock-bar-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; flex: none;
  border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--text-muted); cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.dock-bar-btn:hover { background: var(--bg-tertiary); color: var(--text); }
.dock-history-btn { width: 32px; justify-content: center; }
.dock-launcher { padding: 0 14px; font-size: 13px; font-weight: 500; }
.dock-launcher-logo {
  width: 16px; height: 16px; flex: none; border-radius: 3px;
  background-image: url("/assets/logo-f6cc59c8.png"); background-size: 135%;
  background-position: center 45%; background-repeat: no-repeat;
}
/* Active only while its new-chat panel is open. */
.dock-launcher--active { background: var(--bg-tertiary); border-color: var(--border); color: var(--text); }

/* --- floating panel --- */
.dock-panel {
  position: fixed; right: 20px; bottom: 56px; z-index: 1090;
  width: 400px; height: 560px; max-height: calc(100dvh - 100px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 16px 48px rgba(0,0,0,0.55);
}
.dock-panel--max { width: min(760px, calc(100vw - 40px)); height: calc(100dvh - 100px); }
.dock-panel[hidden], .dock-history-popover[hidden] { display: none; }
.dock-panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px 9px 14px; border-bottom: 1px solid var(--border); flex: none;
}
.dock-panel-title { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-panel-controls { display: flex; align-items: center; gap: 2px; flex: none; }
.dock-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border: none; background: transparent; color: var(--text-muted); border-radius: 6px; cursor: pointer;
}
.dock-icon-btn:hover { background: var(--bg-tertiary); color: var(--text); }

.dock-frame { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* While the frame fetches another chat, hide the stale content so the previous
   thread doesn't flash before the new one arrives. */
/* Hide stale content only while SWITCHING chats (the controller sets
   data-switching when it changes the frame src) — not on in-frame message
   submits, which also make the frame busy but must not blank the thread. */
.dock-frame[data-switching] > * { visibility: hidden; }
.dock-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dock-chat-log { flex: 1; overflow-y: auto; padding: 16px; }

/* Thin, subtle overlay scrollbar for the dock scroll areas (Linear-style). */
.dock-chat-log, .dock-history-list, .dock-pills {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 22%, transparent) transparent;
  overscroll-behavior: contain; /* don't chain scroll to the page behind the sheet */
}
.dock-chat-log::-webkit-scrollbar,
.dock-history-list::-webkit-scrollbar,
.dock-pills::-webkit-scrollbar { width: 10px; height: 10px; }
.dock-chat-log::-webkit-scrollbar-track,
.dock-history-list::-webkit-scrollbar-track,
.dock-pills::-webkit-scrollbar-track { background: transparent; }
.dock-chat-log::-webkit-scrollbar-thumb,
.dock-history-list::-webkit-scrollbar-thumb,
.dock-pills::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text) 20%, transparent);
  border-radius: 999px; border: 3px solid transparent; background-clip: padding-box;
}
.dock-chat-log::-webkit-scrollbar-thumb:hover,
.dock-history-list::-webkit-scrollbar-thumb:hover,
.dock-pills::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text) 34%, transparent); background-clip: padding-box;
}
.dock-chat-log #chat_messages { display: flex; flex-direction: column; gap: 18px; }
.dock-chat-composer { position: static; padding: 10px; background: var(--bg-secondary); }
.dock-chat-composer form { margin: 0; }

/* new-chat intro */
.dock-chat--new { justify-content: flex-end; }
.dock-chat-intro { padding: 24px 18px 8px; }
.dock-chat-intro-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 6px; }
.dock-chat-intro-hint { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* --- history popover --- */
.dock-history-popover {
  position: fixed; right: 12px; bottom: 56px; z-index: 1090;
  width: 340px; max-height: min(60vh, 520px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 16px 48px rgba(0,0,0,0.55);
}
.dock-history-frame { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.dock-history-head { padding: 12px 14px 6px; }
.dock-history-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.dock-history-search { padding: 4px 12px 10px; border-bottom: 1px solid var(--border); }
.dock-history-search-input {
  width: 100%; height: 32px; padding: 0 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text); font-size: 13px;
}
.dock-history-search-input:focus { outline: none; border-color: var(--link); }
.dock-history-list { list-style: none; overflow-y: auto; padding: 6px; }
.dock-history-item { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.dock-history-item:hover { background: var(--bg-tertiary); text-decoration: none; }
.dock-history-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.dock-history-item-time { flex: none; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.dock-history-empty { padding: 18px 14px; color: var(--text-muted); font-size: 13px; }

/* Floating action button — the mobile entry point (shown in the media query
   below). Navigates to the chat as a normal page; no overlay. */
.dock-fab {
  display: none;
  position: fixed; z-index: 1100;
  right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  width: 52px; height: 52px; border-radius: 50%;
  align-items: center; justify-content: center;
  background: var(--bg-secondary); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5); cursor: pointer;
}
.dock-fab:active { transform: scale(0.96); }
.dock-fab .dock-launcher-logo { width: 30px; height: 30px; border-radius: 6px; }

/* --- full-page chat shell (the mobile surface; also desktop deep links) --- */
.chat-page { max-width: 760px; margin: 0 auto; }
.chat-page-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; background: var(--bg);
}
.chat-page-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; color: var(--text-muted); flex: none;
}
.chat-page-back:hover { color: var(--text); background: var(--bg-tertiary); text-decoration: none; }
.chat-page-title {
  flex: 1; min-width: 0; font-weight: 600; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-page-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.chat-page-log #chat_messages { display: flex; flex-direction: column; gap: 18px; }
/* New-chat page: park the intro + composer near the top, under the bar. */
.chat-page--new .dock-chat-intro { padding: 16px 0 8px; }
.dock-history-search--page { padding: 0 0 10px; border-bottom: none; }

@media (max-width: 640px) {
  /* No bottom taskbar on mobile — it steals vertical space and collides with
     the browser chrome. Chat is a normal page reached via the FAB; the dock's
     desktop chrome is hidden entirely. */
  .dock-bar, .dock-panel, .dock-history-popover { display: none; }
  main { padding-bottom: 24px; }
  .dock-fab { display: flex; }
  /* Except on pages with their own bottom composer (project steer bar, chat
     pages), which the FAB would sit on top of. */
  body:has(.composer) .dock-fab, body:has(.chat-page) .dock-fab { display: none; }

  /* No taskbar to clear — page composers sit on the real bottom edge. */
  .composer { bottom: 0; }
}
