/* ================= Variables ================= */

:root {
  /* Branding palette */
  --blue-700: #1B3F87;
  --slate-800: #212E49;
  --purple-500: #9458F4;
  --periwinkle-200: #A8BBF4;
  --gray-100: #F2F2F2;
  --white: #FFFFFF;
  --ink: #1E1E1E;

  /* UI tokens */
  --bg: #F6F8FE;
  --card: var(--white);
  --border: rgba(27, 63, 135, 0.12);
  --shadow: 0 10px 30px rgba(33, 46, 73, 0.10);
  --shadow-sm: 0 6px 16px rgba(33, 46, 73, 0.08);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --font-head: "Urbanist", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --font-body: "Montserrat", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  --focus: 0 0 0 3px rgba(148, 88, 244, 0.25), 0 0 0 1px rgba(148, 88, 244, 0.4);
}

/* ================= Reset ================= */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: radial-gradient(1200px 600px at 20% -10%, rgba(168, 187, 244, 0.55), transparent 60%),
    radial-gradient(900px 500px at 95% 15%, rgba(148, 88, 244, 0.10), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  letter-spacing: 0.1px;
  overflow: hidden;
}

/* ================= Layout ================= */

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  padding: 18px;
  max-width: 1600px;
  margin: 0 auto;
  transition: grid-template-columns 0.3s ease;
  position: relative;
}

.app.sidebarCollapsed {
  grid-template-columns: 0 1fr;
}

/* Expand button (hidden by default) */
.expandBtn {
  position: fixed;
  left: 18px;
  top: 18px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--white);
  color: rgba(33, 46, 73, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.expandBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(33, 46, 73, 0.15);
}

.app.sidebarCollapsed .expandBtn {
  display: flex;
}

/* ================= Sidebar ================= */

.sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 260px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.app.sidebarCollapsed .sidebar {
  opacity: 0;
  transform: translateX(-20px);
  pointer-events: none;
}

.sidebarHeader {
  padding: 16px 16px 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Hide any stray text nodes */
.sidebarHeader > :not(.brandWrap):not(.iconBtn) {
  display: none;
}

.brandWrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.brandLogo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}

.brandText {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.brandName {
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--slate-800);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brandSub {
  font-family: var(--font-body);
  font-size: 12px;
  color: rgba(33, 46, 73, 0.75);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iconBtn {
  border: 1px solid var(--border);
  background: var(--white);
  color: rgba(33, 46, 73, 0.9);
  height: 34px;
  width: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  flex-shrink: 0;
}

.iconBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(33, 46, 73, 0.10);
  border-color: rgba(27, 63, 135, 0.18);
}

.iconBtn:focus {
  outline: none;
  box-shadow: var(--focus);
}

.sidebarBody {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  flex: 1;
}

/* ================= Buttons ================= */

.primaryBtn {
  font-family: var(--font-body);
  font-weight: 600;
  border: 1px solid rgba(27, 63, 135, 0.25);
  background: linear-gradient(180deg, rgba(27, 63, 135, 0.96), rgba(27, 63, 135, 0.90));
  color: var(--white);
  padding: 12px 12px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
  box-shadow: 0 16px 26px rgba(27, 63, 135, 0.18);
}

.primaryBtn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.primaryBtn:active {
  transform: translateY(0px) scale(0.99);
}

.primaryBtn:focus {
  outline: none;
  box-shadow: var(--focus);
}

.secondaryBtn {
  font-family: var(--font-body);
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--slate-800);
  padding: 12px 12px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.secondaryBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(33, 46, 73, 0.10);
  border-color: rgba(27, 63, 135, 0.18);
}

.secondaryBtn:focus {
  outline: none;
  box-shadow: var(--focus);
}

.dangerBtn {
  font-family: var(--font-body);
  font-weight: 600;
  border: 1px solid rgba(244, 63, 94, 0.3);
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.08), rgba(244, 63, 94, 0.04));
  color: rgba(244, 63, 94, 0.95);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  width: 100%;
}

.dangerBtn:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.12), rgba(244, 63, 94, 0.08));
  box-shadow: 0 8px 16px rgba(244, 63, 94, 0.15);
}

/* ================= History ================= */

.sectionLabel {
  font-size: 12px;
  color: rgba(33, 46, 73, 0.75);
  font-weight: 600;
  margin: 2px 2px -2px 2px;
}

.historyList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  /* Never collapses entirely, but otherwise takes ALL leftover sidebar
     space (the old .spacer no longer competes for it). */
  min-height: 120px;
}

.history-item {
  padding: 11px 34px 11px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(242, 242, 242, 0.65), rgba(255, 255, 255, 1));
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  position: relative;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--slate-800);
  flex-shrink: 0; /* items keep their height; the list scrolls instead */
}

/* Single line with ellipsis — full text available via native title tooltip */
.history-item-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(148, 88, 244, 0.04) 100%);
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.history-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(33, 46, 73, 0.12);
  border-color: rgba(148, 88, 244, 0.3);
}

.history-item:hover::before {
  opacity: 1;
}

.history-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: rgba(244, 63, 94, 0.1);
  color: rgba(244, 63, 94, 0.9);
  border: 1px solid rgba(244, 63, 94, 0.2);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 180ms ease, transform 120ms ease, background 120ms ease;
  font-size: 16px;
  line-height: 1;
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  transform: translateY(-50%) scale(1.1);
  background: rgba(244, 63, 94, 0.2);
}

.history-item.active {
  border-color: rgba(148, 88, 244, 0.55);
  background: linear-gradient(180deg, rgba(148, 88, 244, 0.08), rgba(255, 255, 255, 1));
}

.spacer {
  /* Was flex:1, which competed 50/50 with .historyList for leftover sidebar
     space and squeezed Recent chats down to ~3 visible items. Now a fixed
     small gap — the history list absorbs the remainder. */
  flex: 0 0 4px;
}

/* ================= Main Content ================= */

