/* ════════════════════════════════════════════════════════════════════
   Backlog PM — unified app stylesheet
   Brand tokens from style.css; Linear/Jira/ProductBoard-grade surface.
   ════════════════════════════════════════════════════════════════════ */

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

:root {
  --purple: #6E2C8B; --purple-dark: #4A1D5E; --purple-light: #9B59B6;
  --cyan: #00B8CF; --cyan-dark: #008B9A;
  --text: #404B5C; --text-secondary: #6B7280; --text-faint: #9CA3AF;
  --bg: #F8F9FC; --bg-sunken: #F1F2F7;
  --border: #E5E7EB; --border-strong: #D1D5DB; --white: #FFFFFF;
  --success: #059669; --success-bg: #ECFDF5;
  --warning: #D97706; --warning-bg: #FFFBEB;
  --danger: #DC2626; --danger-bg: #FEF2F2;
  --info: #2563EB;
  --font-title: 'Lexend Deca', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 6px; --radius-lg: 8px; --radius-xl: 12px;
  --shadow-xs: 0 1px 2px rgba(16,24,40,0.06);
  --shadow: 0 2px 8px rgba(16,24,40,0.08);
  --shadow-md: 0 4px 14px rgba(16,24,40,0.10);
  --shadow-lg: 0 12px 32px rgba(16,24,40,0.16);
  --transition: 0.16s cubic-bezier(0.4,0,0.2,1);

  /* status accents (canonical + fallbacks) */
  --st-idea: #8B5CF6; --st-building: #2563EB; --st-propen: #D97706;
  --st-done: #059669; --st-default: #6B7280;
}

html, body { height: 100%; }
body {
  font-family: var(--font-body); background: var(--bg); color: var(--text);
  line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(110,44,139,0.16); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D7DAE2; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #BCC0CC; background-clip: content-box; }

/* ─── App frame ─────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  flex-shrink: 0; height: 56px; display: flex; align-items: center;
  gap: 16px; padding: 0 20px; color: var(--white);
  background: linear-gradient(90deg, #6E2C8B 0%, #7B2E8E 38%, #00B8CF 100%);
  box-shadow: 0 1px 0 rgba(0,0,0,0.06); z-index: 40; position: relative;
}
.topbar-logo { height: 24px; opacity: 0.96; display: block; }
.topbar-brand { display: flex; align-items: center; gap: 12px; cursor: pointer; text-decoration: none; color: #fff; }
.topbar-brand .sep { width: 1px; height: 22px; background: rgba(255,255,255,0.28); }
.topbar-brand h1 { font-family: var(--font-title); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; min-width: 0; }
.topbar-breadcrumb .crumb-sep { opacity: 0.5; }
.topbar-breadcrumb .crumb-project { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.topbar-spacer { flex: 1; }

.global-search {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.22); border-radius: 8px; padding: 0 10px;
  height: 34px; width: 300px; max-width: 34vw; transition: background var(--transition);
}
.global-search:focus-within { background: rgba(255,255,255,0.26); border-color: rgba(255,255,255,0.5); }
.global-search svg { width: 15px; height: 15px; opacity: 0.85; flex-shrink: 0; }
.global-search input {
  background: transparent; border: none; outline: none; color: #fff;
  font-family: inherit; font-size: 13px; width: 100%;
}
.global-search input::placeholder { color: rgba(255,255,255,0.75); }

.topbar-auth { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.btn-signin {
  background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.35);
  color: #fff; padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 600;
  transition: background var(--transition);
}
.btn-signin:hover { background: rgba(255,255,255,0.28); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  font-size: 12px; font-family: var(--font-title); border: 1px solid rgba(255,255,255,0.3);
}
.user-menu { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: 38px; background: var(--white); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  min-width: 200px; padding: 8px; z-index: 60; display: none;
}
.user-dropdown.open { display: block; }
.user-dropdown .udd-name { font-weight: 600; font-size: 13px; padding: 6px 8px; }
.user-dropdown .udd-email { font-size: 12px; color: var(--text-secondary); padding: 0 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-dropdown button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 8px; border-radius: 5px; font-size: 13px; color: var(--text); }
.user-dropdown button:hover { background: var(--bg-sunken); }

/* ─── Body: optional rail + content ─────────────────────────────── */
.app-body { flex: 1; display: flex; min-height: 0; }

.rail {
  flex-shrink: 0; width: 208px; background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; overflow-y: auto;
}
.rail-section-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); padding: 10px 10px 4px; }
.rail-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500; color: var(--text-secondary); text-decoration: none;
  transition: background var(--transition), color var(--transition); border: none; background: none; width: 100%; text-align: left;
}
.rail-link:hover { background: var(--bg-sunken); color: var(--text); }
.rail-link.active { background: rgba(110,44,139,0.09); color: var(--purple); font-weight: 600; }
.rail-link.active svg { color: var(--purple); }
.rail-link svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-faint); }
.rail-link .badge-count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-faint); background: var(--bg-sunken); border-radius: 9px; padding: 1px 7px; }
.rail-spacer { flex: 1; }
.rail-back { color: var(--text-faint); font-size: 12.5px; }

.content { flex: 1; min-width: 0; overflow-y: auto; position: relative; }
.content-inner { padding: 24px 28px 64px; }
.content.flush .content-inner { padding: 0; }

