/* ═══════════════════════════════════════════════════════════════
   CLOTO LAYOUT — Header, Columns, Panel, Drawer, Modal
   ═══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   KANBAN HEADER
   ══════════════════════════════════════════════════════════════ */

/* Save dot */
.fbw-save-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  transition: background var(--duration-slow) var(--ease-default), box-shadow var(--duration-slow) var(--ease-default);
}
.fbw-save-dot.is-saving {
  background: var(--cloto-gold);
  box-shadow: var(--shadow-glow-gold);
  animation: cloto-save-pulse 0.8s ease-in-out infinite;
}
@keyframes cloto-save-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Save Status (legacy text — kept for settings/template panels) ── */
.fbw-save-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-text-25);
  transition: color var(--duration-slow) var(--ease-default);
  min-width: 16px;
}
.fbw-save-status.is-ok { color: var(--cloto-success); }

/* Save dot flash (global status) */
.fbw-save-dot.is-flash {
  background: var(--cloto-success);
  box-shadow: 0 0 6px var(--cloto-success-a50);
  animation: cloto-dot-flash 1.5s var(--ease-default) forwards;
}
@keyframes cloto-dot-flash {
  0% { background: var(--cloto-success);
  box-shadow: 0 0 6px var(--cloto-success-a50); }
  70% { background: var(--cloto-success);
  box-shadow: 0 0 4px rgba(74, 222, 128, 0.3); }
  100% { background: transparent;
  box-shadow: none; }
}

/* ── App Menu Dropdown (hamburger ≡) ── */
.fbw-app-menu-dropdown {
  position: fixed;
  z-index: var(--cloto-z-dropdown);
  min-width: 220px;
  background: var(--cloto-surface);
  border: 1px solid var(--cloto-glass-border-hover);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-lg);
}

.fbw-menu-section-label {
  padding: var(--space-4) var(--space-6) var(--space-2);
  font-size: var(--cloto-fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cloto-text-25);
}

.fbw-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  width: 100%;
  padding: var(--space-4) var(--space-6);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-text-70);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
  text-align: left;
}

.fbw-menu-item:hover {
  background: var(--cloto-teal-a6);
  color: var(--cloto-text-100);
}

.fbw-menu-item-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 14px;
}

.fbw-menu-danger {
  color: var(--cloto-danger);
}
.fbw-menu-danger:hover {
  background: var(--cloto-danger-a8);
  color: var(--cloto-danger);
}

.fbw-menu-sep {
  height: 1px;
  background: var(--cloto-glass-border);
  margin: var(--space-2) var(--space-4);
}

/* ── Menu toggle switch ── */
.fbw-menu-toggle {
  justify-content: flex-start;
}

.fbw-menu-toggle-label {
  flex: 1;
  min-width: 0;
}

.fbw-toggle-track {
  position: relative;
  width: 34px;
  height: 18px;
  background: var(--cloto-white-a8);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: background var(--duration-normal) var(--ease-default), border-color var(--duration-normal) var(--ease-default);
}

.fbw-toggle-track.is-on {
  background: var(--cloto-gold-a25);
  border-color: var(--cloto-gold-a35);
}

.fbw-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--cloto-text-40);
  border-radius: 50%;
  transition: transform var(--duration-normal) var(--ease-default), background var(--duration-normal) var(--ease-default);
}

.fbw-toggle-track.is-on .fbw-toggle-thumb {
  transform: translateX(16px);
  background: var(--cloto-gold);
}

body.fd-light .fbw-toggle-track {
  background: var(--cloto-black-a6);
  border-color: var(--cloto-black-a10);
}

body.fd-light .fbw-toggle-track.is-on {
  background: var(--cloto-gold-a20);
  border-color: var(--cloto-gold-a30);
}

body.fd-light .fbw-toggle-thumb {
  background: #999;
}

body.fd-light .fbw-toggle-track.is-on .fbw-toggle-thumb {
  background: var(--cloto-gold);
}

/* ── Language Toggle ── */
.fbw-lang-toggle,
.fbw-menu-lang {
  display: flex;
  gap: 4px;
}
.fbw-lang-toggle { margin-right: 4px; }
.fbw-menu-lang { padding: 6px 12px 8px; }
.fbw-lang-btn {
  background: var(--cloto-surface-a55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--cloto-teal-a8);
  color: var(--cloto-text-40);
  font: 500 var(--font-xs)/1 var(--cloto-font-ui);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
}
.fbw-lang-btn:hover {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a12);
  border-color: var(--cloto-teal-a20);
}
.fbw-lang-btn.active {
  background: var(--cloto-teal-a15);
  color: var(--cloto-teal);
  border-color: var(--cloto-teal-a30);
}
body.fd-light .fbw-lang-btn {
  background: var(--cloto-white-a55);
  border-color: var(--cloto-teal-a10);
  color: #6a6a76;
}
body.fd-light .fbw-lang-btn:hover {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a8);
  border-color: var(--cloto-teal-a25);
}
body.fd-light .fbw-lang-btn.active {
  background: var(--cloto-teal-a15);
  color: var(--cloto-teal);
  border-color: var(--cloto-teal-a30);
}

/* ── History Menu ── */
.fbw-history-menu {
  position: fixed;
  z-index: var(--cloto-z-dropdown);
  background: var(--cloto-surface);
  border: 1px solid var(--cloto-glass-border-hover);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  max-height: 300px;
  overflow-y: auto;
}

/* ── Theme Toggle ── */
.fd-theme-toggle {
  position: relative;
  cursor: pointer;
}

/* Dark mode (default): show sun icon, hide moon */
.fd-theme-toggle .fd-theme-icon--light { display: block; }
.fd-theme-toggle .fd-theme-icon--dark  { display: none; }

/* Light mode: show moon icon, hide sun */
body.fd-light .fd-theme-toggle .fd-theme-icon--light { display: none; }
body.fd-light .fd-theme-toggle .fd-theme-icon--dark  { display: block; }

/* ══════════════════════════════════════════════════════════════
   COLUMNS — Outline Board
   ══════════════════════════════════════════════════════════════ */

.fbw-columns {
  position: relative;
  display: flex;
  gap: var(--space-16);
  padding: var(--space-6);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
  align-items: flex-start;
}

/* ── Golden threads (SVG overlay) ── */
.fbw-threads-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}
.fbw-thread-path {
  fill: none;
  stroke: var(--cloto-gold);
  stroke-width: 1.5;
  opacity: 0.3;
}
.fbw-thread-ancestor {
  stroke: var(--cloto-text-40);
  stroke-width: 1;
  opacity: 0.6;
  stroke-dasharray: 6 4;
}

/* ── Card staggered entrance ── */
.fbw-card-enter {
  opacity: 0;
  transform: translateY(6px);
  animation: fbw-card-appear var(--duration-slow) var(--ease-spring) forwards;
}
@keyframes fbw-card-appear {
  to { opacity: 1;
  transform: translateY(0); }
}