.main {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.mainHeader {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.headerTitle h1 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  color: var(--slate-800);
}

.headerTitle p {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: rgba(33, 46, 73, 0.65);
}

/* ================= Tabs ================= */

.tabs {
  display: flex;
  gap: 6px;
  background: rgba(27, 63, 135, 0.04);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.tab {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: rgba(33, 46, 73, 0.75);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 140ms ease, color 140ms ease;
}

.tab:hover {
  color: var(--slate-800);
  background: rgba(255, 255, 255, 0.5);
}

.tab.active {
  background: var(--white);
  color: var(--blue-700);
  box-shadow: 0 4px 12px rgba(27, 63, 135, 0.10);
}

.tab:focus {
  outline: none;
  box-shadow: var(--focus);
}

.headerActions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.actionBtn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--slate-800);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.actionBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(33, 46, 73, 0.08);
  border-color: rgba(148, 88, 244, 0.25);
}

/* ================= Chat Container ================= */

.contentArea {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.tabContent {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.tabContent.active {
  display: flex;
}

.chatContainer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chatScroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ================= Tab Bar ================= */

.tabBar {
  padding: 10px 18px 0 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(246,248,254,0.6), var(--white));
  flex-shrink: 0;
}

.tabBar .tabs {
  gap: 4px;
  background: rgba(27, 63, 135, 0.04);
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--border);
  display: inline-flex;
}

/* ================= Code Ref Links ================= */

.code-ref {
  color: var(--purple-500);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  padding: 0 2px;
  transition: background 120ms ease, color 120ms ease;
}

.code-ref:hover {
  background: rgba(148, 88, 244, 0.09);
  color: var(--blue-700);
  text-decoration: underline solid;
}

/* ================= Defined Term Tooltips ================= */

em.defined-term {
  font-style: italic;
  color: var(--text-primary, inherit);
  text-decoration: underline dotted;
  text-decoration-color: rgba(20, 184, 166, 0.7);  /* teal-500 */
  text-underline-offset: 3px;
  cursor: help;
  border-radius: 2px;
  padding: 0 1px;
  transition: background 120ms ease;
}

em.defined-term:hover {
  background: rgba(20, 184, 166, 0.10);
}

/* Shared floating tooltip — positioned by JS on mouseenter */
#dt-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 360px;
  background: var(--surface-raised, #1e1e2e);
  border: 1px solid rgba(20, 184, 166, 0.35);
  border-radius: 8px;
  padding: 10px 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
  font-size: 12.5px;
  line-height: 1.55;
}

#dt-tooltip.visible {
  opacity: 1;
}

#dt-tooltip .dt-term {
  font-weight: 700;
  font-style: italic;
  color: rgba(20, 184, 166, 0.9);
  display: block;
  margin-bottom: 4px;
}

#dt-tooltip .dt-defn {
  color: var(--text-secondary, #ccc);
  white-space: pre-wrap;
}

/* ================= Note Ref Links (Appendix A) ================= */

.note-ref {
  color: #B45309;                    /* amber-700 */
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  padding: 0 2px;
  transition: background 120ms ease, color 120ms ease;
}

.note-ref:hover {
  background: rgba(245, 158, 11, 0.10);
  color: #92400E;
  text-decoration: underline solid;
}

/* ================= Code Pane ================= */

.codePane {
  padding: 0;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: row;  /* side-by-side when amendment pane is open */
}

.pdfViewer,
#pdfViewerFrame {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  display: block;
}

/* ── Amendment pane ─────────────────────────────────────────────────── */
.amendmentPane {
  display: flex;
  flex-direction: column;
  width: 48%;
  min-width: 320px;
  border-left: 2px solid #1B3F87;
  background: #E8EBF3;
  transition: width 250ms ease;
}

.amendmentPane.hidden {
  display: none;
}

.amendmentPaneBar {
  height: 38px;
  background: #212E49;
  border-bottom: 2px solid #1B3F87;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
  font-size: 12px;
  font-family: "Montserrat", system-ui, sans-serif;
  gap: 8px;
}

.amendmentPaneInfo {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
}

#amendmentPaneLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#amendmentPaneClose {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.7);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: background 120ms;
}
#amendmentPaneClose:hover { background: rgba(255,255,255,0.18); color: #fff; }

.amendmentPane iframe {
  flex: 1;
  border: none;
  width: 100%;
  display: block;
}

.docCard {
  background: linear-gradient(180deg, rgba(242, 242, 242, 0.5), var(--white));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin: 24px;
}

.docCard h3 {
  margin: 0 0 12px 0;
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--slate-800);
}

.docCard p {
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(33, 46, 73, 0.85);
}

.docCard code {
  background: rgba(27, 63, 135, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
}

.callout {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(148, 88, 244, 0.06);
  border-left: 3px solid var(--purple-500);
  border-radius: 8px;
  font-size: 13px;
  color: rgba(33, 46, 73, 0.85);
  line-height: 1.5;
}

/* ================= Messages ================= */

.msg {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.msg.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.msg.assistant {
  margin-right: auto;
}

.msg .avatar {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(27, 63, 135, 0.1), rgba(148, 88, 244, 0.1));
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--blue-700);
  flex-shrink: 0;
}

.msg.user .avatar {
  background: linear-gradient(135deg, rgba(148, 88, 244, 0.12), rgba(168, 187, 244, 0.12));
  color: var(--purple-500);
}

.msg .bubble {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 14.5px;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.msg.user .bubble {
  background: linear-gradient(135deg, var(--blue-700), rgba(27, 63, 135, 0.92));
  color: var(--white);
  border: 1px solid rgba(27, 63, 135, 0.3);
  box-shadow: 0 8px 20px rgba(27, 63, 135, 0.15);
}

.msg.assistant .bubble {
  background: linear-gradient(180deg, rgba(242, 242, 242, 0.8), var(--white));
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ================= Composer ================= */

.composer {
  padding: 18px 24px 24px 24px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(246, 248, 254, 0.5), var(--white));
}

.composerCard {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.inputWrap {
  flex: 1;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px 12px 16px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  min-width: 0;
}

.inputWrap:focus-within {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(148, 88, 244, 0.1);
}

#input-box {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  min-height: 22px;
  max-height: 140px;
  overflow-y: auto;
}

#input-box:focus {
  outline: none;
}

