/* AI Factory Workspace — every color comes from --ws-* variables generated from theme-*.json. */

:root {
  --ws-font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --ws-font-mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ws-radius-sm: calc(var(--ws-border-radius) * 0.6);
  --ws-topbar-height: 52px;

  /* Bootstrap integration */
  --bs-body-font-family: var(--ws-font-sans);
  --bs-body-bg: var(--ws-background);
  --bs-body-color: var(--ws-text);
  --bs-border-color: var(--ws-border);
  --bs-secondary-color: var(--ws-text-muted);
  --bs-tertiary-bg: var(--ws-surface-elevated);
  --bs-link-color-rgb: inherit;
}

[x-cloak] { display: none !important; }

html, body { background: var(--ws-background); color: var(--ws-text); }
body {
  font-family: var(--ws-font-sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--ws-primary); outline-offset: 2px; }
kbd { background: var(--ws-code-background); color: var(--ws-text); border: 1px solid var(--ws-border); font-size: 0.75em; padding: 0.05rem 0.3rem; box-shadow: none; }

.text-muted-ws { color: var(--ws-text-muted) !important; }
.text-danger-ws { color: var(--ws-danger) !important; }
.text-warning-ws { color: var(--ws-warning) !important; }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--ws-radius-sm); font-weight: 500; font-size: 0.875rem; display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-sm { font-size: 0.8125rem; padding: 0.3rem 0.65rem; }
.btn-ws-primary { background: var(--ws-primary); color: var(--ws-primary-text); border: 1px solid var(--ws-primary); }
.btn-ws-primary:hover, .btn-ws-primary:focus-visible { background: var(--ws-primary-hover); border-color: var(--ws-primary-hover); color: var(--ws-primary-text); }
.btn-ws-primary:disabled { background: var(--ws-primary); border-color: var(--ws-primary); color: var(--ws-primary-text); opacity: 0.45; }
.btn-ws-ghost { background: var(--ws-surface); color: var(--ws-text); border: 1px solid var(--ws-border); }
.btn-ws-ghost:hover { background: var(--ws-accent); color: var(--ws-text); border-color: var(--ws-border); }
.btn-ws-danger { background: var(--ws-danger); color: #fff; border: 1px solid var(--ws-danger); }
.btn-ws-danger:hover { filter: brightness(1.08); color: #fff; }
.btn-ws-danger-ghost { background: transparent; color: var(--ws-danger); border: 1px solid transparent; }
.btn-ws-danger-ghost:hover { background: color-mix(in srgb, var(--ws-danger) 10%, transparent); color: var(--ws-danger); }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--ws-radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--ws-text-muted);
  transition: background-color .12s, color .12s;
}
.icon-button:hover { background: var(--ws-accent); color: var(--ws-text); }
.icon-button-sm { width: 26px; height: 26px; font-size: 0.85rem; }

.ws-input, .form-control.ws-input, .form-select.ws-input {
  background-color: var(--ws-input-background); color: var(--ws-text);
  border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm);
}
.ws-input:focus { background-color: var(--ws-input-background); color: var(--ws-text); border-color: var(--ws-primary); box-shadow: 0 0 0 3px var(--ws-focus); outline: none; }
.form-label { font-size: 0.8125rem; font-weight: 500; color: var(--ws-text-muted); }
.form-error { color: var(--ws-danger); font-size: 0.85rem; margin: 0.75rem 0 0; }

/* ---------- Top bar ---------- */
.app-topbar {
  position: sticky; top: 0; z-index: 1020;
  height: var(--ws-topbar-height);
  background: color-mix(in srgb, var(--ws-surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--ws-border);
}
.app-topbar-inner { height: 100%; display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; }
.app-brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 650; letter-spacing: -0.01em; }
.app-brand-mark {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--ws-primary); color: var(--ws-primary-text); font-size: 0.85rem;
}
.app-nav { display: flex; align-items: center; gap: 0.15rem; }
.app-nav-link {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.65rem; border-radius: var(--ws-radius-sm);
  font-size: 0.875rem; font-weight: 500; color: var(--ws-text-muted); white-space: nowrap;
}
.app-nav-link:hover { color: var(--ws-text); background: var(--ws-accent); }
.app-nav-link.is-active { color: var(--ws-text); background: var(--ws-accent); }
.app-nav-link.is-active .bi { color: var(--ws-primary); }
.app-nav + .app-breadcrumb:not(:empty) { padding-left: 0.75rem; border-left: 1px solid var(--ws-border); }
.app-breadcrumb { display: flex; align-items: center; gap: 0.5rem; min-width: 0; font-size: 0.875rem; color: var(--ws-text-muted); }
.crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb:hover { color: var(--ws-text); }
.crumb-current { color: var(--ws-text); font-weight: 500; }
.crumb-separator { opacity: 0.5; }
.app-topbar-actions { margin-left: auto; display: flex; gap: 0.25rem; }

.app-banner {
  display: flex; gap: 0.75rem; align-items: flex-start;
  margin: 1rem auto 0; max-width: 1080px; padding: 0.75rem 1rem;
  border: 1px solid color-mix(in srgb, var(--ws-warning) 45%, var(--ws-border));
  background: color-mix(in srgb, var(--ws-warning) 10%, var(--ws-surface));
  border-radius: var(--ws-border-radius); font-size: 0.875rem;
}
.app-banner ul { margin: 0.25rem 0 0; padding-left: 1.1rem; color: var(--ws-text-muted); }
.app-banner .icon-button { margin-left: auto; }

/* ---------- Pages ---------- */
.app-main { padding: 2rem 1.25rem 4rem; }
.page { margin: 0 auto; }
.page-narrow { max-width: 1080px; }
.page-wide { max-width: 1480px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.page-subtitle { color: var(--ws-text-muted); margin: 0.35rem 0 0; max-width: 70ch; }

.search-bar {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--ws-input-background); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius);
  padding: 0 0.85rem; height: 42px; margin-bottom: 1.5rem; color: var(--ws-text-muted);
}
.search-bar:focus-within { border-color: var(--ws-primary); box-shadow: 0 0 0 3px var(--ws-focus); }
.search-bar input { flex: 1; border: 0; background: transparent; color: var(--ws-text); outline: none; min-width: 0; }
.search-bar-sm { height: 34px; margin: 0; max-width: 320px; flex: 1; }
.search-count { font-size: 0.8125rem; white-space: nowrap; }

