/**
 * Workspace Unified Stylesheet
 * Combines shell layout, navbar, dialogs, canvas viewport, and node cards.
 */

/**
 * Workspace Shell Styles
 * Layout, top navigation, modals, buttons, and settings dialog styling.
 */

:root {
  --bg-flow-canvas: #f8fafc;
  --bg-flow-grid: rgba(0, 0, 0, 0.06);
  --flow-header-bg: rgba(255, 255, 255, 0.90);
  --flow-border-color: rgba(0, 0, 0, 0.08);
  --flow-text-primary: #0f172a;
  --flow-text-secondary: #475569;
  --flow-text-muted: #64748b;
  --flow-nav-bg: rgba(0, 0, 0, 0.04);
  --flow-nav-border: rgba(0, 0, 0, 0.12);
  --flow-nav-hover: rgba(0, 0, 0, 0.08);
  --flow-modal-bg: #ffffff;
  --flow-modal-border: rgba(0, 0, 0, 0.12);
  --flow-modal-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
  --flow-modal-footer: rgba(0, 0, 0, 0.03);
  --flow-input-bg: rgba(0, 0, 0, 0.03);
  --flow-input-border: rgba(0, 0, 0, 0.15);
  --flow-card-bg: rgba(255, 255, 255, 0.96);
  --flow-card-border: rgba(0, 0, 0, 0.12);
  --flow-card-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --flow-settings-row-bg: #ffffff;
  --flow-cal-weekend-bg: #f4f5f7;
  --color-mint: #58BEA2;
  --color-teal: #2695A2;
  --flow-milestone-date-color: #7C3AED;
  --flow-milestone-date-hover-color: #5B21B6;
  --flow-milestone-date-hover-bg: rgba(124, 58, 237, 0.12);
  --flow-milestone-date-hover-border: rgba(124, 58, 237, 0.28);
}

html.dark {
  --bg-flow-canvas: #090d16;
  --bg-flow-grid: rgba(255, 255, 255, 0.03);
  --flow-header-bg: rgba(15, 23, 42, 0.85);
  --flow-border-color: rgba(255, 255, 255, 0.1);
  --flow-text-primary: #f1f5f9;
  --flow-text-secondary: #94a3b8;
  --flow-text-muted: #64748b;
  --flow-nav-bg: rgba(255, 255, 255, 0.06);
  --flow-nav-border: rgba(255, 255, 255, 0.12);
  --flow-nav-hover: rgba(255, 255, 255, 0.12);
  --flow-modal-bg: #0f172a;
  --flow-modal-border: rgba(255, 255, 255, 0.14);
  --flow-modal-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  --flow-modal-footer: rgba(0, 0, 0, 0.2);
  --flow-input-bg: rgba(255, 255, 255, 0.05);
  --flow-input-border: rgba(255, 255, 255, 0.12);
  --flow-card-bg: rgba(15, 23, 42, 0.9);
  --flow-card-border: rgba(255, 255, 255, 0.14);
  --flow-card-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --flow-settings-row-bg: rgba(255, 255, 255, 0.04);
  --flow-cal-weekend-bg: #141e30;
  --flow-milestone-date-color: #C4B5FD;
  --flow-milestone-date-hover-color: #EDE9FE;
  --flow-milestone-date-hover-bg: rgba(139, 92, 246, 0.22);
  --flow-milestone-date-hover-border: rgba(139, 92, 246, 0.45);
}

/**
 * Native base reset (replaces Bulma).
 *
 * `calendar.html` and `workspace-shell.html` used to load bulma@1.0.2 from a
 * CDN purely for its global reset layer -- an audit found zero actual Bulma
 * component classes (.button, .input, .modal, .columns, etc.) used anywhere
 * in their markup or in JS-rendered output; every visible style comes from
 * this stylesheet's own flow-*/wc-*/settings-* classes. Bulma also directly
 * caused a real bug: its global `.is-hidden { display: none !important; }`
 * helper collided with and silently overrode our own same-named calendar
 * legend state class (see workspace-calendar.js). Replacing the CDN
 * dependency with this equivalent, minimal native reset (mirrors Bulma's
 * bundled minireset.css + base.sass) removes both the dead weight and that
 * whole class of collision risk.
 */
*, *::before, *::after {
  box-sizing: border-box;
}

html,
body,
p,
ol,
ul,
li,
dl,
dt,
dd,
blockquote,
figure,
fieldset,
legend,
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-size: 100%;
  font-weight: normal;
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

a {
  text-decoration: none;
  color: inherit;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-flow-canvas);
  background-image: 
    radial-gradient(var(--bg-flow-grid) 1.5px, transparent 1.5px),
    radial-gradient(var(--bg-flow-grid) 1.5px, var(--bg-flow-canvas) 1.5px);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--flow-text-primary);
  transition: background-color 0.2s, color 0.2s;
}

.flow-app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
}

.flow-top-navbar {
  position: relative;
  height: 52px;
  background: var(--flow-header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--flow-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
  transition: background-color 0.2s, border-color 0.2s;
}

.flow-nav-btn {
  background: var(--flow-nav-bg);
  border: 1px solid var(--flow-nav-border);
  color: var(--flow-text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.2s;
}

.flow-nav-btn:not(:disabled):hover {
  background: var(--flow-nav-hover);
  color: var(--flow-text-primary);
}

.flow-nav-btn.primary {
  background: var(--color-teal);
  border-color: var(--color-teal);
  color: #ffffff;
}

.flow-nav-btn.primary:not(:disabled):hover {
  background: #1f7d89;
  color: #ffffff;
}

.flow-nav-btn:disabled,
.settings-action-btn:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

/* Top Navbar Chromeless Buttons */
.flow-top-navbar .flow-nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--flow-text-secondary);
  box-shadow: none;
  border-radius: 6px;
  padding: 6px 10px;
  transition: all 0.2s ease;
}

.flow-top-navbar .flow-nav-btn:hover {
  background: var(--flow-nav-hover);
  border-color: transparent;
  color: var(--flow-text-primary);
}

.flow-top-navbar #btnOpenSettingsModal {
  background: transparent !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  color: var(--flow-text-secondary);
  border-radius: 6px;
  padding: 5px 7px !important;
}

.flow-top-navbar #btnOpenSettingsModal:hover {
  background: var(--flow-nav-hover) !important;
  border-color: transparent !important;
  color: var(--flow-text-primary);
  transform: scale(1.08);
}

.flow-editable-title:hover {
  background: var(--flow-nav-hover);
  border-color: var(--flow-border-color) !important;
}

/* Left Vertical Toolbar - Collapsible with Micro-animation on Hover */
.flow-left-toolbar {
  position: absolute;
  left: 16px;
  top: 68px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border-radius: 10px;
  background: var(--flow-header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--flow-border-color);
  box-shadow: var(--flow-card-shadow);
  width: 48px;
  box-sizing: border-box;
  overflow: hidden;
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
  user-select: none;
}

