/* ═══════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════ */
:root {
  /* ── Backgrounds (unchanged) ── */
  --bg:      #0b0d12;
  --s1:      #10131b;   /* sidebar */
  --s2:      #13161f;   /* surface */
  --s3:      #191d29;   /* elevated */
  --s4:      #1f2433;   /* hover */

  /* ── Borders (unchanged) ── */
  --b1:      #252a3a;   /* border subtle */
  --b2:      #2e3548;   /* border mid */
  --b3:      #3d4660;   /* border strong */

  /* ── Accent colors (unchanged) ── */
  --accent:  #4fffb0;   /* green  — 9.8:1 on --s2 */
  --blue:    #5b9fff;   /* blue   — 5.8:1 on --s2 */
  --orange:  #ff9f43;   /* Level A badge — 7.4:1 on --s2 */
  --red:     #ff6b6b;   /* fail/danger — 5.3:1 on --s2 */
  --yellow:  #ffd166;   /* warn  — 9.2:1 on --s2 */

  /* ── Text scale (contrast-fixed) ──
     --text  #e4e8f4 : ~15:1 on --bg, ~13:1 on --s2  → primary content
     --text2 #a8b2cc : ~7.6:1 on --bg, ~6.6:1 on --s2 → secondary content (AA large & normal)
     --text3 #6d7fa0 : ~4.6:1 on --bg, ~4.0:1 on --s2 → tertiary / labels (AA large text only)
     --text4 #4a5570 : ~2.8:1 on --bg → decorative chrome only (chevrons, non-text icons)
  ── */
  --text:    #e4e8f4;
  --text2:   #a8b2cc;
  --text3:   #6d7fa0;
  --text4:   #4a5570;   /* decorative only — never on body text */

  --mono:    'IBM Plex Mono', monospace;
  --sans:    'IBM Plex Sans', sans-serif;
  --serif:   'IBM Plex Serif', serif;
  --r:       6px;
  --safe-b:  env(safe-area-inset-bottom, 0px);
  --safe-l:  env(safe-area-inset-left,   0px);
  --safe-r:  env(safe-area-inset-right,  0px);
  --hdr:     52px;
  --tab:     60px;
  --sidebar: 290px;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  min-height: 100dvh;
}