.fbw-col {
  flex: 0 0 var(--cloto-col-width);
  width: var(--cloto-col-width);
  display: flex;
  flex-direction: column;
  background: var(--cloto-glass-bg);
  backdrop-filter: var(--cloto-glass-blur);
  -webkit-backdrop-filter: var(--cloto-glass-blur);
  border: 1px solid var(--cloto-glass-border);
  border-radius: var(--radius-xl);
  transition: border-color var(--duration-normal) var(--ease-spring);
}

.fbw-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-7);
  min-height: 42px;
  border-bottom: 1px solid var(--cloto-glass-border);
  flex-shrink: 0;
}

.fbw-col-title {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--cloto-fs-sm);
  font-weight: 600;
  color: var(--cloto-text-70);
  letter-spacing: 0.05em;
}

.fbw-col-level-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

/* Level accent colors on column headers */
.fbw-col[data-level="volume"] .fbw-col-header,
.fbw-col[data-level="saga"] .fbw-col-header,
.fbw-col[data-level="romanzo"] .fbw-col-header {
  border-bottom-color: var(--cloto-teal-a20);
}
.fbw-col[data-level="volume"] .fbw-col-title,
.fbw-col[data-level="saga"] .fbw-col-title,
.fbw-col[data-level="romanzo"] .fbw-col-title {
  color: var(--cloto-level-volume);
}

.fbw-col[data-level="atto"] .fbw-col-header {
  border-bottom-color: var(--cloto-gold-a20);
}
.fbw-col[data-level="atto"] .fbw-col-title {
  color: var(--cloto-level-atto);
}

.fbw-col[data-level="capitolo"] .fbw-col-header {
  border-bottom-color: var(--cloto-success-a20);
}
.fbw-col[data-level="capitolo"] .fbw-col-title {
  color: var(--cloto-level-capitolo);
}

.fbw-col[data-level="scena"] .fbw-col-header {
  border-bottom-color: var(--cloto-warning-a20);
}
.fbw-col[data-level="scena"] .fbw-col-title {
  color: var(--cloto-level-scena);
}

/* ── Column AI ── */
.fbw-col-ai-wrapper {
  position: relative;
}

.fbw-col-ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--cloto-gold-a15);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--cloto-gold);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
}

.fbw-col-ai-btn:hover {
  background: var(--cloto-gold-a10);
  border-color: var(--cloto-gold-a30);
}

.fbw-col-ai-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: var(--cloto-z-dropdown);
  min-width: 180px;
  background: var(--cloto-surface);
  border: 1px solid var(--cloto-glass-border-hover);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-lg);
}
.fbw-col-ai-wrapper.is-open .fbw-col-ai-dropdown {
  display: block;
}

.fbw-col-ai-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-4) var(--space-5);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-text-70);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-spring);
  text-align: left;
}

.fbw-col-ai-dropdown-item:hover {
  background: var(--cloto-gold-a8);
  color: var(--cloto-gold);
}

.fbw-col-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Column Cards Container ── */
.fbw-col-cards {
  padding: 0.6em;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

/* ══════════════════════════════════════════════════════════════
   OUTLINE CONTAINER + DETAIL PANEL
   ══════════════════════════════════════════════════════════════ */

.fbw-outline-container {
  display: flex;
  position: relative;
  min-height: 0;
  overflow: clip;
  flex: 1 1 auto;
}

.fbw-outline-container .fbw-columns {
  flex: 1 1 auto;
  min-width: 0;
}

/* ── Detail Panel — Glassmorphism Drawer ── */
.fbw-detail-panel {
  flex: 0 0 var(--cloto-panel-width);
  width: var(--cloto-panel-width);
  max-width: 45vw;
  background: rgba(22, 24, 36, 0.72);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  border-left: 2px solid var(--cloto-teal-a18);
  box-shadow:
    -4px 0 24px rgba(0, 0, 0, 0.25),
    inset 2px 0 8px var(--cloto-teal-a4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--duration-fast) var(--ease-default);
}

.fbw-detail-panel:not(.has-card) {
  background: rgba(16, 18, 28, 0.5);
  border-left-color: var(--cloto-teal-a6);
  box-shadow: none;
}

body.fd-light .fbw-detail-panel {
  background: rgba(255, 255, 255, 0.78);
  border-left: 2px solid var(--cloto-teal-a15);
  box-shadow:
    -6px 0 28px var(--cloto-black-a8),
    inset 2px 0 8px var(--cloto-teal-a3);
}

body.fd-light .fbw-detail-panel:not(.has-card) {
  background: rgba(245, 243, 238, 0.5);
  border-left-color: var(--cloto-surface-a6);
  box-shadow: none;
}

/* Info bubble (collapsed panel) */
.fbw-panel-info-bubble {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--cloto-glass-border);
  border-radius: 50%;
  background: var(--cloto-glass-bg);
  backdrop-filter: var(--cloto-glass-blur);
  -webkit-backdrop-filter: var(--cloto-glass-blur);
  color: var(--cloto-text-40);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--duration-normal) var(--ease-default);
}

.fbw-panel-info-bubble:hover {
  color: var(--cloto-text-70);
  border-color: var(--cloto-glass-border-hover);
  transform: scale(1.05);
}

.fbw-panel-collapsed .fbw-detail-panel { display: none; }
.fbw-panel-collapsed .fbw-panel-info-bubble { display: flex; }

/* ── Panel Close Button ── */
.fbw-dp-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--cloto-text-40);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default), color var(--duration-fast) var(--ease-default);
}

.fbw-dp-close:hover {
  background: var(--cloto-teal-a6);
  color: var(--cloto-text-70);
}

/* ── Panel Inner ── */
.fbw-dp-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.fbw-dp-inner.is-promoted {
  border-left: 3px solid var(--cloto-gold);
  background: var(--cloto-gold-a4);
}

/* ── Panel Empty State ── */
.fbw-dp-empty {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--space-16);
  text-align: center;
  color: var(--cloto-text-40);
}

.fbw-dp-empty .fbw-dp-close {
  position: absolute;
  top: 8px;
  right: 8px;
}

.fbw-dp-empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-8);
  opacity: 0.3;
}

.fbw-dp-empty-text {
  font-size: var(--cloto-fs-md);
  line-height: 1.5;
}

/* ── Panel Header ── */
.fbw-dp-header {
  flex: 0 0 auto;
  padding: var(--space-7) var(--space-8);
  border-bottom: 1px solid var(--cloto-glass-border);
}

.fbw-dp-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
}

.fbw-dp-title {
  margin: 0;
  font-size: var(--cloto-fs-xl);
  font-weight: 600;
  line-height: 1.3;
  color: var(--cloto-text-100);
  word-break: break-word;
}

.fbw-dp-header-actions {
  display: flex;
  gap: var(--space-3);
  flex-shrink: 0;
}