.flow-left-toolbar:hover,
.flow-left-toolbar:focus-within,
.flow-left-toolbar.is-expanded {
  width: 140px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

html.dark .flow-left-toolbar:hover,
html.dark .flow-left-toolbar:focus-within,
html.dark .flow-left-toolbar.is-expanded {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.flow-tool-btn {
  background: transparent;
  border: 1px solid transparent;
  width: 100%;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  box-sizing: border-box;
  transition: background 0.18s ease,
              border-color 0.18s ease,
              transform 0.18s ease;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.flow-tool-btn:hover {
  background: var(--flow-nav-hover);
  border-color: rgba(0, 0, 0, 0.05);
}

html.dark .flow-tool-btn:hover {
  border-color: rgba(255, 255, 255, 0.08);
}

.flow-tool-btn:active {
  transform: scale(0.96);
}

.flow-tool-btn.flow-tool-task {
  color: var(--color-teal);
}

.flow-tool-btn.flow-tool-milestone {
  color: #8B5CF6;
}

.flow-tool-btn.flow-tool-review {
  color: #F59E0B;
}

.flow-tool-btn.flow-tool-note {
  color: #64748B;
}

html.dark .flow-tool-btn.flow-tool-note {
  color: #94A3B8;
}

.flow-tool-btn[data-node-type="task"]:hover {
  background: rgba(38, 149, 162, 0.14);
}

.flow-tool-btn[data-node-type="milestone"]:hover {
  background: rgba(139, 92, 246, 0.14);
}

.flow-tool-btn[data-node-type="client_review"]:hover {
  background: rgba(245, 158, 11, 0.14);
}

.flow-tool-btn[data-node-type="note"]:hover {
  background: rgba(100, 116, 139, 0.14);
}

.flow-tool-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.flow-tool-btn:hover .flow-tool-icon {
  transform: scale(1.1);
}

.flow-tool-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--flow-text-primary);
  white-space: nowrap;
  opacity: 0;
  max-width: 0;
  transform: translateX(-8px);
  pointer-events: none;
  overflow: hidden;
  margin-left: 0;
  transition: max-width 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              margin-left 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

.flow-left-toolbar:hover .flow-tool-label,
.flow-left-toolbar:focus-within .flow-tool-label,
.flow-left-toolbar.is-expanded .flow-tool-label {
  opacity: 1;
  max-width: 86px;
  transform: translateX(0);
  margin-left: 2px;
}

/* Divider separating node-type tools from the undo/redo history controls */
.flow-toolbar-divider {
  height: 1px;
  margin: 2px 4px;
  background: var(--flow-border-color);
  opacity: 0.6;
  flex-shrink: 0;
}

.flow-history-group {
  display: none;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.flow-tool-btn.flow-tool-history {
  color: var(--flow-text-secondary);
}

.flow-tool-btn.flow-tool-history:hover {
  background: var(--flow-nav-hover);
}

.flow-tool-btn.flow-tool-history:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.flow-tool-btn.flow-tool-history:disabled:hover {
  background: transparent;
}

.flow-workspace-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  position: relative;
  text-decoration: none;
  cursor: pointer;
  background: transparent !important;
  color: var(--color-teal);
  border: none !important;
  box-shadow: none !important;
  transition: all 0.2s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.flow-workspace-icon-btn:hover {
  transform: scale(1.1);
  background: var(--flow-nav-hover) !important;
  box-shadow: none !important;
}

.flow-icon-resting, .flow-icon-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

.flow-icon-resting {
  opacity: 1;
  transform: scale(1);
}

.flow-icon-back {
  opacity: 0;
  transform: translateX(4px);
  color: var(--flow-text-primary);
}

.flow-workspace-icon-btn:hover .flow-icon-resting {
  opacity: 0;
  transform: translateX(-4px);
}

.flow-workspace-icon-btn:hover .flow-icon-back {
  opacity: 1;
  transform: translateX(0);
}

/* Save Status (always-on autosave; purely informational, non-interactive, centered) */
.flow-save-capsule {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--flow-text-primary);
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  user-select: none;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* Fades to a subtle resting opacity a few seconds after the last status change. */
.flow-save-capsule.is-idle {
  opacity: 0.45;
}

.flow-save-capsule.state-dirty .save-status-text {
  color: #F59E0B;
}

.flow-save-capsule.state-error {
  animation: saveShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.flow-save-capsule.state-error .save-status-text {
  color: #EF4444;
}

@keyframes saveShake {
  10%, 90% { transform: translate3d(-1px, 0, 0) translate(-50%, -50%); }
  20%, 80% { transform: translate3d(2px, 0, 0) translate(-50%, -50%); }
  30%, 50%, 70% { transform: translate3d(-2px, 0, 0) translate(-50%, -50%); }
  40%, 60% { transform: translate3d(2px, 0, 0) translate(-50%, -50%); }
}

.save-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-mint);
  transition: all 0.2s;
  flex-shrink: 0;
}

.save-status-dot.saving {
  background: var(--color-teal);
  animation: pulse 1s infinite;
}

.save-status-dot.dirty {
  background: #F59E0B;
  animation: pulse 1s infinite;
}

.save-status-dot.error {
  background: #EF4444;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* Modals */
.flow-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.flow-modal-backdrop.is-active {
  display: flex;
}

.flow-modal-card {
  background: var(--flow-modal-bg);
  border: 1px solid var(--flow-modal-border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--flow-modal-shadow);
  color: var(--flow-text-primary);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.flow-modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--flow-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flow-modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 70vh;
  overflow-y: auto;
}

.flow-modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--flow-border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--flow-modal-footer);
}

.flow-input-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--flow-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: block;
}

.flow-input-control {
  width: 100%;
  background: var(--flow-input-bg);
  border: 1px solid var(--flow-input-border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--flow-text-primary);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.2s;
}

.flow-input-control:focus {
  border-color: var(--color-teal);
}

/* Workspace Settings Refactored Styles */
.settings-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--flow-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-modal-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: rgba(38, 149, 162, 0.12);
  color: var(--color-teal);
  border: 1px solid rgba(38, 149, 162, 0.22);
  flex-shrink: 0;
}

/* Colored section headers with inline horizontal line */
.settings-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  width: 100%;
}

.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  user-select: none;
}

.settings-section-line {
  flex: 1;
  height: 1px;
  background: var(--flow-border-color);
  opacity: 0.75;
}

.settings-theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--flow-settings-row-bg);
  border: 1px solid var(--flow-border-color);
  color: var(--flow-text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  flex-shrink: 0;
}

.settings-theme-toggle-btn:hover {
  background: var(--flow-nav-hover);
  border-color: var(--color-teal);
}