/* ---------- Project list ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; transition: opacity .15s; }
.project-grid.is-loading { opacity: 0.55; }
.project-card {
  display: flex; flex-direction: column; gap: 0.85rem; padding: 1.1rem 1.15rem;
  background: var(--ws-surface); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius);
  box-shadow: var(--ws-shadow); transition: border-color .15s, transform .15s;
}
.project-card:hover, .project-card:focus-visible { border-color: color-mix(in srgb, var(--ws-primary) 55%, var(--ws-border)); transform: translateY(-1px); }
.project-card-head { display: flex; gap: 0.75rem; align-items: center; }
.project-avatar {
  width: 36px; height: 36px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: var(--ws-accent); color: var(--ws-primary); font-weight: 650; font-size: 0.85rem;
}
.project-card-titles { min-width: 0; }
.library-avatar { font-size: 1rem; }
.library-error { font-size: 0.75rem; color: var(--ws-warning); display: inline-flex; gap: 0.3rem; align-items: center; margin-top: auto; }
.library-detail-head { display: flex; align-items: flex-start; gap: 0.85rem; min-width: 0; }
.library-detail-head .library-avatar { width: 44px; height: 44px; font-size: 1.25rem; }
.library-toolbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.library-warning {
  display: flex; gap: 0.6rem; align-items: flex-start; margin-bottom: 0.75rem; padding: 0.6rem 0.85rem; font-size: 0.85rem;
  border: 1px solid color-mix(in srgb, var(--ws-warning) 50%, var(--ws-border)); border-radius: var(--ws-radius-sm);
  background: color-mix(in srgb, var(--ws-warning) 8%, var(--ws-surface));
}
.library-body-input { font-family: var(--ws-font-mono); font-size: 0.85rem; }
.assignee-chip { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.72rem; color: var(--ws-text-muted); }
.project-name { font-size: 1rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-id { font-family: var(--ws-font-mono); font-size: 0.75rem; color: var(--ws-text-muted); }
.project-open { margin-left: auto; color: var(--ws-text-muted); opacity: 0; transition: opacity .15s; }
.project-card:hover .project-open { opacity: 1; }
.project-description {
  margin: 0; color: var(--ws-text-muted); font-size: 0.875rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em;
}
.project-description.is-empty { font-style: italic; opacity: 0.7; }

.status-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; }
.status-pill {
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; color: var(--ws-text-muted);
  background: var(--ws-column-background); border-radius: 999px; padding: 0.15rem 0.55rem;
}
.status-pill strong { color: var(--ws-text); font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ws-text-muted); flex: none; display: inline-block; }
.tone-active .status-dot, .status-dot.tone-active { background: var(--ws-primary); }
.tone-waiting .status-dot, .status-dot.tone-waiting { background: var(--ws-warning); }
.tone-end .status-dot, .status-dot.tone-end { background: var(--ws-success); }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.75rem; }
.pager-info { font-size: 0.8125rem; color: var(--ws-text-muted); }

.empty-state { text-align: center; padding: 4rem 1rem; border: 1px dashed var(--ws-border); border-radius: var(--ws-border-radius); }
.empty-state-icon {
  width: 52px; height: 52px; margin: 0 auto 1rem; border-radius: 14px; display: grid; place-items: center;
  background: var(--ws-accent); color: var(--ws-primary); font-size: 1.4rem;
}
.empty-state h2 { font-size: 1.1rem; font-weight: 600; }
.empty-state p { color: var(--ws-text-muted); margin-bottom: 1.25rem; }

/* ---------- Modals & toasts ---------- */
.app-modal-backdrop {
  position: fixed; inset: 0; z-index: 1060; display: grid; place-items: center; padding: 1rem;
  background: rgba(10, 10, 12, 0.45);
}
.app-modal {
  width: 100%; max-width: 480px; max-height: calc(100vh - 2rem); overflow: auto;
  background: var(--ws-surface-elevated); color: var(--ws-text);
  border: 1px solid var(--ws-border); border-radius: calc(var(--ws-border-radius) * 1.3);
  padding: 1.5rem; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.column-preview { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.column-chip {
  font-size: 0.75rem; padding: 0.1rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--ws-border); background: var(--ws-surface); color: var(--ws-text);
}
.app-modal-sm { max-width: 420px; }
.app-modal-lg { max-width: 1000px; }
.app-modal-title { font-size: 1.1rem; font-weight: 650; margin-bottom: 0.5rem; display: flex; gap: 0.5rem; align-items: center; }
.app-modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.5rem; }

.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; display: flex; flex-direction: column; gap: 0.5rem; max-width: min(420px, calc(100vw - 2rem)); }
.app-toast {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.6rem 0.6rem 0.85rem; font-size: 0.875rem;
  background: var(--ws-surface-elevated); border: 1px solid var(--ws-border); border-left-width: 3px;
  border-radius: var(--ws-radius-sm); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.app-toast span { flex: 1; }
.app-toast-success { border-left-color: var(--ws-success); } .app-toast-success > .bi:first-child { color: var(--ws-success); }
.app-toast-error { border-left-color: var(--ws-danger); } .app-toast-error > .bi:first-child { color: var(--ws-danger); }
.app-toast-warning { border-left-color: var(--ws-warning); } .app-toast-warning > .bi:first-child { color: var(--ws-warning); }
.app-toast-info { border-left-color: var(--ws-primary); } .app-toast-info > .bi:first-child { color: var(--ws-primary); }

/* ---------- Dashboard ---------- */
.project-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.project-header-main { flex: 1; min-width: 0; }
.task-dependencies { display: flex; flex-direction: column; gap: 0.25rem; margin: 0; padding: 0; list-style: none; font-size: 0.82rem; }
.task-dependencies li { display: flex; gap: 0.4rem; min-width: 0; overflow-wrap: anywhere; }
.clone-box {
  display: flex; align-items: center; gap: 0.5rem; width: min(100%, 34rem); margin-top: 0.6rem; padding: 0.2rem 0.3rem 0.2rem 0.6rem;
  border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm); background: var(--ws-surface);
}
.clone-box-label { flex: none; font-size: 0.72rem; font-weight: 600; color: var(--ws-text-muted); }
.clone-box-url { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ws-text); font-family: var(--ws-font-mono); font-size: 0.8rem; }
.project-folder {
  font-family: var(--ws-font-mono); font-size: 0.75rem; color: var(--ws-text-muted); white-space: nowrap;
  border: 1px solid var(--ws-border); border-radius: 999px; padding: 0.2rem 0.65rem;
}
.view-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--ws-border); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.view-tab {
  display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap;
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 0.55rem 0.75rem; color: var(--ws-text-muted); font-size: 0.875rem; font-weight: 500;
}
.view-tab:hover { color: var(--ws-text); }
.view-tab[aria-selected="true"] { color: var(--ws-text); border-bottom-color: var(--ws-primary); }
.sync-icon { font-size: 0.75rem; opacity: 0.7; }

.board-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.board-count { font-size: 0.8125rem; color: var(--ws-text-muted); }