.fbw-dp-meta {
  margin-top: var(--space-3);
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-text-40);
}

.fbw-dp-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.fbw-dp-badges:empty { display: none; }

/* ── Panel Content ── */
.fbw-dp-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-8);
  min-height: 0;
}

.fbw-dp-summary {
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--cloto-text-100);
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: 0.01em;
}

body.fd-light .fbw-dp-summary {
  color: #2a2c38;
}

.fbw-dp-summary-para + .fbw-dp-summary-para { margin-top: var(--space-6); }

.fbw-dp-summary-empty {
  color: var(--cloto-text-25);
  font-style: italic;
}

/* ── Panel Chips ── */
.fbw-dp-chips {
  flex: 0 0 auto;
  padding: var(--space-5) var(--space-8);
  border-top: 1px solid var(--cloto-teal-a10);
  background: rgba(13, 15, 23, 0.35);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.fbw-dp-chips:empty { display: none; }

/* ── Panel Actions ── */
.fbw-dp-actions {
  flex: 0 0 auto;
  padding: var(--space-6) var(--space-8);
  border-top: 1px solid var(--cloto-teal-a10);
  background: var(--cloto-void-a40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.fbw-dp-actions:empty { display: none; }

.fbw-dp-actions .button {
  flex: 1 1 auto;
  min-width: 80px;
  justify-content: center;
}

/* Light — panel footer */
body.fd-light .fbw-dp-chips {
  background: rgba(236, 232, 223, 0.5);
  border-top-color: var(--cloto-surface-a8);
}

body.fd-light .fbw-dp-actions {
  background: rgba(236, 232, 223, 0.55);
  border-top-color: var(--cloto-surface-a8);
}

body.fd-light .fbw-dp-actions .button {
  color: #3a3c48;
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--cloto-surface-a10);
}

body.fd-light .fbw-dp-actions .button:hover {
  color: var(--cloto-text-100);
  background: var(--cloto-white-a85);
  border-color: var(--cloto-teal-a25);
}

body.fd-light .fbw-dp-actions .fbw-btn-primary,
body.fd-light .fbw-dp-actions .button-primary {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a8);
  border-color: var(--cloto-teal-a30);
}

body.fd-light .fbw-dp-actions .fbw-btn-primary:hover,
body.fd-light .fbw-dp-actions .button-primary:hover {
  color: #14706e;
  background: rgba(94, 198, 198, 0.14);
  border-color: var(--cloto-teal-a40);
}

/* ── Panel Edit Mode ── */
.fbw-dp-edit {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}

.fbw-dp-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.fbw-dp-field-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.fbw-dp-field-half {
  flex: 1 1 auto;
  min-width: 0;
}

.fbw-dp-place-override {
  width: 100%;
  padding: var(--space-3) var(--space-5);
  margin-top: var(--space-3);
  font-size: var(--cloto-fs-base);
  border: 1px solid var(--cloto-teal-a12);
  border-radius: var(--radius-sm);
  background: var(--cloto-void-a60);
  color: var(--cloto-text-100);
  transition: border-color var(--duration-fast) var(--ease-default), box-shadow var(--duration-fast) var(--ease-default);
}

.fbw-dp-place-override:focus {
  border-color: var(--cloto-teal-a35);
  box-shadow: var(--shadow-focus-teal);
}

.fbw-dp-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--cloto-glass-border);
}

/* Scene meta in detail panel */
.fbw-dp-scene-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.fbw-dp-luogo-select,
.fbw-dp-characters-list {
  margin-top: var(--space-2);
}

.fbw-dp-char-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-text-70);
}

/* ══════════════════════════════════════════════════════════════
   DRAWER
   ══════════════════════════════════════════════════════════════ */

.fbw-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: -480px;
  width: 460px;
  max-width: 90vw;
  z-index: var(--cloto-z-drawer);
  display: flex;
  flex-direction: column;
  background: var(--cloto-surface);
  border-left: 1px solid var(--cloto-glass-border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
  transition: right var(--duration-slow) var(--ease-spring);
}

.fbw-drawer.is-open {
  right: 0;
}

.fbw-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-7) var(--space-10);
  border-bottom: 1px solid var(--cloto-glass-border);
  flex-shrink: 0;
}

.fbw-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-7) var(--space-10);
  border-bottom: 1px solid var(--cloto-glass-border);
  flex-shrink: 0;
}

.fbw-drawer-title {
  font-size: var(--cloto-fs-lg);
  font-weight: 600;
  color: var(--cloto-text-100);
}

.fbw-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--cloto-text-40);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
}

.fbw-drawer-close:hover {
  color: var(--cloto-text-70);
  background: var(--cloto-teal-a6);
}

.fbw-drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-10);
}

.fbw-drawer-actions {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-10);
  border-top: 1px solid var(--cloto-glass-border);
  flex-shrink: 0;
}

.fbw-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--cloto-z-drawer) - 1);
  background: var(--cloto-black-a50);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-spring);
}

.fbw-drawer-backdrop.is-open,
.fbw-drawer-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}


/* ══════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════ */

.fbw-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--cloto-z-modal);
  background: var(--cloto-black-a60);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  opacity: 0;
  transition: opacity 200ms ease;
}

.fbw-modal-backdrop.is-visible {
  opacity: 1;
}

.fbw-modal-dialog {
  background: var(--cloto-surface);
  border: 1px solid var(--cloto-glass-border-hover);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 200ms ease;
}

.fbw-modal-backdrop.is-visible .fbw-modal-dialog {
  transform: scale(1);
}

.fbw-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-8) var(--space-10);
  border-bottom: 1px solid var(--cloto-glass-border);
  flex-shrink: 0;
}

.fbw-modal-title {
  font-size: var(--cloto-fs-lg);
  font-weight: 600;
  color: var(--cloto-text-100);
}

.fbw-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-10);
  color: var(--cloto-text-70);
}

.fbw-modal-body p {
  margin: 0 0 var(--space-4);
  line-height: 1.5;
}

.fbw-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-10);
  border-top: 1px solid var(--cloto-glass-border);
  flex-shrink: 0;
}

.fbw-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-8);
  font-size: var(--cloto-fs-sm);
  font-weight: 500;
  border: 1px solid var(--cloto-glass-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--cloto-text-70);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
}

.fbw-modal-btn:hover {
  border-color: var(--cloto-glass-border-hover);
  background: var(--cloto-teal-a4);
}

.fbw-modal-btn-secondary {
  color: var(--cloto-text-40);
}

.fbw-modal-btn-primary {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a8);
  border-color: var(--cloto-teal-a25);
}
.fbw-modal-btn-primary:hover {
  background: var(--cloto-teal-a15);
  border-color: var(--cloto-teal-a40);
}

.fbw-modal-btn-danger {
  color: var(--cloto-danger);
  border-color: var(--cloto-danger-a25);
}
.fbw-modal-btn-danger:hover {
  background: var(--cloto-danger-a8);
}