/* Settings Toggle Switch (Auto-Save) */
.settings-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.settings-switch-check {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-switch-track {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: rgba(148, 163, 184, 0.3);
  position: relative;
  transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
}

.settings-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-switch-check:checked + .settings-switch-track {
  background: var(--color-teal);
}

.settings-switch-check:checked + .settings-switch-track .settings-switch-thumb {
  transform: translateX(18px);
}


.settings-compound-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--flow-input-border);
  border-radius: 8px;
  background: var(--flow-input-bg);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-compound-group:focus-within {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 2px rgba(38, 149, 162, 0.2);
}

.settings-prefix-label {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--flow-text-muted);
  background: var(--flow-modal-footer);
  border-right: 1px solid var(--flow-border-color);
  user-select: none;
  white-space: nowrap;
}

.settings-input-control,
input.settings-input-control,
.settings-compound-group input,
.settings-invite-bar input,
#modalWorkspaceSettings input.settings-input-control {
  flex: 1 1 auto;
  border: none !important;
  border-bottom: none !important;
  background: transparent !important;
  padding: 8px 12px 8px 14px !important;
  padding-left: 14px !important;
  padding-right: 12px !important;
  color: var(--flow-text-primary) !important;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  min-width: 0;
  box-shadow: none !important;
}

.settings-input-control[readonly],
input.settings-input-control[readonly],
.settings-compound-group input[readonly],
#modalWorkspaceSettings input.settings-input-control[readonly] {
  cursor: default;
  opacity: 0.82;
  user-select: all;
}

.settings-action-btn {
  border-radius: 0 !important;
  margin: 0 !important;
  border-top: none !important;
  border-bottom: none !important;
  border-right: none !important;
  border-left: 1px solid var(--flow-border-color) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  padding: 0 14px !important;
  white-space: nowrap !important;
  cursor: pointer;
}

.settings-action-btn.danger {
  color: #EF4444 !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

.settings-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.16) !important;
}

.settings-status-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--flow-nav-bg);
  color: var(--flow-text-muted);
  border: 1px solid var(--flow-nav-border);
  letter-spacing: 0.02em;
  transition: all 0.2s;
  flex-shrink: 0;
}

.settings-count-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--flow-nav-bg);
  color: var(--flow-text-secondary);
  border: 1px solid var(--flow-nav-border);
  flex-shrink: 0;
}

.settings-hint-text {
  font-size: 11.5px;
  color: var(--flow-text-muted);
  margin: 6px 0 0 0;
  line-height: 1.45;
}

.settings-count-badge.is-public {
  background: rgba(34, 197, 94, 0.14);
  color: #22C55E;
  border-color: rgba(34, 197, 94, 0.35);
}

.settings-count-badge.is-password {
  background: rgba(245, 158, 11, 0.14);
  color: #F59E0B;
  border-color: rgba(245, 158, 11, 0.35);
}

.settings-toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.settings-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-toggle-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--flow-nav-bg);
  border: 1px solid var(--flow-nav-border);
  border-radius: 20px;
  transition: background 0.2s, border-color 0.2s;
}

.settings-toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 2px;
  top: 2px;
  background: var(--flow-text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.settings-toggle-switch input:checked + .settings-toggle-slider {
  background: rgba(34, 197, 94, 0.25);
  border-color: #22C55E;
}

.settings-toggle-switch input:checked + .settings-toggle-slider::before {
  transform: translateX(16px);
  background: #22C55E;
}

.settings-feedback-banner {
  font-size: 11.5px;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--flow-settings-row-bg);
  border: 1px solid var(--flow-border-color);
  line-height: 1.4;
}

.settings-invite-bar {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--flow-input-border);
  border-radius: 8px;
  background: var(--flow-input-bg);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-invite-bar:focus-within {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 2px rgba(38, 149, 162, 0.2);
}

.settings-invite-bar input.settings-input-control {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.settings-role-select {
  background-color: var(--flow-modal-footer) !important;
  border: none !important;
  border-left: 1px solid var(--flow-border-color) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: var(--flow-text-primary) !important;
  padding: 0 28px 0 10px !important;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  width: auto !important;
  flex: 0 0 108px !important;
}

.settings-members-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  transition: none;
}

.settings-role-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  letter-spacing: normal;
  text-transform: none;
  flex-shrink: 0;
  color: var(--flow-text-muted);
}

.settings-role-badge.role-owner {
  background: transparent;
  color: #10b981;
  border: none;
}

.settings-role-badge.role-member {
  background: transparent;
  color: var(--flow-text-muted);
  border: none;
}

.settings-role-badge.role-guest {
  background: transparent;
  color: var(--flow-text-muted);
  border: none;
}

/**
 * Workspace Flow Canvas & Node Card Styles
 * Styles for the <workspace-flow-element>, viewport, canvas layers,
 * node cards, ports, connectors, inline controls, and popovers.
 */

workspace-flow-element {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Canvas Viewport & Layers */
.flow-viewport {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}

.flow-viewport.is-readonly {
  cursor: default;
}

.flow-canvas-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
  touch-action: none;
}

.flow-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  pointer-events: none;
  overflow: visible;
  z-index: 1;
}

.flow-temp-wire {
  display: none;
  fill: none;
  stroke: #F59E0B;
  stroke-width: 2.5;
  stroke-dasharray: 6 3;
  filter: url(#flowWireGlow);
  pointer-events: none;
}

.flow-nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  touch-action: none;
}