.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(290px, 1fr); gap: 0.85rem;
  overflow-x: auto; padding-bottom: 0.5rem; align-items: start;
}
.board-column {
  background: var(--ws-column-background); border: 1px solid transparent; border-radius: var(--ws-border-radius);
  padding: 0.6rem; min-height: 240px; display: flex; flex-direction: column; gap: 0.5rem;
  transition: border-color .12s, background-color .12s;
}
.board-column.is-drop-target { border-color: var(--ws-primary); background: color-mix(in srgb, var(--ws-primary) 6%, var(--ws-column-background)); }
.column-header { display: flex; align-items: center; gap: 0.5rem; padding: 0.15rem 0.25rem; }
.column-title { font-size: 0.8125rem; font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ws-text-muted); }
.column-count {
  font-size: 0.72rem; font-weight: 600; color: var(--ws-text-muted); background: var(--ws-surface);
  border: 1px solid var(--ws-border); border-radius: 999px; padding: 0 0.45rem; line-height: 1.5;
}
.column-cards { display: flex; flex-direction: column; gap: 0.5rem; }
.column-empty {
  border: 1px dashed var(--ws-border); border-radius: var(--ws-radius-sm); padding: 1.5rem 0.5rem;
  text-align: center; font-size: 0.8125rem; color: var(--ws-text-muted);
}

.new-task-form { background: var(--ws-card-background); border: 1px solid var(--ws-primary); border-radius: var(--ws-radius-sm); padding: 0.5rem; }
.new-task-input { width: 100%; resize: none; border: 0 !important; box-shadow: none !important; font-size: 0.9rem; padding: 0.25rem; }
.new-task-actions { display: flex; justify-content: flex-end; gap: 0.4rem; }

.task-card {
  position: relative; background: var(--ws-card-background); border: 1px solid var(--ws-border);
  border-radius: var(--ws-radius-sm); padding: 0.7rem 0.8rem; cursor: pointer; box-shadow: var(--ws-shadow);
  transition: border-color .12s, box-shadow .12s, opacity .12s;
}
.task-card:hover { border-color: color-mix(in srgb, var(--ws-text-muted) 45%, var(--ws-border)); }
.task-card:focus-visible { outline: none; border-color: var(--ws-primary); box-shadow: 0 0 0 3px var(--ws-focus); }
.task-card.is-dragging { opacity: 0.45; }
.task-card.priority-urgent::before, .task-card.priority-high::before {
  content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--ws-warning);
}
.task-card.priority-urgent::before { background: var(--ws-danger); }
.task-card.has-error { border-color: color-mix(in srgb, var(--ws-danger) 50%, var(--ws-border)); }
.task-card-top { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.3rem; }
.task-id { font-family: var(--ws-font-mono); font-size: 0.72rem; color: var(--ws-text-muted); }
.task-card .dropdown .icon-button { opacity: 0; }
.task-card:hover .dropdown .icon-button, .task-card:focus-within .dropdown .icon-button, .task-card .dropdown .icon-button[aria-expanded="true"] { opacity: 1; }
.task-title { font-size: 0.9rem; font-weight: 550; line-height: 1.4; margin: 0; word-break: break-word; }
.task-excerpt {
  margin: 0.3rem 0 0; font-size: 0.8125rem; color: var(--ws-text-muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-error { margin: 0.35rem 0 0; font-size: 0.78rem; color: var(--ws-danger); }
.task-meta { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.6rem; font-size: 0.75rem; color: var(--ws-text-muted); }
.task-meta:empty { display: none; }
.meta-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.meta-item.is-complete { color: var(--ws-success); }
.checklist-bar { width: 34px; height: 4px; border-radius: 2px; background: var(--ws-border); overflow: hidden; display: inline-block; }
.checklist-bar span { display: block; height: 100%; background: currentColor; }

.priority-badge { font-size: 0.68rem; font-weight: 600; border-radius: 4px; padding: 0.05rem 0.35rem; text-transform: uppercase; letter-spacing: 0.03em; }
.priority-badge.priority-low { color: var(--ws-text-muted); background: var(--ws-column-background); }
.priority-badge.priority-high { color: var(--ws-warning); background: color-mix(in srgb, var(--ws-warning) 14%, transparent); }
.priority-badge.priority-urgent { color: var(--ws-danger); background: color-mix(in srgb, var(--ws-danger) 14%, transparent); }

.ws-menu { --bs-dropdown-bg: var(--ws-surface-elevated); --bs-dropdown-border-color: var(--ws-border); --bs-dropdown-link-color: var(--ws-text);
  --bs-dropdown-link-hover-bg: var(--ws-accent); --bs-dropdown-link-hover-color: var(--ws-text); --bs-dropdown-header-color: var(--ws-text-muted);
  font-size: 0.85rem; border-radius: var(--ws-radius-sm); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); }
.ws-menu .dropdown-item { display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Task modal ----------
   Fixed height that always fits the viewport: header and footer stay in place, and the main column has a
   single scroll for the title, details, conversation and usage. The sidebar scrolls on its own. */
.task-modal-backdrop {
  position: fixed; inset: 0; z-index: 1050; display: grid; place-items: center; padding: 1.5rem;
  background: rgba(10, 10, 12, 0.45);
}
.task-modal {
  width: min(80vw, 1400px); height: min(calc(100dvh - 3rem), 1000px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ws-surface-elevated); color: var(--ws-text);
  border: 1px solid var(--ws-border); border-radius: calc(var(--ws-border-radius) * 1.3);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}
.task-modal-header {
  flex: none; display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: 0.7rem 0.85rem 0.7rem 1.25rem; border-bottom: 1px solid var(--ws-border);
}
.task-modal-heading { margin: 0; font-size: 0.95rem; }
.task-modal-heading .task-id { font-size: 0.9rem; color: var(--ws-text); font-weight: 600; }
.task-modal-dates { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--ws-text-muted); }
.task-modal-dates .bi { margin-right: 0.2rem; }
.task-modal-loading { flex: 1; display: grid; place-items: center; color: var(--ws-text-muted); }

.task-modal-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.task-sidebar {
  min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; padding: 1.1rem 1rem;
  border-right: 1px solid var(--ws-border); background: var(--ws-surface);
}
.task-sidebar > * { flex: none; }
.task-main { min-height: 0; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem 1.25rem 1.1rem; }
.task-main > * { flex: none; }
.task-title-input {
  flex: none; width: 100%; border: 0; background: transparent; color: var(--ws-text); outline: none;
  font-size: 1.4rem; font-weight: 700; letter-spacing: -0.015em; padding: 0.1rem 0; border-bottom: 1px solid transparent;
}
.task-title-input:focus { border-bottom-color: var(--ws-primary); }
.task-main .workbench { min-height: 0; }
.task-main .workbench-toolbar .save-indicator { display: none; } /* shown in the modal footer instead */
.task-main .workbench-hint { margin-left: auto; }
.task-main .workbench-editor { min-height: 240px; }
.task-main .workbench .cm-editor { min-height: 240px; height: auto; }

.task-modal-footer {
  flex: none; display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1.25rem; border-top: 1px solid var(--ws-border); background: var(--ws-surface);
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ws-text-muted); font-weight: 600; margin: 0; }
.field-hint { font-size: 0.72rem; color: var(--ws-text-muted); align-self: flex-end; }
.field-hint:hover { color: var(--ws-primary); text-decoration: underline; }