.fbw-modal-input {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  background: var(--cloto-void-a60);
  border: 1px solid var(--cloto-teal-a12);
  border-radius: var(--radius-md);
  color: var(--cloto-text-100);
  font-size: var(--cloto-fs-md);
}

.fbw-modal-input:focus {
  border-color: var(--cloto-teal-a35);
  box-shadow: var(--shadow-focus-teal);
  outline: none;
}

/* ══════════════════════════════════════════════════════════════
   LOADING OVERLAY
   ══════════════════════════════════════════════════════════════ */

.fbw-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--cloto-z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 15, 23, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-default);
}

.fbw-loading-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.fbw-loading-overlay__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  text-align: center;
}

.fbw-loading-overlay__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--cloto-teal-a15);
  border-top-color: var(--cloto-teal);
  border-radius: 50%;
  animation: cloto-spin 0.8s linear infinite;
}

.fbw-loading-overlay__message {
  font-size: var(--cloto-fs-md);
  color: var(--cloto-text-70);
}

/* ── Spinner ── */
.fbw-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--cloto-teal-a15);
  border-top-color: var(--cloto-teal);
  border-radius: 50%;
  animation: cloto-spin 0.8s linear infinite;
}

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

/* ── Panel (generic) ── */
.fbw-panel {
  background: var(--cloto-glass-bg);
  border: 1px solid var(--cloto-glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.fbw-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid var(--cloto-glass-border);
}

.fbw-panel-body {
  padding: var(--space-8);
}

/* ══════════════════════════════════════════════════════════════
   LIGHT THEME — Layout Overrides
   ══════════════════════════════════════════════════════════════ */

/* (header removed — floating anchors styled inline) */

body.fd-light .fbw-mode-tab {
  color: #6a6a76;
}
body.fd-light .fbw-mode-tab:hover {
  color: #3a3c48;
  background: var(--cloto-teal-a6);
}
body.fd-light .fbw-mode-tab.is-active {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a8);
  border-color: var(--cloto-teal-a18);
}
body.fd-light .fbw-mode-tab[data-mode="cloto"] {
  color: var(--cloto-gold);
  border-color: var(--cloto-gold-a18);
}
body.fd-light .fbw-mode-tab[data-mode="cloto"]:hover {
  color: var(--cloto-gold);
  background: var(--cloto-gold-a8);
  border-color: rgba(201, 168, 76, 0.28);
}
body.fd-light .fbw-mode-tab[data-mode="cloto"].is-active {
  color: var(--cloto-gold);
  background: var(--cloto-gold-a10);
  border-color: var(--cloto-gold-a30);
}

body.fd-light .fbw-app-menu-dropdown {
  background: #ffffff;
  border-color: var(--cloto-surface-a8);
}
body.fd-light .fbw-menu-item {
  color: #2a2c38;
}
body.fd-light .fbw-menu-item:hover {
  background: var(--cloto-teal-a6);
}
body.fd-light .fbw-menu-section-label {
  color: #8a8a96;
}

body.fd-light .fbw-col {
  background: var(--cloto-white-a55);
  border-color: var(--cloto-teal-a10);
}

body.fd-light .fbw-col-header {
  border-bottom-color: var(--cloto-surface-a8);
}

body.fd-light .fbw-col-title {
  color: #4a4a56;
}

body.fd-light .fbw-dp-header {
  border-bottom-color: var(--cloto-surface-a8);
}

body.fd-light .fbw-dp-title {
  color: var(--cloto-text-100);
}

body.fd-light .fbw-dp-meta {
  color: #6a6a76;
}

body.fd-light .fbw-drawer {
  background: var(--cloto-white-a80);
  border-color: var(--cloto-teal-a10);
  box-shadow: -8px 0 32px var(--cloto-black-a8);
}

body.fd-light .fbw-modal-dialog {
  background: var(--cloto-white-a85);
  border-color: var(--cloto-teal-a10);
}

body.fd-light .fbw-modal-body {
  color: #3a3c48;
}

body.fd-light .fbw-modal-input {
  background: var(--cloto-white-a80);
  border-color: rgba(26, 28, 40, 0.12);
  color: #1a1c28;
}

/* ══════════════════════════════════════════════════════════════
   SPLASH SCREEN — Project Selector (mirrors login design)
   ══════════════════════════════════════════════════════════════ */

/* Canvas background (same simplex noise as login) */
#cloto-splash-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.cloto-splash {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-20) var(--space-12);
  padding-top: calc(var(--space-20) + env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--space-20) + env(safe-area-inset-bottom, 0px));
  gap: var(--space-4);
}

/* Theme toggle — fixed top right */
.cloto-splash-top {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

/* Toolbar icon buttons — on-brand glassmorphism for splash context */
.cloto-splash-top .fbw-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--cloto-teal-a8);
  border-radius: var(--radius-sm);
  background: var(--cloto-surface-a55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--cloto-text-40);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
}

.cloto-splash-top .fbw-icon-btn:hover {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a12);
  border-color: var(--cloto-teal-a20);
}

.cloto-splash-top .fbw-icon-btn svg:not(.fd-theme-icon--light):not(.fd-theme-icon--dark) {
  display: block;
}

body.fd-light .cloto-splash-top .fbw-icon-btn {
  background: var(--cloto-white-a55);
  border-color: var(--cloto-teal-a10);
  color: #6a6a76;
}

body.fd-light .cloto-splash-top .fbw-icon-btn:hover {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a8);
  border-color: var(--cloto-teal-a25);
}

/* Logo SVG */
.cloto-splash-logo {
  width: 100px;
  height: 100px;
  margin-bottom: var(--space-6);
  opacity: 0;
  animation: cloto-fadeIn 1.2s ease-out var(--duration-slow) forwards;
}

/* Wordmark */
.cloto-splash-wordmark {
  font-family: var(--cloto-font-display);
  font-size: 42px;
  font-weight: 400;
  letter-spacing: 14px;
  text-transform: uppercase;
  color: var(--cloto-text-100);
  padding-left: var(--space-7);
  margin-bottom: var(--space-8);
  opacity: 0;
  animation: cloto-fadeIn 1.2s ease-out var(--duration-ambient) forwards;
}

/* Project cards grid */
.cloto-splash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-8);
  width: 100%;
  max-width: 720px;
  opacity: 0;
  animation: cloto-fadeIn 1s ease-out 0.7s forwards;
}

.cloto-splash-card {
  position: relative;
  padding: var(--space-8) var(--space-8);
  background: var(--cloto-surface-a55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--cloto-teal-a8);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
}

.cloto-splash-card:hover {
  border-color: var(--cloto-teal-a30);
  box-shadow: 0 0 24px var(--cloto-teal-a12);
  transform: translateY(-2px);
}

.cloto-splash-card-title {
  font-family: var(--cloto-font-body);
  font-size: var(--cloto-fs-md);
  font-weight: 600;
  color: var(--cloto-text-100);
  word-break: break-word;
  line-height: 1.35;
}