/* Floating Canvas Controls Bar (bottom-right) */
.flow-controls-bar {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 8px;
  background: var(--flow-header-bg, rgba(15, 23, 42, 0.85));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--flow-border-color, rgba(255, 255, 255, 0.12));
  box-shadow: var(--flow-card-shadow, 0 4px 12px rgba(0,0,0,0.3));
  user-select: none;
  transition: right 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.flow-zoom-stepper {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.flow-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: none;
  color: var(--flow-text-primary, #f1f5f9);
  cursor: pointer;
  border-radius: 5px;
  padding: 0;
  transition: background 0.15s, transform 0.15s, color 0.15s;
}

.flow-ctrl-btn svg {
  display: block;
}

.flow-ctrl-btn:hover {
  background: var(--flow-nav-hover, rgba(255, 255, 255, 0.1));
}

.flow-ctrl-btn.btn-zoom-reset {
  color: var(--color-mint);
}

.flow-ctrl-btn.btn-theme-toggle {
  color: var(--flow-text-primary, #f1f5f9);
}

.flow-ctrl-btn.btn-theme-toggle:hover {
  color: #F59E0B;
}

.flow-zoom-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--flow-text-secondary, #94a3b8);
  min-width: 34px;
  padding: 0 1px;
  text-align: center;
  line-height: 1;
  transform: translateY(1px);
}

.flow-ctrl-divider {
  width: 1px;
  height: 14px;
  background: var(--flow-border-color, rgba(255,255,255,0.15));
  margin: 0 1px;
  flex-shrink: 0;
}

/* Node Cards */
.flow-node-card {
  position: absolute;
  width: 260px;
  z-index: 3;
  background: var(--flow-card-bg, rgba(15, 23, 42, 0.88));
  border: 1px solid var(--flow-card-border, rgba(255, 255, 255, 0.14));
  border-radius: 10px;
  box-shadow: var(--flow-card-shadow, 0 4px 16px rgba(0, 0, 0, 0.3));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--flow-text-primary, #f1f5f9);
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s, color 0.2s;
  box-sizing: border-box;
  touch-action: none;
}

.flow-node-card:hover {
  border-color: rgba(88, 190, 162, 0.4);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.flow-node-card.is-selected {
  border-color: var(--color-mint);
  box-shadow: 0 0 0 2px rgba(88, 190, 162, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

.flow-node-card.is-orphan {
  border-style: dashed;
  border-color: rgba(245, 158, 11, 0.35);
}

/* Node Ports */
.flow-port {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: crosshair;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  touch-action: none;
  box-sizing: border-box;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s ease,
              background 0.2s ease,
              border-color 0.2s ease,
              opacity 0.2s ease;
}

.flow-port-left {
  left: 0;
  top: 50%;
}

.flow-port-right {
  left: 100%;
}

.flow-port-top {
  top: 0;
  left: 50%;
}

.flow-port-bottom {
  top: 100%;
}

.flow-port-input {
  --port-color: var(--color-teal);
}

.flow-port-output {
  --port-color: var(--color-mint);
}

.flow-port-output.port-loop {
  --port-color: #F59E0B;
}

/* 1. Unconnected Port - Subtle, calm, blended with card border */
.flow-port:not(.is-connected),
.flow-port.is-unconnected {
  background: var(--flow-card-bg, #ffffff);
  border: 1.5px solid var(--flow-border-color);
  opacity: 0.38;
}

html.dark .flow-port:not(.is-connected),
html.dark .flow-port.is-unconnected {
  background: var(--flow-card-bg, #0f172a);
  border-color: rgba(255, 255, 255, 0.16);
  opacity: 0.35;
}

.flow-port:not(.is-connected) .flow-port-center-dot,
.flow-port.is-unconnected .flow-port-center-dot {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--port-color);
  opacity: 0.5;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Card hover: subtly reveals unconnected ports to hint interactivity */
.flow-node-card:hover .flow-port:not(.is-connected),
.flow-node-card:hover .flow-port.is-unconnected {
  opacity: 0.75;
  border-color: var(--port-color);
}

.flow-node-card:hover .flow-port:not(.is-connected) .flow-port-center-dot,
.flow-node-card:hover .flow-port.is-unconnected .flow-port-center-dot {
  opacity: 0.85;
}

/* 2. Connected Port - Solid, prominent, anchoring the wire cleanly */
.flow-port.is-connected {
  background: var(--port-color);
  border: 2px solid var(--flow-card-bg, #0f172a);
  opacity: 1;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.2);
}

.flow-port.is-connected .flow-port-center-dot {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffffff;
  opacity: 1;
}

/* 3. Direct Port Hover - Active invitation to connect or view.
   Input ports can't start a connection, so they don't get this cursor-hover
   affordance; they still light up via .snap-hover while a wire is being dragged. */
.flow-port-output:hover {
  opacity: 1 !important;
  background: var(--port-color) !important;
  border: 2px solid var(--flow-card-bg, #0f172a) !important;
  transform: translate(-50%, -50%) scale(1.35) !important;
  box-shadow: 0 0 10px var(--port-color) !important;
}

.flow-port-output:hover .flow-port-center-dot {
  background: #ffffff !important;
  opacity: 1 !important;
  transform: scale(1.1);
}

/* 4. While dragging a wire - Guide user to candidate drop targets */
.flow-viewport.is-wiring .flow-port-input {
  opacity: 0.85;
  border-color: var(--color-teal);
}

.flow-port.snap-hover {
  transform: translate(-50%, -50%) scale(1.5) !important;
  background: #F59E0B !important;
  border: 2px solid var(--flow-card-bg, #0f172a) !important;
  box-shadow: 0 0 14px #F59E0B !important;
  opacity: 1 !important;
}

.flow-port.snap-hover .flow-port-center-dot {
  background: #ffffff !important;
  opacity: 1 !important;
}

/* Wire Removal / "X" Button in the middle of wire */
.flow-wire-group {
  cursor: pointer;
}

.flow-wire-delete-btn {
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transform: scale(0.6);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.flow-wire-group:hover .flow-wire-delete-btn,
.flow-wire-delete-btn.is-active {
  opacity: 1 !important;
  pointer-events: auto;
  transform: scale(1);
  transition: none;
}

.flow-wire-delete-circle {
  fill: #EF4444;
  stroke: #ffffff;
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35));
  transition: fill 0.15s ease, stroke-width 0.15s ease;
}

html.dark .flow-wire-delete-circle {
  stroke: #0f172a;
}

.flow-wire-delete-line,
.flow-wire-delete-x {
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;
}

.flow-wire-delete-btn:hover .flow-wire-delete-circle {
  fill: #DC2626;
  stroke-width: 2;
  filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.7));
}

.flow-wire-delete-btn:hover {
  transform: scale(1.22) !important;
}

.flow-wire-delete-btn:active {
  transform: scale(0.95) !important;
}

/* Card Header */
.flow-card-header {
  padding: 6px 8px 5px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-sizing: border-box;
}

.flow-node-card input,
.flow-node-card textarea,
.flow-inline-popover {
  touch-action: auto;
  user-select: auto;
  -webkit-user-select: auto;
}

.flow-card-header-left {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Type Pill */
.flow-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.03em;
  padding: 0 4px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: all 0.2s;
  flex-shrink: 0;
  white-space: nowrap;
}

.flow-type-pill:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
}

.flow-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flow-type-icon svg {
  display: block;
}

.flow-type-name {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

/* Milestone Date Wrap & Labels */
.flow-milestone-date-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  user-select: none;
}

.flow-milestone-date-label {
  display: inline-flex;
  align-items: center;
  height: 18px;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  border-radius: 4px;
  gap: 3.5px;
  padding: 0 4px;
}

.flow-milestone-date-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.85;
}

.flow-milestone-date-icon svg {
  display: block;
  width: 10px;
  height: 10px;
  transform: translateY(-0.5px);
}

.flow-milestone-date-text {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.flow-milestone-date-selected {
  color: var(--flow-milestone-date-color, #7C3AED);
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.flow-milestone-date-wrap:hover .flow-milestone-date-selected {
  color: var(--flow-milestone-date-hover-color, #5B21B6) !important;
  background: var(--flow-milestone-date-hover-bg, rgba(124, 58, 237, 0.12)) !important;
  border-color: var(--flow-milestone-date-hover-border, rgba(124, 58, 237, 0.28)) !important;
}

.flow-milestone-date-unset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--flow-text-muted, #64748b);
  opacity: 0.55;
  border: 1px solid transparent;
  padding: 0 4px;
  transition: all 0.15s;
}

.flow-milestone-date-unset .flow-milestone-date-icon {
  opacity: 1;
}

.flow-milestone-date-wrap:hover .flow-milestone-date-unset {
  opacity: 1 !important;
  color: var(--flow-text-primary, #f1f5f9) !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
}

/* Explicit Dark Theme overrides */
html.dark .flow-milestone-date-selected {
  color: #C4B5FD;
}

html.dark .flow-milestone-date-wrap:hover .flow-milestone-date-selected {
  color: #EDE9FE !important;
  background: rgba(139, 92, 246, 0.22) !important;
  border-color: rgba(139, 92, 246, 0.45) !important;
}

.flow-milestone-date-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: none;
  padding: 0;
  margin: 0;
}

/* Status Pill */
.flow-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
  padding: 1.5px 5px 0.5px 5px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.flow-status-pill:hover {
  filter: brightness(1.2);
}

/* Assignee Component */
.flow-assignee-wrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.flow-assignee-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: all 0.15s;
}

.flow-assignee-assigned {
  cursor: pointer;
  font-weight: 600;
  color: var(--flow-text-secondary, #94a3b8);
  padding: 0 4px;
  white-space: nowrap;
}

.flow-assignee-wrap:hover .flow-assignee-assigned {
  color: var(--flow-text-primary, #f1f5f9) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}

.flow-assignee-unassigned {
  color: var(--flow-text-muted, #64748b);
  opacity: 0.55;
  padding: 0 4px;
}

.flow-assignee-unassigned svg {
  display: block;
  width: 10px;
  height: 10px;
}

.flow-assignee-wrap:hover .flow-assignee-unassigned {
  opacity: 1 !important;
  color: var(--flow-text-primary, #f1f5f9) !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
}

/* Done Button (shown during inline title editing) — chromeless, icon-only */
.flow-node-done-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--color-mint);
  cursor: pointer;
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  padding: 0;
  margin-left: 4px;
  margin-right: 2px;
  border-radius: 4px;
  transition: color 0.18s ease, transform 0.18s ease;
  flex-shrink: 0;
}

.flow-node-done-btn:hover {
  color: #7fd4bd;
  transform: scale(1.12);
}

.flow-node-done-btn svg {
  display: block;
}

.flow-node-card.is-editing {
  border-color: rgba(88, 190, 162, 0.55) !important;
  box-shadow: 0 0 12px rgba(88, 190, 162, 0.16);
}

.flow-node-card.is-editing .flow-node-delete-btn {
  opacity: 0.75;
}

/* Delete Button */
.flow-node-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  background: transparent;
  border: none;
  color: var(--flow-text-muted, #64748b);
  cursor: pointer;
  font-size: 11.5px;
  line-height: 1;
  padding: 0;
  margin-left: 4px;
  opacity: 0.25;
  transition: opacity 0.2s, color 0.2s, transform 0.2s;
  border-radius: 4px;
  flex-shrink: 0;
}

.flow-node-card:hover .flow-node-delete-btn {
  opacity: 0.75;
}

.flow-node-delete-btn:hover {
  opacity: 1 !important;
  color: #EF4444 !important;
  transform: scale(1.15);
}

.flow-node-delete-btn svg {
  display: block;
}

/* Card Content & In-line Title */
.flow-card-body {
  padding: 8px 10px;
  cursor: default;
}

.flow-node-title {
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.flow-node-title:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12) !important;
}

.flow-title-first-line {
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--flow-text-primary, #f1f5f9);
  word-break: break-word;
}

.flow-title-rest {
  margin-top: 3px;
  font-weight: 400;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--flow-text-secondary, #94a3b8);
  word-break: break-word;
}

/* Checkbox Items in Node Content */
.flow-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
  user-select: text;
}

.flow-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.flow-node-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  min-width: 13px;
  margin: 0;
  border: 1.5px solid var(--flow-text-muted, #94a3b8);
  border-radius: 3px;
  background: var(--flow-input-bg, rgba(0, 0, 0, 0.15));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
  vertical-align: middle;
}

.flow-node-checkbox:hover {
  border-color: var(--color-mint);
  box-shadow: 0 0 5px rgba(88, 190, 162, 0.35);
}

.flow-node-checkbox:checked {
  background: var(--color-mint);
  border-color: var(--color-mint);
}

.flow-node-checkbox:checked::after {
  content: '';
  display: block;
  width: 3px;
  height: 6.5px;
  border: solid #0d121d;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg) translate(-0.5px, -1px);
}

.flow-node-checkbox:disabled {
  opacity: 0.45;
  cursor: default;
}

.flow-checkbox-item.is-checked .flow-checkbox-text {
  text-decoration: line-through;
  opacity: 0.65;
}

.flow-checkbox-text {
  flex: 1;
  word-break: break-word;
}

/* Special Divider "---" and Collapsed Content */
.flow-node-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 2px 0;
  user-select: none;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.flow-node-card:hover .flow-node-divider,
.flow-node-card.is-hovered .flow-node-divider {
  opacity: 0.95;
}

.flow-divider-line {
  flex: 1;
  height: 1px;
  background: var(--flow-border-color, rgba(255, 255, 255, 0.18));
}

.flow-divider-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--flow-text-muted, #94a3b8);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease;
}

.flow-node-card:hover .flow-divider-pill,
.flow-node-card.is-hovered .flow-divider-pill {
  transform: rotate(180deg);
  color: var(--flow-text-primary, #f1f5f9);
}

.flow-node-divider-simple {
  height: 1px;
  margin: 4px 0;
  background: var(--flow-border-color, rgba(255, 255, 255, 0.12));
}

/* Collapsible Section after "---" */
.flow-node-collapsible {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: max-height 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.2s ease,
              margin-top 0.2s ease;
  margin-top: 0;
}

.flow-node-card:hover .flow-node-collapsible,
.flow-node-card.is-hovered .flow-node-collapsible,
.flow-node-card.is-editing .flow-node-collapsible {
  max-height: 800px;
  opacity: 1;
  pointer-events: auto;
  margin-top: 4px;
}

.flow-title-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--flow-input-bg, rgba(0, 0, 0, 0.25));
  border: 1px solid var(--color-teal);
  border-radius: 4px;
  color: var(--flow-text-primary, #f1f5f9);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.4;
  padding: 4px 6px;
  outline: none;
  resize: vertical;
  min-height: 48px;
  box-shadow: 0 0 0 2px rgba(38, 149, 162, 0.25);
}

/* WYSIWYG Card Editor (ADR-047) — no bounding box, live-rendered, auto-grow */
.flow-node-title-input.wf-card-editor {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--flow-text-primary, #f1f5f9);
  font-family: inherit;
  padding: 2px 4px;
  outline: none;
  height: auto;
  min-height: 0;
  overflow: visible;
  cursor: text;
  caret-color: var(--color-mint);
  caret-shape: block;
}

.wf-editor-line {
  outline: none;
  word-break: break-word;
}

.wf-editor-line--title {
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1.35;
}

/* Vertical rhythm matches read mode's .flow-title-rest exactly: 4px after the
   title or a divider (mirrors its margin-top), 2px between ordinary lines
   (mirrors its flex `gap`) — dividers keep their own fixed margin regardless
   of what precedes them. */
.wf-editor-line--title + .wf-editor-line:not(.wf-editor-line--divider),
.wf-editor-line--divider + .wf-editor-line:not(.wf-editor-line--divider) {
  margin-top: 4px;
}

.wf-editor-line--text + .wf-editor-line:not(.wf-editor-line--divider),
.wf-editor-line--checkbox + .wf-editor-line:not(.wf-editor-line--divider) {
  margin-top: 2px;
}

.wf-editor-line--text {
  font-weight: 400;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--flow-text-secondary, #94a3b8);
  min-height: 1.45em;
}

/* Checkbox rows in the editor reuse the read-mode classes (flow-checkbox-item,
   flow-checkbox-wrap, flow-node-checkbox, flow-checkbox-text — see §"Checkbox
   Items in Node Content" above) so both modes render pixel-identically off one
   set of rules. Only genuinely edit-specific additions live here. */
.wf-editor-line--checkbox {
  font-size: 11.5px;
  color: var(--flow-text-secondary, #94a3b8);
}

.wf-editor-checkbox-box {
  cursor: pointer;
}

.wf-editor-checkbox-text {
  min-height: 1.4em;
  outline: none;
}

/* Margin matches .flow-node-divider (read mode) exactly so the divider row's
   height/spacing is identical between edit and view mode. */
.wf-editor-line--divider {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 2px 0;
  user-select: none;
}

.wf-editor-divider-rule {
  flex: 1;
  height: 1px;
  border: none;
  background: var(--flow-border-color, rgba(255, 255, 255, 0.18));
  margin: 0;
}

.wf-editor-divider-controls {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Icon-only — no border/background chrome, sized to match the read-mode
   chevron icon (9x9) so the divider's height doesn't change between modes. */
.wf-divider-btn {
  width: 9px;
  height: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--flow-text-muted, #94a3b8);
  cursor: pointer;
  transition: color 0.15s ease;
}

.wf-divider-btn:hover {
  color: var(--color-mint);
}

.wf-divider-btn svg {
  display: block;
}

.wf-editor-controls {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.wf-editor-add-item,
.wf-editor-add-divider {
  font-size: 10.5px;
  color: var(--flow-text-muted, #94a3b8);
  background: transparent;
  border: 1px dashed var(--flow-border-color, rgba(255, 255, 255, 0.2));
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
}

.wf-editor-add-item:hover,
.wf-editor-add-divider:hover {
  color: var(--color-mint);
  border-color: var(--color-mint);
}

/* Hide unconnected ports across the whole canvas while a card is being
   edited (ADR-047 follow-up) — connected ports stay as-is. */
workspace-flow-element.is-node-editing .flow-port.is-unconnected {
  opacity: 0 !important;
  pointer-events: none;
}

/* Bottom port hides completely (connected or not) whenever the collapsed
   divider content is expanded — on hover, and while editing — since the
   expanded content renders underneath/through it otherwise. It reappears
   automatically once hover ends or edit mode exits, at whatever position
   is then current (recomputed resting height post-edit). */
.flow-node-card:hover:has(.flow-node-collapsible) .flow-port-bottom,
.flow-node-card.is-hovered:has(.flow-node-collapsible) .flow-port-bottom,
.flow-node-card.is-editing .flow-port-bottom {
  opacity: 0 !important;
  pointer-events: none;
}

/* Floating selection toolbar */
.wf-editor-toolbar {
  position: fixed;
  z-index: 500;
  display: flex;
  gap: 2px;
  background: var(--flow-modal-bg, #0f172a);
  border: 1px solid var(--flow-modal-border, rgba(255, 255, 255, 0.16));
  border-radius: 6px;
  padding: 3px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.wf-editor-toolbar-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--flow-text-primary, #f1f5f9);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.wf-editor-toolbar-btn--italic {
  font-style: italic;
  font-weight: 400;
}

.wf-editor-toolbar-btn--underline {
  text-decoration: underline;
  font-weight: 400;
}

.wf-editor-toolbar-btn:hover {
  background: rgba(88, 190, 162, 0.18);
  color: var(--color-mint);
}

/* Smooth camera animation while entering/exiting card edit mode (ADR-047) */
.flow-canvas-layer.is-animating-view {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* In-line Popovers (Type, Status, Assignee menus) */
.flow-inline-popover {
  position: absolute;
  top: 30px;
  background: var(--flow-modal-bg, #0f172a);
  border: 1px solid var(--flow-modal-border, rgba(255, 255, 255, 0.16));
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.flow-type-popover {
  min-width: 155px;
}

.flow-status-popover {
  min-width: 145px;
}

.flow-assignee-popover {
  min-width: 160px;
  max-height: 200px;
  overflow-y: auto;
}

.flow-date-popover {
  min-width: 165px;
}

.flow-date-popover-input-row {
  padding: 3px 4px;
  box-sizing: border-box;
}

.flow-date-popover-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--flow-modal-border, rgba(255, 255, 255, 0.16));
  border-radius: 6px;
  padding: 4px 8px;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}

.flow-date-popover-input-wrap:focus-within {
  border-color: #8B5CF6;
  background: rgba(139, 92, 246, 0.1);
}

.flow-date-popover-input-wrap svg {
  color: var(--flow-text-muted, #94a3b8);
  flex-shrink: 0;
}

.flow-popover-date-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--flow-text-primary, #f1f5f9);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  width: 100%;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  color-scheme: dark;
}

html:not(.dark) .flow-popover-date-input {
  color-scheme: light;
}

.flow-popover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--flow-text-primary, #f1f5f9);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
  transition: background 0.15s;
}

.flow-popover-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.flow-popover-item.is-selected {
  background: rgba(255, 255, 255, 0.08);
}

.flow-popover-divider {
  height: 1px;
  background: var(--flow-border-color, rgba(255, 255, 255, 0.1));
  margin: 2px 0;
  flex-shrink: 0;
}

/**
 * Collapsible Right Sidebar: Workspace Context & Groq AI Summary
 */
.flow-right-sidebar {
  position: absolute;
  top: 52px;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  z-index: 15;
  background: var(--flow-header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--flow-border-color);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
  user-select: text;
  box-sizing: border-box;
}

html.dark .flow-right-sidebar {
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
}

.flow-right-sidebar.is-open {
  transform: translateX(0);
}

/* Offset canvas controls when sidebar is open on wider screens */
@media (min-width: 769px) {
  .flow-app-container.has-right-sidebar-open .flow-controls-bar {
    right: 396px;
  }
}

/* Sidebar Header */
.flow-sidebar-header {
  height: 48px;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--flow-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.flow-sidebar-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--flow-text-primary);
  letter-spacing: -0.2px;
}

.flow-sidebar-close-btn {
  padding: 4px 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--flow-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.flow-sidebar-close-btn:hover {
  background: var(--flow-nav-hover);
  color: var(--flow-text-primary);
}

/* Sidebar Scrollable Body */
.flow-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.flow-sidebar-body::-webkit-scrollbar {
  width: 5px;
}

.flow-sidebar-body::-webkit-scrollbar-thumb {
  background: var(--flow-border-color);
  border-radius: 3px;
}

.flow-sidebar-section {
  display: flex;
  flex-direction: column;
}

.flow-sidebar-section + .flow-sidebar-section {
  padding-top: 14px;
  border-top: 1px solid var(--flow-border-color);
}

.flow-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.flow-section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--flow-text-primary);
}

.flow-section-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(88, 190, 162, 0.12);
  color: var(--color-mint);
  border: 1px solid rgba(88, 190, 162, 0.25);
  transition: all 0.2s;
}

.flow-section-badge.is-dirty {
  background: rgba(245, 158, 11, 0.12);
  color: #F59E0B;
  border-color: rgba(245, 158, 11, 0.3);
}

.flow-section-badge.is-saving {
  background: rgba(38, 149, 162, 0.12);
  color: var(--color-teal);
  border-color: rgba(38, 149, 162, 0.3);
}

/* Segmented Write / Preview Tabs */
.flow-context-tabs {
  display: inline-flex;
  background: var(--flow-nav-bg);
  border: 1px solid var(--flow-nav-border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.flow-context-tab {
  border: none;
  background: transparent;
  padding: 4px 7px;
  border-radius: 4px;
  color: var(--flow-text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}

.flow-context-tab svg {
  display: block;
}

.flow-context-tab:hover {
  color: var(--flow-text-primary);
}

.flow-context-tab.is-active {
  background: var(--flow-card-bg);
  color: var(--color-teal);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Context Editor & Toolbar */
.flow-context-editor-wrap {
  border: 1px solid var(--flow-input-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--flow-input-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.flow-context-editor-wrap:focus-within {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(38, 149, 162, 0.15);
}

.flow-context-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--flow-border-color);
  background: var(--flow-nav-bg);
}

.flow-md-tool-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  color: var(--flow-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.flow-md-tool-btn:hover {
  background: var(--flow-nav-hover);
  color: var(--flow-text-primary);
}

.flow-context-textarea {
  width: 100%;
  box-sizing: border-box;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--flow-text-primary);
  resize: vertical;
  min-height: 140px;
  outline: none;
}

.flow-context-textarea::placeholder {
  color: var(--flow-text-muted);
  opacity: 0.7;
}

/* Markdown Preview Panel - Seamless Inline View */
.flow-context-preview-wrap {
  min-height: auto;
  max-height: 380px;
  overflow-y: auto;
  border: none;
  border-radius: 0;
  padding: 2px 0 0 0;
  background: transparent;
  box-sizing: border-box;
}

.flow-context-preview-wrap::-webkit-scrollbar {
  width: 4px;
}

.flow-context-preview-wrap::-webkit-scrollbar-thumb {
  background: var(--flow-border-color);
  border-radius: 2px;
}

.flow-context-preview-content {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--flow-text-primary);
}

.flow-context-preview-content h1,
.flow-context-preview-content h2,
.flow-context-preview-content h3 {
  margin: 8px 0 4px 0;
  font-weight: 700;
  color: var(--flow-text-primary);
  line-height: 1.3;
}

.flow-context-preview-content h1 { font-size: 15px; }
.flow-context-preview-content h2 { font-size: 13.5px; }
.flow-context-preview-content h3 { font-size: 12.5px; }

.flow-context-preview-content p {
  margin: 0 0 6px 0;
}

.flow-context-preview-content ul {
  list-style: disc !important;
  list-style-type: disc !important;
  list-style-position: outside !important;
  padding-left: 20px !important;
  margin: 6px 0 8px 0 !important;
}

.flow-context-preview-content ol {
  list-style: decimal !important;
  list-style-type: decimal !important;
  list-style-position: outside !important;
  padding-left: 20px !important;
  margin: 6px 0 8px 0 !important;
}

.flow-context-preview-content li {
  display: list-item !important;
  list-style-type: inherit !important;
  margin-bottom: 3px;
  line-height: 1.5;
  color: var(--flow-text-primary);
}

.flow-context-preview-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--flow-nav-bg);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--flow-border-color);
}

.flow-context-preview-content pre {
  margin: 6px 0;
  padding: 8px;
  background: var(--flow-nav-bg);
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid var(--flow-border-color);
}

.flow-context-preview-content pre code {
  background: transparent;
  padding: 0;
  border: none;
}

.flow-context-preview-content strong {
  font-weight: 700;
  color: var(--flow-text-primary);
}

.flow-context-preview-content a {
  color: var(--color-teal);
  text-decoration: underline;
}

.flow-context-empty-hint {
  font-style: italic;
  color: var(--flow-text-muted);
  font-size: 12px;
  margin: 0;
}

/* Summary Section */
.flow-summary-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  background: linear-gradient(135deg, var(--color-teal) 0%, #1d7b87 100%);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 6px rgba(38, 149, 162, 0.25);
}

.flow-summary-action-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(38, 149, 162, 0.35);
}

.flow-summary-action-btn:active:not(:disabled) {
  transform: translateY(0);
}

.flow-summary-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.flow-summary-placeholder {
  padding: 8px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--flow-text-muted);
  background: transparent;
  border: none;
}

/* Loading Shimmer State */
.flow-summary-loading {
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: none;
}

.flow-summary-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--flow-border-color);
  border-top-color: var(--color-teal);
  border-radius: 50%;
  animation: flowSpin 0.75s linear infinite;
  margin: 4px auto;
}

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

.flow-summary-loading-text {
  margin: 0;
  font-size: 11.5px;
  color: var(--flow-text-secondary);
  text-align: center;
  font-weight: 500;
}

/* Summary Result & Markdown - Integrated with Sidebar (No container box) */
.flow-summary-result {
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 2px 0 0 0;
  gap: 8px;
}

.flow-summary-markdown {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--flow-text-primary);
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.flow-summary-markdown::-webkit-scrollbar {
  width: 4px;
}

.flow-summary-markdown::-webkit-scrollbar-thumb {
  background: var(--flow-border-color);
  border-radius: 2px;
}

.flow-summary-markdown h1,
.flow-summary-markdown h2,
.flow-summary-markdown h3 {
  margin: 6px 0 3px 0;
  font-weight: 700;
  color: var(--flow-text-primary);
  font-size: 12.5px;
}

.flow-summary-markdown p {
  margin: 0 0 6px 0;
}

.flow-summary-markdown ul {
  list-style: disc !important;
  list-style-type: disc !important;
  list-style-position: outside !important;
  padding-left: 20px !important;
  margin: 4px 0 6px 0 !important;
}

.flow-summary-markdown ol {
  list-style: decimal !important;
  list-style-type: decimal !important;
  list-style-position: outside !important;
  padding-left: 20px !important;
  margin: 4px 0 6px 0 !important;
}

.flow-summary-markdown li {
  display: list-item !important;
  list-style-type: inherit !important;
  margin-bottom: 2px;
  line-height: 1.5;
}

.flow-summary-markdown strong {
  color: var(--flow-text-primary);
  font-weight: 700;
}

.flow-summary-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--flow-border-color);
  margin-top: 2px;
}

.flow-summary-time {
  font-size: 10.5px;
  color: var(--flow-text-muted);
}

.flow-summary-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--flow-nav-bg);
  border: 1px solid var(--flow-border-color);
  font-size: 11px;
  font-weight: 600;
  color: var(--flow-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.flow-summary-copy-btn:hover {
  background: var(--flow-nav-hover);
  color: var(--flow-text-primary);
}

/* ============================================================
   Workspace Calendar (<workspace-calendar-element>) — ADR-049 Phase 2
   ============================================================ */

workspace-calendar-element {
  display: block;
  width: 100%;
  height: 100%;
}

.wc-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--flow-text-primary);
  font-family: inherit;
}