/* ─── Generic bits ──────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-family: var(--font-title); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: #1f2733; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; border: 1px solid var(--border-strong); background: var(--white);
  color: var(--text); transition: all var(--transition); white-space: nowrap;
}
.btn:hover { border-color: var(--purple-light); color: var(--purple); box-shadow: var(--shadow-xs); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); color: #fff; }
.btn-cyan { background: var(--cyan); border-color: var(--cyan); color: #053b42; }
.btn-cyan:hover { background: var(--cyan-dark); border-color: var(--cyan-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text); border-color: transparent; box-shadow: none; }
.btn-danger { color: var(--danger); border-color: #F3C9C9; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: var(--radius); }

.input, .select, textarea.input {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-family: var(--font-body); font-size: 13.5px; color: var(--text); background: var(--white);
  outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--purple-light); box-shadow: 0 0 0 3px rgba(155,89,182,0.14); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.55; }
label.field-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 6px; }

.pill-toggle { display: inline-flex; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.pill-toggle button { border: none; background: transparent; padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.pill-toggle button.active { background: var(--white); color: var(--purple); box-shadow: var(--shadow-xs); }

/* ─── Chips / badges ────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 11px; white-space: nowrap; line-height: 1.5; }
.chip-mono { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-secondary); background: var(--bg-sunken); padding: 1px 6px; border-radius: 5px; }
.prio { border: 1px solid transparent; }
.prio-must { color: #B91C1C; background: #FEE9E9; border-color: #F7CFCF; }
.prio-should { color: #B45309; background: #FEF3E2; border-color: #FADFB2; }
.prio-could { color: #1D4ED8; background: #E8F0FE; border-color: #C7DAFB; }
.prio-wont { color: #6B7280; background: #F1F2F7; border-color: #E2E4EB; }
.effort { color: var(--text-secondary); background: var(--bg-sunken); border: 1px solid var(--border); font-weight: 700; min-width: 26px; justify-content: center; }
.status-chip { color: #fff; }
/* Off-list (legacy) status — visibly flagged across chips, columns, selects. */
.status-chip-unknown { color: #B45309; background: #FFFBEB; border: 1px dashed #D97706; }
.status-unknown { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #B45309; background: #FFFBEB; border: 1px dashed #D97706; border-radius: 9px; padding: 1px 6px; white-space: nowrap; }
.kcol-unknown { outline: 1px dashed #D97706; outline-offset: -1px; }
.status-unknown-select { border: 1px dashed #D97706 !important; }
.wontdo-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; white-space: nowrap; margin-right: 8px; }
.type-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; }
.type-feature { color: var(--purple); }
.type-bug { color: var(--danger); }
.type-chore { color: var(--text-secondary); }
.theme-tag { font-size: 11px; font-weight: 600; color: var(--cyan-dark); background: #E2F8FB; border: 1px solid #BEEFF5; padding: 1px 8px; border-radius: 11px; }
/* Tags (BKL-TAGS-RANK): neutral chips; epic:/release: prefixes get their own colour. */
/* Parent link chip (BKL-epics-1, E3) + epic type */
.parent-chip { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; font-family: var(--font-mono); color: var(--text-secondary); background: var(--bg-sunken); border: 1px dashed var(--border); padding: 1px 7px; border-radius: 5px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.parent-chip.epic { color: var(--purple); border-color: rgba(110,44,139,0.35); }
.parent-chip.hidden { color: var(--text-faint); font-style: italic; }
.type-icon.type-epic { color: var(--purple); }
.epic-pill { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: #fff; background: var(--purple); border-radius: 4px; padding: 1px 6px; }
.ws-parent-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ws-parent-btn { max-width: 100%; text-align: left; }
.pp-modal .pp-list { max-height: 320px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; }
.pp-modal .pp-group { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); padding: 8px 10px 4px; }
.pp-modal .pp-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; background: none; text-align: left; cursor: pointer; font-size: 13px; }
.pp-modal .pp-row:hover, .pp-modal .pp-row:focus-visible { background: var(--bg-sunken); outline: none; }
.pp-modal .pp-row.current { font-weight: 600; }
.pp-modal .pp-id { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.pp-modal .pp-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.pp-modal .pp-proj { font-size: 11px; font-family: var(--font-mono); color: var(--text-faint); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }
.pp-modal .pp-error { margin-top: 8px; color: var(--danger, #B42318); font-size: 13px; }
.pp-modal .pp-note { margin-top: 8px; color: var(--text-faint); font-size: 12px; }

.tag-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; font-family: var(--font-mono); color: #3F4756; background: var(--bg-sunken); border: 1px solid var(--border); padding: 1px 7px; border-radius: 5px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tag-chip::before { content: '#'; opacity: .45; }
.tag-chip.tag-epic { color: var(--purple); background: rgba(110,44,139,0.08); border-color: rgba(110,44,139,0.22); }
.tag-chip.tag-release { color: #92400E; background: #FEF3C7; border-color: #FCD34D; }
.tag-chip.tag-more::before { content: none; }
.tag-chip-edit { padding-right: 0; }
.tag-x { border: none; background: none; color: inherit; opacity: .7; padding: 0 6px 0 2px; font-size: 13px; line-height: 1; cursor: pointer; }
.tag-x:hover { opacity: 1; }
.tag-filter { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag-filter .select { max-width: 150px; }
.pill-toggle-sm button { padding: 3px 9px; font-size: 11.5px; }
.bl-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 8px; vertical-align: middle; }
.ws-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ws-tag-input { width: 150px; font-size: 12px; padding: 4px 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ─── Portfolio ─────────────────────────────────────────────────── */
.portfolio-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.portfolio-stat-row { display: flex; gap: 12px; margin-bottom: 26px; flex-wrap: wrap; }
.kpi { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 18px; min-width: 130px; box-shadow: var(--shadow-xs); }
.kpi-value { font-family: var(--font-title); font-size: 24px; font-weight: 700; color: #1f2733; line-height: 1.1; }
.kpi-label { font-size: 11.5px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

.proj-section-label { font-family: var(--font-title); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin: 8px 0 14px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; margin-bottom: 34px; }
.proj-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 18px; box-shadow: var(--shadow-xs); transition: all var(--transition); cursor: pointer; display: flex; flex-direction: column; gap: 12px; position: relative; }
.proj-card:hover { border-color: var(--purple-light); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.proj-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.proj-card-name { font-family: var(--font-title); font-size: 16px; font-weight: 700; color: #1f2733; letter-spacing: -0.01em; }
.proj-card-slug { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.proj-card-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 18px; }
.proj-card-edit { opacity: 0; flex-shrink: 0; }
.proj-card:hover .proj-card-edit { opacity: 1; }
.rollup { display: flex; flex-direction: column; gap: 7px; }
.rollup-bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; background: var(--bg-sunken); }
.rollup-seg { height: 100%; }
.rollup-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--text-secondary); }
.rollup-legend span { display: inline-flex; align-items: center; gap: 5px; }
.proj-card-foot { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-secondary); border-top: 1px solid var(--border); padding-top: 11px; margin-top: auto; }
.proj-card-foot .sprint-hint { display: inline-flex; align-items: center; gap: 5px; color: var(--cyan-dark); font-weight: 600; }

.create-proj-card { border: 1.5px dashed var(--border-strong); background: transparent; box-shadow: none; align-items: center; justify-content: center; min-height: 150px; color: var(--text-secondary); font-weight: 600; font-size: 14px; gap: 8px; flex-direction: row; }
.create-proj-card:hover { border-color: var(--purple-light); color: var(--purple); transform: none; box-shadow: none; }

/* Portfolio filter/sort bar */
.portfolio-filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -6px 0 20px; flex-wrap: wrap; }
.pf-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pf-chip { font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 13px; border-radius: 16px; border: 1px solid var(--border); background: var(--white); color: var(--text-secondary); cursor: pointer; transition: all var(--transition); }
.pf-chip:hover { border-color: var(--purple-light); color: var(--purple); }
.pf-chip.active { background: var(--purple); border-color: var(--purple); color: #fff; }
.pf-sort-wrap { display: inline-flex; align-items: center; gap: 8px; }
.pf-sort-label { font-size: 12px; font-weight: 600; color: var(--text-faint); }
.pf-sort.select { width: auto; padding: 6px 10px; font-size: 12.5px; }

/* Project category badge (Internal / Client / other) */
.badge-category { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 11px; background: var(--bg-sunken); color: var(--text-secondary); white-space: nowrap; }
.badge-category.cat-internal { background: rgba(110,44,139,0.1); color: var(--purple); }
.badge-category.cat-client { background: #E2F8FB; color: var(--cyan-dark); }

/* ─── Board (kanban) ────────────────────────────────────────────── */
.board-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--white); flex-wrap: wrap; }
.board-scroll { display: flex; gap: 14px; padding: 18px 24px 28px; overflow-x: auto; align-items: flex-start; min-height: calc(100vh - 56px - 60px); }
.kcol { flex: 0 0 300px; width: 300px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 56px - 60px - 46px); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px 9px; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.kcol-head .dot { width: 9px; height: 9px; }
.kcol-title { font-family: var(--font-title); font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em; color: var(--text); }
.kcol-count { font-size: 11px; font-weight: 600; color: var(--text-faint); background: var(--white); border: 1px solid var(--border); border-radius: 9px; padding: 0 7px; }
.kcol-head-bar { height: 3px; border-radius: 3px 3px 0 0; }
.kcol-body { padding: 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcol-add { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.kcol-add input { flex: 1; padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 12.5px; font-family: inherit; outline: none; }
.kcol-add input:focus { border-color: var(--purple-light); }

.kcard { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 11px 12px; box-shadow: var(--shadow-xs); cursor: pointer; display: flex; flex-direction: column; gap: 9px; transition: box-shadow var(--transition), border-color var(--transition); }
.kcard:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.kcard.sortable-ghost { opacity: 0.4; }
.kcard.sortable-chosen { box-shadow: var(--shadow-md); }
.kcard.saving { opacity: 0.6; pointer-events: none; }
.kcard-top { display: flex; align-items: center; gap: 7px; }
.kcard-id { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-faint); }
.kcard-top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.kcard-title { font-size: 13.5px; font-weight: 500; color: #283040; line-height: 1.35; }
.kcard-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kcard-foot { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-secondary); }
.kcard-foot .spacer { flex: 1; }
.kcard-assignee { display: inline-flex; align-items: center; gap: 5px; }
.mini-avatar { width: 19px; height: 19px; border-radius: 50%; background: var(--purple); color: #fff; font-size: 9.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-title); }
.mini-avatar.agent { background: var(--cyan-dark); }
.kcard-icon { color: var(--text-faint); display: inline-flex; }
.kcard-icon svg { width: 13px; height: 13px; }
.kcard-icon.has-pr { color: var(--success); }

/* ─── Backlog list / table ──────────────────────────────────────── */
.list-toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 0; flex-wrap: wrap; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; }
.filter-chip .select { width: auto; padding: 6px 9px; font-size: 12.5px; }
.bl-group { margin-bottom: 22px; }
.bl-group-head { display: flex; align-items: center; gap: 10px; padding: 8px 4px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.bl-group-title { font-family: var(--font-title); font-size: 13px; font-weight: 700; color: var(--text); }
.bl-group-count { font-size: 11px; color: var(--text-faint); font-weight: 600; }
.bl-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.bl-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); padding: 10px 12px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none; }
.bl-table th:hover { color: var(--purple); }
.bl-table th .sort-ind { font-size: 9px; margin-left: 3px; opacity: 0.6; }
.bl-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.bl-table tr:last-child td { border-bottom: none; }
.bl-table tbody tr { cursor: pointer; transition: background var(--transition); }
.bl-table tbody tr:hover { background: var(--bg); }
.bl-cell-title { font-weight: 500; color: #283040; max-width: 420px; }
.bl-cell-title .id { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-right: 8px; }
.inline-select { border: 1px solid transparent; background: transparent; font-family: inherit; font-size: 12px; font-weight: 600; padding: 3px 6px; border-radius: 6px; color: var(--text); }
.inline-select:hover { border-color: var(--border-strong); background: var(--white); }
.row-pr-link { color: var(--success); display: inline-flex; }
.row-pr-link svg { width: 15px; height: 15px; }

/* ─── Roadmap ───────────────────────────────────────────────────── */
.roadmap-grid { display: flex; flex-direction: column; gap: 2px; }
.roadmap-cols-head { display: grid; grid-template-columns: 180px 1fr 1fr 1fr; gap: 2px; position: sticky; top: 0; z-index: 6; }
.roadmap-col-label { padding: 11px 14px; font-family: var(--font-title); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: #fff; border-radius: var(--radius) var(--radius) 0 0; text-align: center; }
.rc-now { background: linear-gradient(180deg, var(--purple) 0%, #7a3597 100%); }
.rc-next { background: var(--purple-light); }
.rc-later { background: #94A3B8; }
.roadmap-corner { background: transparent; }
.roadmap-lane { display: grid; grid-template-columns: 180px 1fr 1fr 1fr; gap: 2px; }
.lane-label { background: var(--white); border: 1px solid var(--border); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.lane-label .ll-name { font-weight: 700; font-size: 13px; color: #283040; }
.lane-label .ll-count { font-size: 11px; color: var(--text-faint); }
.lane-cell { background: rgba(255,255,255,0.55); border: 1px solid var(--border); padding: 8px; min-height: 64px; display: flex; flex-direction: column; gap: 7px; }
.lane-cell.now { background: rgba(110,44,139,0.045); }
.rmcard { background: var(--white); border: 1px solid var(--border); border-left: 3px solid var(--st-default); border-radius: var(--radius); padding: 8px 10px; cursor: pointer; box-shadow: var(--shadow-xs); transition: box-shadow var(--transition); }
.rmcard:hover { box-shadow: var(--shadow); }
.rmcard-title { font-size: 12.5px; font-weight: 500; color: #283040; line-height: 1.3; margin-bottom: 5px; }
.rmcard-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ─── Sprints ───────────────────────────────────────────────────── */
.sprint-block { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 16px; overflow: hidden; }
.sprint-block-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); background: var(--bg-sunken); }
.sprint-status { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 9px; border-radius: 11px; }
.sprint-status.active { color: var(--success); background: var(--success-bg); }
.sprint-status.planned { color: var(--info); background: #EAF1FE; }
.sprint-status.done { color: var(--text-secondary); background: var(--bg-sunken); border: 1px solid var(--border); }
.sprint-block-title { font-family: var(--font-title); font-weight: 700; font-size: 15px; color: #1f2733; }
.sprint-block-body { padding: 8px; }
.sprint-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; }
.sprint-row:hover { background: var(--bg); }
.sprint-row + .sprint-row { border-top: 1px solid var(--border); }
.sprint-move { margin-left: auto; }
.sprint-empty { padding: 16px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

/* ─── Directives ────────────────────────────────────────────────── */
.cat-block { margin-bottom: 26px; }
.cat-label { font-family: var(--font-title); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 12px; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.dir-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-xs); display: flex; flex-direction: column; gap: 10px; }
.dir-card.inactive { opacity: 0.62; }
.dir-card-head { display: flex; align-items: flex-start; gap: 10px; }
.dir-card-title { font-family: var(--font-title); font-weight: 700; font-size: 14.5px; color: #1f2733; flex: 1; }
.dir-card-key { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.dir-card-body { font-size: 13px; color: var(--text); line-height: 1.5; max-height: 220px; overflow: hidden; position: relative; }
.dir-card-body.collapsed::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 40px; background: linear-gradient(transparent, var(--white)); }
.dir-card-actions { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.toggle { position: relative; width: 36px; height: 20px; border-radius: 11px; background: var(--border-strong); transition: background var(--transition); border: none; flex-shrink: 0; }
.toggle.on { background: var(--success); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left var(--transition); box-shadow: var(--shadow-xs); }
.toggle.on::after { left: 18px; }

/* ─── Docs ──────────────────────────────────────────────────────── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.doc-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-xs); cursor: pointer; display: flex; flex-direction: column; gap: 9px; transition: all var(--transition); }
.doc-card:hover { border-color: var(--purple-light); box-shadow: var(--shadow); }
.doc-card-head { display: flex; align-items: flex-start; gap: 8px; }
.doc-card-title { font-family: var(--font-title); font-weight: 700; font-size: 14.5px; color: #1f2733; flex: 1; line-height: 1.3; }
.doc-card-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-secondary); flex-wrap: wrap; }
.doc-type-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 5px; background: rgba(110,44,139,0.1); color: var(--purple); }
.doc-status-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 11px; }
.ds-draft { color: var(--text-secondary); background: var(--bg-sunken); }
.ds-review { color: var(--warning); background: var(--warning-bg); }
.ds-approved { color: var(--success); background: var(--success-bg); }
.ds-superseded { color: var(--text-faint); background: var(--bg-sunken); text-decoration: line-through; }
.doc-tags { display: flex; flex-wrap: wrap; gap: 5px; }

/* ─── Insights ──────────────────────────────────────────────────── */
.insights-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.panel { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-xs); }
.panel-title { font-family: var(--font-title); font-size: 14px; font-weight: 700; color: #1f2733; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel-title .count-pill { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-secondary); background: var(--bg-sunken); border-radius: 9px; padding: 1px 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { width: 110px; font-size: 12px; color: var(--text-secondary); flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.bar-track { flex: 1; height: 18px; background: var(--bg-sunken); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); min-width: 2px; }
.bar-value { width: 34px; text-align: right; font-size: 12px; font-weight: 700; color: var(--text); flex-shrink: 0; }
.gauge { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.gauge-num { font-family: var(--font-title); font-size: 34px; font-weight: 700; color: var(--purple); }
.gauge-label { font-size: 13px; color: var(--text-secondary); }
.viol-list { display: flex; flex-direction: column; gap: 8px; }
.viol-item { display: flex; gap: 10px; padding: 9px 11px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--border); font-size: 12.5px; cursor: pointer; }
.viol-item:hover { border-color: var(--border-strong); }
.viol-item .viol-dot { margin-top: 4px; }
.viol-item .viol-id { font-family: var(--font-mono); font-weight: 600; color: var(--text); }
.viol-item .viol-msg { color: var(--text-secondary); }
.clean-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px; color: var(--success); font-size: 13px; font-weight: 600; }

/* ─── Claims ────────────────────────────────────────────────────── */
.claims-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.claims-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); padding: 10px 14px; background: var(--bg-sunken); border-bottom: 1px solid var(--border); }
.claims-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.claims-table tr:last-child td { border-bottom: none; }

/* ─── Drawer (item detail) ──────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(20,24,32,0.42); backdrop-filter: blur(1.5px); opacity: 0; transition: opacity var(--transition); z-index: 80; }
.overlay.open { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 540px; max-width: 94vw; background: var(--white); box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform 0.26s cubic-bezier(0.4,0,0.2,1); z-index: 90; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.drawer-head-top { display: flex; align-items: flex-start; gap: 12px; }
.drawer-id { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text-faint); }
.drawer-title-input { font-family: var(--font-title); font-size: 18px; font-weight: 700; color: #1f2733; border: 1px solid transparent; border-radius: var(--radius); padding: 4px 6px; margin: 2px -6px 0; width: 100%; background: transparent; outline: none; line-height: 1.3; }
.drawer-title-input:hover { background: var(--bg-sunken); }
.drawer-title-input:focus { background: var(--white); border-color: var(--purple-light); box-shadow: 0 0 0 3px rgba(155,89,182,0.14); }
.drawer-close { flex-shrink: 0; width: 32px; height: 32px; border-radius: var(--radius); border: none; background: var(--bg-sunken); color: var(--text-secondary); font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.drawer-close:hover { background: var(--border); color: var(--text); }
.drawer-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.drawer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-bottom: 18px; }
.drawer-field.full { grid-column: 1 / -1; }
.md-editor { position: relative; }
.md-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.md-tab { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); background: var(--bg-sunken); border: 1px solid var(--border); padding: 3px 10px; border-radius: 6px; }
.md-tab.active { color: var(--purple); background: var(--white); border-color: var(--purple-light); }
.md-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-height: 90px; font-size: 13px; line-height: 1.6; background: var(--bg); }
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 { font-family: var(--font-title); margin: 0.7em 0 0.4em; color: #1f2733; }
.md-preview h1 { font-size: 17px; } .md-preview h2 { font-size: 15px; } .md-preview h3 { font-size: 14px; }
.md-preview p { margin: 0.5em 0; } .md-preview ul, .md-preview ol { margin: 0.5em 0 0.5em 1.3em; }
.md-preview code { font-family: var(--font-mono); background: var(--bg-sunken); padding: 1px 4px; border-radius: 4px; font-size: 0.88em; }
.md-preview pre { background: #1f2733; color: #e6e9ef; padding: 10px 12px; border-radius: var(--radius); overflow-x: auto; margin: 0.6em 0; }
.md-preview pre code { background: none; color: inherit; padding: 0; }
.md-preview table { width: 100%; border-collapse: collapse; margin: 0.6em 0; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; font-size: 12.5px; }
.md-preview th { background: var(--bg-sunken); }
.md-preview blockquote { border-left: 3px solid var(--purple-light); padding-left: 12px; color: var(--text-secondary); margin: 0.5em 0; }
.md-preview a { color: var(--purple); }
.dep-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dep-chip { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--purple); background: rgba(110,44,139,0.08); border: 1px solid rgba(110,44,139,0.18); padding: 3px 8px; border-radius: 6px; }
.dep-chip:hover { background: rgba(110,44,139,0.14); }
.dep-chip.missing { color: var(--danger); background: var(--danger-bg); border-color: #F3C9C9; }
.attach-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12.5px; }
.attach-row a { color: var(--purple); font-weight: 500; text-decoration: none; }
.attach-row a:hover { text-decoration: underline; }
.activity-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--purple-light); margin-top: 5px; flex-shrink: 0; }
.activity-meta { color: var(--text-faint); font-size: 11px; }
.drawer-foot { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg); }
.drawer-foot .spacer { flex: 1; }
.drawer-save-status { font-size: 12px; color: var(--text-faint); transition: color .2s; }
.drawer-save-status.ok { color: var(--text-secondary); }
.drawer-save-status.err { color: var(--danger, #d33); }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin: 18px 0 8px; }

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -48%); background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 560px; max-width: 94vw; max-height: 90vh; display: flex; flex-direction: column; z-index: 90; opacity: 0; transition: opacity var(--transition), transform var(--transition); }
.modal.open { opacity: 1; transform: translate(-50%, -50%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-title { font-family: var(--font-title); font-size: 17px; font-weight: 700; color: #1f2733; flex: 1; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg); }
.modal-foot .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-row2 { margin-bottom: 14px; }
.form-msg { font-size: 12.5px; padding: 8px 11px; border-radius: var(--radius); margin-top: 12px; display: none; }
.form-msg.err { display: block; color: var(--danger); background: var(--danger-bg); border: 1px solid #F3C9C9; }
.form-msg.ok { display: block; color: var(--success); background: var(--success-bg); border: 1px solid #BBF7D0; }

/* ─── Toasts ────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 120; }
.toast { display: flex; align-items: center; gap: 10px; background: #1f2733; color: #fff; padding: 11px 15px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500; min-width: 240px; max-width: 380px; transform: translateX(120%); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); }
.toast.show { transform: translateX(0); }
.toast.success { background: #064E3B; }
.toast.error { background: #7F1D1D; }
.toast .toast-icon { flex-shrink: 0; display: flex; }
.toast .toast-icon svg { width: 17px; height: 17px; }
.toast .toast-action { margin-left: auto; font-weight: 700; text-decoration: underline; cursor: pointer; white-space: nowrap; }

/* ─── Empty / loading states ────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 60px 24px; text-align: center; color: var(--text-secondary); }
.empty-state .es-icon { width: 46px; height: 46px; color: var(--text-faint); opacity: 0.7; }
.empty-state .es-title { font-family: var(--font-title); font-size: 15px; font-weight: 700; color: var(--text); }
.empty-state .es-sub { font-size: 13px; max-width: 360px; }
.skeleton { background: linear-gradient(90deg, #eef0f5 25%, #f6f7fa 50%, #eef0f5 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-card { height: 150px; border-radius: var(--radius-xl); }
.skel-line { height: 12px; margin: 8px 0; }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .rail { width: 64px; padding: 12px 8px; }
  .rail-link span.rl-text, .rail-section-label, .rail-link .badge-count { display: none; }
  .rail-link { justify-content: center; padding: 10px; }
  .global-search { width: 180px; }
}
@media (max-width: 720px) {
  .content-inner { padding: 16px; }
  .global-search { display: none; }
  .drawer-grid, .form-grid { grid-template-columns: 1fr; }
  .roadmap-cols-head, .roadmap-lane { grid-template-columns: 110px 1fr; }
  .roadmap-col-label.rc-next, .roadmap-col-label.rc-later, .lane-cell.col-next, .lane-cell.col-later { display: none; }
}
.hidden { display: none !important; }

/* ── Acceptance checklist (drawer) ─────────────────────────────────── */
.ac-list { display: flex; flex-direction: column; gap: 8px; }
.ac-row { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--white); }
.ac-text { font-size: 13px; line-height: 1.4; }
.ac-controls { display: flex; gap: 6px; align-items: center; }
.ac-controls .ac-status { max-width: 120px; }
.ac-controls .input { flex: 1; min-width: 0; }
.ac-status-pass { color: var(--success); font-weight: 600; }
.ac-status-fail { color: var(--danger); font-weight: 600; }
.ac-status-pending { color: var(--text-secondary); }

/* ── Discussion thread (drawer) ────────────────────────────────────── */
.comment-thread { display: flex; flex-direction: column; gap: 8px; }
.comment { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--white); }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-author { font-size: 12px; font-weight: 600; }
.comment-meta { font-size: 11px; color: var(--text-faint); }
.comment-del { margin-left: auto; cursor: pointer; opacity: .5; font-size: 16px; line-height: 1; }
.comment-del:hover { opacity: 1; color: var(--danger); }
.comment-body { font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

/* ── Activity feed (view) ──────────────────────────────────────────── */
.feed { display: flex; flex-direction: column; }
.feed-row { display: flex; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--st-default); }
.feed-created { background: var(--success); } .feed-updated { background: var(--st-building); }
.feed-commented { background: var(--st-idea); } .feed-ac { background: var(--warning); }
.feed-claimed { background: var(--cyan); } .feed-deleted { background: var(--danger); }
.feed-main { flex: 1; min-width: 0; }
.feed-text { font-size: 13px; }
.feed-item-link { color: var(--cyan-dark); cursor: pointer; font-weight: 600; }
.feed-item-link:hover { text-decoration: underline; }
.feed-meta { font-size: 11px; color: var(--text-faint); margin-top: 2px; }


/* ── Item drawer: Context section (ADR-004) ───────────────────────── */
.ctx-body { display: flex; flex-direction: column; gap: 8px; }
.ctx-sub { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.ctx-sub svg { width: 12px; height: 12px; }
.ctx-note { font-size: 12px; color: var(--text-faint); }
.ctx-ref { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--white); }
.ctx-ref-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ctx-kind { font-size: 16px; line-height: 1; }
.ctx-ref-main { flex: 1; min-width: 160px; }
.ctx-ref-title { font-size: 13px; font-weight: 600; color: var(--text); }
.ctx-ref-path { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); overflow-wrap: anywhere; }
.ctx-ref-actions { display: flex; gap: 4px; margin-left: auto; }
.ctx-badge { font-size: 11px; }
.ctx-ok { background: #e3f4ea; color: #1e7a45; }
.ctx-stale { background: #fff1d6; color: #8a5a00; }
.ctx-err { background: #fde2e2; color: #a12a2a; }
.ctx-ref-pane:empty { display: none; }
.ctx-ref-pane { margin-top: 8px; }
.ctx-frame-wrap { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.ctx-frame-wrap:fullscreen { border: none; border-radius: 0; }
.ctx-frame { display: block; width: 100%; height: 420px; border: 0; }
.ctx-frame-wrap:fullscreen .ctx-frame { height: 100vh; }
.ctx-md { font-size: 13px; max-height: 360px; overflow: auto; padding: 8px; background: var(--bg-sunken); border-radius: var(--radius); }
.ctx-pre { font-size: 11px; max-height: 360px; overflow: auto; white-space: pre-wrap; background: var(--bg-sunken); padding: 8px; border-radius: var(--radius); margin: 0; }
.ctx-diff { font-size: 12px; color: #8a5a00; margin-bottom: 6px; }
.ctx-doc { font-size: 13px; }
.ctx-atts { display: flex; flex-wrap: wrap; gap: 8px; }
.ctx-att { display: flex; flex-direction: column; gap: 4px; font-size: 12px; max-width: 150px; text-decoration: none; color: var(--text-secondary); }
.ctx-att-img { width: 150px; height: 96px; object-fit: cover; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-sunken); }
.ctx-att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.ctx-att-name svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ── Project kind / archive + master board (BKL-master-board) ── */
.badge-archived { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 11px; background: #FEF3C7; color: #92400E; white-space: nowrap; }
.proj-card.archived { opacity: 0.72; border-style: dashed; }
.pf-archived-toggle { margin-left: 4px; }
.kcard-project { margin: -2px 0 6px; }
.kcard-project-chip { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: rgba(110,44,139,0.1); color: var(--purple); }
.kcard-project-chip.kind-external { background: #E2F8FB; color: var(--cyan-dark); }
.mb-toolbar { gap: 12px; }
.mb-title { margin-right: 6px; }
.mb-picker { position: relative; }
.mb-picker > summary { list-style: none; cursor: pointer; }
.mb-picker > summary::-webkit-details-marker { display: none; }
.mb-picker-list { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 260px; max-height: 50vh; overflow-y: auto; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.mb-picker-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.mb-picker-row:hover { background: var(--bg-sunken); }
.mb-picker-row > span:nth-child(2) { flex: 1; }
.rail-master { color: var(--purple); }
a.btn { text-decoration: none; }

/* ─── Item workspace (BKL-review-workspace / BKL-rw-1) ─────────────
   Fullscreen, opaque (no blur — BR-RW-2) overlay above the board and below
   modals (overlay 80 / modal 90). Readable metadata uses --text-secondary
   (--text-faint fails AA). */
:root {
  --ws-left: 236px; --ws-right: 344px; --ws-rail-closed: 36px; --ws-read-max: 860px;
  /* BR-RW-14a — one state vocabulary; each state also gets a text badge. */
  --ws-pin: #6E2C8B; --ws-pending: #7C3AED; --ws-outdated: #B45309; --ws-gone: #6B7280;
}
.ws-state-pin { border: 1px solid var(--ws-pin); color: var(--ws-pin); }
.ws-state-pending { border: 1px dashed var(--ws-pending); color: var(--ws-pending); }
.ws-state-outdated { border: 1px dashed var(--ws-outdated); color: #7a4f00; background: #FEF3C7; }
.ws-state-gone { border: 1px solid var(--ws-gone); color: var(--ws-gone); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.ws { position: fixed; inset: 0; z-index: 70; background: var(--white); display: flex; flex-direction: column; color: var(--text); }
.ws kbd { font-family: var(--font-mono); font-size: 10.5px; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--bg-sunken); color: var(--text-secondary); }
.ws-head { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ws-head .spacer { flex: 1; }
.ws-id { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.ws-title-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 0 1 auto; max-width: 52vw; }
.ws-title-wrap.editing { flex: 1 1 420px; max-width: none; }
.ws-title { font-family: var(--font-title); font-size: 18px; font-weight: 700; color: #1f2733; margin: 0; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: var(--radius); padding: 2px 4px; }
.ws-title:focus { outline: none; }
.ws-title:focus-visible { outline: 2px solid var(--purple-light); outline-offset: 1px; }
.ws-title-input { flex: 1; font-family: var(--font-title); font-size: 17px; font-weight: 700; padding: 5px 8px; border: 1px solid var(--purple-light); border-radius: var(--radius); box-shadow: 0 0 0 3px rgba(155,89,182,0.14); outline: none; min-width: 0; }
.ws-pencil { border: none; background: transparent; color: var(--text-secondary); font-size: 14px; padding: 2px 6px; border-radius: var(--radius); opacity: 0; transition: opacity var(--transition); }
.ws-title-wrap:hover .ws-pencil, .ws-pencil:focus { opacity: 1; }
.ws-pencil:hover { background: var(--bg-sunken); color: var(--purple); }
.ws-head-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ws-pr-chip { display: inline-flex; align-items: center; gap: 4px; background: #FFF7ED; color: #9A3412; text-decoration: none; }
.ws-pr-chip svg { width: 13px; height: 13px; }
.ws-pos { display: flex; align-items: center; gap: 2px; }
.ws-pos-text { font-size: 12px; color: var(--text-secondary); min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.ws-icon-btn { width: 32px; height: 32px; border-radius: var(--radius); border: none; background: var(--bg-sunken); color: var(--text-secondary); font-size: 17px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.ws-icon-btn:hover:not([disabled]) { background: var(--border); color: var(--text); }
.ws-icon-btn[disabled] { opacity: .4; cursor: default; }
.ws-close { font-size: 22px; }
.ws-more { position: relative; }
.ws-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 5px; z-index: 5; }
.ws-menu.open { display: flex; flex-direction: column; }
.ws-menu-item { text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 5px; font-size: 13px; color: var(--text); }
.ws-menu-item:hover, .ws-menu-item:focus { background: var(--bg-sunken); outline: none; }
.ws-menu-item.danger { color: var(--danger); }
.ws-tabs { display: flex; align-items: stretch; gap: 2px; min-height: 42px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.ws-tab { display: inline-flex; align-items: center; gap: 6px; border: none; background: none; padding: 0 12px; font-size: 13px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid transparent; white-space: nowrap; }
.ws-tab:hover { color: var(--text); }
.ws-tab.active { color: var(--purple); border-bottom-color: var(--purple); }
.ws-tab-key { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.ws-tab-count { font-size: 11px; background: var(--bg-sunken); color: #4B5563; border-radius: 9px; padding: 1px 7px; }
.ws-dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.ws-tab-hint { align-self: center; margin-left: auto; font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; padding-left: 12px; }
.ws-body { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--ws-left) minmax(0, 1fr) var(--ws-right); }
.ws.ws-left-closed .ws-body { grid-template-columns: var(--ws-rail-closed) minmax(0, 1fr) var(--ws-right); }
.ws.ws-right-closed .ws-body { grid-template-columns: var(--ws-left) minmax(0, 1fr) var(--ws-rail-closed); }
.ws.ws-left-closed.ws-right-closed .ws-body { grid-template-columns: var(--ws-rail-closed) minmax(0, 1fr) var(--ws-rail-closed); }
.ws-body.ws-body-single { display: block; overflow: auto; }
.ws-left, .ws-right { overflow-y: auto; background: var(--white); padding: 10px 14px 24px; position: relative; }
.ws-left { border-right: 1px solid var(--border); }
.ws-right { border-left: 1px solid var(--border); }
.ws-left-closed .ws-left, .ws-right-closed .ws-right { padding: 6px 2px; overflow: hidden; }
.ws-rail-toggle { border: none; background: var(--bg-sunken); color: var(--text-secondary); width: 28px; height: 24px; border-radius: 5px; font-size: 13px; display: block; margin-left: auto; }
.ws-right .ws-rail-toggle { margin-left: 0; }
.ws-left-closed .ws-left .ws-rail-toggle, .ws-right-closed .ws-right .ws-rail-toggle { margin: 0 auto; }
.ws-rail-toggle:hover { background: var(--border); color: var(--text); }
.ws-rail-vlabel { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); margin: 12px auto 0; }
.ws-rail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin: 16px 0 6px; font-family: var(--font-body); }
.ws-rail-label-row { display: flex; align-items: baseline; justify-content: space-between; }
.ws-rail-link { display: block; width: 100%; text-align: left; border: none; background: none; padding: 4px 6px; border-radius: 5px; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-rail-link:hover { background: var(--bg-sunken); color: var(--purple); }
.ws-rail-link.lvl-2 { padding-left: 14px; } .ws-rail-link.lvl-3 { padding-left: 22px; } .ws-rail-link.lvl-4 { padding-left: 30px; }
.ws-rail-link.ac-pass { color: var(--success); } .ws-rail-link.ac-fail { color: var(--danger); }
.ws-rail-empty, .ws-empty-text { font-size: 12.5px; color: var(--text-secondary); list-style: none; }
.ws-link-btn { border: none; background: none; color: var(--purple); font-size: 12px; font-weight: 600; padding: 2px 4px; }
.ws-center { overflow-y: auto; background: var(--bg); min-width: 0; }
.ws-center:focus { outline: none; }
.ws-center-inner { max-width: var(--ws-read-max); margin: 0 auto; padding: 22px 28px 60px; }
.ws-notfound { padding: 60px 16px; }
.ws-banner { border-radius: var(--radius); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.ws-banner-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
/* BR-RW-22 — conflict banner (A2) + "updated elsewhere" bar (A7) */
.ws-conflict { border: 1px solid #F3C9C9; background: var(--danger-bg); border-radius: var(--radius-lg, 8px); padding: 12px 14px; margin: 0 0 12px; }
.ws-conflict.reloaded { border-color: #FDE68A; background: #FFFBEB; }
.ws-conflict-h { font-weight: 700; color: #991B1B; font-size: 13px; }
.ws-conflict.reloaded .ws-conflict-h { color: #92400E; }
.ws-conflict p { font-size: 12.5px; margin: 4px 0 10px; color: #7F1D1D; }
.ws-conflict.reloaded p { color: #78350F; }
.ws-diff { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; margin-bottom: 10px; }
.ws-diff-col { background: #fff; border: 1px solid #F3C9C9; border-radius: var(--radius); overflow: hidden; min-width: 0; }
.ws-diff-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 5px 8px; background: #FFF5F5; border-bottom: 1px solid #F3C9C9; color: #7F1D1D; }
.ws-diff-b { max-height: 260px; overflow: auto; padding: 4px 0; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11.5px; line-height: 1.55; }
.ws-diff-l { padding: 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ws-diff-l.add { background: #E7F7EE; }
.ws-diff-l.del { background: #FDE8E8; text-decoration: line-through; text-decoration-color: rgba(185,28,28,.5); }
.ws-conflict-a { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-updated-bar { display: flex; align-items: center; gap: 10px; background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; border-radius: var(--radius); padding: 7px 8px 7px 12px; font-size: 13px; margin-bottom: 14px; }
.ws-updated-bar .ws-updated-t { flex: 1; min-width: 0; }
.toast button.toast-action { background: none; border: none; font: inherit; cursor: pointer; }
@media (max-width: 720px) { .ws-diff { grid-template-columns: 1fr; } .ws-conflict-a .btn { flex: 1 1 auto; justify-content: center; } }
.ws-banner-closed { background: var(--success-bg); color: #065F46; border: 1px solid #A7F3D0; font-weight: 600; }
.ws-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.ws-stat { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 12px; min-width: 0; }
.ws-stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
.ws-stat-value { font-size: 14px; font-weight: 600; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-bar { height: 5px; background: var(--bg-sunken); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.ws-bar span { display: block; height: 100%; background: var(--success); }
.ws-progress { background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: var(--radius); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.ws-field { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px 14px; margin-bottom: 16px; }
.ws-field.editing { border-color: var(--purple-light); box-shadow: 0 0 0 3px rgba(155,89,182,0.10); }
.ws-field-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ws-field-label { font-family: var(--font-body); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); margin: 0; flex: 0 0 auto; }
.ws-key-assets .ws-field-label, .ws-deps-box .ws-field-label, .ws-center-inner > .ws-field-label { margin: 18px 0 8px; }
.ws-field-hint { font-size: 11.5px; color: var(--text-secondary); margin-left: auto; }
.ws-pencil-btn kbd { margin-left: 4px; }
.ws-read { border-radius: var(--radius); padding: 4px 6px; margin: 0 -6px; outline: none; }
.ws-read.editable:hover { outline: 1px dashed var(--border-strong); outline-offset: 2px; }
.ws-read:focus-visible { outline: 2px solid var(--purple-light); outline-offset: 2px; }
.ws-md { font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.ws-md h1, .ws-md h2, .ws-md h3, .ws-md h4 { font-family: var(--font-title); color: #1f2733; margin: 0.9em 0 0.4em; scroll-margin-top: 12px; }
.ws-md h1 { font-size: 19px; } .ws-md h2 { font-size: 16.5px; } .ws-md h3 { font-size: 15px; } .ws-md h4 { font-size: 14px; }
.ws-md p { margin: 0.5em 0; } .ws-md ul, .ws-md ol { margin: 0.5em 0 0.5em 1.4em; }
.ws-md a { color: var(--purple); }
.ws-md code { font-family: var(--font-mono); background: var(--bg-sunken); padding: 1px 4px; border-radius: 4px; font-size: 0.88em; }
.ws-md pre { background: #1f2733; color: #e6e9ef; padding: 10px 12px; border-radius: var(--radius); overflow-x: auto; }
.ws-md pre code { background: none; color: inherit; }
.ws-md table { border-collapse: collapse; margin: 0.6em 0; display: block; overflow-x: auto; }
.ws-md th, .ws-md td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; font-size: 13px; }
.ws-md img { max-width: 100%; }
textarea.ws-editor-ta { width: 100%; min-height: 280px; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; resize: vertical; }
.ws-editor-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; min-height: 120px; background: var(--bg); }
.ws-editor-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.ws-editor-foot kbd { margin-left: 4px; background: transparent; color: inherit; border-color: currentColor; }
.ws-unsaved { font-size: 12px; color: #92400E; font-weight: 600; margin-left: auto; }
.ws-asset-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ws-asset-tile { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: left; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px; min-width: 0; }
.ws-asset-tile:hover { border-color: var(--purple-light); }
.ws-asset-tile img { width: 100%; height: 92px; object-fit: cover; border-radius: 5px; background: var(--bg-sunken); }
.ws-asset-glyph { height: 92px; display: flex; align-items: center; justify-content: center; background: var(--bg-sunken); border-radius: 5px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); }
.ws-asset-label { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-deps .dep-chip, .ws-deps-box .dep-chip { padding: 0; gap: 0; }
.dep-open { border: none; background: none; color: inherit; font: inherit; padding: 3px 8px; cursor: pointer; }
.dep-open[disabled] { cursor: default; }
.dep-x { border: none; background: none; color: inherit; opacity: .7; padding: 3px 7px 3px 0; font-size: 13px; }
.ws-dep-input { width: 140px; font-size: 12px; padding: 4px 8px; }
.ws-props { display: flex; flex-direction: column; gap: 6px; }
.ws-prop { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 8px; }
.ws-prop-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.ws-prop-select, .ws-prop-input { font-size: 12.5px; padding: 4px 8px; min-width: 0; width: 100%; }
.ws-prop-value { font-size: 13px; }
.ws-comments, .ws-events { list-style: none; margin: 0; padding: 0; }
.ws-comments .comment { list-style: none; }
.ws-composer { width: 100%; margin-top: 8px; font-size: 13px; }
.ws-composer-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.ws-meta { font-size: 11.5px; color: var(--text-secondary); }
.ws-events-full { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 4px 14px; }
.ws-ac-list .ac-row { background: var(--white); }
.ws-help { width: 100%; border-collapse: collapse; font-size: 13px; }
.ws-help td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.ws-help td:first-child { width: 150px; }
/* Readable metadata inside the workspace must pass AA (--text-faint does not). */
.ws .ctx-note, .ws .comment-meta, .ws .ctx-ref-path, .ws .activity-meta { color: var(--text-secondary); }
.ws .md-tab:not(.active) { color: #4B5563; }
@media (max-width: 1199px) {
  :root { --ws-right: 300px; }
}
/* Phones: a simple stacked view; nothing overflows. The phone fallback
   proper (.ws-phone, BKL-rw-15) is at the end of this file. */
@media (max-width: 720px) {
  .ws-head { padding: 8px 12px; gap: 6px; }
  .ws-title-wrap { max-width: 100%; flex: 1 1 100%; order: 5; }
  .ws-title { white-space: normal; font-size: 16px; }
  .ws-pos, .ws-tab-key, .ws-tab-hint, .ws-rail-toggle, .ws-field-hint { display: none; }
  .ws-body, .ws.ws-left-closed .ws-body, .ws.ws-right-closed .ws-body, .ws.ws-left-closed.ws-right-closed .ws-body { display: block; overflow-y: auto; }
  .ws-left { display: none; }
  .ws-center { overflow: visible; }
  .ws-center-inner { padding: 14px 16px 24px; }
  .ws-right, .ws-right-closed .ws-right { border-left: none; border-top: 1px solid var(--border); padding: 4px 16px 24px; overflow: visible; }
  .ws-right-closed .ws-right .ws-rail-vlabel { display: none; }
  .ws-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ws-asset-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .ws-pencil { transition: none; } }

/* Anchored comments (BKL-rw-2): composer chip, thread label + state badge */
.composer-anchor { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.anchor-chip, .anchor-label { color: var(--purple); background: rgba(110, 44, 139, 0.09); white-space: normal; }
.anchor-remove { padding: 0 6px; }
.comment-anchor { margin: 2px 0 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.anchor-state-outdated { color: #B45309; background: #FFFBEB; border: 1px dashed #D97706; }
.anchor-state-gone { color: var(--text-secondary); background: var(--bg-sunken); }
.composer-error { display: none; font-size: 12px; color: var(--danger, #B91C1C); margin-top: 4px; }
.composer-error.show { display: block; }

/* Threads, replies, resolve/reopen, pins (BKL-rw-8) */
.ws-tcount { margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: none; letter-spacing: 0; }
.ws-th-filter { display: flex; gap: 2px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 7px; padding: 2px; margin: 4px 0 10px; }
.ws-th-filter button { flex: 1; border: none; background: none; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); padding: 4px; border-radius: 5px; white-space: nowrap; cursor: pointer; }
.ws-th-filter button.on { background: var(--white); color: var(--purple); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.ws-threads { display: flex; flex-direction: column; gap: 10px; }
.ws-thread > .comment { border: none; padding: 0; background: none; }
.ws-thread.hl { border-color: var(--purple-light); box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.18); transition: box-shadow .2s; }
.ws-thread.resolved { opacity: .72; background: var(--bg-sunken); }
.ws-replies { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.comment.comment-reply { border: none; border-left: 2px solid var(--border); border-radius: 0; padding: 0 0 0 10px; background: none; }
.ws-resolved-line { font-size: 11.5px; color: var(--text-secondary); margin-top: 6px; }
.ws-th-actions { display: flex; gap: 14px; margin-top: 7px; }
.ws-reply-box { margin-top: 8px; }
.ws-reply-input { width: 100%; font-size: 13px; }
.ws-reply-box .ws-composer-foot { gap: 6px; }
.ws-pins { display: inline-flex; gap: 4px; margin-right: 6px; vertical-align: middle; }
.ws-pin { display: inline-flex; align-items: center; justify-content: center; min-width: 19px; height: 19px; padding: 0 5px; border: none; border-radius: 10px; background: var(--purple); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1; cursor: pointer; flex-shrink: 0; }
.ws-pin.muted { background: #75654A; }
.anchor-label.muted, .anchor-state.muted { opacity: .65; filter: grayscale(.6); }
@media (prefers-reduced-motion: reduce) { .ws-thread.hl { transition: none; } }
/* Phones: replies and resolve are a larger-screen feature (BR-RW-47). */
@media (max-width: 720px) { .ws-th-actions, .ws-reply-box { display: none; } }

/* Spec tab (BKL-rw-4): heading gutters, outline counts, selection button,
   task lists, deferred external images, mermaid */
.spec-h-row { display: flex; align-items: center; gap: 10px; margin: 0.9em 0 0.4em; }
.ws-md .spec-h-row > .spec-h { margin: 0; }
.spec-h { position: relative; outline: none; border-radius: 4px; }
.spec-h:focus { box-shadow: 0 0 0 2px var(--purple-light); }
.spec-gutter { user-select: none; -webkit-user-select: none; display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; font-family: var(--font-body); font-weight: 600; }
.spec-comment-btn { opacity: 0; border: 1px solid var(--border-strong); background: var(--white); color: var(--purple); border-radius: 6px; font-size: 12px; padding: 1px 7px; cursor: pointer; transition: opacity var(--transition); }
.spec-comment-btn kbd { font-size: 10px; }
.spec-h-row:hover .spec-comment-btn, .spec-h-row:focus-within .spec-comment-btn { opacity: 1; }
.spec-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ws-pin, #6E2C8B); color: #fff; font-size: 11px; font-weight: 700; font-family: var(--font-body); }
.spec-count-outdated { background: #FEF3C7; color: #7a4f00; border: 1px dashed #D97706; }
.spec-outline-link { display: flex; align-items: center; gap: 6px; }
.spec-outline-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ws-rail-sub { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); margin: 8px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-pane { margin-top: 18px; }
.spec-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); margin: 0 0 8px; }
.spec-path { font-family: var(--font-mono); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-sel-btn { position: fixed; z-index: 60; box-shadow: var(--shadow-md); }
.spec-sel-btn kbd { font-size: 10px; background: rgba(255,255,255,0.2); border-radius: 3px; padding: 0 3px; }
.ws-md ul.task-list, .md-body ul.task-list { list-style: none; margin-left: 0.2em; }
.task-item input[type=checkbox] { margin: 0 6px 0 0; vertical-align: -1px; }
.md-ext-img { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px dashed var(--border-strong); border-radius: 6px; font-size: 12.5px; background: var(--bg-sunken); }
.md-load-preview { border: 1px solid var(--border-strong); background: var(--white); border-radius: 5px; font-size: 12px; padding: 1px 8px; cursor: pointer; color: var(--purple); }
.ws-md .mermaid { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin: 0.6em 0; overflow-x: auto; text-align: center; }
.ws-md .mermaid:not([data-processed]) { white-space: pre-wrap; font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); text-align: left; }
@media (prefers-reduced-motion: reduce) { .spec-comment-btn { transition: none; } }

/* ─── Review draft + Submit dialog (BKL-rw-12, BR-RW-14a/36/38) ───── */
.wsr-head { display: inline-flex; align-items: center; gap: 4px; }
.wsr-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px dashed var(--ws-pending); border-radius: 999px; background: #F5F3FF; color: #5B21B6; font-size: 12.5px; cursor: pointer; }
.wsr-badge:hover, .wsr-badge:focus-visible { background: #EDE9FE; }
.wsr-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ws-pending); }
.wsr-submit { font-weight: 700; text-decoration: underline; }
.wsr-chip { border: 1px dashed var(--ws-pending); color: #5B21B6; background: #F5F3FF; font-size: 11px; margin-right: 6px; }
.ws-thread.wsr-pending { border: 1px dashed var(--ws-pending); border-left: 3px dashed var(--ws-pending); background: #FAF8FF; }
.comment-reply.wsr-pending { border: 1px dashed var(--ws-pending); border-left: 3px dashed var(--ws-pending); background: #FAF8FF; padding: 6px 8px; border-radius: var(--radius); }
.ac-row.wsr-pending { outline: 1px dashed var(--ws-pending); outline-offset: 2px; background: #FAF8FF; }
.ws-pin.pending { background: var(--ws-pending); outline: 2px dashed var(--ws-pending); outline-offset: 1px; }
.wsp-n.wsp-posted.pending { background: var(--ws-pending); }
.wsr-post-now { margin-right: auto; }
.wsr-card { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--border); border-left: 3px solid var(--ws-pin); border-radius: var(--radius); background: var(--bg); }
.wsr-card.wsr-v-request_changes { border-left-color: #B91C1C; }
.wsr-card.wsr-v-approve { border-left-color: #15803D; }
.wsr-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.wsr-card-body { font-size: 13px; white-space: pre-wrap; }
.wsr-card-meta { margin-top: 4px; }
.wsr-verdict-request_changes { background: #FEE2E2; color: #991B1B; }
.wsr-verdict-approve { background: #DCFCE7; color: #166534; }
.wsr-verdict-comment { background: #EDE9FE; color: #5B21B6; }
.wsr-dialog .modal-body { display: flex; flex-direction: column; gap: 10px; }
.wsr-verdicts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wsr-vcard { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--white); cursor: pointer; }
.wsr-vcard.on { border: 2px solid var(--purple); background: #FAF5FF; }
.wsr-vlabel { font-weight: 700; font-size: 13.5px; }
.wsr-vhint { font-size: 12px; color: var(--text-secondary); }
.wsr-warn { font-size: 12.5px; color: #7a4f00; background: #FEF3C7; border-radius: var(--radius); padding: 6px 10px; }
.wsr-h3 { font-size: 13px; margin: 6px 0 0; }
.wsr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.wsr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 6px; border: 1px dashed var(--ws-pending); border-radius: var(--radius); }
.wsr-row.invalid { border-color: #B91C1C; border-style: solid; }
.wsr-row-open { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; text-align: left; background: none; border: none; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.wsr-row-text { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsr-row-err { flex-basis: 100%; }
.wsr-effect { padding: 8px 12px; border-radius: var(--radius); background: var(--bg-sunken); }
.wsr-effect.warn { background: #FEF3C7; }
.wsr-effect-line { font-weight: 600; font-size: 13.5px; }
.wsr-ctl { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 13px; }
.wsr-final { font-size: 12px; color: var(--text-secondary); }
.wsr-banner { padding: 10px 12px; border-radius: var(--radius); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.wsr-banner-error { background: #FEE2E2; color: #7F1D1D; }
.wsr-banner-conflict { background: #FEF3C7; color: #713F12; }
.wsr-banner-actions { display: flex; gap: 8px; margin-top: 4px; }
.wsr-changes { margin: 2px 0 0 18px; padding: 0; }
.wsr-spin { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: wsr-spin .8s linear infinite; vertical-align: -2px; }
@keyframes wsr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wsr-spin { animation: none; } }

/* Phone fallback (BKL-rw-15, BR-RW-47 / D11): one readable column, a scrolling
   tab strip, 16px gutters, targets ≥ 40px, Discussion at the end of every tab,
   no edit/review tooling. workspace.js sets .ws-phone at ≤ 720px and does not
   render the rails; the rules below only apply there. */
@media (max-width: 720px) {
  .ws-phone .ws-head { padding: 8px 16px; flex-wrap: wrap; row-gap: 6px; }
  /* Row 1: id · ⋯ · ×; row 2: the title (wrapping); row 3: status chips. */
  .ws-phone .ws-head > .ws-id { order: 1; }
  .ws-phone .ws-head > .spacer { order: 2; flex: 1 1 auto; }
  .ws-phone .ws-head > .ws-more { order: 3; }
  .ws-phone .ws-head > .ws-close { order: 4; }
  .ws-phone .ws-head > .ws-title-wrap { order: 5; flex: 1 1 100%; }
  .ws-phone .ws-head > .ws-head-chips { order: 6; flex: 1 1 100%; flex-wrap: wrap; }
  .ws-phone .ws-icon-btn { min-width: 40px; min-height: 40px; }
  .ws-phone .ws-head [aria-label^="Keyboard shortcuts"] { display: none; }
  .ws-phone .ws-pr-chip { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .ws-phone .ws-tabs { padding: 0 16px; scroll-padding: 0 16px; overscroll-behavior-x: contain; }
  .ws-phone .ws-tab { min-height: 44px; flex-shrink: 0; }
  .ws-phone .ws-center-inner { padding: 14px 16px 32px; overflow-wrap: anywhere; }
  .ws-phone .ws-md img, .ws-phone .ws-md svg, .ws-phone .ws-md video { max-width: 100%; height: auto; }
  .ws-phone .ws-md pre, .ws-phone .ws-md table { display: block; max-width: 100%; overflow-x: auto; }
  .ws-phone .wsa-chip, .ws-phone .ws-link-btn, .ws-phone .ws-th-filter button, .ws-phone .wsa-tile-actions > * { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .ws-phone .wsa-chip { min-width: 40px; }
  .ws-phone .ws-phone-discussion .btn { min-height: 40px; min-width: 88px; justify-content: center; }
  .ws-phone .ws-composer { font-size: 16px; }   /* no iOS zoom-on-focus */
  /* Not on phones: pins and heading counts (comment mode), spec gutters. */
  .ws-phone .ws-pins, .ws-phone .ws-pin, .ws-phone .spec-gutter, .ws-phone .spec-sel-btn { display: none; }
  .ws-phone .spec-split-btn, .ws-phone .ws-split, .ws-phone .ws-split-bar { display: none; }   /* belt and braces: JS never renders them */
  .ws-phone-note { margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-sunken); color: var(--text-secondary); font-size: 12.5px; }
  .ws-phone-discussion { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--border); }
}