#input-box::placeholder {
  color: rgba(33, 46, 73, 0.45);
}

.hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11.5px;
  color: rgba(33, 46, 73, 0.5);
}

.kbd {
  background: rgba(27, 63, 135, 0.06);
  border: 1px solid rgba(27, 63, 135, 0.12);
  border-radius: 5px;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: rgba(33, 46, 73, 0.75);
}

.sendBtn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 20px;
  border: none;
  background: linear-gradient(135deg, var(--blue-700), rgba(148, 88, 244, 0.92));
  color: var(--white);
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
  box-shadow: 0 12px 24px rgba(27, 63, 135, 0.20);
  flex-shrink: 0;
}

.sendBtn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 16px 32px rgba(27, 63, 135, 0.25);
}

.sendBtn:active {
  transform: translateY(0px) scale(0.98);
}

.sendBtn:focus {
  outline: none;
  box-shadow: var(--focus);
}

/* ================= Modals ================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modalOverlay {
  position: absolute;
  inset: 0;
  background: rgba(33, 46, 73, 0.4);
  backdrop-filter: blur(4px);
}

.modalContent {
  position: relative;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(33, 46, 73, 0.20);
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modalLarge {
  max-width: 900px;
}

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

.modalHeader h3 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 20px;
  color: var(--slate-800);
}

.modalClose {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--white);
  color: rgba(33, 46, 73, 0.75);
  border-radius: 10px;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform 120ms ease, background 120ms ease;
}

.modalClose:hover {
  transform: scale(1.05);
  background: rgba(244, 63, 94, 0.06);
  color: rgba(244, 63, 94, 0.9);
}

.modalBody {
  padding: 24px;
  overflow-y: auto;
}

.modalBody p {
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(33, 46, 73, 0.85);
}

.modalBody ul {
  margin: 12px 0;
  padding-left: 24px;
  font-size: 14px;
  line-height: 1.8;
  color: rgba(33, 46, 73, 0.85);
}

/* ================= Forms ================= */

.formGroup {
  margin-bottom: 20px;
}

.formGroup > label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--slate-800);
}

.formGroup select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.formGroup select:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(148, 88, 244, 0.1);
}

.formGroup input[type="text"],
.formGroup input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.formGroup input[type="text"]:focus,
.formGroup input[type="number"]:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(148, 88, 244, 0.1);
}

.formGroup input[type="checkbox"] {
  margin-right: 8px;
  width: 18px;
  height: 18px;
  accent-color: var(--blue-700);
  cursor: pointer;
}

.formGroup label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 0;
}

.checkboxGroup {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.checkboxGroup label {
  display: flex;
  align-items: center;
  font-weight: 400;
  cursor: pointer;
}

.featureNote {
  margin-top: 16px;
  padding: 12px;
  background: rgba(148, 88, 244, 0.06);
  border-left: 3px solid var(--purple-500);
  border-radius: 8px;
  font-size: 13px;
  color: rgba(33, 46, 73, 0.85);
  font-style: italic;
}

/* ================= Loading Overlay ================= */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(33, 46, 73, 0.5);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 200ms ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader {
  text-align: center;
}

.ring {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(148, 88, 244, 0.2);
  border-top-color: var(--purple-500);
  border-radius: 50%;
  margin: 0 auto 16px auto;
  animation: spin 0.8s linear infinite;
}

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

.loader .text {
  color: var(--white);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
}

/* ================= Markdown Formatting ================= */

.msg.assistant .bubble h1,
.msg.assistant .bubble h2,
.msg.assistant .bubble h3 {
  margin: 14px 0 8px 0;
  font-family: var(--font-head);
  line-height: 1.3;
  color: var(--slate-800);
}

.msg.assistant .bubble h1 { font-size: 20px; }
.msg.assistant .bubble h2 { font-size: 18px; }
.msg.assistant .bubble h3 { font-size: 16px; }

.msg.assistant .bubble p { margin: 8px 0; }

.msg.assistant .bubble ul,
.msg.assistant .bubble ol {
  margin: 10px 0;
  padding-left: 24px;
}

.msg.assistant .bubble li { margin: 5px 0; }

.msg.assistant .bubble blockquote {
  margin: 12px 0;
  padding: 10px 16px;
  border-left: 3px solid var(--purple-500);
  background: rgba(148, 88, 244, 0.05);
  border-radius: 8px;
}

.msg.assistant .bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(27, 63, 135, 0.08);
  border: 1px solid rgba(27, 63, 135, 0.12);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--blue-700);
}

.msg.assistant .bubble pre {
  margin: 12px 0;
  padding: 14px 16px;
  background: rgba(27, 63, 135, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}

.msg.assistant .bubble pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--ink);
}

.msg.assistant .bubble a {
  color: var(--purple-500);
  text-decoration: underline;
}

.msg.assistant .bubble a:hover {
  color: var(--blue-700);
}

/* ── Tables ── */

.msg.assistant .bubble table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  font-size: 0.88em;
}

.msg.assistant .bubble table th,
.msg.assistant .bubble table td {
  border: 1px solid rgba(27, 63, 135, 0.3);
  padding: 8px 14px;
  text-align: left;
  vertical-align: top;
  min-width: 80px;
  white-space: normal;
  word-break: break-word;
}

.msg.assistant .bubble table th {
  background: rgba(27, 63, 135, 0.09);
  font-weight: 600;
  color: var(--slate-800);
  white-space: nowrap;
}

.msg.assistant .bubble table tbody tr:nth-child(even) {
  background: rgba(27, 63, 135, 0.03);
}

.msg.assistant .bubble table tbody tr:hover {
  background: rgba(27, 63, 135, 0.06);
}

/* ================= Scrollbar ================= */

.chatScroll::-webkit-scrollbar,
.sidebarBody::-webkit-scrollbar,
.modalBody::-webkit-scrollbar {
  width: 8px;
}