.wc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  flex-shrink: 0;
}

.wc-month-label {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  text-align: center;
}

.wc-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--flow-nav-border);
  background: var(--flow-nav-bg);
  color: var(--flow-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.wc-nav-btn:hover {
  background: var(--flow-nav-hover);
  color: var(--flow-text-primary);
}

.wc-today-btn {
  width: auto;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
}

.wc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 4px 10px 4px;
  flex-shrink: 0;
}

.wc-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--flow-border-color);
  background: var(--flow-nav-bg);
  color: var(--flow-text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

/* Not named "is-hidden": Bulma (loaded on these pages) defines a global
   .is-hidden { display: none !important; } helper that would otherwise
   collide with and fully hide this button instead of just dimming it. */
.wc-legend-item.wc-inactive {
  opacity: 0.4;
}

.wc-legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.wc-error {
  padding: 24px;
  text-align: center;
  color: var(--flow-text-muted);
  font-size: 13px;
}

.wc-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex-shrink: 0;
}

.wc-weekday {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--flow-text-muted);
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wc-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(96px, 1fr);
  gap: 1px;
  background: var(--flow-border-color);
  border: 1px solid var(--flow-border-color);
  border-radius: 8px;
  overflow: hidden;
}

/* Full-page calendar: bleed the grid edge-to-edge across the viewport
   instead of the popup's inset card look. */