.cloto-splash-card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: var(--space-2);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-spring);
}

.cloto-splash-card:hover .cloto-splash-card-actions {
  opacity: 1;
}

.cloto-splash-card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--cloto-void-a40);
  color: var(--cloto-text-40);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
}

.cloto-splash-card-action svg {
  display: block;
}

.cloto-splash-card-action:hover {
  color: var(--cloto-text-70);
  background: var(--cloto-teal-a12);
  border-color: var(--cloto-teal-a20);
}

.cloto-splash-card-action.is-danger:hover {
  color: var(--cloto-danger);
  background: var(--cloto-danger-a12);
  border-color: var(--cloto-danger-a20);
}

/* Action buttons */
.cloto-splash-actions {
  display: flex;
  gap: var(--space-6);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-16);
  opacity: 0;
  animation: cloto-fadeIn 1s ease-out 0.9s forwards;
}

.cloto-splash-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-12);
  font-family: var(--cloto-font-body);
  font-size: var(--cloto-fs-sm);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid var(--cloto-teal-a12);
  border-radius: var(--radius-md);
  background: var(--cloto-surface-a50);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--cloto-text-70);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
}

.cloto-splash-btn:hover {
  border-color: var(--cloto-teal-a35);
  background: var(--cloto-teal-a8);
  color: var(--cloto-teal);
}

.cloto-splash-btn-primary {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a8);
  border-color: var(--cloto-teal-a25);
}

.cloto-splash-btn-primary:hover {
  background: var(--cloto-teal-a15);
  border-color: var(--cloto-teal-a40);
}

/* Empty state */
.cloto-splash-empty {
  font-family: var(--cloto-font-body);
  font-size: var(--cloto-fs-md);
  font-weight: 400;
  text-align: center;
  color: var(--cloto-text-40);
  letter-spacing: 1px;
  padding: var(--space-16) 0;
  line-height: 1.8;
  opacity: 0;
  animation: cloto-fadeIn 1s ease-out 0.7s forwards;
}

/* Splash animations */
@keyframes cloto-fadeIn {
  from { opacity: 0;
  transform: translateY(12px); }
  to   { opacity: 1;
  transform: translateY(0); }
}

/* ── Splash fading (behind create-project prompt) ── */
.cloto-splash--fading {
  transition: opacity 1.5s var(--ease-default) !important;
  opacity: 0 !important;
}

/* ── Splash instant (skip animations after first visit) ── */
.cloto-splash-instant .cloto-splash-logo,
.cloto-splash-instant .cloto-splash-wordmark,
.cloto-splash-instant .cloto-splash-grid,
.cloto-splash-instant .cloto-splash-empty,
.cloto-splash-instant .cloto-splash-actions {
  animation: none;
  opacity: 1;
}

/* Light theme — splash brand */
body.fd-light .cloto-splash-logo {
  filter: brightness(0.8) saturate(1.3);
}
body.fd-light .cloto-splash-wordmark {
  color: var(--cloto-text-100);
}
body.fd-light .cloto-splash-card {
  background: var(--cloto-white-a55);
  border-color: var(--cloto-teal-a10);
}
body.fd-light .cloto-splash-card:hover {
  border-color: var(--cloto-teal-a30);
  box-shadow: 0 0 24px var(--cloto-teal-a8);
}
body.fd-light .cloto-splash-card-title {
  color: var(--cloto-text-100);
}
body.fd-light .cloto-splash-card-action {
  color: #6a6a76;
  background: rgba(255, 255, 255, 0.5);
}
body.fd-light .cloto-splash-btn {
  color: #2a2c38;
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--cloto-teal-a12);
}
body.fd-light .cloto-splash-btn:hover {
  color: var(--cloto-teal);
  border-color: var(--cloto-teal-a30);
  background: var(--cloto-teal-a6);
}
body.fd-light .cloto-splash-btn-primary {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a8);
  border-color: var(--cloto-teal-a25);
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT V2 — Three-panel grid (sidebar | kanban | workspace)
   Scoped under .fbw-outline-v2 — zero impact on v1
   ══════════════════════════════════════════════════════════════ */

.fbw-outline-v2 {
  display: grid;
  grid-template-columns: var(--cloto-v2-kanban-share) 1fr;
  transition: grid-template-columns 1400ms var(--ease-sheet);
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* ── Prefunnel: full-width void layout before expansion ── */
.fbw-outline-v2.is-prefunnel {
  grid-template-columns: 0px 1fr;
}
.fbw-outline-v2.is-prefunnel .fbw-v2-kanban {
  min-width: 0;
  opacity: 0;
  overflow: hidden;
  border-right-color: transparent;
}
.fbw-outline-v2.is-prefunnel .fbw-v2-workspace {
  background: var(--cloto-void);
}
.fbw-outline-v2.is-prefunnel .fbw-v2-workspace-header {
  display: none;
}
.fbw-outline-v2.is-prefunnel .fbw-v2-workspace-content {
  display: none !important;
}
.fbw-outline-v2.is-prefunnel .fbw-ws-resize-handle {
  display: none !important;
}
.fbw-outline-v2.is-prefunnel .fbw-ws-chips {
  display: none;
}
.fbw-outline-v2.is-prefunnel #fbw-workspace-chat {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto !important;
  min-height: 0;
  background: var(--cloto-void);
  overflow: hidden;
  opacity: 1 !important;
  pointer-events: auto !important;
}
/* Close button — hidden by default, shown only in prefunnel */
.wiz-prefunnel-close {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  background: none;
  border: none;
  color: var(--cloto-text-30);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  line-height: 0;
  transition: color 0.2s, background 0.2s;
}
.wiz-prefunnel-close:hover {
  color: var(--cloto-text-60);
  background: var(--cloto-surface-hover, rgba(255,255,255,.06));
}
.is-prefunnel .wiz-prefunnel-close {
  display: block;
}
/* Hide standalone close when qa-header provides its own */
#fbw-workspace-chat:has(.wiz-qa-header) .wiz-prefunnel-close {
  display: none;
}
/* Sidebar off-screen during prefunnel (transform, not display:none, for animation) */
body:has(.fbw-outline-v2.is-prefunnel) .cloto-sidebar {
  transform: translateX(-48px);
  opacity: 0;
  pointer-events: none;
}
/* Reset main margin when sidebar off-screen */
body:has(.fbw-outline-v2.is-prefunnel) .cloto-main {
  margin-left: 0;
}

/* ── Drawer shrink transitions (prefunnel → full V2) ── */
body:has(.fbw-outline-v2) .cloto-sidebar {
  transition: transform 1400ms var(--ease-sheet),
              opacity 600ms ease-out 300ms;
}
body:has(.fbw-outline-v2) .cloto-main {
  transition: margin-left 1400ms var(--ease-sheet);
}

