:root {
  --bg:       #f6f4ef;
  --panel:    #ffffff;
  --ink:      #1f1f1f;
  --muted:    #6b6b6b;
  --accent:   #e4572e;
  --teal:     #3b6b5c;
  --border:   #e6e2da;
  --shadow:   0 4px 20px rgba(31, 31, 31, 0.08);
  --radius:   16px;
  --font:     "Space Grotesk", system-ui, sans-serif;
  --mono:     "IBM Plex Mono", monospace;
}

* {
  box-sizing: border-box;
}

/* Ensure hidden attribute always wins over display: flex/block */
[hidden] { display: none !important; }

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(ellipse at top left, #fef1e6 0%, #f6f4ef 45%),
              radial-gradient(ellipse at bottom right, #e7f0ec, transparent 60%);
  color: var(--ink);
  font-family: var(--font);
}

/* ── App shell ─────────────────────────────────────────────────────────── */
.app {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

/* ── Status toast ──────────────────────────────────────────────────────── */
.status-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: #2b2b2b;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s;
}
.status-bar.error { background: #b93030; }
.status-bar.fading { opacity: 0; }

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.header-brand {
  flex: 1;
  min-width: 0;
}

.brand-home-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.header-brand h1 {
  margin: 0 0 1px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

/* ── Brand logo: mini inline sequence diagram ────────────────────────────── */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  margin: 0 0 1px;
  font-family: var(--font);
  letter-spacing: 0;
}

.brand-actor {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(31,31,31,0.07);
}

.brand-actor-hot {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff8f5;
}

.brand-wire {
  display: inline-block;
  width: 18px;
  height: 1.5px;
  background: var(--teal);
  flex-shrink: 0;
  position: relative;
  top: 0;
}

.brand-arrowhead {
  color: var(--teal);
  font-size: 9px;
  margin-left: -2px;
  margin-right: 0;
  line-height: 1;
}

.brand-down {
  font-size: 11px;
  color: var(--teal);
  font-family: var(--mono);
  font-weight: 500;
  margin-left: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-down em {
  font-style: normal;
  font-size: 10px;
  opacity: 0.7;
}

.tagline {
  font-size: 12px;
  color: var(--muted);
}

/* Connecting-mode SVG indicators */
svg.connecting .action-menu { display: none; }

svg.connecting .connect-hint .connect-ring  { opacity: 0; transition: opacity 0.12s; }
svg.connecting .connect-hint .connect-label { opacity: 0; transition: opacity 0.12s; }

svg.connecting .participant-group:hover .connect-ring  { opacity: 0.45; }
svg.connecting .participant-group:hover .connect-label { opacity: 1; }

/* Highlighted activation boxes — show which activations a return would affect */
.act-hl-source { animation: act-pulse-src 1s ease-in-out infinite alternate; }
.act-hl-target { animation: act-pulse-tgt 1s ease-in-out infinite alternate; }

@keyframes act-pulse-src {
  from { opacity: 0.7; }
  to   { opacity: 1;   }
}
@keyframes act-pulse-tgt {
  from { opacity: 0.6; }
  to   { opacity: 1;   }
}

/* Message drag handle — seq number column becomes a grab handle on hover */
.msg-drag-handle { opacity: 0.4; transition: opacity 0.1s; }
.msg-group:hover .msg-drag-handle { opacity: 1; }

/* Returnable activation boxes (top proc) — clickable to start a forced return */
.act-returnable {
  transition: filter 0.1s, stroke-width 0.1s;
}
.act-returnable:hover {
  filter: drop-shadow(0 0 3px rgba(59, 107, 92, 0.6));
  stroke-width: 2 !important;
}

/* Hover tint on activation box hit overlay — signals the box is clickable */
.act-hit:hover {
  fill: rgba(59, 107, 92, 0.12) !important;
  rx: 2;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.header-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font);
  line-height: 1;
  transition: transform 0.12s, filter 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(228, 87, 46, 0.25);
}
.btn:active {
  transform: translateY(0);
  filter: brightness(0.97);
}
.btn.ghost {
  background: #f3efe7;
  color: var(--ink);
  border-color: var(--border);
}
.btn.ghost:hover {
  background: #fff;
  box-shadow: none;
  filter: none;
}
.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}
.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
.btn.ghost.btn-loading::after {
  border-color: rgba(31,31,31,0.2);
  border-top-color: var(--ink);
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* ── Toolbar icon buttons ──────────────────────────────────────────────── */
.tb-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  flex-shrink: 0;
}
.tb-icon:hover:not(:disabled) {
  background: #f0ece4;
  border-color: var(--border);
}
.tb-icon:active:not(:disabled) { background: #e6e2da; }
.tb-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.tb-icon.active {
  background: #e4f0e8;
  color: var(--teal);
  border-color: #bcd4c4;
}
/* icon buttons that also have a caret need a little extra width */
.tb-icon-caret {
  width: auto;
  padding: 0 5px;
  gap: 2px;
  font-size: 8px;
}
.tb-icon-caret::after {
  content: '▾';
  font-size: 8px;
  opacity: 0.55;
}

/* ── Export dropdown ───────────────────────────────────────────────────── */
.dl-dropdown {
  position: relative;
}
.dl-trigger {
  gap: 4px;
}
.dl-trigger.active {
  background: #fff;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}
.dl-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 148px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
  padding: 4px 0;
  z-index: 300;
  animation: dl-pop 0.12s ease;
}
@keyframes dl-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  gap: 10px;
  text-align: left;
  transition: background 0.1s;
}
.dl-item:hover {
  background: #f3efe7;
}
.dl-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.dl-ext {
  font-family: var(--mono);
  font-size: 10px;
  color: #a09890;
  font-weight: 400;
}

/* ── Diagram wrapper ───────────────────────────────────────────────────── */
.diagram-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #fffaf3;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

.diagram-svg {
  display: block;
  min-width: 100%;
}

/* ── SVG hover-revealed elements ───────────────────────────────────────── */

/* Action menu pill [ ✎ | × ] — shared by participants and messages */
.action-menu {
  opacity: 0;
  transition: opacity 0.15s;
}
.participant-group:hover .action-menu,
.msg-group:hover .action-menu {
  opacity: 1;
}

/* Note text — only visible on hover */
.note-text {
  opacity: 0;
  transition: opacity 0.15s;
}
.participant-group:hover .note-text,
.msg-group:hover .note-text {
  opacity: 1;
}

/* ── Message kind tag (classification) ─────────────────────────────────── */
.kind-btn {
  opacity: 0;
  transition: opacity 0.15s;
}
.msg-group:hover .kind-btn {
  opacity: 1;
}
/* When a kind is set the tag is always visible */
.kind-btn.kind-set {
  opacity: 1;
}

/* Floating classification menu */
.kind-menu {
  position: fixed;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(31,31,31,0.13);
  padding: 4px 0;
  min-width: 194px;
  font-family: var(--font);
}

.kind-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink);
  transition: background 0.1s;
}
.kind-menu-item:hover { background: #f3efe7; }
.kind-menu-item.active { background: #f3efe7; font-weight: 600; }

.kind-menu-abbr {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  min-width: 34px;
  text-align: center;
}

/* ── Floating panel (input + type toggle) ──────────────────────────────── */
.floating-panel {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.floating-input {
  display: block;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 4px 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  text-align: center;
  box-shadow: 0 4px 16px rgba(228, 87, 46, 0.16);
}

.floating-panel-notes { width: 360px; }
.note-panel-cols {
  display: flex;
  gap: 8px;
  padding: 8px 8px 4px;
}
.note-panel-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.note-col-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.note-panel-dos  .note-col-label { color: #3b6b5c; }
.note-panel-donts .note-col-label { color: #c0392b; }
.note-col-ta {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font-size: 12px;
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  min-height: 80px;
  line-height: 1.5;
}
.note-panel-dos  .note-col-ta:focus { border-color: #3b6b5c; box-shadow: 0 0 0 2px rgba(59,107,92,.15); }
.note-panel-donts .note-col-ta:focus { border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192,57,43,.15); }

/* ── Type hint (Tab to toggle call/return) ─────────────────────────────── */
.type-hint {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  background: #fff;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
}

/* ── Draft restore banner ──────────────────────────────────────────────── */
.draft-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef8ec;
  border: 1px solid #e6c96a;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--ink);
  z-index: 20;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  white-space: nowrap;
}
.draft-banner-msg { flex: 1; }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  gap: 6px;
}

.empty-icon {
  font-size: 40px;
  opacity: 0.25;
  line-height: 1;
  margin-bottom: 8px;
}

.empty-state p {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.empty-sub {
  font-size: 12px !important;
  opacity: 0.7;
}


/* ── Split button (+ Participant) ──────────────────────────────────────── */
.split-btn {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}
.split-btn-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 1px solid rgba(255,255,255,0.25);
}
.split-btn-caret {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding: 0 9px;
  font-size: 11px;
}
.split-btn-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 170px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  z-index: 50;
  overflow: hidden;
}
.split-btn-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--font);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}
.split-btn-menu-item:hover { background: var(--bg); }
.split-btn-menu-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.split-btn-menu-empty {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* ── Second accent button ──────────────────────────────────────────────── */
.btn.accent2 {
  background: var(--teal);
}
.btn.accent2:hover {
  box-shadow: 0 4px 12px rgba(59, 107, 92, 0.3);
}

/* ── Content area (sidebar + canvas side-by-side) ──────────────────────── */
.content-area {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 8px;
  align-items: stretch;
  overflow: hidden;
}

/* ── Library sidebar ───────────────────────────────────────────────────── */
.library {
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  width: 252px;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: width 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.library.collapsed {
  width: 0;
  border-color: transparent;
  box-shadow: none;
}

.lib-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.library.collapsed .lib-inner {
  opacity: 0;
  pointer-events: none;
}

.lib-header {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.lib-manage-btn {
  font-size: 10px;
  padding: 2px 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.lib-title {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Drag-to-resize handle between lib-inner and lib-toggle */
.lib-resize {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  align-self: stretch;
}
.lib-resize:hover,
.lib-resize.resizing {
  background: rgba(228, 87, 46, 0.18);
}
.library.collapsed .lib-resize {
  display: none;
}
/* Disable width transition while dragging */
.library.resizing {
  transition: none !important;
}
/* When sidebar is collapsed the toggle arrow flips */
#library.collapsed + .lib-toggle {
  border-radius: 8px;
}

/* Collapse / expand toggle — standalone between sidebar and canvas */
.lib-toggle {
  flex-shrink: 0;
  align-self: flex-start;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.lib-toggle:hover {
  background: #f3efe7;
  color: var(--ink);
}

.rb-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  background: #faf8f4;
  box-sizing: border-box;
}
.rb-search:focus { border-color: var(--accent); background: #fff; }

.rb-filters {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rb-workspace-tabs {
  display: flex;
  gap: 4px;
  padding: 4px 10px 2px;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-height: 0;
  border-bottom: 1px solid var(--border);
}
.rb-workspace-tabs:empty { display: none; }
.rb-ws-tab {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  line-height: 1.5;
}
.rb-ws-tab:hover { background: var(--bg3); }
.rb-ws-tab.active { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.rb-ws-tab.ws-add { background: transparent; color: var(--muted); border-style: dashed; }

.rb-filter-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  background: #faf8f4;
  outline: none;
  cursor: pointer;
  transition: border-color 0.12s;
}
.rb-filter-select:focus { border-color: var(--accent); background: #fff; }

.rb-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 0;
}

.rb-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.rb-loading { display: flex; align-items: center; justify-content: center; gap: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 11px; height: 11px;
  border: 2px solid #e6e2da;
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
  vertical-align: middle;
}

.rb-group { margin-bottom: 4px; }

.rb-repo-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 16px 4px;
  background: var(--border);
  margin: 4px 0 2px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
.rb-repo-name:hover { color: var(--ink); }
.rb-repo-arrow {
  font-size: 9px;
  line-height: 1;
  flex-shrink: 0;
}

.rb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  transition: background 0.1s;
}
.rb-row:hover { background: #f3efe7; }
.rb-row-repo { opacity: 0.6; font-style: italic; }
.rb-row-repo:hover { opacity: 1; }
.rb-row-used { opacity: 0.55; cursor: default; }
.rb-row-used:hover { background: transparent; }
.rb-on-canvas {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-2);
  flex-shrink: 0;
}

.rb-badge {
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  min-width: 62px;
  text-align: center;
}
.rb-badge-repo       { background: #e6e2da; color: #6b6b6b; }
.rb-badge-controller { background: #fde8e0; color: #c0391f; }
.rb-badge-service    { background: #e0eeeb; color: #2a5a4a; }
.rb-badge-business   { background: #e8e4f8; color: #4a3a80; }

.rb-name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ── Diagram title overlay (inside canvas) ──────────────────────────────── */
.diagram-title-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 2px 8px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
  min-width: 60px;
  max-width: 340px;
  width: auto;
  outline: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.diagram-title-overlay::placeholder { color: var(--muted); opacity: 0.4; }
.diagram-title-overlay:hover { border-bottom-color: var(--border); color: var(--text); }
.diagram-title-overlay:focus {
  border-bottom-color: var(--accent);
  color: var(--text);
  background: rgba(255,255,255,0.75);
  border-radius: 4px 4px 0 0;
}

/* ── Account avatar (logged-in state) ──────────────────────────────────── */
.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  transition: opacity 0.12s;
  flex-shrink: 0;
}
.account-avatar:hover { opacity: 0.82; }

/* ── Account dropdown ───────────────────────────────────────────────────── */
.account-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 180px;
  z-index: 300;
  padding: 6px 0;
}
.account-dropdown-email {
  padding: 8px 14px 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.account-dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.account-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.account-dropdown-item:hover {
  background: var(--hover);
}

/* ── Modal overlay ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 31, 31, 0.46);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(31, 31, 31, 0.18);
  width: 100%;
  max-width: 380px;
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box-wide { max-width: 760px; }
.modal-box-sm   { max-width: 320px; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
}
.modal-close:hover { color: var(--ink); background: #f3efe7; }

/* Inline close (inside flex header) */
.modal-close-inline {
  position: static;
  margin-left: auto;
}

/* ── Auth modal ─────────────────────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.modal-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.modal-tab:hover:not(.active) { color: var(--ink); }

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  background: #faf8f4;
  box-sizing: border-box;
  transition: border-color 0.12s, background 0.12s;
}
.modal-input:focus { border-color: var(--accent); background: #fff; }

.modal-error {
  font-size: 12px;
  color: var(--accent);
  padding: 4px 0 0;
}

.modal-form-label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.modal-msg {
  background: #dff0eb;
  color: #1a5e40;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal-msg p { margin: 0; }

/* ── Google Sign-In button ───────────────────────────────────────────────── */
.google-btn-wrap {
  display: flex;
  justify-content: center;
  min-height: 44px;
  margin-top: 4px;
}
.google-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 0 8px;
  color: var(--muted);
  font-size: 13px;
}
.google-loader-spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.auth-or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.auth-or-divider::before,
.auth-or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-forgot-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  align-self: flex-end;
  text-decoration: underline;
  font-family: var(--font);
  transition: color 0.12s;
  margin-top: -4px;
}
.auth-forgot-link:hover { color: var(--ink); }
.auth-hint { font-size: 11px; color: var(--muted); margin: -6px 0 4px; line-height: 1.4; }

/* ── About feedback section ──────────────────────────────────────────────── */
.about-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 0;
}

.about-feedback {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}

.about-feedback-label {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.feedback-textarea {
  min-height: 72px;
  resize: vertical;
  font-family: var(--font);
}

/* ── Diagrams modal ─────────────────────────────────────────────────────── */
.modal-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.diagrams-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 420px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}
.diagrams-empty {
  padding: 32px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.diagram-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.diagram-row:hover { background: #f3efe7; }
.diagram-row.active {
  border-left-color: var(--teal);
  background: #f0f6f4;
}

.diagram-row-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.diagram-row-date {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  flex-shrink: 0;
  white-space: nowrap;
}
.diagram-row-del {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.1s;
  flex-shrink: 0;
}
.diagram-row:hover .diagram-row-del { opacity: 1; }
.diagram-row-del:hover { background: #fde8e0; color: var(--accent); }

/* ── About modal ────────────────────────────────────────────────────────── */
.about-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 4px 0 8px;
}
.about-desc {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}
.about-credit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.about-credit strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.about-links {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.about-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  transition: background 0.12s, border-color 0.12s;
}
.about-link:hover { background: #f3efe7; border-color: #d4cfc7; }

/* ── Library management modal ───────────────────────────────────────────── */
/* kept for any lingering references */
.lib-modal-body {
  max-height: 460px;
  overflow-y: auto;
  padding: 4px 0 8px;
  display: flex;
  flex-direction: column;
}

/* ── Library full page ────────────────────────────────────────────────────── */
#libPage {
  position: fixed;
  inset: 0;
  display: flex;
  background: var(--bg);
  z-index: 100;
}
#libPage[hidden] { display: none; }

.lib-page-sidebar {
  width: 210px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #f3efe7;
  overflow-y: auto;
}
.lib-page-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px 13px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid var(--border);
  width: 100%;
  transition: background 0.1s;
}
.lib-page-back:hover { background: #ede9e0; }

.lib-page-nav {
  display: flex;
  flex-direction: column;
  padding: 10px 0 16px;
  gap: 1px;
}
.lib-nav-item {
  display: block;
  width: 100%;
  padding: 8px 16px 8px 18px;
  border: none;
  border-left: 3px solid transparent;
  background: none;
  text-align: left;
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  box-sizing: border-box;
}
.lib-nav-item:hover { background: #ede9e0; }
.lib-nav-item.active {
  background: var(--bg);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}
.lib-nav-sep {
  height: 1px;
  background: var(--border);
  margin: 8px 16px;
}

.lib-page-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  max-width: 760px;
}

/* Section common */
.lib-section-desc {
  font-size: 13px;
  color: var(--muted);
  padding: 16px 24px 8px;
  line-height: 1.5;
  margin: 0;
}
.lib-section-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 20px 24px;
  font-style: italic;
}
.lib-section-textarea {
  margin: 0 24px;
  width: calc(100% - 48px);
  box-sizing: border-box;
  height: calc(100vh - 150px);
  min-height: 200px;
  border-radius: 6px;
  resize: vertical;
}
.lib-section-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 24px 16px;
}

/* ── Lib section header ───────────────────────────────────────────────────── */
.lib-section-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 44px 32px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.lib-section-title {
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 5px;
  letter-spacing: -0.01em;
}
.lib-section-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Repo connection cards ────────────────────────────────────────────────── */
.repo-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 32px 32px;
}
.repo-card {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  gap: 14px 16px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #faf9f6;
  transition: box-shadow 0.15s;
}
.repo-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.repo-card-connected { border-color: #b8d9cc; background: #f4faf7; }
.repo-card-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-row: span 2;
}
.repo-card-provider {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  align-self: end;
}
.repo-card-desc {
  font-size: 12px;
  color: var(--muted);
  align-self: start;
}
.repo-card-badge {
  grid-row: span 2;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  align-self: center;
}
.repo-card-badge.connected    { background: #d4f0e4; color: #1a6b45; }
.repo-card-badge.disconnected { background: #f0e6d4; color: #7a4a1a; }
.repo-card-actions {
  grid-row: span 2;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: center;
}

/* Override bb-import-section padding for full-page layout */
#libPage .bb-import-section { padding: 12px 24px 8px; }
#libPage .bb-import-header  { flex-wrap: wrap; }
#libPage .bb-repo-search    { width: 100%; }

/* BB section body — fills remaining height in full-page layout */
.bb-section-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 24px 16px;
  gap: 6px;
}
.bb-section-body .bb-repo-list {
  flex: 1;
  max-height: none;
  min-height: 0;
}
#libPage .lib-import-strip  { padding: 16px 24px; border-top: none; }
#libPage .lib-add-form      { padding: 12px 24px; }
#libPage .lib-list-hdr      { padding: 6px 24px 4px; }
#libPage .lib-item-row      { padding: 7px 24px; }
#libPage .rb-row            { padding: 6px 24px; }

.lib-add-form {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 10px 20px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.lib-add-form-col {
  flex-direction: column;
  align-items: stretch;
}

.lib-add-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  background: #faf8f4;
  box-sizing: border-box;
  min-width: 0;
  transition: border-color 0.12s;
}
.lib-add-input:focus { border-color: var(--accent); background: #fff; }

.lib-add-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  background: #faf8f4;
  cursor: pointer;
  transition: border-color 0.12s;
  flex-shrink: 0;
}
.lib-add-select:focus { border-color: var(--accent); }

.lib-list-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px 4px;
  border-bottom: 1px solid var(--border);
}
.lib-list-count {
  font-size: 11px;
  color: #9e9a94;
}

/* ── Unified import panel ─────────────────────────────────────────────────── */
.lib-import-panel {
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
}
.lib-import-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: #f3efe7;
}
.lib-import-tab {
  flex: 1;
  padding: 7px 12px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.lib-import-tab:hover { background: #ede9e0; color: var(--ink); }
.lib-import-tab.active {
  background: var(--bg);
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.lib-import-panel-body { display: flex; flex-direction: column; }

/* ── Exclude patterns ─────────────────────────────────────────────────────── */
.lib-exclude-details {
  border-top: 1px solid var(--border);
  padding: 0;
}
.lib-exclude-details summary {
  padding: 7px 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lib-exclude-details summary:hover { color: var(--ink); }
.lib-exclude-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 20px;
  border: none;
  border-top: 1px solid var(--border);
  background: #faf9f6;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  resize: vertical;
  min-height: 90px;
  max-height: 200px;
  outline: none;
}
.lib-exclude-textarea:focus { background: #fff; }
.lib-exclude-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 20px 8px;
  gap: 8px;
  background: #faf9f6;
  border-top: 1px solid var(--border);
}
.lib-exclude-actions span {
  font-size: 10px;
  color: var(--muted);
}

.lib-import-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.lib-import-sample {
  font-size: 11px;
  color: var(--accent-2);
  text-decoration: none;
  white-space: nowrap;
}
.lib-import-sample:hover { text-decoration: underline; }
.lib-import-status {
  font-size: 11px;
  color: var(--accent-2);
  flex: 1;
  min-width: 0;
}
.lib-import-status:not(:empty) { margin-left: 4px; }

.lib-color-swatches {
  display: flex;
  gap: 6px;
  padding: 4px 0 2px;
  flex-wrap: wrap;
}
.lib-color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.lib-color-dot:hover { transform: scale(1.15); }
.lib-color-dot.selected {
  border-color: var(--ink);
  transform: scale(1.1);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--ink);
}

.lib-group-hdr {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 10px 20px 4px;
}

.lib-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  transition: background 0.1s;
}
.lib-item-row-clickable { cursor: pointer; }
.lib-item-row:hover { background: #f3efe7; }
.lib-item-row-editing {
  background: #f0f6f4;
  border-left: 3px solid var(--teal);
}

.lib-item-name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.lib-item-count {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  font-family: var(--mono);
}

.lib-cat-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lib-item-del {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.1s;
  flex-shrink: 0;
}
.lib-item-row:hover .lib-item-del { opacity: 1; }
.lib-item-del:hover { background: #fde8e0; color: var(--accent); }
.lib-item-del:disabled { opacity: 0.25; cursor: not-allowed; }

.lib-clear-row {
  padding: 6px 24px 10px;
}
.btn.ghost.danger { color: var(--accent); }
.btn.ghost.danger:hover { background: #fde8e0; border-color: var(--accent); }

/* ── Bitbucket import section ──────────────────────────────────────────── */
.bb-import-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 20px 8px;
  flex-shrink: 0;
}

.bb-import-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bb-repo-search {
  width: 100%;
  margin-top: 2px;
  box-sizing: border-box;
}

.bb-repo-list {
  overflow-y: auto;
  max-height: 150px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 0;
}

.bb-repo-item {
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}

.bb-repo-item:hover { background: #f3efe7; }

.bb-repo-item.bb-selected {
  background: #3b6b5c1a;
  color: var(--teal);
  font-weight: 600;
}

/* ── Import modal ───────────────────────────────────────────────────────── */
.modal-box-import { max-width: 460px; }

.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin: 16px 0;
  background: #faf8f4;
}
.import-dropzone:hover,
.import-dropzone.drag-over {
  border-color: var(--accent);
  background: #fef4ef;
}
.import-dropzone-icon {
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--muted);
}
.import-dropzone-text { font-size: 14px; color: var(--muted); }
.import-browse-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}
.import-filename {
  margin-top: 10px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--teal);
  font-weight: 500;
}

.import-mode-section { margin-bottom: 12px; }
.import-mode-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}
.import-mode-options { display: flex; flex-direction: column; gap: 6px; }
.import-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: background 0.1s;
}
.import-mode-option:hover { background: #f3efe7; }
.import-mode-option input[type="radio"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.import-mode-text { display: flex; flex-direction: column; gap: 2px; }
.import-mode-name { font-weight: 600; font-size: 14px; }
.import-mode-desc { font-size: 12px; color: var(--muted); }

.import-ai-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 2px;
}
.import-profile-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
}

.import-actions { margin-top: 16px; }
.import-actions .btn { width: 100%; }

/* ── Profile modal ──────────────────────────────────────────────────────── */
.modal-hint {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 0;
  line-height: 1.5;
}

/* ── Imported repo group in sidebar ────────────────────────────────────── */
.rb-repo-imported { color: var(--muted); font-style: italic; }
.rb-row-imported  { opacity: 0.85; }

/* ── Voice command mic button ───────────────────────────────────────────── */
.mic-btn { transition: color .15s, background .15s; }

.mic-btn.mic-listening {
  color: #e74c3c;
  background: #e74c3c18;
  animation: mic-pulse 1.4s ease-in-out infinite;
}

.mic-btn.mic-processing {
  color: var(--muted);
  opacity: .6;
  cursor: default;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 #e74c3c40; }
  50%       { box-shadow: 0 0 0 5px transparent; }
}

/* ── Import history table ──────────────────────────────────────────────── */
.lib-history-loading {
  padding: 20px 24px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.lib-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.lib-history-table thead th {
  text-align: left;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 52px;
  background: var(--bg);
  z-index: 2;
}
.lib-history-table tbody tr {
  border-bottom: 1px solid var(--border);
}
.lib-history-table tbody tr:hover { background: var(--bg2); }
.lib-hist-when  { padding: 8px 16px; white-space: nowrap; color: var(--muted); width: 180px; }
.lib-hist-src   { padding: 8px 12px; white-space: nowrap; font-weight: 500; width: 100px; }
.lib-hist-detail { padding: 8px 16px; font-family: var(--mono); font-size: 11px; color: var(--accent-2); word-break: break-all; }

/* ── Markdown view panel ──────────────────────────────────────────────── */
.md-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
}
.md-panel-header {
  display: flex;
  align-items: center;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--border);
  gap: 6px;
  flex-shrink: 0;
  background: var(--bg2);
}
.md-panel-title {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
  color: var(--text);
}
.md-panel-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}
.md-panel-close:hover { color: var(--text); }
.md-panel-content {
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
  font-size: 12px;
  font-family: var(--mono);
  white-space: pre;
  line-height: 1.65;
  color: var(--text);
  margin: 0;
  tab-size: 2;
}