workspace-calendar-element[mode="page"] .wc-header,
workspace-calendar-element[mode="page"] .wc-legend {
  padding-left: 16px;
  padding-right: 16px;
}

workspace-calendar-element[mode="page"] .wc-grid {
  border-left: none;
  border-right: none;
  border-radius: 0;
}

.wc-day-cell {
  background: var(--flow-card-bg);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  transition: background 0.12s;
}

.wc-day-cell.is-weekend {
  background: var(--flow-cal-weekend-bg, #f4f5f7);
}

.wc-day-cell.is-muted .wc-day-number {
  color: var(--flow-text-muted);
  opacity: 0.5;
}

.wc-day-cell.is-today .wc-day-number {
  color: #ffffff;
  background: var(--color-teal);
  border-radius: 999px;
}

.wc-day-cell.is-drop-target {
  background: rgba(38, 149, 162, 0.14);
}

.wc-day-number {
  font-size: 11px;
  font-weight: 600;
  color: var(--flow-text-secondary);
  min-width: 18px;
  height: 18px;
  padding: 0 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  white-space: nowrap;
}

.wc-day-events {
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* Room for the first pill's folder tab (~16px tall) to poke up into
     without being clipped by this container's own top edge (see
     .wc-pill-tab) -- must stay >= the tab's rendered height. */
  padding-top: 16px;
  overflow: hidden;
}