/* ── SKIP LINK ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  background: var(--accent);
  color: #000;
  padding: 8px 14px;
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  z-index: 9999;
  transition: top 0.15s;
  text-decoration: none;
}
.skip-link:focus { top: 8px; outline: 3px solid #fff; outline-offset: 2px; }

/* ═══════════════════════════════════════════
   HEADER
═══════════════════════════════════════════ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--hdr);
  background: var(--s2);
  border-bottom: 1px solid var(--b1);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 calc(12px + var(--safe-l));
  padding-right: calc(12px + var(--safe-r));
  flex-shrink: 0;
}

.logo {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
}
.logo em { color: var(--text4); font-style: normal; }
.logo-word { display: none; }
@media (min-width: 500px) { .logo-word { display: inline; } }

.logo-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--r);
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.logo-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.logo-btn:hover { opacity: 0.8; }

.search-wrap { flex: 1; position: relative; min-width: 0; }
.search-wrap input {
  width: 100%;
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  padding: 7px 36px 7px 36px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,255,176,0.12);
}
.search-wrap input::placeholder { color: var(--text3); }
.search-icon, .search-clear {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
  display: flex; align-items: center;
  font-size: 15px;
}
.search-icon  { left: 11px; }
.search-clear {
  right: 10px;
  pointer-events: all;
  cursor: pointer;
  background: none; border: none;
  color: var(--text3);
  font-size: 14px;
  min-width: 28px; min-height: 28px;
  display: none;
  border-radius: 50%;
  justify-content: center;
}
.search-clear:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-clear.visible { display: flex; }
.search-clear:hover { color: var(--text2); }

.search-scope {
  display: none;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

@media (min-width: 1024px) {
  .search-scope { display: block; }
}

.hdr-actions { display: none; flex-shrink: 0; }
@media (min-width: 768px) { .hdr-actions { display: flex; gap: 6px; } }

/* ── BUTTONS ── */
.btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid var(--b3);
  background: var(--s3);
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  text-decoration: none;
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:active { opacity: 0.72; transform: scale(0.97); }
@media (hover: hover) { .btn:hover { border-color: var(--accent); color: var(--accent); } }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #000; }
@media (hover: hover) { .btn-primary:hover { background: #3beeaa; color: #000; border-color: #3beeaa; } }
.btn-secondary { border-color: rgba(91,159,255,.45); color: var(--blue); }
@media (hover: hover) { .btn-secondary:hover { border-color: var(--blue); color: var(--blue); } }
.btn-danger  { border-color: var(--red); color: var(--red); }
.btn-sm { min-height: 34px; font-size: 10px; padding: 0 10px; }

/* Hide export on mobile header */
.btn-export { display: none; }
@media (min-width: 768px) { .btn-export { display: inline-flex; } }

/* ═══════════════════════════════════════════
   SHELL — SIDEBAR + MAIN
═══════════════════════════════════════════ */
.app-shell {
  display: flex;
  flex-direction: column;    /* mobile: stacked */
  height: calc(100vh - var(--hdr) - var(--tab));
  height: calc(100dvh - var(--hdr) - var(--tab));
  overflow: hidden;
}
@media (min-width: 768px) {
  .app-shell {
    flex-direction: row;
    height: calc(100vh - var(--hdr));
    height: calc(100dvh - var(--hdr));
  }
}

/* ── MOBILE BOTTOM NAV ── */
.mob-tabs {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--s2);
  border-top: 1px solid var(--b1);
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}
@media (min-width: 768px) { .mob-tabs { display: none; } }
.mob-tab {
  flex: 1;
  min-height: var(--tab);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.12s;
}
.mob-tab:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.mob-tab[aria-selected="true"] { color: var(--accent); }
.mob-tab-label { font-size: 11px; letter-spacing: 0.06em; }

/* ── FLOATING ACTION BUTTON (mobile) ── */
.mob-fab {
  display: flex;
  position: fixed;
  bottom: calc(var(--tab) + var(--safe-b) + 14px);
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 140;
  box-shadow: 0 4px 20px rgba(79,255,176,0.35);
  touch-action: manipulation;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.mob-fab:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.mob-fab:active { transform: scale(0.93); }
@media (min-width: 768px) { .mob-fab { display: none; } }
@media (hover: hover) { .mob-fab:hover { box-shadow: 0 6px 24px rgba(79,255,176,0.45); transform: scale(1.04); } }

/* ── SIDEBAR ── */
.sidebar {
  width: 100%;
  background: var(--s1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  border-right: none;
}
@media (min-width: 768px) {
  .sidebar { width: var(--sidebar); min-width: var(--sidebar); border-right: 1px solid var(--b1); }
}
.sidebar[hidden] { display: none !important; }
@media (min-width: 768px) { .sidebar[hidden] { display: flex !important; } }

/* Level filter bar */
.lvl-bar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--b1);
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}
.lvl-label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; color: var(--text3); text-transform: uppercase; padding-right: 2px; }
.lvl-chip {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 20px;
  border: 1px solid var(--b3);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.12s;
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex; align-items: center;
}
.lvl-chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.lvl-chip[aria-pressed="true"].chip-all  { border-color: var(--text2);  color: var(--text2); }
.lvl-chip[aria-pressed="true"].chip-a   { border-color: var(--orange); color: var(--orange); background: rgba(255,159,67,.08); }
.lvl-chip[aria-pressed="true"].chip-aa  { border-color: var(--accent); color: var(--accent); background: rgba(79,255,176,.08); }
.lvl-chip[aria-pressed="true"].chip-aaa { border-color: var(--blue);   color: var(--blue);   background: rgba(91,159,255,.08); }
.lvl-chip.chip-reset { margin-left: auto; color: var(--text3); border-color: var(--b2); font-size: 10px; }
.lvl-chip.chip-reset:hover { color: var(--text); border-color: var(--b3); }
.lvl-chip:active { opacity: 0.7; }