/* ── Use Case context bar ───────────────────────────────────────────────── */
.uc-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--muted);
}
.uc-bar-label { font-weight: 600; }
.uc-bar-name {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--muted);
  transition: background 0.1s, color 0.1s;
}
.uc-bar-name:hover { background: #f3efe7; color: var(--ink); }
.uc-bar-name.uc-active { color: var(--teal); border-color: var(--teal); font-weight: 600; }
.uc-bar-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.uc-bar-clear:hover { color: var(--accent); }

/* ── Use Case new form (inside modal) ───────────────────────────────────── */
.uc-new-form {
  background: #fafaf8;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.uc-new-input, .uc-new-desc {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font);
  background: #fff;
  resize: vertical;
}
.uc-new-input:focus, .uc-new-desc:focus { outline: 2px solid var(--teal); border-color: transparent; }
.uc-new-actions { display: flex; gap: 8px; }

/* ── Use Case row ───────────────────────────────────────────────────────── */
.uc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.uc-row:hover { background: #f3efe7; }
.uc-row.active { border-left-color: var(--teal); background: #f0f6f4; }
.uc-row-body { flex: 1; min-width: 0; }
.uc-row-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uc-row-desc {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.uc-row-count {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  flex-shrink: 0;
  white-space: nowrap;
}
.uc-row-del {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.1s;
  flex-shrink: 0;
}
.uc-row:hover .uc-row-del { opacity: 1; }
.uc-row-del:hover { background: #fde8e0; color: var(--accent); }

/* ── Diagram group header (in diagrams modal) ───────────────────────────── */
.diagrams-group-hdr {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 10px 3px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}
.diagrams-group-hdr:first-child { border-top: none; margin-top: 0; padding-top: 2px; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app      { padding: 8px; }
  .header   { flex-direction: column; align-items: flex-start; }

}