.wc-pill {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 4px 5px 4px 5px;
  /* Top-left stays square so the folder tab (flush against this same left
     edge) reads as a continuous shape with the pill below it. */
  border-radius: 0 4px 4px 4px;
  background: var(--flow-nav-bg);
  cursor: grab;
  min-width: 0;
}

.wc-pill:active {
  cursor: grabbing;
}

.wc-pill.wc-pill-dragging {
  background: transparent;
  box-shadow: none;
}

.wc-pill.wc-pill-dragging .wc-pill-tab {
  background: transparent;
  box-shadow: none;
}

/* Faint tint matching the milestone accent color, so milestone pills read
   as a distinct "type" of item on the grid, not just via the icon. */
.wc-pill-milestone {
  background: color-mix(in srgb, var(--pill-accent) 6%, var(--flow-nav-bg));
}

.wc-pill-milestone .wc-pill-tab {
  background: color-mix(in srgb, var(--pill-accent) 6%, var(--flow-nav-bg));
}

.wc-pill-milestone.wc-pill-dragging,
.wc-pill-milestone.wc-pill-dragging .wc-pill-tab {
  background: transparent;
}

.wc-pill-title {
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--flow-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.wc-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  margin-right: 3px;
  vertical-align: -1.5px;
  flex-shrink: 0;
}