/* Sidebar scroll region */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 8px;
}
.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }

.bp-sidebar {
  border-top: 1px solid var(--b1);
  border-bottom: 1px solid var(--b1);
  background: var(--s2);
}

.bp-side-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.bp-side-toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.bp-side-count {
  color: var(--text3);
  font-size: 10px;
  text-transform: none;
}

.bp-side-body {
  padding: 0 10px 10px;
}

.bp-filter-group.bp-filter-group-side {
  margin: 0 0 8px;
  padding: 8px;
}

.bp-side-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.bp-side-item {
  width: 100%;
  border: 1px solid var(--b2);
  border-radius: 8px;
  background: var(--s3);
  color: var(--text);
  text-align: left;
  padding: 8px 9px;
  cursor: pointer;
}

.bp-side-item.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(79,255,176,.25);
}

.bp-side-title {
  display: block;
  font-size: 12px;
  line-height: 1.4;
}

.bp-mini-tags {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.bp-mini-tag {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text2);
  border: 1px solid var(--b3);
  border-radius: 999px;
  padding: 1px 6px;
}

.bp-side-empty {
  border: 1px dashed var(--b2);
  border-radius: 8px;
  padding: 10px;
  color: var(--text3);
  font-size: 12px;
}

/* Sidebar footer */
.sidebar-foot {
  padding: 9px 12px;
  border-top: 1px solid var(--b1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar-count { font-family: var(--mono); font-size: 10px; color: var(--text2); letter-spacing: 0.04em; }
.btn-export-mob { display: inline-flex; }
@media (min-width: 768px) { .btn-export-mob { display: none; } }

/* ── PRINCIPLE GROUP ── */
.principle-group { border-bottom: 1px solid var(--b1); }

.principle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  transition: background 0.1s;
  min-height: 44px;
}
.principle-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
@media (hover: hover) { .principle-btn:hover { background: var(--s3); } }
.principle-btn:active { background: var(--s4); }

.principle-num {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.05em;
  flex-shrink: 0;
  width: 18px;
}
.principle-name {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  flex: 1;
}
.principle-btn[aria-expanded="true"] .principle-name { color: var(--text); }

.principle-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.principle-count-badge {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}
.principle-chevron {
  font-size: 10px;
  color: var(--text4);
  transition: transform 0.18s;
  flex-shrink: 0;
  line-height: 1;
}
.principle-btn[aria-expanded="true"] .principle-chevron { transform: rotate(180deg); }

/* Guideline sub-groups within a principle */
.principle-body { display: none; }
.principle-body.open { display: block; }

.guideline-group { border-top: 1px solid var(--b1); }

.guideline-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 28px;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  min-height: 44px;
  transition: background 0.1s;
}
.guideline-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
@media (hover: hover) { .guideline-btn:hover { background: var(--s3); } }
.guideline-btn:active { background: var(--s4); }

.guideline-num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  flex-shrink: 0;
  width: 24px;
}
.guideline-name {
  font-size: 11px;
  color: var(--text2);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guideline-chevron {
  font-size: 9px;
  color: var(--text4);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.guideline-btn[aria-expanded="true"] .guideline-chevron { transform: rotate(180deg); }
.guideline-btn[aria-expanded="true"] .guideline-name { color: var(--text); }

.guideline-body { display: none; }
.guideline-body.open { display: block; }

/* ── CRITERION ROW ── */
.sc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 9px 52px;
  cursor: pointer;
  touch-action: manipulation;
  border-left: 3px solid transparent;
  transition: background 0.08s, border-color 0.08s;
  min-height: 44px;
  position: relative;
}
.sc-item:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
@media (hover: hover) { .sc-item:hover { background: var(--s3); } }
.sc-item:active { background: var(--s4); }
.sc-item.active  { background: var(--s3); border-left-color: var(--accent); }
.sc-item.filtered-out { display: none; }

.sc-num {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text2);
  flex-shrink: 0;
  width: 30px;
}
.sc-title {
  font-size: 12px;
  color: var(--text);
  flex: 1;
  line-height: 1.3;
}
.sc-item.active .sc-title { color: var(--text); }
.sc-item.has-notes .sc-title::after {
  content: none; /* dot is rendered via JS element below */
}
.sc-notes-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0.85;
}