.chatScroll::-webkit-scrollbar-track,
.sidebarBody::-webkit-scrollbar-track,
.modalBody::-webkit-scrollbar-track {
  background: transparent;
}

.chatScroll::-webkit-scrollbar-thumb,
.sidebarBody::-webkit-scrollbar-thumb,
.modalBody::-webkit-scrollbar-thumb {
  background: rgba(27, 63, 135, 0.15);
  border-radius: 10px;
}

.chatScroll::-webkit-scrollbar-thumb:hover,
.sidebarBody::-webkit-scrollbar-thumb:hover,
.modalBody::-webkit-scrollbar-thumb:hover {
  background: rgba(27, 63, 135, 0.25);
}

/* ================= Empty State ================= */

.emptyState {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
  gap: 14px;
}

.emptyIcon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, rgba(27, 63, 135, 0.08), rgba(148, 88, 244, 0.08));
  border: 1px solid var(--border);
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: var(--blue-700);
  margin-bottom: 4px;
}

.emptyState h2 {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 600;
  color: var(--slate-800);
  margin: 0;
}

.emptyState p {
  font-size: 14px;
  color: rgba(33, 46, 73, 0.65);
  max-width: 380px;
  line-height: 1.6;
  margin: 0;
}

.suggestionGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
  max-width: 560px;
  width: 100%;
}

.suggestionChip {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  color: var(--slate-800);
  background: linear-gradient(180deg, rgba(242, 242, 242, 0.6), var(--white));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.suggestionChip:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(33, 46, 73, 0.10);
  border-color: rgba(148, 88, 244, 0.3);
}

/* ================= Error bubble ================= */

.msg.error {
  margin: 0 auto;
  max-width: 75%;
}

.errorBubble {
  background: rgba(244, 63, 94, 0.06);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13.5px;
  color: rgba(200, 30, 55, 0.9);
  line-height: 1.5;
}

/* ================= Responsive ================= */

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }

  .sidebar {
    display: none;
  }

  .msg {
    max-width: 95%;
  }
}

/* ================= Washroom Buddy Tool Button ================= */

.wbToolBtn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid rgba(148, 88, 244, 0.28);
  background: linear-gradient(180deg, rgba(148,88,244,0.07), rgba(148,88,244,0.03));
  color: var(--purple-500);
  padding: 11px 12px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
  width: 100%;
}

.wbToolBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(148, 88, 244, 0.14);
  background: linear-gradient(180deg, rgba(148,88,244,0.12), rgba(148,88,244,0.06));
  border-color: rgba(148, 88, 244, 0.40);
}

.wbToolBtn:focus {
  outline: none;
  box-shadow: var(--focus);
}

/* ================= Integrated Tools Group (sidebar) ================= */

.toolsGroup {
  /* Anchor for the absolutely-positioned dropdown body */
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Header button — same visual family as .wbToolBtn, left-aligned with chevron */
.toolsGroupToggle {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid rgba(148, 88, 244, 0.28);
  background: linear-gradient(180deg, rgba(148,88,244,0.07), rgba(148,88,244,0.03));
  color: var(--purple-500);
  padding: 11px 12px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
}

.toolsGroupToggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(148, 88, 244, 0.14);
  background: linear-gradient(180deg, rgba(148,88,244,0.12), rgba(148,88,244,0.06));
  border-color: rgba(148, 88, 244, 0.40);
}

.toolsGroupToggle:focus {
  outline: none;
  box-shadow: var(--focus);
}

.toolsGroupChevron {
  margin-left: auto;
  transition: transform 180ms ease;
}

.toolsGroupToggle.open .toolsGroupChevron {
  transform: rotate(180deg);
}

/* Dropdown body — floats OVER the content below (Recent chats) instead of
   pushing it down, so adding more tools never squeezes the history list.
   Scrolls internally if the tool count outgrows the cap. `visibility`
   keeps hidden buttons out of the tab order without JS bookkeeping. */
.toolsGroupBody {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--white);
  border: 1px solid rgba(148, 88, 244, 0.28);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(33, 46, 73, 0.18);
  max-height: min(52vh, 440px);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
}

.toolsGroupBody.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s;
}

/* ============ Major occupancies chip input (Project Information) ============ */

.occChips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.occChips:empty {
  display: none;
}

.occChip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  border: 1px solid rgba(27, 63, 135, 0.25);
  background: rgba(27, 63, 135, 0.06);
  color: var(--slate-800);
  border-radius: 999px;
  font-size: 12.5px;
  line-height: 1.2;
  max-width: 100%;
}

.occChip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.occChipRemove {
  border: none;
  background: rgba(27, 63, 135, 0.12);
  color: var(--slate-800);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.occChipRemove:hover {
  background: rgba(244, 63, 94, 0.18);
  color: rgba(244, 63, 94, 0.95);
}

.occInputRow {
  display: flex;
  gap: 8px;
}

.occInputRow input[type="text"] {
  flex: 1;
  min-width: 0;
}

.occAddBtn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--slate-800);
  padding: 0 14px;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.occAddBtn:hover {
  border-color: rgba(27, 63, 135, 0.3);
  box-shadow: 0 4px 10px rgba(33, 46, 73, 0.10);
}

/* Jurisdiction notice inside the Flowchart panel (non-VBBL codes) */
.fcCodeNotice {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.07);
  color: #92400e;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
}

/* ================= Washroom Buddy Slide Panel ================= */

.wbPanelOverlay {
  position: fixed;
  inset: 0;
  background: rgba(33, 46, 73, 0.35);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.wbPanelOverlay.open {
  opacity: 1;
  pointer-events: auto;
}

.wbPanel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 75vw;
  max-width: 980px;
  min-width: 640px;
  background: var(--white);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0, 0.17, 1);
  box-shadow: -8px 0 40px rgba(33, 46, 73, 0.18);
}

.wbPanel.open {
  transform: translateX(0);
}

.wbPanelHeader {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--slate-800);
  border-bottom: 2px solid var(--blue-700);
  flex-shrink: 0;
}