/* ── Kill all transitions instantly (used for layout snaps) ── */
.cloto-no-transition,
.cloto-no-transition *,
.cloto-no-transition *::before,
.cloto-no-transition *::after {
  transition: none !important;
}

/* ── Kanban panel (left) ── */
.fbw-v2-kanban {
  display: flex;
  flex-direction: column;
  background: var(--cloto-zone-kanban);
  border-right: 1px solid var(--cloto-glass-border);
  overflow: hidden;
  min-height: 0;
  transition: opacity 400ms ease-out 800ms, border-right-color 400ms ease-out, background 600ms ease-out;
}

.fbw-outline-v2 .fbw-columns {
  gap: var(--space-6);
  padding: var(--space-4);
}

.fbw-outline-v2 .fbw-col {
  flex: 0 0 var(--cloto-v2-col-width);
  width: var(--cloto-v2-col-width);
}

.fbw-outline-v2 .fbw-card-title {
  font-size: 13px;
}

.fbw-outline-v2 .fbw-card-short {
  font-size: var(--cloto-fs-2xs);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fbw-outline-v2 .fbw-card-meta {
  display: none;
}

.fbw-outline-v2 .fbw-col-header {
  min-height: 32px;
  padding: var(--space-3) var(--space-5);
}

.fbw-outline-v2 .fbw-col-level-name {
  font-size: var(--cloto-fs-2xs);
}

.fbw-outline-v2 .fbw-col-cards {
  padding: var(--space-3);
  gap: var(--space-3);
}

/* Hide zen button and wait indicator in compact v2 */
.fbw-outline-v2 .fbw-card-zen-float,
.fbw-outline-v2 .cloto-wait {
  display: none;
}

/* ── Workspace panel (right) ── */
.fbw-v2-workspace {
  display: flex;
  flex-direction: column;
  background: var(--cloto-zone-content);
  min-height: 0;
  overflow: hidden;
  transition: background 600ms ease-out;
}

.fbw-v2-workspace-header {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  border-bottom: 1px solid var(--cloto-glass-border);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-text-40);
  flex-shrink: 0;
}

.fbw-v2-workspace-header .fbw-v2-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fbw-v2-breadcrumb-sep {
  color: var(--cloto-text-25);
  margin: 0 var(--space-1);
}

.fbw-v2-breadcrumb-current {
  font-weight: 600;
  color: var(--cloto-text-70);
}

.fbw-v2-workspace-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  color: var(--cloto-text-25);
  font-size: var(--cloto-fs-md);
  text-align: center;
}

.fbw-v2-workspace-placeholder-icon {
  font-size: 48px;
  opacity: 0.3;
}

/* ── Workspace Content (Fase 2) ── */
.fbw-v2-workspace-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  transition: opacity 150ms ease;
}

.fbw-v2-workspace-content.fbw-ws-fading {
  opacity: 0;
}

.fbw-ws-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.fbw-ws-inner--past {
  background: var(--cloto-surface);
}

.fbw-ws-header {
  flex-shrink: 0;
  padding: var(--space-16) var(--space-20) var(--space-6);
}

.fbw-ws-title {
  margin: 0;
  font-family: var(--cloto-font-brand);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--cloto-text-100);
  word-break: break-word;
}

.fbw-ws-meta {
  margin-top: var(--space-3);
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-text-40);
}

/* Content zones */
.fbw-ws-content-zone {
  flex: 0 1 auto;
  padding: 0 var(--space-20) var(--space-16);
  min-height: 0;
}

.fbw-ws-content-full {
  flex: 1 1 auto;
  padding: 0 var(--space-20) var(--space-16);
  min-height: 0;
}

.fbw-ws-body-text {
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--cloto-text-100);
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: 0.01em;
}

.fbw-ws-body-para + .fbw-ws-body-para {
  margin-top: var(--space-6);
}

.fbw-ws-body-empty {
  color: var(--cloto-text-25);
  font-style: italic;
  font-size: var(--cloto-fs-md);
  padding: 0 var(--space-20);
}

/* Divider between content and reserved area */
.fbw-ws-divider {
  height: 1px;
  margin: 0 var(--space-20);
  background: var(--cloto-glass-border);
  flex-shrink: 0;
}

/* Resize handle between content and chat */
.fbw-ws-resize-handle {
  flex-shrink: 0;
  height: 8px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  background: var(--cloto-zone-content);
  transition: background 600ms ease-out;
  touch-action: none;
}
.fbw-ws-resize-handle::after {
  content: '';
  width: 40px;
  height: 3px;
  border-radius: 2px;
  background: var(--cloto-text-15);
  transition: background 0.15s;
}
.fbw-ws-resize-handle:hover::after,
.fbw-ws-resize-handle:active::after {
  background: var(--cloto-teal);
}

/* Chat container in workspace */
#fbw-workspace-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--cloto-zone-chat);
  border-top: 1px solid var(--cloto-zone-chat-border);
  transition: background 600ms ease-out;
}

/* Chat departing: Cloto retracts after expansion reveal (desktop) */
#fbw-workspace-chat.fbw-chat-departing {
  transition: flex 0.4s ease-out, opacity 0.3s ease-out;
  flex: 0 0 0 !important;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Chat header — hidden: breadcrumb already provides context */
.wiz-chat-header {
  display: none;
}
.wiz-chat-header__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.wiz-chat-header__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Conversation inside workspace: no max-width, tighter padding */
#fbw-workspace-chat .wiz-conversation {
  max-width: none;
  padding: var(--space-4) var(--space-6) var(--space-4);
}

/* Reveal footer — celebration + nav button in workspace after Cloto departs */
.fbw-ws-reveal-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--cloto-text-10);
  margin-top: var(--space-4);
  opacity: 0;
  transition: opacity 0.4s ease-in;
}
.fbw-ws-reveal-footer.is-visible { opacity: 1; }

.fbw-ws-reveal-celebration {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-text-40);
}

/* Read-only badge for past cards — outside scroll area, bottom of workspace */
.fbw-ws-readonly-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-20);
  border-top: 1px solid var(--cloto-glass-border);
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-text-25);
  background: var(--cloto-void);
}

/* Entity chips (workspace) — fixed footer between content and chat, no scroll */
.fbw-ws-chips {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-20) var(--space-6);
  background: var(--cloto-zone-content);
  border-top: 1px solid var(--cloto-glass-border);
}

.fbw-ws-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-5);
  font-size: var(--cloto-fs-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.fbw-ws-chip--character {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a10);
  border: 1px solid var(--cloto-teal-a20);
}

.fbw-ws-chip--location {
  color: var(--cloto-purple);
  background: rgba(167, 139, 250, 0.10);
  border: 1px solid var(--cloto-purple-a20);
}

.fbw-ws-chip--conflict {
  color: var(--cloto-danger);
  background: rgba(248, 113, 113, 0.10);
  border: 1px solid var(--cloto-danger-a20);
}