.level-pill {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 1.4;
}
.lp-a   { background: rgba(255,159,67,.12); color: var(--orange); }
.lp-aa  { background: rgba(79,255,176,.12); color: var(--accent); }
.lp-aaa { background: rgba(91,159,255,.12); color: var(--blue);   }

/* New-in-2.2 badge */
.sc-new {
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(79,255,176,.15);
  color: var(--accent);
  border: 1px solid rgba(79,255,176,.25);
  flex-shrink: 0;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════
   MAIN DETAIL PANEL
═══════════════════════════════════════════ */
.main-panel {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}
.main-panel[hidden] { display: none !important; }
@media (min-width: 768px) { .main-panel[hidden] { display: flex !important; } }
.main-panel::-webkit-scrollbar { width: 4px; }
.main-panel::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }

.panel-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(11,13,18,.98) 0%, rgba(11,13,18,.94) 100%);
  border-bottom: 1px solid var(--b1);
  backdrop-filter: blur(12px);
}
@media (min-width: 768px) {
  .panel-toolbar {
    justify-content: space-between;
    padding: 16px 24px 14px;
  }
}

/* Mobile back button — only visible on mobile in detail view */
.mob-back-btn {
  display: none;
}
@media (max-width: 767px) {
  .mob-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    padding: 6px 10px 6px 6px;
    min-height: 44px;
    border-radius: var(--r);
    touch-action: manipulation;
    transition: opacity 0.12s;
    -webkit-appearance: none;
    appearance: none;
  }
  .mob-back-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .mob-back-btn:active { opacity: 0.7; }
  .mob-back-btn[hidden] { display: none !important; }
}

.workspace-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.workspace-chip {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.workspace-chip[aria-selected="true"] {
  background: rgba(79,255,176,.12);
  color: var(--accent);
}
.workspace-chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.workspace-meta {
  color: var(--text2);
  font-size: 12px;
  line-height: 1.5;
  max-width: 56ch;
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  padding: 48px 24px;
  color: var(--text2);
  text-align: center;
  transition: opacity 0.18s ease, transform 0.18s ease, max-height 0.18s ease, padding 0.18s ease;
  max-height: 420px;
  overflow: hidden;
}
.empty-icon { opacity: 0.2; }
.empty-state h2 { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.empty-state p  { font-size: 13px; max-width: 280px; line-height: 1.6; color: var(--text2); }

.empty-state.scrolled-away {
  opacity: 0;
  transform: translateY(-16px);
  max-height: 0 !important;
  overflow: hidden !important;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  pointer-events: none;
  visibility: hidden;
}

#emptyState, #bpEmptyState {
  flex: 0;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  margin: 0 16px 12px;
  padding: 18px 18px 16px;
  text-align: left;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 10px;
  max-height: none;
  overflow: visible;
}
@media (min-width: 600px) { #emptyState, #bpEmptyState { margin: 0 28px 14px; } }
@media (min-width: 1000px) { #emptyState, #bpEmptyState { margin: 0 40px 16px; } }
#emptyState .empty-icon, #bpEmptyState .empty-icon { opacity: 0.35; width: 40px; height: 40px; }
#emptyState h2, #bpEmptyState h2 { font-size: 13px; margin: 0; }
#emptyState p, #bpEmptyState p { max-width: 70ch; }

.workspace-intro {
  margin: 0 16px 12px;
  padding: 18px 18px 16px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 10px;
  transition: opacity 0.18s ease, transform 0.18s ease, max-height 0.18s ease, margin 0.18s ease, padding 0.18s ease;
  max-height: 220px;
  overflow: hidden;
}
@media (min-width: 600px) { .workspace-intro { margin: 0 28px 14px; } }
@media (min-width: 1000px) { .workspace-intro { margin: 0 40px 16px; } }

.workspace-intro h2 {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.workspace-intro p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text2);
  max-width: 70ch;
}

.workspace-intro.scrolled-away {
  opacity: 0;
  transform: translateY(-16px);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Detail view */
.detail {
  padding: 22px 16px calc(22px + var(--safe-b));
  max-width: 880px;
}
@media (min-width: 600px)  { .detail { padding: 28px 28px; } }
@media (min-width: 1000px) { .detail { padding: 32px 40px; } }

.bp-filter-bar {
  display: flex;
  padding: 10px 16px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
@media (min-width: 600px) { .bp-filter-bar { padding: 10px 28px; } }
@media (min-width: 1000px) { .bp-filter-bar { padding: 10px 40px; } }

.bp-tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bp-tag-chip {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 20px;
  border: 1px solid var(--b3);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
}
.bp-tag-chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.bp-tag-chip[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(79,255,176,.08);
}
.bp-tag-chip:active { opacity: 0.7; }

.bp-filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: 10px;
}

.filter-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.filter-select-wrap::after {
  content: '';
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text3);
  pointer-events: none;
}

.filter-select {
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 28px 6px 10px;
  min-height: 34px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,255,176,0.12);
}
.filter-select option {
  background: var(--s3);
  color: var(--text);
}

/* Detail header */
.detail-hdr {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--b1);
  margin-bottom: 24px;
}
@media (min-width: 580px) { .detail-hdr { flex-direction: row; align-items: flex-start; } }