.attachments { display: flex; flex-direction: column; min-height: 140px; }
.task-sidebar > .attachments { flex: 1 0 140px; }
.attachments-header { flex: none; display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.attachments-header h3 { display: flex; align-items: center; gap: 0.4rem; }
.dropzone {
  flex: 1; min-height: 70px; overflow-y: auto; border: 1px dashed var(--ws-border); border-radius: var(--ws-radius-sm);
  padding: 0.35rem; transition: border-color .12s, background-color .12s;
}
.dropzone.is-over { border-color: var(--ws-primary); background: var(--ws-accent); }
.dropzone-hint { margin: 0; padding: 1rem 0.25rem; text-align: center; font-size: 0.78rem; color: var(--ws-text-muted); }
.attachment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.attachment { display: flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.3rem; border-radius: var(--ws-radius-sm); font-size: 0.8rem; }
.attachment:hover { background: var(--ws-accent); }
.attachment > .bi { color: var(--ws-text-muted); }
.attachment-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-name:hover { text-decoration: underline; }
.attachment-size { color: var(--ws-text-muted); font-size: 0.7rem; }
.attachment .icon-button { opacity: 0; }
.attachment:hover .icon-button, .attachment:focus-within .icon-button { opacity: 1; }

/* ---------- Documents ---------- */
.document-section { width: 100%; }
.document-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.document-files { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.file-chip {
  display: inline-flex; align-items: center; gap: 0.35rem; font-family: var(--ws-font-mono); font-size: 0.78rem;
  border: 1px solid var(--ws-border); background: var(--ws-surface); border-radius: 6px; padding: 0.15rem 0.5rem;
}
.sync-note { font-size: 0.78rem; color: var(--ws-text-muted); display: inline-flex; gap: 0.3rem; align-items: center; }
.document-loading { color: var(--ws-text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.divergence {
  border: 1px solid color-mix(in srgb, var(--ws-warning) 50%, var(--ws-border));
  background: color-mix(in srgb, var(--ws-warning) 8%, var(--ws-surface));
  border-radius: var(--ws-border-radius); padding: 1rem; margin-bottom: 1rem;
}
.divergence-head { display: flex; gap: 0.75rem; margin-bottom: 1rem; font-size: 0.9rem; }
.divergence-head > .bi { color: var(--ws-warning); font-size: 1.2rem; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.compare-title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.compare-title { font-size: 0.8rem; font-family: var(--ws-font-mono); font-weight: 600; margin: 0 0 0.4rem; }
.compare-title-row .compare-title { margin: 0; }
.compare-pane {
  background: var(--ws-code-background); border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm);
  padding: 0.75rem; font-size: 0.8rem; max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0;
}

/* ---------- Workbench (editor + preview) ---------- */
.workbench {
  background: var(--ws-surface); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius);
  display: flex; flex-direction: column; min-height: 360px;
}
.workbench-toolbar {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--ws-border); flex-wrap: wrap;
}
.workbench-hint { font-size: 0.75rem; color: var(--ws-text-muted); }
.segmented { display: inline-flex; background: var(--ws-column-background); border-radius: var(--ws-radius-sm); padding: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--ws-text-muted); font-size: 0.8rem; font-weight: 500;
  padding: 0.25rem 0.6rem; border-radius: calc(var(--ws-radius-sm) - 2px); display: inline-flex; gap: 0.35rem; align-items: center;
}
.segmented button[aria-selected="true"], .segmented button[aria-checked="true"] { background: var(--ws-surface-elevated); color: var(--ws-text); box-shadow: var(--ws-shadow); }
.save-indicator { margin-left: auto; display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--ws-text-muted); }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ws-border); }
.save-dirty .save-dot { background: var(--ws-warning); }
.save-saving .save-dot { background: var(--ws-primary); animation: pulse 1s infinite; }
.save-saved .save-dot { background: var(--ws-success); }
.save-error { color: var(--ws-danger); } .save-error .save-dot { background: var(--ws-danger); }
@keyframes pulse { 50% { opacity: 0.3; } }

.workbench-body { display: grid; grid-template-columns: 1fr; flex: 1; min-height: 0; }
.mode-split .workbench-body { grid-template-columns: 1fr 1fr; }
.mode-split .workbench-preview { border-left: 1px solid var(--ws-border); }
.workbench-editor { min-width: 0; min-height: 320px; }
.workbench-preview { padding: 1rem 1.5rem; min-width: 0; overflow-wrap: anywhere; transition: opacity .15s; }
.workbench-preview.is-stale { opacity: 0.7; }

/* CodeMirror */
.workbench .cm-editor { height: 100%; min-height: 320px; background: transparent; color: var(--ws-text); font-size: 0.95rem; }
.workbench .cm-editor.cm-focused { outline: none; }
.workbench .cm-scroller { font-family: var(--ws-font-sans); line-height: 1.7; }
.workbench .cm-content { padding: 1rem 0.25rem; caret-color: var(--ws-text); }
.workbench .cm-line { padding: 0 1.25rem; }
.workbench .cm-cursor { border-left-color: var(--ws-text); }
.workbench .cm-activeLine { background: color-mix(in srgb, var(--ws-accent) 45%, transparent); }
.workbench .cm-selectionBackground, .workbench .cm-focused .cm-selectionBackground { background: var(--ws-focus) !important; }
.workbench .cm-placeholder { color: var(--ws-text-muted); }
.workbench .cm-gutters { display: none; }

.cm-tooltip.slash-menu, .cm-tooltip.cm-tooltip-autocomplete {
  background: var(--ws-surface-elevated); border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); padding: 0.25rem; overflow: hidden;
}
.cm-tooltip.cm-tooltip-autocomplete > ul { font-family: var(--ws-font-sans); max-height: 320px; min-width: 250px; }
.cm-tooltip.cm-tooltip-autocomplete > ul > li.slash-option {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0.55rem; border-radius: 6px; color: var(--ws-text); font-size: 0.875rem;
}
.cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected] { background: var(--ws-accent); color: var(--ws-text); }
.slash-icon {
  width: 26px; height: 26px; display: grid; place-items: center; flex: none; border-radius: 6px;
  background: var(--ws-column-background); border: 1px solid var(--ws-border); color: var(--ws-text-muted);
}
.slash-option .cm-completionLabel { flex: 1; }
.slash-option .cm-completionDetail { font-family: var(--ws-font-mono); font-style: normal; font-size: 0.75rem; color: var(--ws-text-muted); margin-left: 0.75rem; }
.slash-option .cm-completionMatchedText { text-decoration: none; font-weight: 600; }