.wbPanelHeaderIcon {
  color: var(--periwinkle-200);
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.wbPanelTitle {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  flex: 1;
  min-width: 0;
}

.wbPanelSub {
  font-family: var(--font-body);
  font-size: 11.5px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
}

.wbPanelBadge {
  background: var(--blue-700);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.wbPanelClose {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border-radius: 10px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 120ms ease;
}

/* ==

/* ================================================================
   Code Picker Modal — Canada Jurisdiction Map
   .codePickerContent is position:relative so it stacks above
   .modalOverlay via DOM order (same pattern as .modalContent).
================================================================ */

.codePickerContent {
  position: relative;
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(33, 46, 73, 0.22);
  width: min(96vw, 820px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.codePickerHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.codePickerTitle {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-800);
  margin: 0 0 2px;
  line-height: 1.2;
}

.codePickerSub {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: rgba(33, 46, 73, 0.50);
  margin: 0;
  line-height: 1.4;
}

.codePickerSkipBtn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: rgba(33, 46, 73, 0.50);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.codePickerSkipBtn:hover {
  background: var(--surface);
  color: var(--slate-800);
  border-color: rgba(33, 46, 73, 0.25);
}

/* Map wrapper fills remaining flex space */
.codePickerMapWrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
  background: linear-gradient(145deg,
    rgba(27, 63, 135, 0.025) 0%,
    rgba(148, 88, 244, 0.018) 100%);
}

.mapLoadingSpinner {
  align-self: center;
  font-family: var(--font-body);
  font-size: 14px;
  color: rgba(33, 46, 73, 0.40);
  padding: 40px;
}

/* SVG map */
#canadaMapSvg {
  display: block;
  max-height: 100%;
  max-width: 100%;
  width: auto;
  height: auto;
  overflow: visible;
}

.map-province {
  fill: rgba(33, 46, 73, 0.07);
  stroke: var(--white, #fff);
  stroke-width: 1.5;
  cursor: default;
  transition: fill 120ms ease;
  outline: none;
}

.map-province.map-available {
  fill: rgba(27, 63, 135, 0.22);
  cursor: pointer;
}

.map-province.map-available:hover,
.map-province.map-available.map-hovered {
  fill: rgba(27, 63, 135, 0.48);
}

/* Province tooltip / popover
   position:absolute — containing block is .codePickerContent (position:fixed + transform).
   Lives outside .codePickerMapWrap so overflow:hidden on that wrap does not clip it. */
.map-tooltip {
  position: absolute;
  z-index: 100;
  min-width: 196px;
  max-width: 256px;
  background: var(--white, #fff);
  border-radius: 14px;
  box-shadow:
    0 10px 36px rgba(33, 46, 73, 0.17),
    0 2px  8px  rgba(33, 46, 73, 0.08);
  border: 1px solid rgba(33, 46, 73, 0.09);
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: scale(0.96) translateY(3px);
  transition: opacity 110ms ease, transform 110ms ease;
  visibility: hidden;
}

.map-tooltip.tt-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  visibility: visible;
}

.map-tt-name {
  font-family: var(--font-head);
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(33, 46, 73, 0.50);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 9px 12px 7px;
  border-bottom: 1px solid rgba(33, 46, 73, 0.07);
  background: rgba(33, 46, 73, 0.02);
}

.map-tt-codes {
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-tt-code {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  width: 100%;
  text-align: left;
}

.map-tt-selectable {
  background: none;
  border: none;
  cursor: pointer;
  transition: background 90ms ease;
}

.map-tt-selectable:hover {
  background: rgba(27, 63, 135, 0.07);
}

.map-tt-selectable:active {
  background: rgba(27, 63, 135, 0.14);
}

.map-tt-label {
  display: block;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-800);
  line-height: 1.2;
}

.map-tt-city {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--purple-500);
  background: rgba(148, 88, 244, 0.10);
  border-radius: 4px;
  padding: 1px 6px;
  margin: 2px 0 1px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-tt-desc {
  display: block;
  font-family: var(--font-body);
  font-size: 11.5px;
  color: rgba(33, 46, 73, 0.50);
  line-height: 1.3;
  margin-top: 2px;
}

.map-tt-arrow {
  flex-shrink: 0;
  margin-left: auto;
  color: rgba(27, 63, 135, 0.35);
  transition: color 100ms ease, transform 100ms ease;
}

.map-tt-selectable:hover .map-tt-arrow {
  color: var(--blue-700, #1b3f87);
  transform: translateX(2px);
}

.map-tt-soon {
  opacity: 0.50;
  cursor: not-allowed;
  pointer-events: none;
}

.map-tt-soon-tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 9.5px;
  font-weight: 600;
  color: rgba(33, 46, 73, 0.45);
  background: rgba(33, 46, 73, 0.07);
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ================= Sidebar version label ================= */

.accountStatus {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid rgba(33, 46, 73, 0.10);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.accountStatusName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-800);
}

.accountStatusMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  color: rgba(33, 46, 73, 0.58);
}

.accountStatusMeta span {
  min-width: 0;
}

.billingBtn {
  width: 100%;
  border: 1px solid rgba(33, 46, 73, 0.14);
  border-radius: 8px;
  background: var(--white);
  color: var(--slate-800);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.billingBtn:hover {
  background: rgba(27, 63, 135, 0.06);
  border-color: rgba(27, 63, 135, 0.25);
}

.billingBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sidebarVersion {
  text-align: center;
  font-size: 11px;
  color: rgba(33, 46, 73, 0.32);
  letter-spacing: 0.05em;
  padding: 4px 0 2px;
  font-weight: 500;
}

/* ================= Project Info: Code selector button ================= */

.codeSelectDisplay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  font-family: var(--font-body);
  text-align: left;
}

.codeSelectDisplay:hover {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(148, 88, 244, 0.1);
}

.codeSelectLeft {
  display: flex;
  align-items: center;
  gap: 10px;
}

.codeSelectLabel {
  font-size: 13px;
  color: rgba(33, 46, 73, 0.75);
}

.codeSelectArrow {
  color: rgba(33, 46, 73, 0.45);
  flex-shrink: 0;
}

/* ================= Settings Modal ================= */

.settingsModal .modalContent {
  max-width: 580px;
}

.settingsBody {
  padding: 0;
}

.settingsSection {
  padding: 22px 24px;
}

.settingsDivider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.settingsSectionLabel {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(33, 46, 73, 0.45);
  margin-bottom: 14px;
}

.settingsHint {
  font-size: 13px;
  color: rgba(33, 46, 73, 0.55);
  margin: -6px 0 14px 0;
}

.settingsGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.settingsGrid .formGroup {
  margin-bottom: 0;
}

/* Email / password inputs inherit from .formGroup text inputs */
.formGroup input[type="email"],
.formGroup input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.formGroup input[type="email"]:focus,
.formGroup input[type="password"]:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(148, 88, 244, 0.1);
}