.detail-meta { flex: 1; min-width: 0; }

.detail-badges {
  display: flex; flex-wrap: wrap;
  align-items: center; gap: 7px;
  margin-bottom: 10px;
}
.badge-id {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--text2); background: var(--s3);
  padding: 3px 10px; border-radius: 4px;
  border: 1px solid var(--b2);
}
.badge-level {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 3px 10px; border-radius: 4px; letter-spacing: 0.08em;
}
.badge-cat {
  font-size: 11px; color: var(--text2);
  padding: 3px 10px; border-radius: 4px;
  border: 1px solid var(--b2); background: var(--s3);
}
.badge-new22 {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 9px; border-radius: 4px;
  background: rgba(79,255,176,.12); color: var(--accent);
  border: 1px solid rgba(79,255,176,.3);
}

.detail-title {
  font-family: var(--serif);
  font-size: 22px; font-weight: 400;
  color: var(--text); line-height: 1.3;
  margin-bottom: 8px;
}
@media (min-width: 600px) { .detail-title { font-size: 24px; } }

.detail-guideline {
  font-size: 12px; color: var(--text2);
  font-family: var(--mono);
}

.detail-actions {
  display: flex; gap: 7px; flex-shrink: 0; flex-wrap: wrap;
}
@media (min-width: 580px) { .detail-actions { flex-direction: column; align-items: flex-end; } }

.detail-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 10px;
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section h3,
.detail-tags h4 {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 12px;
}

.detail-panel,
.detail-empty,
.detail-section > p,
.detail-tags {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 10px;
  padding: 16px;
}

.detail-panel p,
.detail-empty p,
.detail-section > p {
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
}

.detail-empty {
  color: var(--text2);
}

.hint {
  color: var(--text2);
}

.detail-tags > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Sections */
.section { margin-bottom: 24px; }