/* Rendered Markdown */
.markdown-body { font-size: 0.95rem; line-height: 1.7; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { font-weight: 650; letter-spacing: -0.015em; margin: 1.4em 0 0.5em; line-height: 1.3; }
.markdown-body h1 { font-size: 1.6rem; } .markdown-body h2 { font-size: 1.3rem; } .markdown-body h3 { font-size: 1.1rem; } .markdown-body h4 { font-size: 1rem; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body pre, .markdown-body table { margin: 0 0 1em; }
.markdown-body a { color: var(--ws-primary); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body code { font-family: var(--ws-font-mono); font-size: 0.85em; background: var(--ws-code-background); color: var(--ws-text); padding: 0.1em 0.35em; border-radius: 4px; }
.markdown-body pre { background: var(--ws-code-background); border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm); padding: 0.85rem 1rem; overflow-x: auto; }
.markdown-body pre code { background: none; padding: 0; font-size: 0.85rem; }
.markdown-body blockquote { border-left: 3px solid var(--ws-border); padding: 0.1rem 0 0.1rem 1rem; color: var(--ws-text-muted); }
.markdown-body hr { border: 0; border-top: 1px solid var(--ws-border); opacity: 1; margin: 1.5rem 0; }
.markdown-body img { max-width: 100%; border-radius: var(--ws-radius-sm); }
.markdown-body table { border-collapse: collapse; width: auto; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { border: 1px solid var(--ws-border); padding: 0.4rem 0.75rem; }
.markdown-body th { background: var(--ws-column-background); font-weight: 600; }
.markdown-body li.task-list-item { list-style: none; }
.markdown-body ul.contains-task-list { padding-left: 0.5rem; }
.markdown-body .task-list-item-checkbox {
  width: 1.05em; height: 1.05em; margin: 0 0.5rem 0 -0.1rem; vertical-align: -0.15em; cursor: pointer; accent-color: var(--ws-primary);
}
.markdown-body .task-list-item-checkbox:disabled { cursor: progress; }
.markdown-body li.task-list-item:has(> .task-list-item-checkbox:checked), .markdown-body li.task-list-item:has(> p > .task-list-item-checkbox:checked) {
  color: var(--ws-text-muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ws-text-muted) 60%, transparent);
}

/* ---------- Notes (tree + editor) ---------- */
.app-main:has(> .notes-app) { padding-bottom: 1.25rem; }
.notes-app {
  display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: 1rem;
  height: calc(100dvh - var(--ws-topbar-height) - 3.25rem); min-height: 420px; max-width: 1680px; margin: 0 auto;
}
.notes-sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--ws-surface); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius);
}
.notes-sidebar-head { display: flex; align-items: center; gap: 0.15rem; padding: 0.6rem 0.6rem 0.6rem 0.9rem; border-bottom: 1px solid var(--ws-border); }
.notes-sidebar-title { font-size: 0.95rem; font-weight: 650; margin: 0 auto 0 0; }
.notes-tree { flex: 1; min-height: 0; overflow-y: auto; padding: 0.4rem; }
.notes-tree-empty { text-align: center; padding: 2rem 0.5rem; color: var(--ws-text-muted); font-size: 0.875rem; }
.notes-row { display: flex; align-items: center; border-radius: var(--ws-radius-sm); }
.notes-row:hover { background: var(--ws-accent); }
.notes-row.is-selected { background: color-mix(in srgb, var(--ws-primary) 14%, transparent); }
.notes-row-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.35rem; border: 0; background: transparent; color: var(--ws-text);
  font-size: 0.875rem; text-align: left; padding: 0.3rem 0.4rem 0.3rem 0.25rem; border-radius: inherit;
}
.notes-row-chevron {
  width: 0.9rem; flex: none; font-size: 0.7rem; color: var(--ws-text-muted);
  align-self: stretch; margin-block: -0.3rem; display: flex; align-items: center; justify-content: center; position: relative;
}
/* Dotted guide lines: one 1.25rem column per level. The chevron sits right after the columns (its negative margin
   cancels the flex gap), so each vertical line runs under its folder's chevron centre (half of 0.9rem). */
.notes-row-main { --guide-color: color-mix(in srgb, var(--ws-text-muted) 55%, transparent); --guide-x: 0.45rem; }
.notes-guides { display: flex; flex: none; align-self: stretch; margin-block: -0.3rem; }
.notes-guide { position: relative; width: 1.25rem; flex: none; }
.notes-guides + .notes-row-chevron { margin-left: -0.35rem; }
.notes-guide::before, .notes-guide::after { content: ""; position: absolute; }
.notes-guide-pipe::before, .notes-guide-tee::before { left: var(--guide-x); top: 0; bottom: 0; border-left: 1px dotted var(--guide-color); }
.notes-guide-elbow::before { left: var(--guide-x); top: 0; height: 50%; border-left: 1px dotted var(--guide-color); }
.notes-guide-tee::after, .notes-guide-elbow::after { left: var(--guide-x); right: -0.1rem; top: 50%; border-top: 1px dotted var(--guide-color); }
.notes-row:not(.is-folder) .notes-guide-tee::after, .notes-row:not(.is-folder) .notes-guide-elbow::after { right: -1.1rem; }
/* Drag and drop of folders. */
.notes-row { position: relative; }
.notes-row.is-dragging { opacity: 0.45; }
.notes-row.drop-inside { background: color-mix(in srgb, var(--ws-primary) 14%, transparent); box-shadow: inset 0 0 0 1px var(--ws-primary); }
.notes-row.drop-before::before, .notes-row.drop-after::before {
  content: ""; position: absolute; left: 0.25rem; right: 0.25rem; height: 2px; background: var(--ws-primary); border-radius: 1px; pointer-events: none;
}
.notes-row.drop-before::before { top: -1px; }
.notes-row.drop-after::before { bottom: -1px; }
.notes-tree.drop-root { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ws-primary) 45%, transparent); border-radius: var(--ws-radius-sm); }
.notes-tree-hint { margin: 0; padding: 0.45rem 0.9rem; border-top: 1px solid var(--ws-border); font-size: 0.72rem; color: var(--ws-text-muted); }
/* An open folder starts the line that its children continue. */
.notes-row.is-open .notes-row-chevron::after {
  content: ""; position: absolute; left: 50%; top: calc(50% + 0.45rem); bottom: 0; border-left: 1px dotted var(--guide-color);
}
.notes-row-icon { flex: none; color: var(--ws-text-muted); }
.notes-row.is-folder .notes-row-icon { color: var(--ws-warning); }
.notes-row.is-selected .notes-row-name { font-weight: 600; }
.notes-row.is-selected:not(.is-folder) .notes-row-icon { color: var(--ws-primary); }
.notes-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-row-actions { display: none; flex: none; padding-right: 0.15rem; }
.notes-row:hover .notes-row-actions, .notes-row:focus-within .notes-row-actions { display: inline-flex; }
.notes-row-danger:hover { color: var(--ws-danger); }
.notes-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.notes-placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem 1rem;
  border: 1px dashed var(--ws-border); border-radius: var(--ws-border-radius);
}
.notes-placeholder h2 { font-size: 1.15rem; font-weight: 600; }
.notes-placeholder p { color: var(--ws-text-muted); max-width: 42ch; margin-bottom: 1.25rem; }
.notes-editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.notes-editor-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.notes-editor-titles { min-width: 0; }
.notes-editor-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; }
.notes-editor-path { font-size: 0.78rem; color: var(--ws-text-muted); font-family: var(--ws-font-mono); overflow-wrap: anywhere; }
.notes-editor .workbench { flex: 1; min-height: 0; }
.notes-editor .workbench-body { min-height: 0; grid-template-rows: minmax(0, 1fr); }
.notes-editor .workbench-editor { min-height: 0; overflow: hidden; }
.notes-editor .workbench .cm-editor { min-height: 0; height: 100%; }
.notes-editor .workbench-preview { min-height: 0; overflow-y: auto; }
@media (hover: none) { .notes-row-actions { display: inline-flex; } }
@media (max-width: 767.98px) {
  .notes-app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); height: auto; min-height: 0; }
  .notes-tree { max-height: 38vh; }
  .notes-main { min-height: 70vh; }
}