.wc-pill-icon svg {
  width: 100%;
  height: 100%;
}

/* Project name label extrudes above the pill's own top border like a
   folder tab, instead of sitting inside it as a first line of text. */
.wc-pill-tab {
  position: absolute;
  bottom: 100%;
  left: 0;
  max-width: 100%;
  padding: 1.5px 6px;
  border-radius: 4px 4px 0 0;
  background: var(--flow-nav-bg);
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.08);
}

/* Popup host modal */
.wc-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.wc-popup-backdrop.is-active {
  display: flex;
}

.wc-popup-panel {
  width: 85vw;
  height: 92vh;
  max-height: 92vh;
  background: var(--flow-modal-bg);
  border: 1px solid var(--flow-modal-border);
  border-radius: 12px;
  box-shadow: var(--flow-modal-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 16px 16px 16px;
}

/* Day cells get noticeably more room in the popup than the dedicated page --
   the popup has a fixed, generous viewport-driven height to fill, while the
   page's grid just grows with its scrollable <main>. Min row height is kept
   modest enough that a 6-row month (up to 42 cells) still fits without the
   grid overflowing .wc-body and forcing a scrollbar. */
.wc-popup-panel .wc-grid {
  grid-auto-rows: minmax(88px, 1fr);
}

@media (max-width: 640px) {
  .wc-popup-backdrop {
    padding: 0;
  }

  .wc-popup-panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
}

.wc-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  flex-shrink: 0;
}

.wc-popup-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--flow-text-primary);
}

.wc-popup-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--flow-text-muted);
  cursor: pointer;
  font-size: 16px;
}

.wc-popup-close-btn:hover {
  color: var(--flow-text-primary);
  background: var(--flow-nav-hover);
}