.settingsRow {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.settingsRowAligned {
  margin-top: 0;
  justify-content: space-between;
}

.settingsActionBtn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  border: 1.5px solid var(--blue-700);
  background: var(--blue-700);
  color: var(--white);
  cursor: pointer;
  transition: opacity 140ms ease, transform 120ms ease;
}

.settingsActionBtn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.settingsActionBtnSecondary {
  background: var(--white);
  color: var(--slate-800);
  border-color: var(--border);
}

.settingsActionBtnDanger {
  background: transparent;
  color: rgba(220, 38, 38, 0.85);
  border-color: rgba(220, 38, 38, 0.3);
}

.settingsActionBtnDanger:hover {
  background: rgba(220, 38, 38, 0.06);
}

/* Subscription card */
.subscriptionCard {
  background: rgba(27, 63, 135, 0.04);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}

.subscriptionPlan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.subscriptionPlanName {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-800);
}

.subscriptionBadge {
  background: linear-gradient(135deg, var(--purple-500), var(--blue-700));
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.subscriptionBadgeCode {
  font-size: 12px;
}

.subscriptionPrice {
  font-size: 12px;
  font-weight: 500;
  color: rgba(33, 46, 73, 0.45);
  margin-left: 4px;
}

.subscriptionStatus {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.subscriptionStatusActive {
  background: rgba(34, 197, 94, 0.12);
  color: rgba(22, 163, 74, 0.9);
}

.subscriptionMeta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.subscriptionMetaItem {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.subscriptionMetaLabel {
  font-size: 11px;
  color: rgba(33, 46, 73, 0.45);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.subscriptionMetaValue {
  font-size: 13px;
  color: var(--slate-800);
  font-weight: 500;
}

/* Default code display */
.defaultCodeDisplay {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Token usage */
.tokenUsageWrap {
  background: rgba(27, 63, 135, 0.04);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.tokenUsageHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tokenUsageCount {
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-800);
}

.tokenUsagePct {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-700);
}

.tokenUsageBarTrack {
  height: 8px;
  background: rgba(27, 63, 135, 0.10);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 8px;
}

.tokenUsageBarFill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-700), var(--purple-500));
  border-radius: 100px;
  transition: width 0.6s ease;
}

.tokenUsageFooter {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(33, 46, 73, 0.5);
}

/* Bottom hint bar */
.mapHint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 11.5px;
  color: rgba(33, 46, 73, 0.38);
  background: rgba(255,255,255,0.80);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(33,46,73,0.09);
  border-radius: 20px;
  padding: 4px 14px;
  pointer-events: none;
  white-space: nowrap;
}
(inside map wrap) ─────────────────────── */

.mapHint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 11.5px;
  color: rgba(33, 46, 73, 0.38);
  background: rgba(255,255,255,0.80);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(33,46,73,0.09);
  border-radius: 20px;
  padding: 4px 14px;
  pointer-events: none;
  white-space: nowrap;
}

/* ================= Canada Map Jurisdiction Picker ================= */

/* Content card — position: relative so it stacks above .modalOverlay via DOM order,
   same pattern as .modalContent in the base modal styles */