.section-hdr {
  font-family: var(--mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.section-hdr::after { content: ''; flex: 1; height: 1px; background: var(--b2); max-width: 180px; }

/* Intent/description */
.prose {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 8px;
  padding: 16px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.75;
}
.prose p + p { margin-top: 10px; }

/* Cards grid */
.cards { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 580px) { .cards { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 8px;
  padding: 12px 14px;
}
.card-type {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 6px;
}
.card-fail { color: var(--red); }
.card-pass { color: var(--accent); }
.card p { font-size: 13px; color: var(--text); line-height: 1.55; }

/* Text examples */
.tex-item {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-left: 3px solid var(--blue);
  border-radius: 0 8px 8px 0;
  padding: 11px 54px 11px 14px;
  margin-bottom: 8px;
  position: relative;
}
.tex-label {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  letter-spacing: 0.1em; color: var(--blue); text-transform: uppercase;
  margin-bottom: 5px;
}
.tex-text {
  font-size: 13px; color: var(--text);
  font-family: var(--serif); font-style: italic;
  line-height: 1.6; word-break: break-word;
}
.tex-item .copy-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  right: 8px; min-height: 30px; min-width: 44px;
  font-size: 10px; padding: 0 8px;
}

/* Code blocks */
.code-block {
  background: #090b10;
  border: 1px solid var(--b2);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}
.code-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px;
  background: var(--s3);
  border-bottom: 1px solid var(--b2);
  gap: 8px;
}
.code-lang {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; color: var(--text2); text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.copy-btn {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  min-height: 34px; min-width: 44px; padding: 0 10px;
  border-radius: 5px; border: 1px solid var(--b3);
  background: transparent; color: var(--text2);
  cursor: pointer; transition: all 0.12s;
  letter-spacing: 0.06em; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  touch-action: manipulation; -webkit-appearance: none; appearance: none;
}
.copy-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.copy-btn:active { opacity: 0.6; }
.copy-btn.copied { border-color: var(--accent); color: var(--accent); }

.code-scroll { padding: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.code-scroll::-webkit-scrollbar { height: 3px; }
.code-scroll::-webkit-scrollbar-thumb { background: var(--b2); }
pre { font-family: var(--mono); font-size: 12px; line-height: 1.75; color: #c9d1e0; white-space: pre; word-break: normal; }

/* Syntax */
.t-tag  { color: #7eb8f7; } .t-attr { color: #c9a8f5; }
.t-val  { color: #98e8a0; } .t-str  { color: #98e8a0; }
.t-com  { color: #687a9b; font-style: italic; }
.t-prop { color: #79d9e6; } .t-num  { color: #f5b38a; }
.t-kw   { color: #c9a8f5; } .t-sel  { color: #7eb8f7; }

/* Tags */
.tags-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 8px; border-radius: 3px;
  background: var(--s3); color: var(--text2);
  border: 1px solid var(--b2);
}

/* ═══════════════════════════════════════════
   MODAL / FORM
═══════════════════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.8);
  z-index: 400;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
@media (min-width: 640px) { .modal-bg { align-items: center; padding: 20px; } }
.modal-bg.open { opacity: 1; pointer-events: all; }

.modal {
  width: 100%;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 16px 16px 0 0;
  max-height: 92dvh; max-height: 92vh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateY(16px); transition: transform 0.2s;
  padding-bottom: var(--safe-b);
}
@media (min-width: 640px) { .modal { max-width: 680px; border-radius: 10px; max-height: 90dvh; max-height: 90vh; padding-bottom: 0; } }
.modal-bg.open .modal { transform: translateY(0); }
.modal::-webkit-scrollbar { width: 3px; }
.modal::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }

.drag-handle { width: 36px; height: 4px; background: var(--b2); border-radius: 2px; margin: 10px auto 0; }
@media (min-width: 640px) { .drag-handle { display: none; } }

.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--b1);
  position: sticky; top: 0; background: var(--s2); z-index: 1;
}
@media (min-width: 640px) { .modal-hdr { padding: 18px 24px 14px; } }
.modal-title { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text); letter-spacing: 0.06em; }
.modal-close {
  background: none; border: 1px solid var(--b3); border-radius: var(--r);
  color: var(--text2); cursor: pointer; font-size: 15px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; -webkit-appearance: none; appearance: none;
}
.modal-close:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.modal-close:active { background: var(--s4); }

.modal-body { padding: 14px 14px 0; }
@media (min-width: 640px) { .modal-body { padding: 20px 24px 0; } }

.form-row { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
@media (min-width: 480px) { .form-row { grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; } }
.form-row.full { grid-template-columns: 1fr !important; }
.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text2);
}
input[type="text"], textarea, select {
  background: var(--s3); border: 1px solid var(--b3);
  border-radius: var(--r); color: var(--text);
  font-family: var(--sans); font-size: 16px;
  padding: 10px 12px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%; -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,255,176,0.12);
}
input::placeholder, textarea::placeholder { color: var(--text3); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236d7fa0'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
select option { background: #13161f; color: #e4e8f4; }
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
textarea.mono-ta { font-family: var(--mono); font-size: 13px; min-height: 120px; background: #090b10; }

.form-divider { border: none; border-top: 1px solid var(--b2); margin: 14px 0; }
.form-sec-title {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text2); margin-bottom: 10px;
}

.add-btn {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--blue); background: none;
  border: 1px dashed rgba(91,159,255,.45); border-radius: var(--r);
  padding: 0 14px; min-height: 44px;
  cursor: pointer; width: 100%; margin-top: 6px;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; -webkit-appearance: none; appearance: none;
  transition: border-color 0.12s, background 0.12s;
}
.add-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.add-btn:active { background: rgba(91,159,255,.08); }

.rep-field { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.rep-field > textarea, .rep-field > input { flex: 1; min-width: 0; }

.rm-btn {
  background: none; border: 1px solid var(--b3); border-radius: var(--r);
  color: var(--text2); cursor: pointer; font-size: 15px;
  width: 44px; height: 44px; min-width: 44px;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px; touch-action: manipulation; flex-shrink: 0; -webkit-appearance: none; appearance: none;
}
.rm-btn:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.rm-btn:active { border-color: var(--red); color: var(--red); }

.modal-foot {
  padding: 12px 14px; border-top: 1px solid var(--b2);
  display: flex; gap: 8px;
  position: sticky; bottom: 0; background: var(--s2);
  align-items: center;
  flex-wrap: wrap;
}
@media (min-width: 640px) { .modal-foot { padding: 14px 24px; justify-content: flex-end; } }
.modal-foot .btn { flex: 1; }
@media (min-width: 640px) { .modal-foot .btn { flex: 0 0 auto; min-width: 100px; } }

.modal-error {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--red);
  line-height: 1.5;
}

.cef-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 400px) { .cef-grid { grid-template-columns: 1fr 1fr; } }

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toasts {
  position: fixed;
  bottom: calc(16px + var(--safe-b));
  left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 340px;
  z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
@media (min-width: 640px) { .toasts { left: auto; right: 20px; transform: none; width: auto; bottom: 20px; } }
.toast {
  background: var(--s4); border: 1px solid var(--b3);
  border-radius: 8px; padding: 11px 16px;
  font-family: var(--mono); font-size: 12px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
  animation: toastIn .2s ease forwards;
}
.toast.out { animation: toastOut .25s ease forwards; }
.toast-ok  { border-left: 3px solid var(--accent); }
.toast-err { border-left: 3px solid var(--red); }
@keyframes toastIn  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(4px); } }

/* ═══════════════════════════════════════════
   SEARCH OVERLAY
═══════════════════════════════════════════ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.18s, transform 0.18s;
}
.search-overlay.open {
  opacity: 1;
  pointer-events: all;
  transform: none;
}
.search-overlay-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--s2);
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.search-overlay-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 0 6px 0 0;
  min-width: 36px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  touch-action: manipulation;
  transition: color 0.12s;
}
.search-overlay-close:hover { color: var(--accent); }
.search-overlay-close:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.search-overlay-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.search-hint {
  padding: 40px 20px;
  text-align: center;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 12px;
}
.search-section { border-bottom: 1px solid var(--b1); }
.search-section-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 12px 16px 6px;
}
.search-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 16px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--b1);
  cursor: pointer;
  transition: background 0.1s;
  min-height: 44px;
  touch-action: manipulation;
}
.search-result:last-child { border-bottom: none; }
.search-result:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
@media (hover: hover) { .search-result:hover { background: var(--s3); } }
.search-result-id {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  flex-shrink: 0;
  padding-top: 2px;
  min-width: 40px;
  letter-spacing: 0.04em;
}
.search-result-body { flex: 1; min-width: 0; }
.search-result-name { flex: 1; font-size: 13px; color: var(--text); line-height: 1.35; }
.search-result-title {
  display: block;
  font-size: 13px;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 2px;
}
.search-result-sub {
  display: block;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-no-results {
  padding: 40px 20px;
  text-align: center;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 12px;
}

/* Header search — readonly trigger for overlay */
.search-wrap input[readonly] { cursor: pointer; }

/* ═══════════════════════════════════════════
   SEARCH HIGHLIGHT
═══════════════════════════════════════════ */
mark { background: rgba(79,255,176,.22); color: var(--text); border-radius: 2px; padding: 0 1px; }

/* Screen-reader only utility */
.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;
}

/* ── QUICK-ADD RESULT LIST ── */
.qa-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  touch-action: manipulation;
  border-bottom: 1px solid var(--b1);
  transition: background 0.08s;
  min-height: 44px;
}
.qa-result:last-child { border-bottom: none; }
.qa-result:focus { outline: 3px solid var(--accent); outline-offset: -3px; }
@media (hover:hover) { .qa-result:hover { background: var(--s3); } }
.qa-result:active { background: var(--s4); }
.qa-result[aria-selected="true"] { background: var(--s3); }
.qa-num  { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--text2); flex-shrink: 0; width: 36px; }
.qa-name { font-size: 13px; color: var(--text); flex: 1; line-height: 1.3; }
.qa-empty { padding: 24px 14px; text-align: center; color: var(--text2); font-size: 12px; font-family: var(--mono); }

/* ── QUICK-ADD SELECTED CRITERION HEADER ── */
.qa-sc-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.qa-sc-id {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  color: var(--text); background: var(--s4);
  padding: 3px 10px; border-radius: 4px;
  border: 1px solid var(--b3);
}
.qa-sc-name {
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--text2); flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* No results */
.no-res { padding: 28px 14px; text-align: center; color: var(--text2); font-size: 12px; font-family: var(--mono); }

/* ═══════════════════════════════════════════
   BEST PRACTICES STYLES
═══════════════════════════════════════════ */

/* Breadcrumb back navigation */
.bp-breadcrumb {
  padding: 0 0 16px;
}
.bp-back-btn {
  background: none;
  border: none;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 6px 0;
  min-height: 34px;
  -webkit-appearance: none;
  appearance: none;
  transition: color 0.12s;
}
.bp-back-btn:hover { color: var(--accent); }
.bp-back-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.bp-list {
  padding: 16px;
  overflow-y: auto;
}
@media (min-width: 600px) { .bp-list { padding: 20px 28px 28px; } }
@media (min-width: 1000px) { .bp-list { padding: 24px 40px 32px; } }

.bp-item {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.bp-item:hover {
  background: var(--s3);
  border-color: var(--b3);
}

.bp-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(79,255,176,.18);
}

/* Card top: title + edit button */
.bp-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.bp-edit-btn {
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.bp-item:hover .bp-edit-btn,
.bp-item:focus-within .bp-edit-btn {
  opacity: 1;
}

/* Title: smaller in list, full-size in detail */
.bp-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--text);
  margin: 0;
}
.bp-list .bp-title {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
}

.bp-kicker {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

.bp-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

/* Description: truncated in list, full in detail */
.bp-desc {
  color: var(--text2);
  margin-bottom: 6px;
  line-height: 1.5;
  font-size: 13px;
}
.bp-list .bp-desc {
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bp-related {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  margin: 0;
  letter-spacing: 0.02em;
}

.bp-empty {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 10px;
  padding: 28px;
}

.related-scs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.related-sc {
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.related-sc:hover {
  background: var(--s4);
}

.related-sc.invalid {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--red);
  color: var(--red);
}

.related-sc:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }