/* ── Note Flowchart Mode — dedicated full page ───────────── */

body.fcflow-open {
  overflow: hidden;
}

body.fcflow-open #app {
  visibility: hidden;
}

.fcflow-root {
  position: fixed;
  inset: 0;
  z-index: 10200;
  background: #0b1220;
}

.fcflow-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: #e8edf5;
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(14, 165, 233, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(99, 102, 241, 0.14), transparent 50%),
    linear-gradient(165deg, #0b1220 0%, #111827 45%, #0f172a 100%);
}

/* Header */
.fcflow-page__header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.fcflow-page__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.fcflow-page__back:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(14, 165, 233, 0.5);
  color: #fff;
}

.fcflow-page__header-meta {
  flex: 1;
  min-width: 0;
}

.fcflow-page__subject {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #38bdf8;
  font-weight: 600;
}

.fcflow-page__note {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fcflow-page__header-actions {
  display: flex;
  gap: 8px;
}

.fcflow-page__btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, transform 0.1s;
}

.fcflow-page__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.fcflow-page__btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.fcflow-page__btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.fcflow-page__btn--primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  border-color: transparent;
}

.fcflow-page__btn--primary:hover {
  filter: brightness(1.08);
}

.fcflow-page__body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Loading / error */
.fcflow-page__loading,
.fcflow-page__error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
}

.fcflow-page__loading h2,
.fcflow-page__error h2 {
  margin: 0 0 10px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  color: #f8fafc;
}

.fcflow-page__loading p,
.fcflow-page__error p {
  margin: 0;
  color: #94a3b8;
  max-width: 400px;
  line-height: 1.6;
}

.fcflow-page__loading-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.fcflow-page__loading-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0ea5e9;
  box-shadow: 0 0 20px rgba(14, 165, 233, 0.6);
}

.fcflow-page__loading-dot--pulse {
  animation: fcflow-pulse 1.2s ease-in-out infinite;
}

.fcflow-page__loading-line {
  width: 2px;
  height: 32px;
  background: linear-gradient(to bottom, #0ea5e9, rgba(14, 165, 233, 0.2));
  margin: 6px 0;
}

@keyframes fcflow-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* Layout: sidebar + canvas */
.fcflow-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.fcflow-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fcflow-sidebar__head {
  padding: 20px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.fcflow-sidebar__kicker {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
  margin-bottom: 4px;
}

.fcflow-sidebar__count {
  font-size: 12px;
  color: #94a3b8;
}

.fcflow-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fcflow-sidebar__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.fcflow-sidebar__item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.fcflow-sidebar__item.is-active {
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(14, 165, 233, 0.35);
  color: #f8fafc;
}

.fcflow-sidebar__num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
}

.fcflow-sidebar__item.is-active .fcflow-sidebar__num {
  background: #0ea5e9;
  color: #fff;
}

.fcflow-sidebar__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.fcflow-sidebar__text strong {
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fcflow-sidebar__text small {
  font-size: 11px;
  color: #64748b;
}

/* Main canvas */
.fcflow-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px 40px;
}

.fcflow-page__badge {
  display: inline-block;
  margin-bottom: 16px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.fcflow-canvas__hero {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.fcflow-canvas__kicker {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #38bdf8;
  margin-bottom: 8px;
  font-weight: 600;
}

.fcflow-canvas__title {
  margin: 0 0 12px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.25;
  color: #f8fafc;
  max-width: 720px;
}

.fcflow-canvas__overview {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: #94a3b8;
  max-width: 680px;
}

.fcflow-flow__heading {
  margin: 0 0 24px;
  font-size: 1.15rem;
  font-weight: 600;
  color: #e2e8f0;
  padding-left: 52px;
}

/* Pipeline — timeline style (not flashcards) */
.fcflow-pipeline {
  max-width: 720px;
}

.fcflow-pipeline__row {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.fcflow-pipeline__rail {
  width: 48px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fcflow-pipeline__dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: #334155;
  border: 3px solid #475569;
  flex-shrink: 0;
  z-index: 1;
}

.fcflow-pipeline__row--start .fcflow-pipeline__dot {
  background: #059669;
  border-color: #34d399;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.fcflow-pipeline__row--step .fcflow-pipeline__dot {
  background: #0284c7;
  border-color: #38bdf8;
}

.fcflow-pipeline__row--decision .fcflow-pipeline__dot {
  background: #d97706;
  border-color: #fbbf24;
  border-radius: 6px;
  transform: rotate(0deg);
}

.fcflow-pipeline__row--key .fcflow-pipeline__dot {
  background: #7c3aed;
  border-color: #a78bfa;
}

.fcflow-pipeline__row--end .fcflow-pipeline__dot {
  background: #0d9488;
  border-color: #2dd4bf;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.2);
}

.fcflow-pipeline__stem {
  flex: 1;
  width: 3px;
  min-height: 24px;
  background: linear-gradient(to bottom, rgba(148, 163, 184, 0.5), rgba(148, 163, 184, 0.15));
  margin: 4px 0;
}

.fcflow-pipeline__content {
  flex: 1;
  padding-bottom: 8px;
  min-width: 0;
  overflow: visible;
}

.fcflow-pipeline__card {
  position: relative;
  padding: 18px 22px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 4px solid #475569;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.fcflow-pipeline__card--expandable {
  cursor: pointer;
}

.fcflow-pipeline__card--expandable:hover,
.fcflow-pipeline__card--expandable:focus-within {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 8px 32px rgba(14, 165, 233, 0.18);
  transform: translateY(-1px);
}

.fcflow-pipeline__card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 10px;
}

.fcflow-pipeline__hover-hint {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  opacity: 0;
  transition: opacity 0.15s;
}

.fcflow-pipeline__card--expandable:hover .fcflow-pipeline__hover-hint,
.fcflow-pipeline__card--expandable:focus-within .fcflow-pipeline__hover-hint {
  opacity: 1;
  color: #7dd3fc;
}

.fcflow-pipeline__row--start .fcflow-pipeline__card { border-left-color: #34d399; }
.fcflow-pipeline__row--step .fcflow-pipeline__card { border-left-color: #38bdf8; }
.fcflow-pipeline__row--decision .fcflow-pipeline__card { border-left-color: #fbbf24; }
.fcflow-pipeline__row--key .fcflow-pipeline__card { border-left-color: #a78bfa; }
.fcflow-pipeline__row--end .fcflow-pipeline__card { border-left-color: #2dd4bf; }

.fcflow-pipeline__tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.fcflow-pipeline__tag--start { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.fcflow-pipeline__tag--step { background: rgba(14, 165, 233, 0.2); color: #7dd3fc; }
.fcflow-pipeline__tag--decision { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.fcflow-pipeline__tag--key { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
.fcflow-pipeline__tag--end { background: rgba(20, 184, 166, 0.2); color: #5eead4; }

.fcflow-pipeline__label {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.4;
}

.fcflow-pipeline__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: #94a3b8;
}

.fcflow-pipeline__connector {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 0 6px 8px;
}

.fcflow-pipeline__connector-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.fcflow-pipeline__branches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.fcflow-pipeline__branch {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.fcflow-pipeline__branch-label {
  font-weight: 700;
  color: #fbbf24;
  margin-right: 6px;
}

.fcflow-pipeline__branch-target {
  color: #cbd5e1;
}

/* Hover detail popover — fixed portal (see flowchartService.js) */
.fcflow-popover-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15000;
}

.fcflow-pipeline__popover {
  position: fixed;
  width: min(380px, calc(100vw - 24px));
  padding: 16px 18px;
  border-radius: 14px;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
  z-index: 15001;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.fcflow-pipeline__popover.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.fcflow-pipeline__popover-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.fcflow-pipeline__popover-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
}

.fcflow-pipeline__popover-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.35;
}

.fcflow-pipeline__popover-body {
  font-size: 13px;
  line-height: 1.65;
  color: #cbd5e1;
}

.fcflow-pipeline__popover-body p {
  margin: 0 0 10px;
}

.fcflow-pipeline__popover-body p:last-child {
  margin-bottom: 0;
}

.fcflow-pipeline__popover-branches {
  margin-top: 8px !important;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: #94a3b8;
}

.fcflow-pipeline__popover-branches em {
  font-style: normal;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.fcflow-pipeline__popover-hint {
  margin: 12px 0 0;
  font-size: 10px;
  color: #64748b;
  text-align: right;
}

.fcflow-canvas__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  max-width: 720px;
}

.fcflow-canvas__pager {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

/* Editor toolbar button */
.note-editor__flowchart-btn {
  color: #0284c7;
  background: color-mix(in srgb, #0284c7 12%, transparent);
  border-color: #0284c7;
}
.note-editor__flowchart-btn:hover {
  background: #0284c7;
  color: #fff;
}
.note-editor__flowchart-btn.is-scoped {
  box-shadow: 0 0 0 2px color-mix(in srgb, #0284c7 35%, transparent);
}

@media print {
  body.fcflow-open #app {
    visibility: visible;
  }

  .fcflow-root {
    position: static;
    background: #fff;
    color: #000;
  }

  .fcflow-page__header,
  .fcflow-sidebar,
  .fcflow-canvas__nav {
    display: none !important;
  }

  .fcflow-canvas {
    padding: 0;
  }

  .fcflow-pipeline__card {
    background: #fff;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .fcflow-pipeline__popover {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .fcflow-layout {
    flex-direction: column;
  }

  .fcflow-sidebar {
    width: 100%;
    max-height: 160px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .fcflow-sidebar__nav {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .fcflow-sidebar__item {
    min-width: 200px;
    flex-shrink: 0;
  }

  .fcflow-canvas {
    padding: 20px 16px 32px;
  }

  .fcflow-flow__heading {
    padding-left: 0;
  }

  .fcflow-page__header {
    flex-wrap: wrap;
    padding: 12px 16px;
  }
}