.fbw-ws-chip--theme {
  color: var(--cloto-info);
  background: rgba(96, 165, 250, 0.10);
  border: 1px solid var(--cloto-info-a20);
}

/* Mini chips for kanban cards (V2) */
.fbw-card-mini-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: var(--space-2) 0 0;
}

.fbw-mini-chip {
  display: inline-block;
  padding: 0 var(--space-3);
  font-size: 9px;
  font-weight: 500;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 16px;
}

.fbw-mini-chip--character {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a25);
  border: 1px solid var(--cloto-teal-a35);
}

.fbw-mini-chip--location {
  color: var(--cloto-purple);
  background: rgba(167, 139, 250, 0.25);
  border: 1px solid var(--cloto-purple-a35);
}

.fbw-mini-chip--conflict {
  color: var(--cloto-danger);
  background: var(--cloto-danger-a25);
  border: 1px solid var(--cloto-danger-a35);
}

.fbw-mini-chip--theme {
  color: var(--cloto-info);
  background: rgba(96, 165, 250, 0.25);
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.fbw-mini-chip--more {
  color: var(--cloto-text-40);
  background: rgba(232, 230, 225, 0.14);
  border: 1px solid rgba(232, 230, 225, 0.18);
}

/* Synopsis short on kanban cards (V2) — hidden by default, expands on selection */
.fbw-outline-v2 .fbw-card-synopsis {
  font-size: 11px;
  line-height: 1.4;
  color: var(--cloto-text-40);
  padding: var(--space-1) 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* "Prima traccia" draft note under synopsis */
.fbw-outline-v2 .fbw-card-draft-note {
  font-size: 10px;
  line-height: 1.3;
  color: var(--cloto-gold);
  opacity: 0.7;
  padding-top: var(--space-1);
  font-style: italic;
  font-family: var(--cloto-font-ui);
}

/* Hide tooltip on selected cards (synopsis already visible) */
.fbw-outline-v2 .fbw-card.is-selected .cloto-tooltip::before,
.fbw-outline-v2 .fbw-card.is-selected .cloto-tooltip::after,
.fbw-outline-v2 .fbw-card.is-peeking .cloto-tooltip::before,
.fbw-outline-v2 .fbw-card.is-peeking .cloto-tooltip::after,
.fbw-outline-v2 .fbw-card.is-wizard-active .cloto-tooltip::before,
.fbw-outline-v2 .fbw-card.is-wizard-active .cloto-tooltip::after {
  display: none;
}

/* ── Light theme V2 ── */
body.fd-light .fbw-v2-kanban {
  border-right-color: var(--cloto-surface-a8);
}

body.fd-light .fbw-v2-workspace {
  background: var(--cloto-zone-content);
}

body.fd-light .fbw-v2-workspace-header {
  border-bottom-color: var(--cloto-surface-a6);
}

body.fd-light .fbw-ws-inner--past {
  background: var(--cloto-zone-content);
}

body.fd-light .fbw-ws-body-text {
  color: #2a2c38;
}

body.fd-light .fbw-ws-chip--character {
  color: var(--cloto-teal);
  background: rgba(26, 138, 138, 0.08);
  border-color: rgba(26, 138, 138, 0.20);
}

body.fd-light .fbw-ws-chip--location {
  color: var(--cloto-purple);
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.20);
}

body.fd-light .fbw-ws-readonly-badge {
  background: var(--cloto-void);
}

body.fd-light .fbw-mini-chip--character {
  color: var(--cloto-teal);
  background: rgba(26, 138, 138, 0.10);
}

body.fd-light .fbw-mini-chip--location {
  color: var(--cloto-purple);
  background: rgba(124, 58, 237, 0.10);
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet (iPad portrait & landscape) ── */
@media (max-width: 1024px) {
  :root {
    --fbw-col-width: 280px;
    --fbw-col-gap: var(--space-10);
  }

  .fbw-columns {
    padding: var(--space-6) var(--space-5) var(--space-5);
  }

  /* Detail panel overlays as drawer instead of eating flex space */
  .fbw-outline-container .fbw-detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    flex: none;
    width: var(--cloto-panel-width);
    max-width: 80vw;
    background: rgba(22, 24, 36, 0.94);
    box-shadow:
      -8px 0 32px rgba(0, 0, 0, 0.4),
      inset 2px 0 8px var(--cloto-teal-a4);
  }

  body.fd-light .fbw-outline-container .fbw-detail-panel {
    background: rgba(255, 255, 255, 0.96);
    box-shadow:
      -8px 0 32px var(--cloto-black-a10),
      inset 2px 0 8px var(--cloto-teal-a3);
  }

  .fbw-outline-container .fbw-detail-panel:not(.has-card) {
    background: rgba(16, 18, 28, 0.88);
  }

  body.fd-light .fbw-outline-container .fbw-detail-panel:not(.has-card) {
    background: rgba(245, 243, 238, 0.92);
  }

  /* Splash — gentle adaptation for tablet width (portrait has plenty height) */
  .cloto-splash {
    padding: var(--space-16) var(--space-12);
  }

  .cloto-splash-logo {
    width: 88px;
    height: 88px;
    margin-bottom: var(--space-5);
  }

  .cloto-splash-wordmark {
    font-size: 38px;
    letter-spacing: 12px;
    padding-left: var(--space-6);
  }

  .cloto-splash-grid {
    max-width: 700px;
    gap: var(--space-7);
  }

  .cloto-splash-card {
    padding: var(--space-8) var(--space-8);
  }

  .cloto-splash-actions {
    margin-top: var(--space-6);
  }

  .cloto-splash-btn {
    padding: var(--space-5) var(--space-12);
  }

  .cloto-splash-empty {
    padding: var(--space-12) 0;
  }
}

/* ── iPad 13" landscape & similar (height ≤ 1050px) — gentle compaction ── */
@media (max-height: 1050px) {
  .cloto-splash {
    padding: var(--space-12) var(--space-12);
    gap: var(--space-3);
  }

  .cloto-splash-logo {
    width: 72px;
    height: 72px;
    margin-bottom: var(--space-3);
  }

  .cloto-splash-wordmark {
    font-size: 34px;
    letter-spacing: 11px;
    padding-left: var(--space-6);
  }

  .cloto-splash-grid {
    gap: var(--space-6);
  }

  .cloto-splash-card {
    padding: var(--space-7) var(--space-7);
  }

  .cloto-splash-btn {
    padding: var(--space-4) var(--space-8);
  }

  .cloto-splash-empty {
    padding: var(--space-8) 0;
  }
}

/* ── Short landscape (≤ 768px height) — aggressive compaction ── */
@media (max-height: 768px) {
  .cloto-splash {
    padding: var(--space-6) var(--space-10);
    gap: var(--space-1);
  }

  .cloto-splash-logo {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-2);
  }

  .cloto-splash-wordmark {
    font-size: 28px;
    letter-spacing: 9px;
    padding-left: var(--space-4);
  }

  .cloto-splash-grid {
    gap: var(--space-4);
  }

  .cloto-splash-card {
    padding: var(--space-6) var(--space-6);
  }

  .cloto-splash-actions {
    gap: var(--space-4);
  }

  .cloto-splash-btn {
    padding: var(--space-4) var(--space-7);
    letter-spacing: 0.5px;
  }

  .cloto-splash-empty {
    padding: var(--space-5) 0;
  }
}