/* ---------- Small screens ---------- */
@media (max-width: 767.98px) {
  .app-main { padding: 1.25rem 0.85rem 3rem; }
  .app-brand-name { display: none; }
  .app-nav-link span, .app-breadcrumb { display: none; }
  .page-header, .project-header { flex-direction: column; align-items: stretch; }
  .page-title { font-size: 1.35rem; }
  .board { grid-auto-columns: 86vw; scroll-snap-type: x mandatory; }
  .board-column { scroll-snap-align: start; }
  .task-card .dropdown .icon-button { opacity: 1; }
  .mode-split .workbench-body { grid-template-columns: 1fr; }
  /* Phones: full-screen modal; the sidebar becomes a compact strip above the editor. */
  .task-modal-backdrop { padding: 0; }
  .task-modal { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .task-modal-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .task-sidebar { flex-direction: row; flex-wrap: wrap; gap: 0.75rem; padding: 0.75rem 1rem; border-right: 0; border-bottom: 1px solid var(--ws-border); max-height: 40dvh; }
  .task-sidebar > .field { flex: 1 1 140px; }
  .task-sidebar > .attachments { flex: 1 1 100%; min-height: 0; }
  .dropzone { max-height: 110px; min-height: 0; }
  .task-main { padding: 0.75rem 1rem; }
  .attachment .icon-button { opacity: 1; }
  .search-bar-sm { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Agent skills ---------- */
.skill-options { display: grid; gap: 0.35rem; max-height: 220px; overflow-y: auto; padding: 0.25rem 0; }
.skill-option { display: grid; grid-template-columns: auto 1fr; column-gap: 0.55rem; align-items: start; padding: 0.45rem 0.6rem; border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm); cursor: pointer; }
.skill-option:has(input:checked) { border-color: var(--ws-primary); }
.skill-option input { margin-top: 0.2rem; grid-row: span 2; }
.skill-option-name { font-weight: 600; font-family: var(--ws-font-mono); font-size: 0.82rem; }
.skill-option-description { font-size: 0.76rem; color: var(--ws-text-muted); }
.skill-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }
.skill-chip { font-size: 0.7rem; font-family: var(--ws-font-mono); padding: 0.1rem 0.45rem; border-radius: 999px; border: 1px solid var(--ws-border); color: var(--ws-text-muted); }

/* ---------- Permission requests ---------- */
.permission-alerts { position: fixed; top: calc(var(--ws-topbar-height, 56px) + 0.75rem); right: 1rem; z-index: 1090; display: flex; flex-direction: column; gap: 0.6rem; width: min(400px, calc(100vw - 2rem)); pointer-events: none; }
.permission-alert { pointer-events: auto; background: var(--ws-surface-elevated); color: var(--ws-text); border: 1px solid var(--ws-border); border-left: 4px solid var(--ws-danger); border-radius: var(--ws-border-radius); box-shadow: var(--ws-shadow); padding: 0.8rem 0.9rem; animation: permission-in 0.2s ease-out; }
.permission-alert-head { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.5rem; }
.permission-alert-head .bi { color: var(--ws-danger); font-size: 1.1rem; }
.permission-alert-timer { margin-left: auto; font-family: var(--ws-font-mono); font-size: 0.78rem; color: var(--ws-text-muted); }
.permission-alert-meta { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.7rem; margin: 0; font-size: 0.82rem; }
.permission-alert-meta dt { color: var(--ws-text-muted); font-weight: 500; }
.permission-alert-meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.permission-alert-detail { margin: 0.55rem 0 0; max-height: 140px; overflow: auto; font-size: 0.75rem; background: var(--ws-code-background); border-radius: var(--ws-radius-sm); padding: 0.45rem 0.55rem; white-space: pre-wrap; word-break: break-word; }
.permission-alert-actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 0.7rem; }
.permission-rule { font-size: 0.95rem; overflow-wrap: anywhere; }
@keyframes permission-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .permission-alert { animation: none; } }

/* ---------- Project deletion ---------- */
.project-delete { border: 0; background: none; padding: 0; margin-left: 0.4rem; font-size: 0.85rem; font-weight: 500; color: var(--ws-danger); vertical-align: middle; cursor: pointer; }
.project-delete:hover { text-decoration: underline; }
.project-delete:focus-visible { outline: 2px solid var(--ws-focus); outline-offset: 2px; border-radius: 3px; }

/* ---------- Task blocks ("--- agent | date") ---------- */
.task-block { border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm); padding: 0.75rem 0.9rem; margin-bottom: 0.75rem; background: var(--ws-surface); }
.task-block > :last-child { margin-bottom: 0; }
.task-block-agent { border-left: 3px solid var(--ws-primary); }
.task-block-head { display: flex; align-items: center; gap: 0.45rem; margin: -0.15rem 0 0.6rem; padding-bottom: 0.45rem; border-bottom: 1px solid var(--ws-border); font-size: 0.82rem; }
.task-block-head .bi { color: var(--ws-primary); }
.task-block-date { margin-left: auto; color: var(--ws-text-muted); font-family: var(--ws-font-mono); font-size: 0.75rem; }