.codePickerContent {
  position: relative;
  background: var(--bg-primary, #fff);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  width: min(96vw, 700px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header row */
.codePickerHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 12px;
  flex-shrink: 0;
}

.codePickerTitle {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 2px;
  color: var(--text-primary, #111);
}

.codePickerSub {
  font-size: 0.82rem;
  color: var(--text-secondary, #666);
  margin: 0;
}

.codePickerSkipBtn {
  flex-shrink: 0;
  padding: 5px 14px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 8px;
  background: none;
  color: var(--text-secondary, #555);
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms;
}
.codePickerSkipBtn:hover {
  background: var(--bg-hover, #f3f4f6);
}

/* Map wrapper — scrollable if SVG is taller than available space */
.codePickerMapWrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0 16px 16px;
  overflow: hidden;
}

/* The SVG scales to fill its container without overflow */
#canadaMapSvg {
  display: block;
  width: 100%;
  height: 100%;
  max-height: calc(92vh - 90px);  /* viewport minus header */
  object-fit: contain;
}

.mapLoadingSpinner {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #888);
  font-size: 0.88rem;
  width: 100%;
  min-height: 200px;
}

/* Province paths */
.map-province {
  fill: #CBD5E8;
  stroke: #fff;
  stroke-width: 1;
  cursor: default;
  transition: fill 120ms ease;
}
.map-province.map-available {
  fill: #A8BBF4;
  cursor: pointer;
}
.map-province.map-hovered {
  fill: #3b5fc0 !important;
}
.map-province.map-available.map-hovered {
  fill: #2952c9 !important;
}

/* Floating tooltip */
.map-tooltip {
  position: absolute;
  z-index: 100;
  min-width: 210px;
  max-width: 280px;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  padding: 10px 12px;
  pointer-events: auto;
}

.map-tt-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary, #555);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* A single code option row */
.map-tt-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border-radius: 8px;
  padding: 7px 9px;
  margin-bottom: 4px;
  font-size: 0.82rem;
  text-align: left;
}
.map-tt-code:last-child { margin-bottom: 0; }

/* Selectable code option (button) */
.map-tt-selectable {
  border: 1px solid var(--border, #d1d5db);
  background: var(--bg-secondary, #f8faff);
  color: var(--text-primary, #111);
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
}
.map-tt-selectable:hover {
  background: #e8eeff;
  border-color: #6b8df5;
}

/* Coming-soon row (div, not button) */
.map-tt-soon {
  background: var(--bg-secondary, #f8f8f8);
  border: 1px solid transparent;
  color: var(--text-muted, #aaa);
  justify-content: space-between;
}

.map-tt-label {
  font-weight: 700;
  display: block;
}
.map-tt-city {
  font-size: 0.74rem;
  color: var(--blue-600, #2563eb);
  display: block;
  margin-top: 1px;
}
.map-tt-desc {
  font-size: 0.74rem;
  color: var(--text-secondary, #666);
  display: block;
  margin-top: 1px;
}
.map-tt-soon-tag {
  font-size: 0.7rem;
  background: #e5e7eb;
  color: #9ca3af;
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.map-tt-arrow {
  flex-shrink: 0;
  color: var(--text-secondary, #888);
}

/* Header badge showing selected code */
.codeActiveBadge {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--blue-100, #dbeafe);
  color: var(--blue-700, #1d4ed8);
  border-radius: 5px;
  padding: 1px 6px;
  vertical-align: middle;
}

/* ================================================================
   Canada Map Jurisdiction Picker
================================================================ */

/* Modal override for the wider picker layout */
#codePickerModal .modalOverlay {
  background: rgba(33, 46, 73, 0.55);
  backdrop-filter: blur(6px);
}

.codePickerContent {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1001;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(33,46,73,0.22);
  padding: 28px 32px 32px;
  width: min(92vw, 860px);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.codePickerHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.codePickerTitle {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 600;
  color: var(--slate-800);
  margin: 0 0 4px;
}

.codePickerSub {
  font-size: 13px;
  color: rgba(33,46,73,0.55);
  margin: 0;
}

.codePickerSkipBtn {
  flex-shrink: 0;
  padding: 8px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: rgba(33,46,73,0.55);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  white-space: nowrap;
}
.codePickerSkipBtn:hover {
  background: var(--gray-100);
  color: var(--slate-800);
}

/* Map SVG container */
.codePickerMapWrap {
  position: relative;
  width: 100%;
}

#canadaMapSvg {
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
}

/* Province / territory paths */
.map-province {
  fill: #CBD5E8;
  stroke: #fff;
  stroke-width: 2;
  stroke-linejoin: round;
  transition: fill 140ms ease;
}

.map-province.map-available {
  fill: #A8BBF4;  /* periwinkle-200 – has a real code */
}

.map-province.map-hovered {
  fill: var(--purple-500) !important;
}

.map-province.map-available.map-hovered {
  fill: var(--blue-700) !important;
}

/* Province labels */
.map-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  fill: rgba(33,46,73,0.75);
  letter-spacing: 0.3px;
  user-select: none;
}

/* ---- Tooltip ---- */
.map-tooltip {
  position: absolute;
  z-index: 100;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(33,46,73,0.18);
  padding: 14px 16px;
  min-width: 230px;
  max-width: 310px;
  pointer-events: auto;   /* allow clicking inside */
  transition: opacity 120ms ease;
}

.map-tt-name {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-800);
  margin-bottom: 10px;
}

.map-tt-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.map-tt-code:last-child { margin-bottom: 0; }

.map-tt-selectable {
  background: rgba(168,187,244,0.12);
  border: 1px solid rgba(27,63,135,0.12);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease;
}
.map-tt-selectable:hover {
  background: rgba(27,63,135,0.10);
  border-color: var(--blue-700);
}

.map-tt-soon {
  background: var(--gray-100);
  border: 1px solid transparent;
  opacity: 0.65;
}

.map-tt-label {
  display: block;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-800);
}

.map-tt-desc {
  display: block;
  font-size: 11px;
  color: rgba(33,46,73,0.55);
  margin-top: 2px;
}

.map-tt-city {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--purple-500);
  background: rgba(148,88,244,0.08);
  border-radius: 6px;
  padding: 1px 6px;
  margin-top: 3px;
  letter-spacing: 0.2px;
}

.map-tt-soon-tag {
  font-size: 10px;
  font-weight: 600;
  color: rgba(33,46,73,0.45);
  background: rgba(33,46,73,0.08);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
}

.map-tt-arrow {
  flex-shrink: 0;
  color: var(--blue-700);
  opacity: 0.7;
}

/* Header badge showing the active code */
.codeActiveBadge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(27,63,135,0.10);
  color: var(--blue-700);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}
  flex-shrink: 0;
}

.wbPanelClose:hover {
  background: rgba(255,255,255,0.18);
}

.wbPanelBody {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wbPanelBody iframe {
  width: 100%;
  height: 100%;
  border: none;
  flex: 1;
  display: block;
}

.wbPanelFooter {
  padding: 8px 20px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(246,248,254,0.5), var(--white));
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  color: rgba(33,46,73,0.55);
  flex-shrink: 0;
}

.wbPanelFooter svg {
  flex-shrink: 0;
  color: var(--purple-500);
  opacity: 0.7;
}

@media (max-width: 768px) {
  .wbPanel {
    width: 100vw;
    min-width: unset;
  }
}

/* ================================================================
   Part 11 Article Viewer Panel
   ================================================================ */

.p11PanelBody {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.p11ArticleContent {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--slate-800);
  line-height: 1.65;
}

.p11EntryKey {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple-500);
  margin-bottom: 4px;
}

.p11EntryTitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-800);
  margin-bottom: 14px;
  line-height: 1.4;
}

.p11Sentences {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.p11Sentences li {
  line-height: 1.6;
}

.p11NoteBody p {
  margin: 0 0 12px;
  line-height: 1.65;
}

.p11NoteBody p:last-child {
  margin-bottom: 0;
}

/* Part 11 inline link style */
a.p11-ref {
  border-bottom-color: #9458F4;
  color: #7c3aed;
}
a.p11-ref:hover {
  background: rgba(124, 58, 237, 0.08);
}

/* ================================================================
   Wider panel variant for flowcharts
   ================================================================ */

.wbPanelWide {
  min-width: 480px;
  width: 560px;
}

@media (max-width: 768px) {
  .wbPanelWide {
    width: 100vw;
    min-width: unset;
  }
}

/* ================================================================
   Flowchart Panel — FC1/FC2/FC3
   ================================================================ */

.fcPanelBody {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Tab bar ── */
.fcTabBar {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fcTab {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--slate-600);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.fcTab:hover  { color: var(--slate-800); }
.fcTab.active { color: var(--purple-500); border-bottom-color: var(--purple-500); }

/* ── Scrollable content area ── */
.fcContent {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ── Legend ── */
.fcLegend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 11.5px;
  font-family: var(--font-body);
  color: var(--slate-600);
}
.fcLegendItem { display: flex; align-items: center; gap: 5px; }
.fcLegendDot  { width: 10px; height: 10px; border-radius: 2px; }

/* ── Upgrade level colours ── */
.lv1  { background: #dcfce7; color: #15803d; }
.lv2  { background: #dbeafe; color: #1d4ed8; }
.lv3  { background: #ffedd5; color: #b45309; }
.lv4  { background: #fee2e2; color: #b91c1c; }
.lvNA { background: #f1f5f9; color: #64748b; }

.fcLegendDot.lv1  { background: #86efac; }
.fcLegendDot.lv2  { background: #93c5fd; }
.fcLegendDot.lv3  { background: #fdba74; }
.fcLegendDot.lv4  { background: #fca5a5; }
.fcLegendDot.lvNA { background: #cbd5e1; }

/* ── Table (FC1, FC3) ── */
.fcTable {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: 13px;
  margin-bottom: 18px;
}

.fcTable th, .fcTable td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

.fcThProject, .fcTdProject {
  text-align: left;
  font-weight: 500;
  color: var(--slate-700);
  min-width: 140px;
}

.fcTdProject.fcTdSub {
  padding-left: 20px;
  font-size: 12.5px;
}

.fcTdGroup {
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
  background: var(--bg-secondary, #f8fafc);
  padding: 6px 10px;
}

/* ── Active row highlight ── */
tr.fcRowActive td {
  outline: 2px solid #3b82f6;
  outline-offset: -1px;
}
tr.fcRowActive .fcTdProject {
  font-weight: 700;
  color: #1d4ed8;
}
tr.fcRowActive .fcTdProject::before {
  content: "▶ ";
  font-size: 10px;
  color: #3b82f6;
}

/* ── Active decision block (FC2) ── */
.fcDecisionActive {
  border: 2px solid #3b82f6 !important;
  border-radius: 6px;
}
.fcDecisionActive .fcDecisionQ {
  color: #1d4ed8;
  font-weight: 700;
}

/* ── FC2 Decision tree ── */
.fcDecision {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}
.fcDecisionQ {
  background: var(--bg-secondary, #f8fafc);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--slate-700);
  border-bottom: 1px solid var(--border);
}
.fcDecisionBranches {
  display: flex;
  gap: 0;
}
.fcBranchBlock {
  flex: 1;
  padding: 10px 12px;
  min-width: 0;
}
.fcBranchYesBlock {
  border-right: 1px solid var(--border);
}
.fcBranchArrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.fcBranchArrowYes { color: #16a
/* ── Part-detected notification pill ───────────────────────────────────── */
.partDetectedNote {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent, #1B3F87);
  background: color-mix(in srgb, var(--accent, #1B3F87) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #1B3F87) 25%, transparent);
  border-radius: 20px;
  padding: 3px 10px;
  margin: 4px auto;
}
.partDetectedNote::before {
  content: '⟳';
  font-size: 12px;
}

}
.fcFootnote { margin-bottom: 5px; line-height: 1.5; }
.fcFootnoteN { font-weight: 700; margin-right: 4px; }

/* ── FC toolbar button ── */
.actionBtnFC {
  align-items: center;
  gap: 6px;
}

/* ================= Auth Gate (full-page login/signup/forgot) ================= */
/* Not enforced yet — see index.html comment above #authGate for the AUTH_ENABLED plan. */

.authGate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.authGate.active {
  display: flex;
}

.authGateBg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--blue-700, #1B3F87), rgba(27, 63, 135, 0.85));
}

.authGateCard {
  position: relative;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 32px 28px 28px;
}

.authGateCloseBtn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(33, 46, 73, 0.06);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--slate-700);
}

.authGateCloseBtn:hover {
  background: rgba(33, 46, 73, 0.12);
}

.authGateBrand {
  text-align: center;
  margin-bottom: 18px;
}

.authGateBrand h1 {
  font-family: var(--font-head);
  font-size: 22px;
  margin: 0;
  color: var(--slate-800);
}

.authGateBrand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: rgba(33, 46, 73, 0.6);
}

.authGateTitle {
  font-family: var(--font-head);
  font-size: 18px;
  margin: 0 0 14px 0;
  color: var(--slate-800);
  text-align: center;
}

.authTabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.authTab {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  background: none;
  border: none;
  padding: 10px 14px;
  color: rgba(33, 46, 73, 0.55);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.authTab:hover {
  color: var(--slate-800);
}

.authTab.active {
  color: var(--blue-700, #1B3F87);
  border-bottom-color: var(--blue-700, #1B3F87);
}

.authPane {
  display: none;
}

.authPane.active {
  display: block;
}

.authError {
  font-size: 13px;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  margin: -6px 0 12px 0;
}

.authSuccess {
  font-size: 13px;
  color: #15803d;
  background: rgba(21, 128, 61, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  margin: -6px 0 12px 0;
}

.authLinkRow {
  text-align: center;
  margin: 14px 0 0 0;
}

.authLinkBtn {
  background: none;
  border: none;
  color: var(--blue-600, #2563eb);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-family: var(--font-body);
}