/* ── Small tablet / iPad Mini portrait ── */
@media (max-width: 768px) {
  :root {
    --fbw-col-width: 260px;
    --fbw-col-gap: var(--space-7);
  }

  .fbw-columns {
    padding: var(--space-6) var(--space-4) var(--space-4);
  }

  .fbw-col-header {
    padding: var(--space-4) var(--space-5);
  }

  .fbw-kanban-cloto {
    font-size: 13px;
    letter-spacing: 5px;
    padding: var(--space-2) var(--space-6) var(--space-2) var(--space-4);
    gap: var(--space-3);
  }
  .fbw-kanban-cloto-logo {
    width: 20px;
    height: 20px;
  }

  .fbw-outline-container .fbw-detail-panel {
    width: 320px;
  }
}

/* ── Phone ── */
@media (max-width: 480px) {
  :root {
    --fbw-col-width: 78vw;
  }

  .cloto-splash-grid {
    grid-template-columns: 1fr;
  }
  .cloto-splash {
    padding: var(--space-12) var(--space-8);
  }
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT V2 — Mobile (< 768px)
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* V2: workspace fills full viewport */
  .fbw-outline-v2 .fbw-v2-workspace {
    height: 100vh;
    height: 100dvh;
  }

  /* Workspace header: compact */
  .fbw-outline-v2 .fbw-v2-workspace-header {
    height: 44px;
    padding: 0 var(--space-4);
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--cloto-zone-content);
  }

  /* Content: collapsible */
  .fbw-outline-v2 .fbw-v2-workspace-content {
    flex: none;
    max-height: 80px;
    overflow: hidden;
    position: relative;
    transition: max-height 250ms ease;
  }

  .fbw-outline-v2 .fbw-v2-workspace-content.fbw-ws-mobile-expanded {
    max-height: 50vh;
    overflow-y: auto;
  }

  /* Fade-out gradient when collapsed */
  .fbw-outline-v2 .fbw-v2-workspace-content:not(.fbw-ws-mobile-expanded)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: linear-gradient(transparent, var(--cloto-zone-content));
    pointer-events: none;
  }

  /* Content padding reduced */
  .fbw-outline-v2 .fbw-ws-header {
    padding: var(--space-4) var(--space-6) var(--space-2);
  }
  .fbw-outline-v2 .fbw-ws-title {
    font-size: 18px;
  }
  .fbw-outline-v2 .fbw-ws-content-zone,
  .fbw-outline-v2 .fbw-ws-content-full {
    padding: 0 var(--space-6) var(--space-4);
  }

  /* Hide chips, resize handle, readonly badge on mobile */
  .fbw-outline-v2 .fbw-ws-chips,
  .fbw-outline-v2 .fbw-ws-resize-handle,
  .fbw-outline-v2 .fbw-ws-readonly-badge {
    display: none !important;
  }

  /* Chat takes remaining space */
  .fbw-outline-v2 #fbw-workspace-chat {
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Safe area for input on iOS */
  .fbw-outline-v2 #fbw-workspace-chat .wiz-input {
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  }
}

/* Toggle button at bottom of collapsed content */
.fbw-ws-mobile-toggle {
  display: none;
}

@media (max-width: 768px) {
  .fbw-outline-v2 .fbw-ws-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) 0;
    border: none;
    border-top: 1px solid var(--cloto-glass-border);
    background: var(--cloto-zone-content);
    color: var(--cloto-text-40);
    font-size: 11px;
    font-family: var(--cloto-font-ui);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
  }

  .fbw-ws-mobile-toggle:active {
    background: var(--cloto-teal-a6);
  }

  .fbw-ws-mobile-toggle__chevron {
    transition: transform 200ms ease;
    font-size: var(--cloto-fs-2xs);
  }

  .fbw-ws-mobile-expanded .fbw-ws-mobile-toggle__chevron {
    transform: rotate(180deg);
  }
}

/* ── Touch devices — always show card actions, larger tap targets ── */
@media (hover: none) and (pointer: coarse) {
  .fbw-columns {
    touch-action: pan-x pan-y;
  }

  .fbw-card-zen-float {
    opacity: 1;
  }

  .cloto-splash-card-actions {
    opacity: 1;
  }

  /* Revert absolute panel to flex on touch — absolute blocks scroll propagation */
  .fbw-outline-container .fbw-detail-panel {
    position: static;
    z-index: auto;
    flex: 0 0 320px;
    width: 320px;
    max-width: 45vw;
  }

  .fbw-card-editbtn,
  .fbw-card-firstbtn,
  .fbw-card-zenbtn,
  .fbw-card-dupebtn,
  .fbw-card-exportbtn,
  .fbw-card-aigenbtn,
  .fbw-card-aifbbtn {
    width: 32px;
    height: 32px;
    font-size: var(--cloto-fs-reading);
  }

  .fbw-card-footer-btn,
  .fbw-card-conclude-btn {
    min-height: 36px;
    padding: var(--space-3) var(--space-5);
  }

  .fbw-mode-tab {
    padding: var(--space-4) var(--space-7);
  }

  .fbw-icon-btn {
    width: 36px;
    height: 36px;
  }

  .fbw-dp-close {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }

  .fbw-panel-info-bubble {
    width: 44px;
    height: 44px;
  }
}


/* ══════════════════════════════════════════════════════════════
   ACCESSIBILITY — Focus styles & screen-reader-only
   ══════════════════════════════════════════════════════════════ */

/* Screen-reader-only: visually hidden but accessible */
.fbw-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus ring on kanban cards */
.fbw-card:focus {
  outline: 2px solid var(--cloto-teal);
  outline-offset: -2px;
  box-shadow: var(--shadow-focus-teal);
}
.fbw-card:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}
.fbw-card:focus-visible {
  outline: 2px solid var(--cloto-teal);
  outline-offset: -2px;
  box-shadow: var(--shadow-focus-teal);
}

/* Focus ring on workspace content area (when receiving focus from card change) */
.fbw-v2-workspace-content:focus {
  outline: none;
}

/* Resize handle focus */
.fbw-ws-resize-handle:focus {
  outline: 2px solid var(--cloto-teal);
  outline-offset: -1px;
}
.fbw-ws-resize-handle:focus:not(:focus-visible) {
  outline: none;
}
.fbw-ws-resize-handle:focus-visible {
  outline: 2px solid var(--cloto-teal);
  outline-offset: -1px;
  background: var(--cloto-teal-deep);
}