/* ---------- Agent working on a task (agentRunning: 1) ---------- */
.task-card.is-agent-running { border-color: var(--ws-agent-running); box-shadow: 0 0 0 1px var(--ws-agent-running); }
.agent-running-chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; font-weight: 600; color: var(--ws-agent-running); min-width: 0; }
.agent-running-time { font-weight: 400; white-space: nowrap; }
.agent-running-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--ws-agent-running); animation: agent-running-pulse 1.4s ease-in-out infinite; flex: none; }
@keyframes agent-running-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .agent-running-dot { animation: none; } }
:root { --ws-agent-running: #e8710a; }
[data-theme="dark"] { --ws-agent-running: #ff9a3c; }

/* Cron: scheduled tasks */
.cron-card.is-disabled { opacity: 0.65; }
.cron-switch { margin: 0 0 0 auto; padding-left: 2.5em; }
.cron-summary, .cron-next { margin: 0; font-size: 0.85rem; }
.cron-next { color: var(--ws-text-muted); }
.cron-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.cron-form { display: flex; flex-direction: column; gap: 1rem; }
.cron-section { border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius); background: var(--ws-surface); padding: 1rem 1.1rem; }
.cron-section-title { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.75rem; }
.cron-modes { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.85rem; }
.cron-mode, .cron-day { border: 1px solid var(--ws-border); background: transparent; color: var(--ws-text); border-radius: var(--ws-radius-sm); padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.cron-mode[aria-checked="true"], .cron-day[aria-pressed="true"] { border-color: var(--ws-primary); background: var(--ws-primary); color: var(--ws-primary-text); }
.cron-day { width: 2.2rem; padding: 0.3rem 0; font-weight: 600; }
.cron-days { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.cron-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.cron-number { width: 5.5rem; display: inline-block; }
.cron-time { width: 8rem; display: inline-block; }
.cron-expression { font-family: var(--ws-font-mono); }
.cron-preview { margin-top: 0.85rem; padding-top: 0.75rem; border-top: 1px dashed var(--ws-border); }
.cron-preview-summary { margin: 0 0 0.25rem; font-weight: 600; }
.cron-preview-cron { margin: 0 0 0.35rem; font-size: 0.8rem; color: var(--ws-text-muted); }
.cron-preview-runs { margin: 0 0 0.35rem; padding-left: 1.4rem; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.cron-history { margin-top: 1.25rem; }
.cron-task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.cron-task-list li { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.cron-task-status { font-size: 0.75rem; padding: 0.05rem 0.45rem; border-radius: 999px; border: 1px solid var(--ws-border); color: var(--ws-text-muted); }
.cron-task-status.is-open { border-color: var(--ws-primary); color: var(--ws-primary); }

/* Credits and help pages */
.app-topbar-actions { align-items: center; }
.credits-link .bi, .credits-link.is-active .bi, .credits-heart { color: #e0245e; }
.info-section { border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius); background: var(--ws-surface); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.info-section-title { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.85rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.credits-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.credits-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; }
.credits-name { font-weight: 600; color: var(--ws-primary); }
.credits-name .bi { font-size: 0.7em; }
.credits-version, .credits-license { font-size: 0.72rem; padding: 0.05rem 0.45rem; border-radius: 999px; border: 1px solid var(--ws-border); color: var(--ws-text-muted); font-family: var(--ws-font-mono); }
.credits-purpose { margin: 0.15rem 0 0; font-size: 0.875rem; color: var(--ws-text-muted); }
.help-page { scroll-padding-top: calc(var(--ws-topbar-height) + 1rem); }
.help-page .info-section { scroll-margin-top: calc(var(--ws-topbar-height) + 1rem); }
.help-toc { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.help-toc a { font-size: 0.82rem; padding: 0.25rem 0.65rem; border: 1px solid var(--ws-border); border-radius: 999px; color: var(--ws-text-muted); }
.help-toc a:hover { color: var(--ws-text); border-color: var(--ws-primary); }
.help-path { font-size: 0.78rem; font-weight: 400; color: var(--ws-text-muted); }
.help-subtitle { font-size: 0.95rem; font-weight: 600; margin: 1.25rem 0 0.5rem; display: flex; align-items: center; gap: 0.4rem; }
.help-example { background: var(--ws-code-background); border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm); padding: 0.75rem 0.9rem; font-size: 0.8rem; overflow-x: auto; margin: 0 0 0.85rem; }
.help-example code { color: var(--ws-text); white-space: pre; }
.help-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 0.75rem; }
.help-table th, .help-table td { border-top: 1px solid var(--ws-border); padding: 0.45rem 0.5rem; vertical-align: top; text-align: left; }
.help-table th { color: var(--ws-text-muted); font-weight: 600; font-size: 0.78rem; }
.help-table td:first-child { white-space: nowrap; width: 1%; }
@media (max-width: 767.98px) { .help-table td:first-child { white-space: normal; } }

/* ---------- Usage (Consumo) ---------- */
.usage-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-bottom: 0.75rem; }
.usage-filters .field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 180px; }
.usage-range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.usage-period-label { color: var(--ws-text-muted); font-size: 0.85rem; padding-bottom: 0.35rem; }
.usage-disclaimer { font-size: 0.82rem; color: var(--ws-text-muted); margin: 0 0 1.25rem; display: flex; gap: 0.45rem; align-items: baseline; }
.usage-page .is-loading { opacity: 0.55; }
.usage-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.usage-stat {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 0.85rem 1rem;
  background: var(--ws-card-background); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius);
}
.usage-stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ws-text-muted); font-weight: 600; }
.usage-stat-value { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.usage-stat-change { font-size: 0.75rem; color: var(--ws-text-muted); font-variant-numeric: tabular-nums; }
.usage-week-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.6rem; margin-bottom: 0.6rem; }
.usage-week-hint { font-size: 0.8rem; color: var(--ws-text-muted); }
.usage-divider { border: 0; border-top: 1px solid var(--ws-border); opacity: 1; margin: 2rem 0 1.25rem; }
.usage-charts { display: flex; flex-direction: column; gap: 0.75rem; }
.usage-charts > .segmented { align-self: flex-start; flex-wrap: wrap; }
.usage-chart {
  min-width: 0; padding: 0.85rem 1rem;
  background: var(--ws-card-background); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius);
}
.usage-chart-title { font-size: 0.85rem; font-weight: 600; margin: 0 0 0.6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-chart-note { font-size: 0.75rem; color: var(--ws-text-muted); margin: 0.5rem 0 -0.25rem; }
.usage-chart-grid-agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.usage-chart-summary { font-size: 0.78rem; color: var(--ws-text-muted); margin: 0.5rem 0 0; font-variant-numeric: tabular-nums; }
.usage-chart-figure { --usage-chart-axis: 3.75rem; }
.usage-chart-figure.is-compact { --usage-chart-axis: 0px; }
.usage-chart-plot { position: relative; padding-left: var(--usage-chart-axis); }
.usage-chart-area { position: relative; height: 100%; }
.usage-chart-area svg { display: block; width: 100%; height: 100%; overflow: visible; }
.usage-chart-yaxis { position: absolute; left: 0; top: 0; bottom: 0; width: var(--usage-chart-axis); }
.usage-chart-yaxis span {
  position: absolute; right: 0.5rem; transform: translateY(50%); font-size: 0.68rem; line-height: 1;
  color: var(--ws-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.usage-chart-grid { stroke: var(--ws-border); stroke-width: 1; }
.usage-chart-bar { fill: var(--ws-primary); opacity: 0.7; outline: none; }
.usage-chart-bar:hover, .usage-chart-bar:focus-visible { opacity: 1; }
.usage-chart-bar:focus-visible { stroke: var(--ws-text); stroke-width: 2; vector-effect: non-scaling-stroke; }
.usage-chart-bar.is-today { opacity: 1; }
.usage-chart-bar.is-zero { fill: var(--ws-border); opacity: 1; }
.usage-chart-peak {
  position: absolute; transform: translate(-50%, -0.2rem); font-size: 0.72rem; font-weight: 600; line-height: 1;
  color: var(--ws-text); white-space: nowrap; font-variant-numeric: tabular-nums; pointer-events: none;
}
.usage-chart-xaxis {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin: 0.4rem 0 0 var(--usage-chart-axis);
  font-size: 0.72rem; color: var(--ws-text-muted); text-align: center; white-space: nowrap;
}
.usage-chart-xaxis .is-today { color: var(--ws-text); font-weight: 700; }
.usage-sections { display: flex; flex-direction: column; gap: 1.75rem; }
.usage-section-title { font-size: 1rem; font-weight: 600; margin: 0 0 0.5rem; }
.usage-section-hint { font-size: 0.82rem; color: var(--ws-text-muted); margin: 0 0 0.5rem; }
.usage-summary { font-size: 0.9rem; margin: 0 0 0.5rem; }
.usage-table-wrap { overflow-x: auto; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.usage-table th, .usage-table td { border-top: 1px solid var(--ws-border); padding: 0.4rem 0.55rem; text-align: left; white-space: nowrap; }
.usage-table th { color: var(--ws-text-muted); font-weight: 600; font-size: 0.75rem; border-top: none; }
.usage-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.usage-exit { font-size: 0.75rem; padding: 0.05rem 0.4rem; border-radius: var(--ws-radius-sm); background: var(--ws-accent); }
.usage-exit-ok { color: var(--ws-success); }
.usage-exit-error, .usage-exit-timeout, .usage-exit-blocked, .usage-exit-start-error { color: var(--ws-danger); }
.usage-note { font-size: 0.78rem; color: var(--ws-text-muted); margin: 0.4rem 0 0; }
.task-usage-line {
  display: flex; align-items: center; gap: 0.75rem; margin-top: 0.55rem; padding-top: 0.5rem;
  border-top: 1px solid var(--ws-border); font-size: 0.72rem; color: var(--ws-text-muted); font-variant-numeric: tabular-nums;
}
.task-usage-line > span { display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap; }
.project-usage { padding-top: 0.5rem; }
.project-usage .is-loading { opacity: 0.55; }
.project-usage .pager { margin-top: 1rem; }
.usage-task-cell { max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.task-usage { flex: none; border: 1px solid var(--ws-border); border-radius: var(--ws-radius-sm); padding: 0.45rem 0.7rem; font-size: 0.85rem; }
.task-usage summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.task-usage[open] .usage-table-wrap { max-height: 220px; overflow: auto; margin-top: 0.5rem; }

/* ---- Login, profile and user menu ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ws-bg); padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--ws-surface); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius); box-shadow: var(--ws-shadow); padding: 2rem; }
.login-brand { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.25rem; font-weight: 600; }
.login-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.25rem; }
.profile-section { background: var(--ws-surface); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius); padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.profile-section h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 1rem; }
.form-success { color: var(--ws-success, #2f8f4e); font-size: 0.875rem; margin: 0 0 0.75rem; }
.form-hint { color: var(--ws-text-muted); font-size: 0.78rem; margin: 0.3rem 0 0; }
.user-menu { margin-left: 0.25rem; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--ws-border); background: var(--ws-accent, var(--ws-primary)); color: #fff; font-weight: 600; font-size: 0.875rem; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.user-menu-email { font-size: 0.8rem; color: var(--ws-text-muted); }
.user-menu .dropdown-item { display: flex; align-items: center; gap: 0.5rem; }
.default-credentials-warning { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; max-width: 360px; display: flex; gap: 0.6rem; align-items: flex-start; background: var(--ws-danger); color: #fff; border-radius: var(--ws-border-radius); box-shadow: var(--ws-shadow); padding: 0.75rem 1rem; font-size: 0.875rem; }
.default-credentials-warning a { color: #fff; font-weight: 600; text-decoration: underline; }

/* ---- Library fields, task conversation, project settings ---- */
.library-fields { background: var(--ws-surface); border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius); padding: 1rem 1.25rem 0.25rem; margin-bottom: 1rem; }
.library-fields-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; }
.library-fields-row-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ordered-skills { list-style: none; padding: 0; margin: 0 0 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.ordered-skills li { display: flex; align-items: center; gap: 0.25rem; }
.task-conversation { margin-top: 1.5rem; border-top: 1px solid var(--ws-border); padding-top: 1rem; }
.task-conversation h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; }
.task-note { border: 1px solid var(--ws-border); border-radius: var(--ws-border-radius); background: var(--ws-surface); padding: 0.6rem 0.85rem; margin-bottom: 0.6rem; }
.task-note-system { background: color-mix(in srgb, var(--ws-text-muted) 6%, var(--ws-surface)); }
.task-note-agent { border-left: 3px solid var(--ws-primary); }
.task-note-human { border-left: 3px solid var(--ws-success, #2f8f4e); }
.task-note-head { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--ws-text-muted); margin-bottom: 0.35rem; }
.task-note-head strong { color: var(--ws-text); font-weight: 600; }
.task-note-body { font-size: 0.875rem; }
.task-note-body > :last-child { margin-bottom: 0; }
.task-note-new textarea { min-height: 90px; }
.settings-columns { width: 100%; border-collapse: separate; border-spacing: 0 0.35rem; }
.settings-columns th { font-size: 0.75rem; font-weight: 500; color: var(--ws-text-muted); text-align: left; padding: 0 0.35rem; }
.settings-columns td { padding: 0 0.35rem; vertical-align: middle; }
.settings-columns .form-select, .settings-columns .form-control { font-size: 0.85rem; padding-top: 0.25rem; padding-bottom: 0.25rem; }
@media (max-width: 720px) { .library-fields-row { grid-template-columns: 1fr; } }
.project-settings { max-width: 1000px; }
