/* ============================================================================
   Vinco — 2-Row Interlocked Modular Card Architecture
   ----------------------------------------------------------------------------
   Clean solid matte cards, concentric curved borders, zero dividers, engraved
   camouflaged hotkey footer, integrated status footer inside the workspace
   card, folder/settings breadcrumbs, and full custom theme token support.
   ============================================================================ */

:root {
  color-scheme: light;

  /* Unslop Graphite Neutral Ramp (Light — Drafting Paper & Ink) */
  --bg-stage: #f4f4f5;
  --bg-card: #ffffff;
  --bg-subcard: #f4f4f5;
  --bg-hover: #ececef;
  --bg-active: #e4e4e7;
  --bg-input: #ffffff;
  --bg-kbd: #f4f4f5;

  --border-card: #e2e2e4;
  --border-subcard: #ebebed;
  --border-strong: #d0d0d4;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.05);
  --top-highlight: none;
  --shadow-popover: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 16px 40px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);

  --text-primary: #171717;
  --text-secondary: #525252;
  --text-tertiary: #737373;
  --text-inverse: #ffffff;
  --focus-ring: rgba(23, 23, 23, 0.28);

  --btn-primary-bg: #171717;
  --btn-primary-hover: #262626;
  --btn-primary-text: #ffffff;

  /* Typewriter-Stamped Corner Imprint */
  --engrave-text: rgba(23, 23, 23, 0.26);
  --engrave-highlight: rgba(255, 255, 255, 0.85);
  --engrave-bg: rgba(23, 23, 23, 0.03);

  /* Semantic Tones (Unslop muted palette) */
  --danger-text: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --danger-solid: #dc2626;
  --danger-solid-hover: #b91c1c;
  --ok-dot: #16a34a;
  --warn-dot: #a16207;
  --star-color: #ca8a04;

  /* Typography Families (Full UTF-8 & Emoji Fallback) */
  --font-sans: "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  --font-serif: "Georgia", "Cambria", "Times New Roman", "Segoe UI Emoji", "Apple Color Emoji", serif;
  --font-mono: "SF Mono", "Cascadia Code", "Cascadia Mono", Consolas, "Segoe UI Emoji", monospace;
  --font-humanist: "Segoe UI Semilight", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-rounded: "SF Pro Rounded", "Nunito", "Varela Round", "Quicksand", "Segoe UI Variable Display", "Segoe UI", sans-serif;

  --ui-font-size: 14px;
  --editor-font: var(--font-sans);
  --editor-font-size: 15px;
  --editor-line-height: 1.7;
  --editor-measure: 98ch;

  /* Aligned Rounded Subtle Card Grid (Zero Stray Gaps) */
  --win-chrome-h: 32px;
  --stage-pad: 8px;
  --grid-gap: 8px;
  --sidebar-w: 260px;
  --outline-w: 262px;
  --row-top-h: 44px;

  /* Proportional Concentric Curves (Outer 16 -> Bar 14 -> Sub 10 -> Btn 8 -> Inner 6) */
  --r-card: 16px;
  --r-bar: 14px;
  --r-sub: 10px;
  --r-btn: 8px;
  --r-kbd: 6px;
  --r-pill: 999px;

  /* Fluid Single Motion Curve */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-drawer: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  /* Subtle Rounded Graphite Ramp (Dark — Distinct Matte Stage vs Soft Rounded Cards) */
  --bg-stage: #0c0c0e;
  --bg-card: #151518;
  --bg-subcard: #1d1d21;
  --bg-hover: #242429;
  --bg-active: #2b2b31;
  --bg-input: #1a1a1e;
  --bg-kbd: #242429;

  --border-card: #262629;
  --border-subcard: #1f1f23;
  --border-strong: #343439;

  --shadow-card: none;
  --top-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-popover: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-modal: 0 24px 56px rgba(0, 0, 0, 0.56);

  --text-primary: #ededed;
  --text-secondary: #a1a1a6;
  --text-tertiary: #85858b;
  --text-inverse: #141415;
  --focus-ring: rgba(237, 237, 237, 0.34);

  --btn-primary-bg: #ededed;
  --btn-primary-hover: #dcdce0;
  --btn-primary-text: #141415;

  --engrave-text: rgba(237, 237, 237, 0.22);
  --engrave-highlight: rgba(0, 0, 0, 0.55);
  --engrave-bg: rgba(237, 237, 237, 0.03);

  --danger-text: #e5484d;
  --danger-bg: rgba(229, 72, 77, 0.12);
  --danger-solid: #e5484d;
  --danger-solid-hover: #c9373c;
  --ok-dot: #4cc38a;
  --warn-dot: #e5b84b;
  --star-color: #eab308;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--bg-stage);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--ui-font-size);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  user-select: none;
}

@media (pointer: fine) {
  html {
    overscroll-behavior: none;
  }
}

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

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.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;
}

.skip-link {
  position: fixed;
  top: -64px;
  left: 14px;
  z-index: 1000;
  padding: 8px 16px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-radius: var(--r-btn);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: top 160ms var(--ease-out);
}

.skip-link:focus-visible {
  top: 12px;
}

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

.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

/* ============================================================================
   Stage & Subtle Rounded Card Architecture (Aligned Borders, Zero Gaps)
   ============================================================================ */

.win-chrome-bar {
  position: fixed;
  top: 0;
  right: 0;
  width: 152px;
  height: 36px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  background-color: var(--bg-stage);
  border-bottom-left-radius: calc(36px - var(--stage-pad) - var(--r-card));
  user-select: none;
  pointer-events: none;
  z-index: 80;
}

.win-notch-outline {
  position: absolute;
  top: calc(var(--stage-pad) + var(--r-card));
  right: calc(var(--stage-pad) + var(--r-card));
  bottom: 0;
  left: 0;
  border-left: 1px solid var(--border-card);
  border-bottom: 1px solid var(--border-card);
  border-bottom-left-radius: calc(36px - var(--stage-pad) - var(--r-card));
  pointer-events: none;
}

.win-notch-fillet-left {
  position: absolute;
  top: var(--stage-pad);
  left: calc(1px - var(--r-card));
  width: var(--r-card);
  height: var(--r-card);
  border-top-right-radius: var(--r-card);
  border-top: 1px solid var(--border-card);
  border-right: 1px solid var(--border-card);
  box-shadow: 6px -6px 0 6px var(--bg-stage);
  pointer-events: none;
}

.win-notch-fillet-right {
  position: absolute;
  right: var(--stage-pad);
  bottom: calc(1px - var(--r-card));
  width: var(--r-card);
  height: var(--r-card);
  border-top-right-radius: var(--r-card);
  border-top: 1px solid var(--border-card);
  border-right: 1px solid var(--border-card);
  box-shadow: 6px -6px 0 6px var(--bg-stage);
  pointer-events: none;
}

.win-chrome-bar .win-cluster {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: stretch;
  height: 30px;
  gap: 0;
  margin: 0;
  flex-shrink: 0;
  pointer-events: auto;
}

.win-chrome-bar .win-btn {
  width: 46px;
  height: 100%;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .win-chrome-bar .win-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
  .win-chrome-bar .win-btn-close:hover {
    background-color: #e81123;
    color: #ffffff;
  }
}

:root[data-platform="pwa"] .win-chrome-bar {
  display: none;
}

.app-stage {
  position: relative;
  display: flex;
  align-items: stretch;
  padding: var(--stage-pad);
  gap: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-stage);
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--r-btn);
  background-color: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), color 140ms ease, opacity 140ms ease, transform 110ms var(--ease-out);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
  .icon-btn-danger:hover {
    background-color: var(--danger-bg);
    color: var(--danger-text);
  }
  .win-btn-close:hover {
    background-color: #e81123;
    color: #ffffff;
  }
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn[aria-pressed="true"],
.icon-btn.is-active {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

#btn-fav-note[aria-pressed="true"] {
  color: var(--star-color);
}

#btn-fav-note[aria-pressed="true"] svg,
svg.star-badge-filled,
.star-badge-filled svg {
  color: var(--star-color);
  fill: var(--star-color);
}

/* Persistent Top-Left Controls (Centered vertically inside 44px Top Bar: 8px stage + 8px inner) */
.leading-dock {
  position: absolute;
  top: calc(var(--stage-pad) + 8px);
  left: calc(var(--stage-pad) + 8px);
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================================
   LEFT SUBTLE ROUNDED CARD: Unified Single Sidebar (Fluid Zero-Gap Collapse)
   ============================================================================ */

.sidebar-stack {
  position: relative;
  width: var(--sidebar-w);
  flex: 0 0 auto;
  margin-right: var(--grid-gap);
  z-index: 20;
  display: flex;
  overflow: hidden;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  will-change: width, margin-right, opacity, transform;
  transition:
    width 260ms var(--ease-out),
    margin-right 260ms var(--ease-out),
    opacity 200ms var(--ease-out),
    transform 260ms var(--ease-out),
    border-color 200ms var(--ease-out);
}

.sidebar-inner {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.app-stage.sidebar-collapsed:not(.force-sidebar-open) .sidebar-stack {
  width: 0;
  margin-right: 0;
  opacity: 0;
  border-color: transparent;
  border-width: 0;
  transform: translate3d(-12px, 0, 0);
  pointer-events: none;
}

/* Sidebar Top Header (Exact 44px height matching Top Bar Card!) */
.sidebar-head-card {
  height: var(--row-top-h);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subcard);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px 0 136px;
}

.sidebar-head-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sidebar-search-full {
  width: 100%;
}

.sidebar-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
}

.sidebar-filter-row .sidebar-filter-anchor {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  height: 32px;
}

.sidebar-filter-row .sidebar-filter-btn {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  gap: 8px;
  justify-content: flex-start;
  border: none;
}

.sidebar-filter-row .sidebar-filter-label {
  flex: 1 1 auto;
  max-width: none;
  text-align: left;
}

.sidebar-filter-row .sidebar-filter-btn .count-badge {
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-filter-row > .sidebar-view-btn.sidebar-icon-toggle {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  line-height: 0;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
}

.sidebar-filter-row > .sidebar-view-btn.sidebar-icon-toggle > span,
.sidebar-filter-row .sidebar-filter-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.sidebar-filter-row > .sidebar-view-btn.sidebar-icon-toggle svg,
.sidebar-filter-row .sidebar-filter-icon svg {
  display: block;
}

.sidebar-filter-row > .sidebar-view-btn.sidebar-icon-toggle:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-brand {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-secondary);
}

.sidebar-home-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--text-secondary);
}

.sidebar-home-btn[aria-pressed="true"] {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

/* Sidebar Body & Mode Panels */
.sidebar-body-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 8px;
  overflow: hidden;
}

.sidebar-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.sidebar-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* Search Sub-Card */
.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  display: inline-flex;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 34px;
  padding: 0 32px;
  border: 1px solid var(--border-subcard);
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  border-color: var(--border-strong);
  background-color: var(--bg-input);
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--r-kbd);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .search-clear:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

/* Collection Switcher Sub-Card */
.collection-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.collection-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background-color: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), color 140ms ease, border-color 140ms ease, transform 100ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .collection-tab:hover {
    color: var(--text-primary);
  }
}

.collection-tab:active {
  transform: scale(0.97);
}

.collection-tab.is-active {
  background-color: var(--bg-card);
  border-color: var(--border-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

.count-badge {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.collection-tab.is-active .count-badge {
  color: var(--text-secondary);
}

/* Compact Local Folders Row inside Sidebar */
.folders-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
}

.folders-chips {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 14px), transparent 100%);
}

.folders-chips::-webkit-scrollbar {
  display: none;
}

.folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border-subcard);
  border-radius: 7px;
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .folder-chip:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

.folder-chip.is-active {
  background-color: var(--bg-active);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.folder-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border-subcard);
  border-radius: 7px;
  background-color: var(--bg-subcard);
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms ease, color 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .folder-add-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

.folder-add-btn.is-active,
.folder-add-btn[aria-pressed="true"] {
  background-color: var(--bg-active);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Trash Banner Sub-Card */
.trash-subcard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  border-radius: var(--r-sub);
  background-color: var(--danger-bg);
  font-size: 12px;
  color: var(--danger-text);
  flex-shrink: 0;
}

.btn-inline-danger {
  border: none;
  border-radius: var(--r-kbd);
  background-color: var(--bg-card);
  color: var(--danger-text);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
}

/* Note Cards List (Double-click blank space creates a new note!) */
.notes-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 4px 8px 0;
}

.note-card {
  --card-surface: transparent;
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--r-sub);
  background-color: var(--card-surface);
  border: none;
  content-visibility: auto;
  contain-intrinsic-size: 68px;
  user-select: none;
  -webkit-touch-callout: none;
  transition: background-color 140ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .note-card:hover {
    --card-surface: var(--bg-hover);
    background-color: var(--card-surface);
  }
}

.note-card.is-selected {
  --card-surface: var(--bg-active);
  background-color: var(--card-surface);
  border: none;
  box-shadow: none;
}

.note-card.is-checked {
  --card-surface: var(--bg-active);
  background-color: var(--card-surface);
  border: none;
  box-shadow: inset 0 0 0 1.5px var(--text-primary);
}

/* Multi-Select Checkbox & Batch Action Bar */
.sidebar-top-slot {
  position: relative;
  height: 32px;
  flex-shrink: 0;
  z-index: 45;
  transition: height 160ms var(--ease-out);
}

.sidebar-top-slot.has-search-open,
.sidebar-top-slot.is-selecting {
  height: 70px;
}

.sidebar-top-slot > .sidebar-controls {
  position: absolute;
  inset: 0;
  height: 100%;
  justify-content: space-between;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  z-index: 2;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.sidebar-top-slot.is-selecting > .sidebar-controls {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.note-select-check {
  width: 17px;
  height: 17px;
  margin-left: 4px;
  margin-right: 8px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  background-color: transparent;
  color: var(--btn-primary-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms var(--ease-out);
}

.notes-list.is-entering-select .note-select-check {
  animation: select-check-in 180ms var(--ease-out) both;
}

@keyframes select-check-in {
  from {
    opacity: 0;
    transform: scale(0.6) translateX(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

.note-select-check.is-checked {
  background-color: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
}

.batch-bar {
  position: absolute;
  inset: 0;
  height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  padding: 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: none;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.sidebar-top-slot.is-selecting > .batch-bar {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.batch-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}

.batch-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.batch-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.batch-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--r-kbd);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.batch-act-btn {
  flex: 1 1 0;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subcard);
  border-radius: var(--r-btn);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, transform 90ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .batch-mini-btn:hover,
  .batch-act-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
  .batch-act-btn.is-danger:hover {
    background-color: var(--danger-bg);
    border-color: transparent;
    color: var(--danger-text);
  }
}

.batch-act-btn:active {
  transform: scale(0.95);
}

.note-card-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: none;
  border-radius: var(--r-sub);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.note-card-main:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1.5px var(--focus-ring);
}

.note-card-main:active {
  transform: scale(0.99);
}

.note-item-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
}

.note-item-title {
  flex: 1 1 auto;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-primary);
  min-width: 0;
}

.note-item-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: opacity 130ms ease;
}

.note-item-badges .pin-badge {
  color: var(--text-secondary);
  opacity: 0.82;
}

.note-item-badges .star-badge-filled {
  color: #f59e0b;
  fill: #f59e0b;
}

.note-item-excerpt {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  min-width: 0;
}

.note-item-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  min-width: 0;
}

.note-item-date {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.note-item-folder {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--text-tertiary);
  min-width: 0;
}

/* Minimalist Single 3-Dots Hover Trigger with Seamless Gradient Text Fade (Hidden in Select Mode) */
.note-card-actions {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  display: inline-flex;
  align-items: flex-start;
  padding: 4px 8px 0 32px;
  border-radius: 0 var(--r-sub) var(--r-sub) 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--card-surface, var(--bg-hover)) 70%, transparent) 38%,
    var(--card-surface, var(--bg-hover)) 66%,
    var(--card-surface, var(--bg-hover)) 100%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms var(--ease-out);
}

.notes-list[data-display-mode="compact"] .note-card-actions {
  padding-top: 4px;
}

.notes-list.is-select-mode .note-card-actions {
  display: none !important;
}

@media (hover: hover) and (pointer: fine) {
  .note-card:hover .note-card-actions,
  .note-card:focus-within .note-card-actions {
    opacity: 1;
    pointer-events: auto;
  }
  .note-card:hover .note-item-badges {
    opacity: 0;
  }
}

.note-quick-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease, transform 90ms var(--ease-out);
}

.note-quick-btn.is-active {
  color: var(--text-primary);
}

.note-quick-btn:hover {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

.note-quick-btn:active {
  transform: scale(0.92);
}

.sidebar-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
}

.notes-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 8px 4px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-tertiary);
  user-select: none;
}

.notes-section-head:first-child {
  padding-top: 4px;
}

/* Typewriter-Stamped Shortcut Imprint (Non-interactive, tucked into bottom-left corner) */
.sidebar-engraved-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 8px;
  pointer-events: none;
  user-select: none;
}

.engraved-hotkey-stamp {
  display: inline-block;
  color: var(--engrave-text);
  font-family: "Courier New", "Cascadia Mono", Consolas, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  text-shadow: 0 1px 0 var(--engrave-highlight);
  pointer-events: none;
  user-select: none;
}

/* Keycaps in Settings */
.kbd-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 8px;
  border: 1px solid var(--border-card);
  border-radius: var(--r-kbd);
  background-color: var(--bg-kbd);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

/* ============================================================================
   RIGHT STRUCTURAL COLUMN: 2 Linked Cards (Command + Unified Workspace/Status)
   ============================================================================ */

.main-stack {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

/* Row 1: Unified Top Command Bar (44px, merged with main card via bottom divider) */
.command-card {
  height: var(--row-top-h);
  flex-shrink: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border-subcard);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 0 0 16px;
  position: relative;
  z-index: 40;
  transition:
    padding-left 260ms var(--ease-out),
    border-bottom-color 240ms var(--ease-out);
}


:root[data-platform="pwa"] .command-card {
  padding-right: 8px;
}

:root[data-platform="pwa"] .inspector-top-tabs {
  transform: translate(0, -50%);
}

:root[data-platform="pwa"] .command-card:not(.has-outline-open) .cmd-trailing-zone {
  flex-basis: 0px;
  width: 0px;
  padding-right: 0;
}

#toolbar-breadcrumb {
  display: none !important;
}

.doc-tab.is-tab-selected {
  background-color: color-mix(in srgb, var(--btn-primary-bg) 18%, var(--bg-active));
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1.5px var(--focus-ring);
}

.app-stage.sidebar-collapsed:not(.force-sidebar-open) .command-card {
  padding-left: 144px;
}

.cmd-main-zone {
  transition: padding-right var(--panel-time) var(--panel-ease);
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cmd-trailing-zone {
  position: relative;
  flex: 0 0 152px;
  width: 152px;
  padding-right: 152px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition:
    flex-basis var(--panel-time) var(--panel-ease),
    width var(--panel-time) var(--panel-ease),
    padding var(--panel-time) var(--panel-ease);
}

/* The panel, its header and the note actions move as one piece */
:root {
  --panel-time: 300ms;
  --panel-ease: cubic-bezier(0.3, 0.7, 0.2, 1);
}

/* When Right Outline Panel is open, align .cmd-main-zone's right edge (Note Actions) flush with the Right Sidebar left border! */
.command-card.has-outline-open .cmd-trailing-zone {
  flex: 0 0 clamp(296px, 26vw, 316px);
  width: clamp(296px, 26vw, 316px);
  min-width: 0;
  padding-left: 8px;
  padding-right: 152px;
  justify-content: flex-start;
}

.win-cluster {
  height: 100%;
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  margin-left: 4px;
  flex-shrink: 0;
}

.win-btn {
  width: 46px;
  height: 100%;
  border-radius: 0;
  color: var(--text-secondary);
}

.win-btn:active {
  transform: none;
}

/* Realigned Sidebar Utilities inside Top Bar: shown ONLY when Sidebar is collapsed / Tabs mode */
.topbar-sidebar-only {
  display: none !important;
}

.app-stage.sidebar-collapsed:not(.force-sidebar-open) .topbar-sidebar-only {
  display: inline-flex !important;
}

#btn-top-home {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
}

#btn-top-home[aria-pressed="true"] {
  background-color: var(--bg-active);
  color: var(--text-primary);
}


.command-card.has-outline-open .cmd-trailing-zone > .bar-sep {
  display: none;
}

/* Row 2: Aligned Workspace Row (Big Unified Writing+Info Card + Collapsible Right Card) */
.workspace-row {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
}

.cmd-leading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 80px;
  height: 100%;
}

.bar-sep {
  width: 1px;
  height: 16px;
  background-color: var(--border-strong);
  opacity: 0.55;
  flex-shrink: 0;
  margin: 0 4px;
}

#toolbar-doc-actions[hidden] + .bar-sep {
  display: none;
}

/* Browser-Style Top Tabs Strip (Integrated cleanly inside top of big rounded workspace block) */
.top-tabs-bar {
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  background-color: var(--bg-subcard);
  border-bottom: 1px solid var(--border-subcard);
  min-width: 0;
  animation: ribbon-in 200ms var(--ease-out);
}

.top-tabs-scroll {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100%;
  min-width: 0;
  flex: 0 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 8px 8px 0;
}

.top-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.doc-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 33px;
  min-width: 96px;
  max-width: 204px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  margin-bottom: 4px;
  background-color: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background-color 140ms ease,
    color 140ms ease,
    border-color 140ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .doc-tab:hover:not(.is-active) {
    background-color: color-mix(in srgb, var(--text-primary) 5%, transparent);
    color: var(--text-primary);
  }
}

.doc-tab.is-active {
  --tab-active-bg: color-mix(in srgb, var(--text-primary) 8%, var(--bg-card));
  background-color: var(--tab-active-bg);
  border-color: var(--border-card);
  border-bottom: none;
  height: 35px;
  margin-bottom: 0;
  color: var(--text-primary);
  font-weight: 500;
  z-index: 2;
}

.doc-tab.is-active::before,
.doc-tab.is-active::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 10px;
  height: 10px;
  pointer-events: none;
}

.doc-tab.is-active::before {
  left: -10px;
  border-bottom-right-radius: 10px;
  border-right: 1px solid var(--border-card);
  border-bottom: 1px solid var(--border-card);
  box-shadow: 4px 4px 0 3px var(--tab-active-bg);
}

.doc-tab.is-active::after {
  right: -10px;
  border-bottom-left-radius: 10px;
  border-left: 1px solid var(--border-card);
  border-bottom: 1px solid var(--border-card);
  box-shadow: -4px 4px 0 3px var(--tab-active-bg);
}

.doc-tab-icon {
  display: inline-flex;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.doc-tab-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.doc-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 110ms ease, background-color 110ms ease, color 110ms ease;
}

.doc-tab:hover .doc-tab-close,
.doc-tab.is-active .doc-tab-close,
.doc-tab:focus-within .doc-tab-close {
  opacity: 0.72;
}

@media (hover: hover) and (pointer: fine) {
  .doc-tab-close:hover {
    opacity: 1;
    background-color: var(--bg-active);
    color: var(--text-primary);
  }
}

.tab-new-btn {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.top-tabs-trailing {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.tabs-browse-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .tabs-browse-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

/* Breadcrumb Path inside Top Command Card (Document Folder Path OR Settings Path) */
.cmd-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.crumb-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: none;
  border-radius: var(--r-kbd);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 120ms ease, color 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .crumb-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

.crumb-current {
  color: var(--text-primary);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb-sep {
  display: inline-flex;
  color: var(--text-tertiary);
  opacity: 0.65;
  flex-shrink: 0;
}

.cmd-drag-flex {
  flex: 1 1 12px;
  height: 100%;
}

.cmd-center {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cmd-trailing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cmd-cluster {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  background-color: transparent;
  border: none;
}

.cmd-cluster .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-btn);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-kbd);
  background-color: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), color 140ms ease, border-color 140ms ease, transform 100ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .seg-btn:hover {
    color: var(--text-primary);
  }
}

.seg-btn:active {
  transform: scale(0.98);
}

.seg-btn.is-active,
.seg-btn[aria-selected="true"],
.seg-btn[aria-checked="true"] {
  background-color: var(--bg-card);
  border-color: var(--border-card);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-card), var(--top-highlight);
}

/* Popover Card */
.menu-anchor {
  position: relative;
}

.popover-card {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  min-width: 220px;
  padding: 8px;
  border-radius: 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-popover);
  transform-origin: top right;
  animation: popover-in 150ms var(--ease-out);
}

.context-menu {
  position: fixed;
  top: auto;
  right: auto;
  z-index: 250;
  min-width: 214px;
  transform-origin: top left;
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: none;
  border-radius: var(--r-btn);
  background-color: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 110ms ease, transform 90ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .menu-item:hover {
    background-color: var(--bg-hover);
  }
  .menu-item-danger:hover {
    background-color: var(--danger-bg);
  }
}

.menu-item:active {
  transform: scale(0.98);
}

.menu-item-icon {
  display: inline-flex;
  color: var(--text-secondary);
}

.menu-group-gap {
  margin-top: 8px;
}

.menu-item-danger,
.menu-item-danger .menu-item-icon {
  color: var(--danger-text);
}

/* ============================================================================
   Row 2 Right Card (flex: 1): Unified Editor Card + Integrated Bottom Status
   ============================================================================ */

.workspace-card {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Subtle Reopen Handle on Right Edge when Right Sidebar is Minimized */
/* ============================================================================
   Retractable Quick-Actions Bar — 4 Distinct Pro Layouts
   (Figma Bottom Dock · Photoshop Vertical Rail · Word Labeled Ribbon)
   ============================================================================ */

.tools-handle {
  position: absolute;
  z-index: 32;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--border-card);
  background-color: var(--bg-subcard);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  opacity: 0.62;
  transition: opacity 150ms ease, background-color 140ms ease, color 140ms ease, transform 160ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .tools-handle:hover {
    opacity: 1;
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

.tools-handle:active {
  transform: scale(0.96);
}

.tools-handle-icon {
  display: inline-flex;
}

/* Base Quick Actions Bar & Tool Buttons */
.quick-actions-wrap {
  z-index: 35;
}

/* While the bar swells out of its handle (animateQaBar) it is laid out as open,
   and its box is sized frame by frame */
.workspace-card[data-tools-anim][data-tools-layout] .quick-actions-wrap {
  display: block;
  opacity: 1 !important;
  transform: var(--qa-open-transform, none) !important;
  pointer-events: none !important;
}

.workspace-card[data-tools-anim][data-tools-layout="photoshop"] .quick-actions-wrap {
  display: flex;
}

.workspace-card[data-tools-anim] .quick-actions-bar {
  justify-content: center;
  min-width: 0 !important;
  min-height: 0 !important;
  flex-wrap: nowrap !important;
  overflow: hidden !important;
}

/* The ribbon rolls up completely, padding included */
.workspace-card[data-tools-anim][data-tools-layout="word"] .quick-actions-bar {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.workspace-card[data-tools-anim] .quick-actions-bar > * {
  flex-shrink: 0;
}

.workspace-card[data-tools-anim] .tools-handle {
  visibility: hidden;
}

.quick-actions-bar {
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-popover);
}

.qa-group {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qa-buttons {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.qa-ribbon-label {
  display: none;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-tertiary);
  margin-top: 4px;
  user-select: none;
}

.qa-layout-anchor {
  position: relative;
}

.qa-layout-menu {
  min-width: 196px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: none;
  border-radius: 9px;
  background-color: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, transform 100ms cubic-bezier(0.23, 1, 0.32, 1);
}

.tool-btn-text { letter-spacing: -0.02em; }

@media (hover: hover) and (pointer: fine) {
  .tool-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

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

/* --- Directional Liquid Sub-Bars (Bar emerging smoothly from inside the main bar) --- */
.qa-subbar-group {
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
}

.qa-sub-trigger {
  gap: 4px;
  padding: 0 8px;
  flex-shrink: 0;
}

.qa-subbar-group[data-open="true"] > .qa-sub-trigger {
  color: var(--text-primary);
  background-color: var(--bg-active);
}

.qa-sub-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.qa-sub-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.65;
  /* Default (Bottom Dock): points UP */
  transform: rotate(-90deg);
  transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1), opacity 150ms ease;
}

.qa-subbar-group[data-open="true"] .qa-sub-caret {
  opacity: 1;
  transform: rotate(90deg);
}

/* Flyout: an extension of the bar itself. Its outline is one vector shape,
   redrawn on every frame (drawQaTray), so the corners and the body grow and
   shrink together and there are no joins to leave seams.
   --qa-edge is the distance from the trigger to the bar's edge and --qa-shift
   keeps the flyout inside the card (both measured in placeQaTray). */
.qa-sub-tray {
  --qa-fly-bg: var(--bg-card);
  --qa-fly-line: var(--border-card);
  position: absolute;
  left: calc(50% + var(--qa-shift, 0px));
  bottom: calc(100% + var(--qa-edge, 4px));
  z-index: 48;
  display: flex;
  align-items: center;
  padding: 4px 8px;
  transform: translateX(-50%);
  visibility: hidden;
  pointer-events: none;
}

.qa-subbar-group[data-open="true"] > .qa-sub-tray {
  pointer-events: auto;
}

.qa-shape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  /* The shadow never falls back onto the bar */
  clip-path: inset(-32px -32px -1px -32px);
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.28));
}

.workspace-card .qa-shape .qa-shape-fill {
  fill: var(--qa-fly-bg);
  stroke: none;
}

.workspace-card .qa-shape .qa-shape-line {
  fill: none;
  stroke: var(--qa-fly-line);
  stroke-width: 1;
}

.qa-sub-tray-inner {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* Top ribbon: horizontal bar -> flyout grows DOWNWARD */
.workspace-card[data-tools-layout="word"] .qa-sub-caret {
  transform: rotate(90deg);
}
.workspace-card[data-tools-layout="word"] .qa-subbar-group[data-open="true"] .qa-sub-caret {
  transform: rotate(-90deg);
}
.workspace-card[data-tools-layout="word"] .qa-sub-tray {
  top: calc(100% + var(--qa-edge, 4px));
  bottom: auto;
  padding: 4px 8px;
}
.workspace-card[data-tools-layout="word"] .qa-shape {
  clip-path: inset(-1px -32px -32px -32px);
}

.workspace-card[data-tools-layout="word"] .qa-shape {
  filter: none;
}

/* Left Vertical Rail (photoshop): vertical bar -> vertical flyout to the RIGHT */
.workspace-card[data-tools-layout="photoshop"] .qa-sub-caret {
  transform: rotate(0deg);
}
.workspace-card[data-tools-layout="photoshop"] .qa-subbar-group[data-open="true"] .qa-sub-caret {
  transform: rotate(180deg);
}
.workspace-card[data-tools-layout="photoshop"] .qa-sub-tray {
  left: calc(100% + var(--qa-edge, 3px));
  top: calc(50% + var(--qa-shift, 0px));
  bottom: auto;
  padding: 4px;
  transform: translateY(-50%);
}
.workspace-card[data-tools-layout="photoshop"] .qa-shape {
  clip-path: inset(-32px -32px -32px -1px);
}
.workspace-card[data-tools-layout="photoshop"] .qa-sub-tray-inner {
  flex-direction: column;
}
.workspace-card[data-tools-layout="photoshop"] .qa-sub-tray-inner .tbl-pill-btn {
  justify-content: center;
  align-self: stretch;
  height: 22px;
}
.workspace-card[data-tools-layout="photoshop"] .qa-sub-tray-inner > .tbl-tray-sep {
  width: 100%;
  height: 1px;
  margin: 4px 0;
}
/* The rich table panels keep their own rows */
.workspace-card[data-tools-layout="photoshop"] .qa-sub-tray-inner.qa-tbl-stack {
  align-items: flex-start;
}
.workspace-card[data-tools-layout="photoshop"] .qa-tbl-tray-rich {
  padding: 8px;
}

.workspace-card[data-tools-docked="true"] .qa-shape {
  filter: none;
}

@media (prefers-reduced-motion: reduce) {
  .qa-sub-caret {
    transition-duration: 120ms;
  }
}

/* --- LAYOUT 1: FIGMA (Floating Bottom Dock Card) --- */
.workspace-card[data-tools-layout="figma"] .tools-handle {
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  height: 28px;
  padding: 0 16px;
  border-radius: 10px;
}

.workspace-card[data-tools-layout="figma"] .tools-handle:active {
  transform: translateX(-50%) scale(0.96);
}

.workspace-card[data-tools-layout="figma"] .quick-actions-wrap {
  position: absolute;
  left: 50%;
  bottom: 48px;
  width: max-content;
  max-width: calc(100% - 20px);
  transform: translate3d(-50%, 10px, 0) scale(0.96);
  opacity: 0;
  pointer-events: none;
}

.workspace-card[data-tools-layout="figma"][data-tools-open="true"] .quick-actions-wrap {
  transform: translate3d(-50%, 0, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.workspace-card[data-tools-layout="figma"] .quick-actions-bar {
  padding: 4px;
  gap: 4px;
  border-radius: 12px;
  flex-wrap: wrap;
  row-gap: 4px;
  justify-content: center;
}

.workspace-card[data-tools-layout="figma"] .qa-group {
  padding: 0 4px;
  border-radius: 0;
  background-color: transparent;
  border-left: 1px solid var(--border-subcard);
}

.workspace-card[data-tools-layout="figma"] .qa-group:first-child {
  border-left: none;
  padding-left: 4px;
}

.workspace-card[data-tools-layout="figma"] .tool-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border-radius: 7px;
}

.workspace-card[data-tools-layout="figma"] .qa-layout-menu {
  top: auto;
  bottom: calc(100% + 8px);
  right: 0;
  transform-origin: bottom right;
}

.workspace-card[data-tools-layout="figma"][data-tools-open="true"] .editor-canvas {
  padding-bottom: 88px;
}

/* --- LAYOUT 2: PHOTOSHOP (Vertical Left Tool Rail Card) --- */
.workspace-card[data-tools-layout="photoshop"] .tools-handle {
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 54px;
  padding: 0;
  border-radius: var(--r-btn);
}

.workspace-card[data-tools-layout="photoshop"] .tools-handle .tools-handle-label {
  display: none;
}

.workspace-card[data-tools-layout="photoshop"] .tools-handle:active {
  transform: translateY(-50%) scale(0.96);
}

.workspace-card[data-tools-layout="photoshop"] .quick-actions-wrap {
  position: absolute;
  left: 8px;
  top: 12px;
  bottom: 48px;
  display: flex;
  align-items: center;
  transform: translate3d(-14px, 0, 0) scale(0.97);
  opacity: 0;
  pointer-events: none;
}

.workspace-card[data-tools-layout="photoshop"][data-tools-open="true"] .quick-actions-wrap {
  transform: translate3d(0, 0, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.workspace-card[data-tools-layout="photoshop"] .quick-actions-bar {
  flex-direction: column;
  width: 36px;
  max-height: 100%;
  overflow: visible;
  scrollbar-width: none;
  padding: 4px;
  gap: 4px;
  border-radius: 11px;
}

.workspace-card[data-tools-layout="photoshop"] .quick-actions-bar::-webkit-scrollbar {
  display: none;
}

.workspace-card[data-tools-layout="photoshop"] .qa-group {
  width: 100%;
  padding: 4px 0 0;
  border-radius: 0;
  background-color: transparent;
  border-top: 1px solid var(--border-subcard);
}

.workspace-card[data-tools-layout="photoshop"] .qa-group:first-child {
  border-top: none;
  padding-top: 0;
}

.workspace-card[data-tools-layout="photoshop"] .qa-buttons {
  flex-direction: column;
  width: 100%;
}

.workspace-card[data-tools-layout="photoshop"] .tool-btn {
  width: 28px;
  min-width: 28px;
  height: 24px;
  padding: 0;
  border-radius: 7px;
  font-size: 12px;
}

.workspace-card[data-tools-layout="photoshop"] .qa-sub-trigger {
  gap: 0;
}

.workspace-card[data-tools-layout="photoshop"] .qa-layout-menu {
  top: auto;
  bottom: 0;
  left: calc(100% + 8px);
  right: auto;
  transform-origin: bottom left;
}

.workspace-card[data-tools-layout="photoshop"] .editor-canvas {
  padding-left: max(64px, 4%);
}

/* --- LAYOUT 3: WORD (Structured Top Labeled Ribbon Card) --- */
.workspace-card[data-tools-layout="word"] .tools-handle {
  left: 50%;
  top: 7px;
  transform: translateX(-50%);
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-btn);
}

.workspace-card[data-tools-layout="word"] .tools-handle:active {
  transform: translateX(-50%) scale(0.96);
}

.workspace-card[data-tools-layout="word"] .quick-actions-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 38;
  padding: 0;
  display: none;
  transform: translate3d(0, -6px, 0);
  opacity: 0;
}

.workspace-card[data-tools-layout="word"][data-tools-open="true"] .quick-actions-wrap {
  display: block;
  transform: translate3d(0, 0, 0);
  opacity: 1;
}

@keyframes ribbon-in {
  from { opacity: 0; transform: translate3d(0, -6px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.workspace-card[data-tools-layout="word"] .quick-actions-bar {
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  min-height: var(--row-top-h);
  row-gap: 4px;
  padding: 8px 16px;
  border-radius: 0;
  background-color: transparent;
  border: none;
  border-bottom: 1px solid var(--border-card);
  box-shadow: none;
}

.workspace-card[data-tools-layout="word"] .qa-group {
  padding: 0 4px;
  border-radius: 0;
  background-color: transparent;
  border: none;
  border-left: 1px solid var(--border-subcard);
}

.workspace-card[data-tools-layout="word"] .qa-group:first-child {
  border-left: none;
}

.workspace-card[data-tools-layout="word"] .tool-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
}

.workspace-card[data-tools-layout="word"] .tool-btn svg {
  width: 15px;
  height: 15px;
}

.workspace-card[data-tools-layout="figma"] .tool-btn svg,
.workspace-card[data-tools-layout="photoshop"] .tool-btn svg {
  width: 14px;
  height: 14px;
}

.workspace-card .tool-btn .qa-sub-caret svg {
  width: 10px;
  height: 10px;
}

#btn-qa-dock[aria-pressed="true"] {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

/* --- Docked: the bar sits flush against its edge, without moving the text --- */
.workspace-card[data-tools-docked="true"] .quick-actions-bar {
  border-radius: 0;
  box-shadow: none;
}

.workspace-card[data-tools-docked="true"][data-tools-layout="figma"] .quick-actions-wrap {
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  max-width: none;
  transform: translate3d(0, 10px, 0);
}

.workspace-card[data-tools-docked="true"][data-tools-layout="figma"][data-tools-open="true"] .quick-actions-wrap {
  transform: none;
}

.workspace-card[data-tools-docked="true"][data-tools-layout="figma"] .quick-actions-bar {
  min-height: 40px;
  border-width: 1px 0 0;
}

.workspace-card[data-tools-docked="true"][data-tools-layout="figma"][data-tools-open="true"] .workspace-footer {
  margin-bottom: 48px;
}

.workspace-card[data-tools-docked="true"][data-tools-layout="photoshop"] .quick-actions-wrap {
  left: 0;
  top: 0;
  bottom: 0;
  align-items: stretch;
  transform: translate3d(-14px, 0, 0);
}

.workspace-card[data-tools-docked="true"][data-tools-layout="photoshop"][data-tools-open="true"] .quick-actions-wrap {
  transform: none;
}

.workspace-card[data-tools-docked="true"][data-tools-layout="photoshop"] .quick-actions-bar {
  width: 40px;
  height: 100%;
  max-height: none;
  justify-content: center;
  border-width: 0 1px 0 0;
}

.workspace-card[data-tools-docked="true"][data-tools-layout="photoshop"][data-tools-open="true"] .workspace-footer {
  padding-left: 64px;
}

/* With the sidebar collapsed, the navigation dock occupies the top-left corner */
.app-stage.sidebar-collapsed:not(.force-sidebar-open) .workspace-card[data-tools-docked="true"][data-tools-layout="photoshop"] .quick-actions-wrap {
  top: var(--row-top-h);
}

/* Settings Layout Gallery Cards (4 Miniature Wireframe Previews) */
.layout-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 920px) {
  .layout-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.layout-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, transform 100ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .layout-card:hover { border-color: var(--border-strong); }
}

.layout-card:active { transform: scale(0.98); }

.layout-card.is-active {
  border-color: var(--btn-primary-bg);
  box-shadow: 0 0 0 1px var(--btn-primary-bg);
}

.layout-wireframe {
  position: relative;
  height: 54px;
  border-radius: 7px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  overflow: hidden;
  padding: 8px;
}

.lw-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px auto 0;
  width: 58%;
}

.lw-line {
  height: 3px;
  border-radius: 99px;
  background-color: var(--border-strong);
}

.lw-line.short { width: 62%; }

.lw-bar {
  position: absolute;
  border-radius: 4px;
  background-color: var(--btn-primary-bg);
  opacity: 0.78;
}

.lw-figma .lw-bar {
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  width: 56%;
  height: 7px;
}

.lw-photoshop .lw-bar {
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 7px;
}

.lw-photoshop .lw-lines { margin-left: 24%; }

.lw-word .lw-bar {
  left: 5px;
  right: 5px;
  top: 5px;
  height: 9px;
}

.lw-word .lw-lines { margin-top: 16px; }

.layout-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.layout-card-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.3;
}

/* Find-in-Note Sub-Card */
.find-subcard {
  position: absolute;
  top: 52px;
  right: 12px;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 4px 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-popover);
}

.find-icon {
  display: inline-flex;
  color: var(--text-tertiary);
}

.find-input {
  width: 164px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  user-select: text;
}

.find-input:focus-visible { outline: none; }
.find-input::placeholder { color: var(--text-tertiary); }

.find-count {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  padding: 0 4px;
  white-space: nowrap;
}

.find-nav-btn {
  width: 26px;
  height: 26px;
}

/* Trashed Notice Sub-Card */
.notice-subcard-wrap {
  padding: 8px 8px 0;
  flex-shrink: 0;
}

.notice-subcard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  font-size: 13px;
  color: var(--text-secondary);
}

.inline-notice-copy {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.inline-notice-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Editor Split Workspace (Writing Canvas + Floating Right Outline Panel — Invariable Note Centering) */
.workspace-row {
  position: relative;
}

.editor-split {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
  position: relative;
}

.editor-canvas {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px 48px 72px;
  transition: padding-top 260ms var(--ease-out);
}

.editor-measure {
  width: 100%;
  max-width: var(--editor-measure);
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: max-width 180ms var(--ease-out);
}

.workspace-card[data-width-mode="full"] .editor-measure {
  max-width: 100%;
}

.workspace-card[data-width-mode="focused"] .editor-measure {
  max-width: min(62ch, var(--editor-measure));
}

.outline-add-btn {
  margin-top: 4px;
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  align-self: flex-start;
}

.detail-link-btn {
  border: none;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: var(--r-kbd);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .detail-link-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

/* Companion Right Inspector Pane (Spacious, Breathable Pane — Never cramped) */
.doc-outline-panel {
  position: relative;
  flex: 0 0 clamp(296px, 26vw, 316px);
  width: clamp(296px, 26vw, 316px);
  margin-left: 0;
  border-radius: 0;
  border-left: 1px solid var(--border-subcard);
  display: flex;
  overflow: hidden;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  will-change: width, opacity;
  transition:
    width var(--panel-time) var(--panel-ease),
    flex-basis var(--panel-time) var(--panel-ease),
    opacity var(--panel-time) var(--panel-ease),
    border-color var(--panel-time) var(--panel-ease);
}

/* Fixed width inside the moving panel: content slides in instead of reflowing */
.doc-outline-panel > .outline-inner {
  flex: 0 0 auto;
  width: calc(clamp(296px, 26vw, 316px) - 1px);
}

.doc-outline-panel.is-collapsed {
  width: 0;
  flex-basis: 0;
  margin-left: 0;
  opacity: 0;
  border-left-width: 0;
  border-color: transparent;
  pointer-events: none;
}

.outline-inner {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

@media (max-width: 1040px) {
  :root {
    --outline-w: 204px;
  }
  .editor-canvas {
    padding: 32px 32px 64px;
  }
}

@media (max-width: 820px) {
  .command-card .icon-btn {
    width: 28px;
    height: 28px;
  }
  .editor-canvas {
    padding: 24px 24px 56px;
  }
}

@media (max-width: 760px) {
  .command-card.has-outline-open .cmd-trailing-zone {
    flex: 0 0 auto;
    width: auto;
    padding-left: 0;
  }
}

.outline-head-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.outline-collapse-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.outline-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  border-radius: 0;
  background-color: transparent;
  border: none;
}

.outline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.outline-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-tertiary);
}

.outline-search-input {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-subcard);
  border-radius: var(--r-kbd);
  background-color: var(--bg-subcard);
  color: var(--text-primary);
  font-size: 12px;
}

.outline-search-input::placeholder { color: var(--text-tertiary); }

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

.outline-item {
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  border: none;
  border-radius: var(--r-kbd);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.35;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
}

.outline-item.lvl-2 { padding-left: 16px; font-size: 12px; }
.outline-item.lvl-3 { padding-left: 24px; font-size: 11.5px; color: var(--text-tertiary); }

@media (hover: hover) and (pointer: fine) {
  .outline-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

.outline-empty {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.45;
  padding: 4px 0;
}

.outline-details {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-subcard);
}

.details-grid {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.details-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.details-row dt {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.details-row dd {
  margin: 0;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 0;
}

.tasks-progress {
  height: 5px;
  border-radius: var(--r-pill);
  background-color: var(--bg-subcard);
  overflow: hidden;
  margin-top: 4px;
}

/* ============================================================================
   Sidebar View Bar, Compact Display Mode, Folder Hierarchy & Right File Tree
   ============================================================================ */

.sidebar-view-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 4px;
}

.sidebar-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: 7px;
  background-color: transparent;
  color: var(--text-tertiary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  transition: background-color 120ms ease, color 120ms ease;
}

.sidebar-view-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1.5px var(--focus-ring);
}

.sidebar-view-btn.sidebar-icon-toggle,
.sidebar-view-btn:last-child {
  flex: 0 0 26px;
  padding: 0;
}

.sidebar-view-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-view-btn.is-active,
.sidebar-view-btn[aria-pressed="true"] {
  background-color: var(--bg-subcard);
  color: var(--text-primary);
}

.search-input:focus-visible,
.sidebar-filter-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1.5px var(--focus-ring);
}

/* Compact display mode */
.notes-list[data-display-mode="compact"] {
  gap: 4px;
}

.notes-list[data-display-mode="compact"] .note-card-main {
  padding: 4px 8px;
  gap: 4px;
}

.notes-list[data-display-mode="compact"] .note-item-title {
  font-size: 12.5px;
}

.notes-list[data-display-mode="compact"] .note-item-excerpt {
  display: none;
}

.notes-list[data-display-mode="compact"] .note-item-foot {
  margin-top: 0;
}

.notes-list[data-display-mode="compact"] .note-item-date {
  font-size: 10.5px;
}

/* Hierarchical folder rows inside sidebar */
.folder-tree-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sub);
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.notes-list[data-display-mode="compact"] .folder-row {
  padding: 4px 8px;
  font-size: 12px;
}

.folder-row:hover {
  background-color: var(--bg-hover);
}

.folder-row.is-active {
  background-color: var(--bg-active);
}

.folder-row.is-drag-over,
.tree-folder-row.is-drag-over,
.tree-root-drop.is-drag-over,
.folder-chip.is-drag-over {
  background-color: color-mix(in srgb, var(--accent, var(--btn-primary-bg)) 14%, transparent);
  border-color: var(--focus-ring);
}

.note-card.is-dragging {
  opacity: 0.46;
  transform: scale(0.98);
  transition: opacity 140ms ease, transform 140ms var(--ease-out);
}

.note-card.is-drop-before {
  transform: translateY(5px);
  box-shadow: 0 -2px 0 0 var(--text-primary);
  transition: transform 160ms var(--ease-out), box-shadow 120ms ease;
}

.note-card.is-drop-after {
  transform: translateY(-5px);
  box-shadow: 0 2px 0 0 var(--text-primary);
  transition: transform 160ms var(--ease-out), box-shadow 120ms ease;
}

.note-card.is-pin-flying {
  position: relative;
  z-index: 12;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.note-card.is-favoriting {
  animation: note-fav-pulse 320ms var(--ease-out);
}

.note-card.is-favoriting .star-badge-filled {
  animation: fav-star-pop 220ms var(--ease-out);
}

@keyframes note-fav-pulse {
  0% { background-color: color-mix(in srgb, var(--star-color) 12%, var(--bg-card)); }
  100% { background-color: transparent; }
}

@keyframes fav-star-pop {
  0% { transform: scale(0.86); }
  55% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.folder-row-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
  transition: transform 150ms var(--ease-out);
  flex-shrink: 0;
}

.folder-row.is-expanded .folder-row-chevron {
  transform: rotate(90deg);
}

.folder-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.folder-row-name {
  flex: 1 1 auto;
  min-width: 0;
}

.folder-row-children {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 16px;
}

/* Folder tag is redundant for notes already nested under their folder */
.notes-list .folder-row-children .note-item-folder {
  display: none;
}

.folder-row-children[hidden] {
  display: none;
}

/* Right-hand File Tree Pane */
.file-tree-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.file-tree-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.file-tree-root {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tree-root-drop {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px dashed var(--border-subcard);
  border-radius: 8px;
  color: var(--text-tertiary);
  font-size: 11px;
  margin-bottom: 4px;
}

.tree-folder-row,
.tree-note-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease, border-color 110ms ease;
}

.tree-folder-row:hover,
.tree-note-row:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.tree-note-row.is-active {
  background-color: var(--bg-active);
  color: var(--text-primary);
  font-weight: 500;
}

.tree-folder-children {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 16px;
  margin-left: 8px;
  border-left: 1px solid var(--border-subcard);
}

.tree-folder-children[hidden] {
  display: none;
}

/* Folder style modal swatches & icon grid */
.folder-style-icons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.folder-style-icon-btn {
  height: 32px;
  border: 1px solid var(--border-subcard);
  border-radius: 8px;
  background: var(--bg-subcard);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.folder-style-icon-btn.is-active {
  border-color: var(--text-primary);
  background: var(--bg-active);
  color: var(--text-primary);
}

.folder-style-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.folder-style-color-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
}

.folder-style-color-btn.is-active {
  border-color: var(--text-primary);
  transform: scale(1.1);
}

.tasks-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--r-pill);
  background-color: var(--btn-primary-bg);
  transition: width 200ms var(--ease-out);
}

.note-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 8px;
  margin-bottom: 8px;
}

/* Document Folder Path Control inside Editor Meta */
.doc-path-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.path-segment-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border-subcard);
  border-radius: var(--r-kbd);
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .path-segment-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

.note-timestamp {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--r-kbd);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.editor-title {
  width: 100%;
  padding: 4px 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: clamp(26px, 2.6vw, 32px);
  font-weight: 650;
  line-height: 1.24;
  letter-spacing: -0.025em;
  user-select: text;
}

.editor-title:focus-visible { outline: none; }
.editor-title::placeholder { color: var(--text-tertiary); opacity: 0.48; font-weight: 500; }

.editor-body {
  width: 100%;
  flex: 1 1 auto;
  min-height: 320px;
  padding: 4px 0 32px;
  border: none;
  resize: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--editor-font);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  letter-spacing: 0;
  user-select: text;
  overflow: hidden;
}

.editor-body:focus-visible { outline: none; }
.editor-body::placeholder { color: var(--text-tertiary); }

/* Markdown Preview */
.markdown-preview {
  user-select: text;
  color: var(--text-primary);
  font-family: var(--editor-font);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  padding-bottom: 32px;
  word-wrap: break-word;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  font-family: var(--font-sans);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 24px 0 8px;
  text-wrap: balance;
}

.markdown-preview h1 { font-size: 1.45em; }
.markdown-preview h2 { font-size: 1.22em; }
.markdown-preview h3 { font-size: 1.05em; }
.markdown-preview p { margin: 0 0 16px; }
.markdown-preview ul,
.markdown-preview ol { margin: 0 0 16px; padding-left: 24px; }
.markdown-preview li { margin: 4px 0; }

.markdown-preview .task-item {
  list-style: none;
  margin-left: -24px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.markdown-preview .task-item input[type="checkbox"] {
  accent-color: var(--btn-primary-bg);
  cursor: pointer;
}

.markdown-preview .task-item.is-done span {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.markdown-preview blockquote {
  position: relative;
  margin: 16px 0;
  padding: 8px 16px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  color: var(--text-secondary);
}

.markdown-preview blockquote::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: var(--r-pill);
  background-color: var(--border-strong);
}

.markdown-preview code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 4px 8px;
  border-radius: var(--r-kbd);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.markdown-preview pre {
  margin: 16px 0;
  padding: 16px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  overflow-x: auto;
}

.markdown-preview pre code { padding: 0; border: none; background: transparent; }

.markdown-preview hr {
  border: none;
  height: 3px;
  width: 48px;
  border-radius: var(--r-pill);
  background-color: var(--bg-active);
  margin: 24px auto;
}

/* Integrated Transparent Bottom Status Strip (Floating at Bottom of Writing Block — Zero Layout Shift) */
.workspace-footer {
  position: absolute;
  left: 0;
  right: 12px;
  bottom: 0;
  z-index: 25;
  height: 38px;
  padding: 4px 8px 4px 24px;
  border-bottom-left-radius: var(--r-card);
  background-color: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.workspace-footer .status-leading,
.workspace-footer .status-metrics {
  pointer-events: auto;
}

/* Long notes scroll behind the footer: fade them out so the status stays legible.
   Custom page surfaces and backdrops keep their own colour showing through. */
.editor-split:not([data-page-surface="custom"]):not([data-has-backdrop="true"]) ~ .workspace-footer {
  background-image: linear-gradient(to top, var(--bg-card) 72%, transparent);
}

.status-metrics {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* One line at any width: the save status shortens first, then the counters
   and the sync label give way */
.workspace-footer {
  container: note-footer / inline-size;
  gap: 16px;
  white-space: nowrap;
}

.workspace-footer .status-leading {
  flex: 0 1 auto;
  overflow: hidden;
}

.workspace-footer #save-status {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-footer .status-dot-sep,
.workspace-footer .footer-path-control,
.workspace-footer .sync-status-pill,
.workspace-footer .status-metrics {
  flex-shrink: 0;
}

@container note-footer (max-width: 520px) {
  #metric-chars,
  .status-metrics .status-dot-sep {
    display: none;
  }
}

@container note-footer (max-width: 420px) {
  .status-metrics,
  .status-leading .sync-status-pill span {
    display: none;
  }
}

.status-dot-sep {
  width: 3px;
  height: 3px;
  border-radius: var(--r-pill);
  background-color: var(--text-tertiary);
  opacity: 0.55;
}

/* Empty & Locked States */
.empty-state,
.locked-gate {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.empty-card,
.locked-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px;
  border-radius: var(--r-card);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.empty-icon,
.locked-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-title,
.locked-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-wrap: balance;
}

.empty-copy,
.locked-subtitle {
  margin: 0 0 8px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  text-wrap: pretty;
}

.unlock-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

/* ============================================================================
   Buttons, Inputs & Toggles
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 34px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 130ms ease, border-color 130ms ease, color 130ms ease, transform 100ms var(--ease-out);
}

.btn:active { transform: scale(0.97); }
.btn-primary { background-color: var(--btn-primary-bg); color: var(--btn-primary-text); }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background-color: var(--btn-primary-hover); }
  .btn-secondary:hover { background-color: var(--bg-hover); }
  .btn-ghost:hover { background-color: var(--bg-hover); color: var(--text-primary); }
  .btn-danger:hover { background-color: var(--danger-solid-hover); }
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-ghost { background-color: transparent; color: var(--text-secondary); }
.btn-danger { background-color: var(--danger-solid); color: #ffffff; }

.field-block { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-primary); }

.text-input {
  width: 100%;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-btn);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: 13.5px;
  user-select: text;
  transition: border-color 130ms ease;
}

.text-input::placeholder { color: var(--text-tertiary); }
.text-input:focus,
.text-input:focus-visible { outline: none; border-color: var(--text-primary); }
.field-error { margin: 0; font-size: 12px; color: var(--danger-text); }

.select-input {
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-btn);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  color-scheme: inherit;
}

.select-input:focus-visible {
  outline: none;
  border-color: var(--text-primary);
}

.select-input option {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

/* Universal Custom Themed Dropdown (replaces native OS select popups) */
.folio-select-native {
  display: none !important;
}

.folio-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 156px;
  height: 36px;
  padding: 0 8px 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sub);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 450;
  text-align: left;
  cursor: pointer;
  transition: border-color 130ms ease, background-color 130ms ease;
}

.folio-select-trigger.is-block {
  width: 100%;
}

.folio-select-trigger:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.folio-select-trigger:focus-visible,
.folio-select-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--text-primary);
}

.folio-select-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folio-select-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: transform 160ms var(--ease-out);
}

.folio-select-trigger[aria-expanded="true"] .folio-select-chevron {
  transform: rotate(180deg);
}

.folio-select-menu {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  max-height: 248px;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid var(--border-card);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-popover);
  animation: popover-in 140ms var(--ease-out);
}

.folio-select-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color 100ms ease, color 100ms ease;
}

.folio-select-opt:hover,
.folio-select-opt:focus-visible {
  outline: none;
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.folio-select-opt.is-selected {
  background-color: var(--bg-active);
  color: var(--text-primary);
  font-weight: 500;
}

.folio-select-opt-check {
  display: inline-flex;
  align-items: center;
  color: var(--text-primary);
  flex-shrink: 0;
}

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.toggle-track {
  width: 38px;
  height: 22px;
  border-radius: var(--r-pill);
  background-color: var(--bg-active);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background-color 180ms var(--ease-out), border-color 180ms ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-pill);
  background-color: var(--bg-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  transition: transform 180ms var(--ease-out);
}

.toggle input:checked + .toggle-track {
  background-color: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
  background-color: var(--btn-primary-text);
}

.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ============================================================================
   Settings Single-Sidebar Category Rows & Content Pane (Unslop 4px Grid)
   ============================================================================ */

.settings-surface {
  position: absolute;
  inset: 0 0 36px 0;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: color-mix(in srgb, var(--bg-stage) 38%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow: hidden;
}

.settings-surface[hidden] {
  display: none !important;
}

.settings-modal-dialog {
  width: 100%;
  max-width: 900px;
  height: 100%;
  max-height: 100%;
  display: flex;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background-color: color-mix(in srgb, var(--bg-card) 96%, transparent);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: sheet-in 180ms var(--ease-out);
}

.settings-modal-rail {
  width: 204px;
  flex: 0 0 204px;
  border-right: 1px solid var(--border-subcard);
  background-color: color-mix(in srgb, var(--bg-subcard) 58%, transparent);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.settings-modal-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
}

.settings-modal-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.settings-modal-main {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

@media (max-width: 720px) {
  .settings-modal-rail {
    width: 158px;
    flex-basis: 158px;
  }
}

.settings-cat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
}

.settings-cat-btn {
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border: none;
  border-radius: var(--r-btn);
  background-color: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms var(--ease-out), color 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .settings-cat-btn:hover {
    background-color: var(--bg-hover);
  }
}

.settings-cat-btn:active { transform: scale(0.99); }

.settings-cat-btn.is-active {
  background-color: var(--bg-subcard);
  box-shadow: var(--top-highlight);
}

.settings-cat-btn.is-dimmed {
  opacity: 0.4;
}

.settings-cat-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.settings-cat-btn.is-active .settings-cat-icon {
  color: var(--text-primary);
}

.settings-cat-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-cat-btn.is-active .settings-cat-name {
  font-weight: 500;
  color: var(--text-primary);
}

.cat-match-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  flex-shrink: 0;
}

.settings-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px 48px 64px;
}

.settings-measure {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-search-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border-subcard);
  font-size: 13px;
  color: var(--text-secondary);
}

.settings-search-empty {
  padding: 64px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
}

.settings-search-empty p { margin: 0; font-size: 14px; }

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border-subcard);
}

.settings-section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: var(--text-primary);
}

.settings-section-lead {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.settings-group + .settings-group {
  margin-top: 24px;
}

.settings-subhead {
  margin: 0;
  padding: 4px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.settings-subhead[hidden] {
  display: none;
}

.settings-group {
  padding: 0;
  border-radius: 0;
  background-color: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 0;
  border-radius: 0;
  background-color: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subcard);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row-stack { flex-wrap: wrap; }

.settings-row-block {
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

.settings-row-block > .settings-row-info {
  flex: 0 0 auto;
}

.settings-block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 220px;
}

.settings-label { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }
.settings-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.45; }
.settings-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Theme Gallery Cards (Dual Light & Dark Swatch Preview) */
.theme-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 8px;
}

.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 100ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .theme-card:hover {
    border-color: var(--border-strong);
  }
}

.theme-card:active { transform: scale(0.98); }

.theme-card.is-active {
  border-color: var(--btn-primary-bg);
  box-shadow: 0 0 0 1px var(--btn-primary-bg);
}

.theme-preview-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 40px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border-card);
}

.theme-half {
  display: grid;
  grid-template-columns: 32% 1fr;
  gap: 4px;
  padding: 4px;
}

.theme-mini-side {
  border-radius: 3px;
}

.theme-mini-card {
  border-radius: 3px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px;
}

.theme-mini-dot {
  width: 9px;
  height: 5px;
  border-radius: var(--r-pill);
}

.theme-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}

.theme-card-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 0;
}

.theme-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: var(--r-kbd);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
}

.theme-del-btn:hover {
  background-color: var(--danger-bg);
  color: var(--danger-text);
}

/* Color Editor Grid (Individual Light / Dark / Both Side-by-Side) */
.color-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 8px;
}

.color-field-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.color-field-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.color-pickers-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-chip-label {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--r-btn);
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  cursor: pointer;
  min-width: 0;
}

.color-chip-label input[type="color"] {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.color-chip-label input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-chip-label input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border-strong);
  border-radius: 5px;
}

.color-chip-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.color-chip-mode {
  font-size: 10px;
  color: var(--text-tertiary);
}

.color-chip-hex {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.color-editor-actions {
  display: flex;
  justify-content: flex-end;
}

.path-card {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 8px;
  max-width: 100%;
  border-radius: var(--r-btn);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  user-select: text;
}

.hotkey-recorder-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.hotkey-recorder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-btn);
  background-color: var(--bg-input);
  cursor: pointer;
  transition: border-color 130ms ease, background-color 130ms ease, transform 90ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .hotkey-recorder:hover { background-color: var(--bg-hover); }
}

.hotkey-recorder:active { transform: scale(0.98); }
.hotkey-recorder.is-recording { border-color: var(--text-primary); background-color: var(--bg-subcard); }
.hotkey-recorder-hint { font-size: 12px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.reset-hotkey-btn { background-color: var(--bg-subcard); border: 1px solid var(--border-subcard); }
.hotkey-feedback { margin: 4px 0 0; font-size: 12px; color: var(--text-secondary); }
.hotkey-feedback.is-error { color: var(--danger-text); }
.hotkey-feedback.is-ok { color: var(--ok-dot); }

.range-control { display: inline-flex; align-items: center; gap: 16px; flex-shrink: 0; }
.range-control input[type="range"] { width: 124px; accent-color: var(--btn-primary-bg); cursor: pointer; }

.range-value {
  min-width: 44px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* ============================================================================
   Modal Card & Toast Card
   ============================================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background-color: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  width: 100%;
  max-width: 448px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-modal);
  overscroll-behavior: contain;
  animation: sheet-in 180ms var(--ease-out);
}

/* Note Properties Sheet inside Modal */
.props-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}

.props-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subcard);
  font-size: 13px;
}

.props-row:last-child {
  border-bottom: none;
}

.props-row dt {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.props-row dd {
  margin: 0;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 0;
  word-break: break-word;
}

.props-path-box {
  display: block;
  margin-top: 4px;
  padding: 8px;
  border-radius: var(--r-btn);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  word-break: break-all;
  user-select: text;
}

.props-badges {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.props-tag {
  padding: 4px 8px;
  border-radius: var(--r-kbd);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  font-size: 11.5px;
  color: var(--text-secondary);
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-title { margin: 0; font-size: 16px; font-weight: 500; letter-spacing: 0; }
.modal-body { display: flex; flex-direction: column; gap: 16px; font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.modal-body p { margin: 0; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* "Sincronizar" dialog */
.modal-card.modal-card-sync {
  max-width: 560px;
  max-height: calc(100dvh - 32px);
}

.modal-card-sync .modal-body,
.sync-dialog {
  min-height: 0;
}

.sync-dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sync-loading,
.sync-error {
  padding: 24px 0;
  text-align: center;
}

.sync-error {
  color: var(--danger, #dc2626);
}

.sync-dialog > .btn {
  align-self: center;
}

.sync-paths {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.sync-paths > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.sync-paths dt {
  flex: 0 0 96px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.sync-paths dd {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.sync-seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-hover);
}

.sync-seg button {
  flex: 1;
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
}

.sync-seg button[aria-pressed="true"] {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

.sync-flow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sync-flow > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border-subcard);
  border-radius: 12px;
}

.sync-flow strong {
  color: var(--text-primary);
  font-size: 13px;
}

.sync-flow span {
  font-size: 12px;
}

.sync-flow > .is-off,
.sync-folder.is-off {
  opacity: 0.5;
}

.sync-folders-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text-primary);
}

.sync-folders {
  flex: 1 1 auto;
  min-height: 80px;
  max-height: 232px;
  overflow-y: auto;
  border: 1px solid var(--border-subcard);
  border-radius: 12px;
}

.sync-folders > .sync-note {
  padding: 16px;
}

.sync-folder + .sync-folder {
  border-top: 1px solid var(--border-subcard);
}

.sync-folder-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
}

.sync-folder-main input {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--btn-primary-bg);
}

.sync-folder-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sync-folder-name {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-folder-size,
.sync-item-size {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.sync-folder-badges {
  display: flex;
  gap: 4px;
}

.sync-badge,
.sync-tag {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg-hover);
  font-size: 11.5px;
  line-height: 20px;
  white-space: nowrap;
  color: var(--text-primary);
}

.sync-tag[data-kind="new"] { background: rgba(34, 197, 94, 0.18); }
.sync-tag[data-kind="conflict"] { background: rgba(234, 179, 8, 0.24); }
.sync-tag[data-kind="deleted"] { background: rgba(220, 38, 38, 0.18); }

.sync-folder details {
  padding: 0 12px 8px 40px;
  font-size: 12px;
}

.sync-folder summary {
  cursor: pointer;
  color: var(--text-tertiary);
}

.sync-folder ul {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.sync-folder li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.sync-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-body .sync-note {
  font-size: 12px;
  color: var(--text-tertiary);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 52px;
  z-index: 260;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-sub);
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-size: 13px;
  box-shadow: var(--shadow-popover);
  transition: opacity 160ms var(--ease-out), transform 180ms var(--ease-out);
}

.toast-action {
  border: none;
  border-radius: var(--r-kbd);
  background-color: rgba(128, 128, 128, 0.28);
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

@media (max-width: 780px) {
  :root { --sidebar-w: 224px; }
  .editor-canvas { padding: 24px 24px 48px; }
  .settings-scroll { padding: 16px 16px 48px; }
  .cmd-leading { flex-basis: 120px; }
}

/* ============================================================================
   Cloud Sync Status Pill, Account Modal & iPhone / Mobile PWA Adaptations
   ============================================================================ */

.status-leading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sync-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border-subcard);
  border-radius: var(--r-pill);
  background-color: var(--bg-subcard);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .sync-status-pill:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

.sync-status-pill.is-ok {
  color: var(--text-secondary);
}

.sync-status-pill.is-syncing {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.sync-status-pill.is-error {
  color: var(--danger-text);
  border-color: var(--danger-text);
}

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

.icon.is-spinning {
  animation: folio-spin 900ms linear infinite;
}

.account-form {
  margin: 0;
}

.account-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  width: 100%;
}

.account-form .sync-server-details {
  width: 100%;
}

.account-message {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.account-message.is-error {
  color: var(--danger-text);
}

/* Rows that only apply in a given state; settings search never overrides this */
.is-gated {
  display: none !important;
}

.sync-server-details {
  padding: 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.sync-server-details[open] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-server-summary {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

:root[data-platform="pwa"] .win-cluster,
:root[data-platform="pwa"] #btn-always-on-top,
:root[data-platform="pwa"] #btn-pick-folder,
:root[data-platform="pwa"] #btn-open-folder,
:root[data-platform="pwa"] [data-menu-action="reveal-folder"] {
  display: none !important;
}

/* ============================================================================
   3-Mode Editor (Normal WYSIWYG, Obsidian Live Preview & Raw Markdown)
   + Per-Note Custom Color Swatches & Adaptive Note Surfaces
   ============================================================================ */

#editor-view[data-note-tinted="true"] {
  background-color: var(--note-card-bg, var(--bg-card));
  border-color: var(--note-border-color, var(--border-card));
  transition: background-color 180ms ease, border-color 180ms ease;
}

#editor-view[data-note-tinted="true"] .path-segment-btn,
#editor-view[data-note-tinted="true"] .meta-badge,
#editor-view[data-note-tinted="true"] .markdown-preview blockquote,
#editor-view[data-note-tinted="true"] .markdown-preview code,
#editor-view[data-note-tinted="true"] .markdown-preview pre,
#editor-view[data-note-tinted="true"] .live-line-rendered blockquote,
#editor-view[data-note-tinted="true"] .live-line-rendered code {
  background-color: var(--note-subcard-bg, var(--bg-subcard));
  border-color: var(--note-border-color, var(--border-subcard));
}

.note-color-trigger {
  position: relative;
}

.note-color-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background-color: var(--bg-subcard);
  border: 1.75px solid var(--text-secondary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  transition: transform 120ms ease, background-color 120ms ease;
}

.note-color-popover {
  top: calc(100% + 8px);
  right: 0;
  width: 214px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-popover-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 4px;
}

.note-color-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.note-color-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border-radius: var(--r-btn);
  border: 1.5px solid var(--border-strong);
  cursor: pointer;
  position: relative;
  transition: transform 100ms ease, border-color 120ms ease;
}

.note-color-swatch:hover {
  transform: scale(1.06);
}

.note-color-swatch.is-active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 1.5px var(--text-primary);
}

.note-color-custom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  border-radius: var(--r-btn);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.note-color-custom-row input[type="color"] {
  width: 22px;
  height: 22px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.note-card-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

/* Mode 1: Normal / Word-like WYSIWYG Rich Editor (Zero Markdown Symbols) */
.rich-editor {
  flex: 1 1 auto;
  min-height: 320px;
  padding: 4px 0 48px;
  outline: none;
  user-select: text;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  pointer-events: none;
}

.rich-editor h1:first-child,
.rich-editor h2:first-child,
.rich-editor h3:first-child,
.rich-editor p:first-child {
  margin-top: 4px;
}

.rich-editor ul.rich-checklist {
  list-style: none;
  padding-left: 4px;
}

.rich-editor .task-item {
  margin-left: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

/* Mode 2: Real-Time Obsidian Live Preview Editor */
.live-editor {
  flex: 1 1 auto;
  min-height: 320px;
  padding: 4px 0 48px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: text;
  user-select: text;
  font-family: var(--editor-font);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  color: var(--text-primary);
}

.live-line-rendered {
  min-height: 1.55em;
  padding: 4px;
  margin: 0 -4px;
  border-radius: 6px;
  cursor: text;
  word-break: break-word;
}

.live-line-rendered:hover {
  background-color: rgba(128, 128, 128, 0.045);
}

.live-line-rendered h1,
.live-line-rendered h2,
.live-line-rendered h3,
.live-line-rendered p,
.live-line-rendered blockquote,
.live-line-rendered ul,
.live-line-rendered ol {
  margin: 0;
}

.live-line-rendered h1 {
  font-family: var(--font-sans);
  font-size: 1.45em;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.28;
  padding: 4px 0;
}

.live-line-rendered h2 {
  font-family: var(--font-sans);
  font-size: 1.22em;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
  padding: 4px 0;
}

.live-line-rendered h3 {
  font-family: var(--font-sans);
  font-size: 1.06em;
  font-weight: 650;
  line-height: 1.35;
}

.live-line-rendered blockquote {
  padding: 4px 16px;
  border-left: 3px solid var(--border-strong);
  background-color: var(--bg-subcard);
  border-radius: 0 var(--r-kbd) var(--r-kbd) 0;
  color: var(--text-secondary);
}

.live-line-rendered code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 4px;
  border-radius: var(--r-kbd);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.live-line-input {
  width: calc(100% + 8px);
  margin: 0 -4px;
  padding: 4px;
  border: none;
  border-radius: 6px;
  background-color: rgba(128, 128, 128, 0.07);
  color: var(--text-primary);
  font-family: var(--editor-font);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  resize: none;
  overflow: hidden;
  outline: none;
  box-shadow: inset 2px 0 0 var(--btn-primary-bg);
}

.live-line-input.is-h1 {
  font-family: var(--font-sans);
  font-size: 1.45em;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.28;
}

.live-line-input.is-h2 {
  font-family: var(--font-sans);
  font-size: 1.22em;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.live-line-input.is-h3 {
  font-family: var(--font-sans);
  font-size: 1.06em;
  font-weight: 650;
}

@media (max-width: 760px) {
  .app-stage {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .leading-dock {
    top: calc(11px + env(safe-area-inset-top, 0px));
    left: 14px;
  }
  .sidebar-stack {
    position: fixed;
    top: calc(6px + env(safe-area-inset-top, 0px));
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    left: 6px;
    width: min(86vw, 310px);
    z-index: 160;
    box-shadow: var(--shadow-modal);
  }
  .app-stage.sidebar-collapsed .sidebar-stack {
    transform: translateX(-110%);
    width: min(86vw, 310px);
    opacity: 0;
    pointer-events: none;
  }
  .app-stage:not(.sidebar-collapsed) .main-stack .cmd-leading {
    padding-left: 144px;
  }
  .app-stage.sidebar-collapsed .main-stack .cmd-leading {
    padding-left: 144px;
  }
  .doc-outline-panel,
  #btn-toggle-outline,
  #btn-collapse-outline {
    display: none !important;
  }
  .editor-canvas {
    padding: 16px 16px 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .settings-scroll { scroll-behavior: auto; }
}

:root[data-reduce-motion="true"] *,
:root[data-reduce-motion="true"] *::before,
:root[data-reduce-motion="true"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

:root[data-reduce-motion="true"] .settings-scroll {
  scroll-behavior: auto;
}

/* ============================================================================
   Grouped Sidebar Filter Popover, Card vs Divider List Style & Resizable Sidebar
   ============================================================================ */

.sidebar-stack {
  position: relative;
}

/* Instantaneous zero-lag sidebar resizing (icons and border move in lockstep) */
.app-stage.is-sidebar-resizing .sidebar-stack,
.app-stage.is-sidebar-resizing .sidebar-inner,
.app-stage.is-sidebar-resizing .command-card {
  transition: none !important;
}

.sidebar-resizer {
  position: absolute;
  top: 12px;
  bottom: 12px;
  right: -3px;
  width: 6px;
  cursor: col-resize;
  z-index: 60;
  border-radius: 999px;
  transition: background-color 140ms ease;
}

.sidebar-resizer:hover,
.sidebar-resizer.is-dragging {
  background-color: var(--border-strong);
}

.app-stage.sidebar-collapsed:not(.force-sidebar-open) .sidebar-resizer {
  display: none;
}

.sidebar-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-search-row .search-field {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar-filter-anchor {
  flex-shrink: 0;
}

.sidebar-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.sidebar-filter-btn:hover,
.sidebar-filter-btn[aria-expanded="true"] {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.sidebar-filter-icon {
  display: inline-flex;
  align-items: center;
  color: var(--text-tertiary);
}

.sidebar-filter-label {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-filter-popover {
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  width: 100%;
  min-width: 216px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 210;
  box-sizing: border-box;
}

.filter-popover-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.filter-popover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-popover-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  padding: 0 4px;
}

.sidebar-filter-popover .segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  gap: 4px;
  padding: 4px;
  box-sizing: border-box;
}

.sidebar-filter-popover .segmented .seg-btn {
  width: 100%;
  justify-content: center;
  padding: 0 8px;
  height: 28px;
}

.sidebar-filter-popover .collection-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 0;
  background: transparent;
  border: none;
  width: 100%;
}

.sidebar-filter-popover .collection-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  height: auto;
  min-height: 46px;
  border-radius: 9px;
  border: 1px solid var(--border-card);
  background: var(--bg-subcard);
  text-align: center;
  font-size: 11.5px;
  line-height: 1.15;
}

.sidebar-filter-popover .collection-tab.is-active {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.sidebar-filter-popover .collection-tab .count-badge {
  font-size: 11px;
  opacity: 0.78;
}

.sidebar-filter-popover .folders-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 4px;
  width: 100%;
  overflow: visible;
  mask-image: none;
  -webkit-mask-image: none;
  padding-right: 0;
}

.sidebar-filter-popover .folders-chips .folder-chip {
  width: 100%;
  justify-content: center;
  height: 30px;
  padding: 0 8px;
  box-sizing: border-box;
}

.filter-popover-footer {
  padding-top: 8px;
  border-top: 1px solid var(--border-subcard);
  width: 100%;
}

.filter-popover-footer .menu-item {
  width: 100%;
  justify-content: center;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-card);
  background: var(--bg-subcard);
  font-weight: 500;
}

.filter-popover-footer .menu-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

/* Sidebar Bottom Footer: Settings & Utilities on Left of Engraved Shortcut */
.sidebar-engraved-footer {
  pointer-events: auto !important;
  justify-content: space-between !important;
  gap: 8px;
  padding: 8px 4px 4px !important;
  border-top: 1px solid var(--border-subcard);
  margin-top: 4px;
}

.sidebar-footer-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sidebar-footer-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

/* Note List Styles: Soft Borderless Subcards vs. 1px Dividers */
.notes-list[data-list-style="cards"] .note-card {
  --card-surface: color-mix(in srgb, var(--bg-subcard) 72%, transparent);
  background-color: var(--card-surface);
  border: none;
}

.notes-list[data-list-style="cards"] .note-card:hover {
  --card-surface: var(--bg-hover);
  background-color: var(--card-surface);
}

.notes-list[data-list-style="cards"] .note-card.is-selected {
  --card-surface: var(--bg-active);
  background-color: var(--card-surface);
  border: none;
}

.notes-list[data-list-style="dividers"] {
  gap: 0;
}

.notes-list[data-list-style="dividers"] .note-card {
  --card-surface: var(--bg-card);
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border-subcard);
  background-color: transparent;
}

.notes-list[data-list-style="dividers"] .note-card:hover {
  --card-surface: var(--bg-hover);
  background-color: var(--card-surface);
}

.notes-list[data-list-style="dividers"] .note-card.is-selected {
  --card-surface: var(--bg-subcard);
  background-color: var(--card-surface);
  box-shadow: inset 3px 0 0 var(--btn-primary-bg);
}

.notes-list[data-show-excerpts="false"] .note-item-excerpt {
  display: none !important;
}

.note-item-emoji {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  margin-right: 4px;
}

/* ============================================================================
   Pinned Bento Grid (1 to 6 Blocks Auto-Aligned & Sized by Count)
   ============================================================================ */

.pinned-bento-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.pinned-bento-grid {
  display: grid;
  gap: 8px;
  width: 100%;
}

/* Dynamic Columns & Spans for 1 to 6 Pinned Notes */
.pinned-bento-grid[data-count="1"] {
  grid-template-columns: 1fr;
}

.pinned-bento-grid[data-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pinned-bento-grid[data-count="3"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.pinned-bento-grid[data-count="3"] .pinned-bento-card:nth-child(1) {
  grid-column: span 2;
}

.pinned-bento-grid[data-count="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pinned-bento-grid[data-count="5"] {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.pinned-bento-grid[data-count="5"] .pinned-bento-card:nth-child(1),
.pinned-bento-grid[data-count="5"] .pinned-bento-card:nth-child(2) {
  grid-column: span 3;
}
.pinned-bento-grid[data-count="5"] .pinned-bento-card:nth-child(3),
.pinned-bento-grid[data-count="5"] .pinned-bento-card:nth-child(4),
.pinned-bento-grid[data-count="5"] .pinned-bento-card:nth-child(5) {
  grid-column: span 2;
}

.pinned-bento-grid[data-count="6"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Homepage wider Bento grid (3 columns on wide canvas) */
#home-pinned-grid[data-count="3"],
#home-pinned-grid[data-count="6"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#home-pinned-grid[data-count="3"] .pinned-bento-card:nth-child(1) {
  grid-column: span 1;
}

.pinned-bento-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  padding: 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  -webkit-touch-callout: none;
  transition: border-color 130ms ease, background-color 130ms ease;
}

.pinned-bento-card:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-card);
}

.pinned-bento-card.is-checked {
  background-color: var(--bg-active);
  border-color: var(--border-strong);
}

.pinned-bento-card.is-selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--text-primary);
}

.pinned-bento-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.pinned-bento-icon {
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pinned-bento-unpin {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
  transition: opacity 120ms ease;
}

.pinned-bento-card:hover .pinned-bento-unpin {
  opacity: 1;
}

.pinned-bento-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================================
   Dynamic Top Bar (#titlebar) with Integrated Tabs Strip
   ============================================================================ */

#titlebar[data-nav-mode="sidebar"] {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-bottom-color: transparent;
  background: transparent;
  pointer-events: none;
}

#titlebar[data-nav-mode="sidebar"] .cmd-leading,
#titlebar[data-nav-mode="sidebar"] .note-header-actions,
#titlebar[data-nav-mode="sidebar"] #topbar-utility-cluster,
#titlebar[data-nav-mode="sidebar"] .cmd-trailing-zone,
#titlebar[data-nav-mode="sidebar"] .popover-card {
  pointer-events: auto;
}

#titlebar[data-nav-mode="sidebar"] .cmd-drag-flex {
  height: 18px;
  align-self: flex-start;
  pointer-events: auto;
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .editor-canvas {
  padding-top: 16px;
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .note-title-bar {
  padding-right: 224px;
}

/* Narrow editor: the title drops below the floating note actions and uses the full width */
.editor-split {
  container: note-editor / inline-size;
}

@container note-editor (max-width: 760px) {
  #titlebar[data-nav-mode="sidebar"] ~ .workspace-row .note-title-bar {
    padding-right: 0;
    margin-top: 32px;
  }

  .app-stage.sidebar-collapsed:not(.force-sidebar-open) #titlebar[data-nav-mode="sidebar"] ~ .workspace-row .note-title-bar {
    margin-top: 0;
  }
}

@container note-editor (max-width: 400px) {
  .note-title-bar .editor-title,
  .note-title-bar .editor-title-fx {
    font-size: 19px;
  }
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .docs-format-ribbon {
  margin-top: var(--row-top-h);
}

/* The drawing tools sit below the floating note actions, never under them */
#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .draw-tools-tab {
  margin-top: var(--row-top-h);
  border-top: 1px solid var(--border-card);
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .draw-tools-tab:not([hidden]) ~ .editor-canvas {
  padding-top: 16px;
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .draw-tools-tab:not([hidden]) ~ .editor-canvas .note-title-bar {
  margin-top: 0;
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .outline-inner {
  padding-top: calc(var(--row-top-h) + 4px);
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .home-scroll {
  padding-top: 32px;
}

.app-stage.sidebar-collapsed:not(.force-sidebar-open) #titlebar[data-nav-mode="sidebar"] ~ .workspace-row .workspace-card:not([data-tools-layout="word"]) .editor-canvas,
.app-stage.sidebar-collapsed:not(.force-sidebar-open) #titlebar[data-nav-mode="sidebar"] ~ .workspace-row .workspace-card[data-tools-layout="word"] #editor-view:not([data-tools-open="true"]) .editor-canvas,
.app-stage.sidebar-collapsed:not(.force-sidebar-open) #titlebar[data-nav-mode="sidebar"] ~ .workspace-row .home-scroll {
  padding-top: calc(var(--row-top-h) + 8px);
}

#titlebar[data-nav-mode="tabs"] .cmd-leading {
  flex: 1 1 auto;
  max-width: none;
  overflow: hidden;
  gap: 8px;
}

#titlebar[data-nav-mode="tabs"] #toolbar-breadcrumb {
  flex: 0 1 auto;
  max-width: 150px;
  padding-right: 8px;
  border-right: 1px solid var(--border-subcard);
}

#titlebar .top-tabs-bar {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  margin-bottom: -1px;
  padding: 0;
  border-bottom: none;
  background: transparent;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

/* ============================================================================
   Minimalist Comfortable Note Title Header (Zero Divider Line)
   ============================================================================ */

.note-title-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 16px;
  padding-bottom: 0;
  border-bottom: none;
}

.note-title-input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}

.note-title-bar .editor-title {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.note-title-input-wrap.has-fx .editor-title {
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text-primary);
}

/* The effect layer draws each letter in its own box, which drops kerning and
   ligatures; turn them off on the input too so caret and glyphs line up in
   every page font (serif and rounded drifted the most). */
.note-title-input-wrap.has-fx .editor-title,
.editor-title-fx {
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: "kern" 0, "liga" 0, "calt" 0;
}

.note-title-input-wrap.has-fx .editor-title::selection {
  background-color: color-mix(in srgb, var(--accent) 26%, transparent);
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.note-title-input-wrap.has-fx .editor-title::placeholder {
  color: var(--text-tertiary);
  -webkit-text-fill-color: var(--text-tertiary);
}

.editor-title-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  white-space: pre;
  padding: 4px 0;
  border: none;
  font-family: var(--font-sans);
  font-size: clamp(26px, 2.6vw, 32px);
  font-weight: 650;
  line-height: 1.24;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  display: block;
}

.title-char {
  display: inline-block;
  will-change: transform, opacity;
}

.title-char.is-enter {
  animation: title-char-in 160ms var(--ease-out) both;
}

.title-char-ghost-anchor {
  position: relative;
  display: inline-block;
  width: 0;
  height: 1em;
  vertical-align: baseline;
  pointer-events: none;
}

.title-char.is-exit {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  animation: title-char-out 150ms var(--ease-out) forwards;
}

@keyframes title-char-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.84);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes title-char-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.76);
  }
}

.note-card.is-entering {
  animation: note-card-in 260ms var(--ease-out) both;
  overflow: hidden;
}

.note-card.is-deleting {
  pointer-events: none;
  overflow: hidden;
  animation: note-card-out 220ms var(--ease-out) forwards;
}

.doc-tab.is-entering {
  animation: doc-tab-in 210ms var(--ease-out) both;
  transform-origin: bottom center;
}

.doc-tab.is-closing {
  pointer-events: none;
  overflow: hidden;
  animation: doc-tab-out 170ms var(--ease-out) forwards;
  transform-origin: bottom center;
}

@keyframes note-card-in {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-8px) scale(0.96);
  }
  to {
    opacity: 1;
    max-height: 120px;
    transform: translateY(0) scale(1);
  }
}

@keyframes note-card-out {
  0% {
    opacity: 1;
    max-height: 110px;
    transform: translateX(0) scale(1);
  }
  55% {
    opacity: 0;
    max-height: 80px;
    transform: translateX(-16px) scale(0.94);
  }
  100% {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    transform: translateX(-18px) scale(0.92);
  }
}

@keyframes doc-tab-in {
  from {
    opacity: 0;
    max-width: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    max-width: 204px;
    min-width: 96px;
    padding-left: 8px;
    padding-right: 8px;
    transform: translateY(0);
  }
}

@keyframes doc-tab-out {
  from {
    opacity: 1;
    max-width: 204px;
    min-width: 96px;
    padding-left: 8px;
    padding-right: 8px;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    max-width: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    border-width: 0;
    transform: translateY(8px);
  }
}

.note-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.note-icon-trigger {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms ease, border-color 120ms ease, transform 100ms ease;
}

.note-icon-trigger:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
  transform: scale(1.04);
}

.note-icon-popover {
  top: calc(100% + 8px);
  left: 0;
  width: 236px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.note-icon-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.note-emoji-btn {
  height: 32px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 100ms ease, transform 100ms ease;
}

.note-emoji-btn:hover {
  background-color: var(--bg-hover);
  transform: scale(1.12);
}

.note-emoji-btn.is-active {
  background-color: var(--bg-active);
  border-color: var(--border-strong);
}

/* Footer Save & Folder Path Merged in Bottom-Left */
.footer-path-control {
  display: inline-flex;
  align-items: center;
}

.footer-path-control .doc-folder-pill {
  height: 20px;
  padding: 0 8px;
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.outline-quick-actions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subcard);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.outline-action-btn {
  width: 100%;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-btn);
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.outline-action-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================================================
   Homepage / Minimalist Full-Viewport Adaptive Hub (#home-view)
   ============================================================================ */

.home-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  container-type: size;
  container-name: hub;
}

.home-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 32px 24px;
  transition: padding-top 260ms var(--ease-out);
}

.home-canvas {
  width: 100%;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 24px;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.home-hero-copy {
  min-width: 0;
}

.home-title {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 650;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.home-subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.home-hero-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 1 auto;
}

.home-jump-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 200px;
  width: clamp(200px, 24vw, 300px);
}

.home-jump-icon {
  position: absolute;
  left: 10px;
  color: var(--text-tertiary);
  pointer-events: none;
  display: inline-flex;
}

.home-jump-input {
  width: 100%;
  height: 34px;
  padding: 0 16px 0 32px;
  border-radius: 9px;
  border: 1px solid var(--border-card);
  background-color: var(--bg-subcard);
  color: var(--text-primary);
  font-size: 12.5px;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.home-jump-input:focus {
  outline: none;
  border-color: var(--border-strong);
  background-color: var(--bg-card);
}

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

.home-util-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-subcard);
}

.home-bento-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(260px, 0.88fr);
  gap: 24px;
  align-items: start;
  min-height: 0;
}

.home-col-main,
.home-col-side {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.home-surface-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border-radius: 12px;
  border: none;
  background-color: color-mix(in srgb, var(--bg-subcard) 56%, transparent);
}

.home-recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.home-recent-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border-radius: 8px;
  border: none;
  background-color: var(--bg-card);
  text-align: left;
  cursor: pointer;
  min-width: 0;
  transition: background-color 140ms var(--ease-out);
}

.home-recent-card:hover {
  background-color: var(--bg-hover);
}

.home-recent-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.home-recent-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1 1 auto;
  min-width: 0;
}

.home-recent-excerpt {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-recent-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.home-folders-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-folder-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 9px;
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, transform 110ms var(--ease-out);
}

.home-folder-pill:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
  transform: translateY(-1px);
}

.home-guide-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subcard);
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.home-guide-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.home-guide-item kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 4px;
  border-radius: 5px;
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
}

.home-guide-dot {
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background-color: var(--border-strong);
}

/* Container Queries: Dynamically add/remove Hub items based on viewport width & height */
@container hub (max-width: 820px) {
  .home-bento-stage {
    grid-template-columns: 1fr;
  }
  .hub-action-secondary {
    display: none;
  }
  .home-jump-wrap {
    width: 100%;
    min-width: 160px;
    flex: 1 1 180px;
  }
}

@container hub (max-width: 600px) {
  .home-guide-strip,
  .home-templates-block,
  .home-primary-cta .inline-kbd {
    display: none;
  }
  .home-recent-excerpt {
    -webkit-line-clamp: 1;
  }
}

@container hub (max-height: 540px) {
  .home-guide-strip,
  .home-templates-block {
    display: none;
  }
  .home-surface-block {
    padding: 8px 16px;
  }
}

.home-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.home-section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0;
}

.btn-text-link {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
}

.btn-text-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.home-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.home-link-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, transform 100ms ease;
}

.home-link-card:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
  transform: translateY(-1px);
}

.home-link-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.home-link-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.home-link-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-link-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-link-del {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
}

.home-link-card:hover .home-link-del {
  opacity: 1;
}

.home-link-del:hover {
  background-color: var(--danger-bg);
  color: var(--danger-text);
}

.home-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.home-template-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.home-template-card:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
}

.home-template-emoji {
  font-size: 20px;
  line-height: 1;
}

.home-template-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.home-template-copy strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.home-template-copy span {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* ============================================================================
   Tables, Freehand Drawings & Wiki/External Links Inside Notes
   ============================================================================ */

.markdown-preview table,
.rich-editor table,
.live-line-rendered table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.94em;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
}

.markdown-preview th,
.markdown-preview td,
.rich-editor th,
.rich-editor td,
.live-line-rendered th,
.live-line-rendered td {
  border: 1px solid var(--border-strong);
  padding: 8px;
  text-align: left;
  min-width: 64px;
}

.markdown-preview th,
.rich-editor th,
.live-line-rendered th {
  background-color: var(--bg-subcard);
  font-weight: 600;
}

.folio-drawing-figure {
  margin: 16px 0;
  padding: 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.folio-drawing-img,
.markdown-preview img,
.rich-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

.folio-wikilink,
.folio-extlink {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  background-color: rgba(128, 128, 128, 0.1);
}

.folio-wikilink:hover,
.folio-extlink:hover {
  background-color: rgba(128, 128, 128, 0.22);
}

/* ============================================================================
   Native In-Note Drawing Layer & Dedicated Drawing Tools Tab
   ============================================================================ */

.draw-mode-trigger {
  position: relative;
}

.draw-mode-trigger.has-ink::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background-color: var(--accent, var(--text-primary));
  pointer-events: none;
}

.draw-mode-trigger[aria-pressed="true"] {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.draw-mode-trigger[aria-pressed="true"]::after {
  display: none;
}

/* Dedicated Drawing Tools Tab Bar */
.draw-tools-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 8px;
  padding: 8px 16px;
  background-color: var(--bg-subcard);
  border-bottom: 1px solid var(--border-card);
  flex-shrink: 0;
  z-index: 25;
  animation: draw-tab-in 150ms var(--ease-out);
}

@keyframes draw-tab-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.draw-tab-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 999px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  user-select: none;
}

.draw-tab-sep {
  width: 1px;
  height: 18px;
  background-color: var(--border-card);
  flex-shrink: 0;
}

.draw-tab-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.draw-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease, border-color 110ms ease, transform 90ms ease;
}

.draw-tool-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.draw-tool-btn.is-active,
.draw-tool-btn[aria-pressed="true"]:not(#btn-draw-toggle-vis) {
  background-color: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--top-highlight);
}

.draw-tool-btn.is-danger:hover {
  background-color: var(--danger-bg);
  color: var(--danger-text);
}

.draw-tool-btn:disabled {
  opacity: 0.36;
  pointer-events: none;
}

.draw-tool-btn:active {
  transform: scale(0.93);
}

/* Ink Color Swatches */
.draw-colors-group {
  gap: 4px;
}

.draw-swatch {
  position: relative;
  width: 19px;
  height: 19px;
  border-radius: 999px;
  border: 2px solid transparent;
  background-color: var(--swatch, var(--text-primary));
  cursor: pointer;
  padding: 0;
  transition: transform 110ms ease, box-shadow 110ms ease;
}

.draw-swatch.is-auto {
  background: linear-gradient(135deg, #111111 50%, #F4F4F5 50%);
  border: 1px solid var(--border-strong);
}

.draw-swatch:hover {
  border-color: var(--text-primary);
}

.draw-swatch.is-active {
  box-shadow: 0 0 0 2px var(--bg-subcard), 0 0 0 3.5px var(--text-primary);
}

.draw-swatch-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-subcard);
  border: 1px dashed var(--border-strong);
  color: var(--text-secondary);
  overflow: hidden;
}

.draw-swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

/* Stroke Width Dots */
.draw-size-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 110ms ease, border-color 110ms ease, color 110ms ease;
}

.draw-size-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.draw-size-btn.is-active {
  background-color: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.draw-size-dot {
  display: block;
  border-radius: 999px;
  background-color: currentColor;
}

/* Paper Guide Button */
.draw-paper-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-card);
  border-radius: var(--r-btn);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease, border-color 110ms ease;
}

.draw-paper-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.draw-paper-btn.is-active {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Done Button */
.draw-done-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  margin-left: 4px;
  border: none;
  border-radius: var(--r-btn);
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 110ms ease, transform 90ms ease;
}

.draw-done-btn:hover {
  opacity: 0.92;
}

.draw-done-btn:active {
  transform: scale(0.96);
}

/* Real In-Note Page Stage (Text + Ink Layer Together) */
.note-page-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 440px;
  border-radius: var(--r-sub);
  transition: background-image 150ms ease;
}

.note-page-stage.is-drawing-active {
  user-select: none;
  -webkit-user-select: none;
}

.note-ink-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  pointer-events: none;
  display: block;
}

.note-ink-canvas.is-hidden-ink {
  opacity: 0;
}

.note-page-stage.is-drawing-active .note-ink-canvas {
  pointer-events: auto;
  touch-action: none;
  cursor: crosshair;
}

.note-page-stage.is-drawing-active[data-draw-tool="eraser"] .note-ink-canvas {
  cursor: cell;
}

/* ============================================================================
   Print / Export as PDF Stylesheet (@media print)
   ============================================================================ */

@media print {
  body, html, .app-stage, .main-stack, .workspace-row, .workspace-card, .editor-split, .editor-canvas {
    background: #FFFFFF !important;
    color: #111111 !important;
    height: auto !important;
    overflow: visible !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #leading-dock,
  #sidebar,
  #titlebar,
  #doc-outline-panel,
  #format-bar-wrap,
  #draw-tools-tab,
  #btn-tools-handle,
  #btn-collapse-outline,
  #find-bar,
  .note-header-actions,
  .workspace-footer,
  #modal-backdrop,
  #toast {
    display: none !important;
  }

  .editor-measure {
    max-width: 100% !important;
    padding: 48px 56px !important;
  }

  .note-title-bar {
    border-bottom: 1px solid #CCCCCC !important;
    margin-bottom: 16px !important;
  }

  .editor-title {
    color: #000000 !important;
    -webkit-text-fill-color: #000000 !important;
    font-size: 24pt !important;
  }

  .editor-title-fx {
    display: none !important;
  }
}

/* ============================================================================
   Empty Space Hints (Icons + Shortcuts) in Sidebar & Hub Quick Actions
   ============================================================================ */

.sidebar-empty-hint {
  margin: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-tertiary);
  text-align: center;
  user-select: none;
  border: none;
  background: transparent;
  pointer-events: none;
  cursor: default;
}

.sidebar-empty-hint-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 500;
}

.sidebar-empty-hint-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
}

.home-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-hub-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.inline-kbd {
  margin-left: 4px;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.24);
  color: inherit;
  font-size: 10.5px;
}

.hub-quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
}

.hub-action-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 8px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 120ms ease, border-color 120ms ease, transform 100ms ease;
}

.hub-action-pill:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.hub-action-icon {
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.hub-action-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pinned-bento-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px;
  border-radius: 4px;
  background-color: rgba(128, 128, 128, 0.14);
  color: var(--text-secondary);
  margin-left: auto;
}

/* Custom Hotkey Rules List in Settings & Hub */
.custom-hotkeys-list,
.home-hotkeys-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.home-hotkeys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.custom-hotkey-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-sub);
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.custom-hotkey-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.custom-hotkey-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.custom-hotkey-sub {
  font-size: 11px;
  color: var(--text-tertiary);
}

.custom-hotkey-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================================================
   Note Lucide Icons & Phone-Style Full Emoji + Icon Picker
   ============================================================================ */

.note-icon-anchor {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.note-lucide-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.note-emoji-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.icon-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 260;
  background-color: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.icon-picker-sheet {
  width: 376px;
  max-width: calc(100vw - 24px);
  max-height: min(460px, calc(100vh - 32px));
  border-radius: 16px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popover-in 150ms var(--ease-out);
}

.icon-picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border-subcard);
}

.icon-picker-search-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.icon-picker-clear {
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
  flex-shrink: 0;
}

.icon-picker-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--border-subcard);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.icon-picker-tabs::-webkit-scrollbar {
  display: none;
}

.icon-picker-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.icon-picker-tab:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.icon-picker-tab.is-active {
  background-color: var(--bg-active);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.icon-picker-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.icon-picker-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin: 4px 4px 8px;
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
}

.icon-picker-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-primary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 100ms ease, transform 100ms ease, border-color 100ms ease;
}

.icon-picker-cell:hover {
  background-color: var(--bg-hover);
  transform: scale(1.1);
}

.icon-picker-cell.is-active {
  background-color: var(--bg-active);
  border-color: var(--border-strong);
}

.icon-picker-empty {
  grid-column: 1 / -1;
  padding: 32px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

/* ============================================================================
   Optimized Inline Media: Images, Embedded Audio Player, PDF & Document Cards
   ============================================================================ */

/* Previews keep the file's own size: never wider than the note's column, never
   taller than --media-max-h. A saved width (after resizing) overrides it. */
.folio-image-figure {
  --media-max-h: 480px;
  position: relative;
  display: block;
  margin: 16px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-subcard);
  box-sizing: border-box;
  width: fit-content;
  min-width: min(160px, 100%);
  max-width: 100%;
  transition: border-color 140ms ease;
}

.folio-image-figure:hover {
  border-color: var(--border-strong);
}

.folio-image-figure img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: var(--media-max-h);
  margin: 0 auto;
  object-fit: contain;
  cursor: zoom-in;
  background-color: var(--bg-stage);
}

.folio-image-figure[data-media-width]:not([data-media-width="0"]) :is(img, .folio-media-video) {
  width: 100%;
}

/* The file name never decides how wide the preview is */
.folio-image-figure > .folio-image-caption {
  width: 0;
  min-width: 100%;
  box-sizing: border-box;
}

/* Documents and text have no size of their own */
.folio-pdf-figure[data-media-width="0"] {
  width: min(100%, 520px);
}

.folio-text-figure[data-media-width="0"] {
  width: 100%;
}

.folio-audio-card[data-media-width="0"],
.folio-doc-card[data-media-width="0"] {
  width: min(100%, 480px);
}

.folio-media-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background-color: rgba(20, 20, 24, 0.76);
  backdrop-filter: blur(8px);
  color: #FFFFFF;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.folio-image-figure:hover .folio-media-toolbar,
.folio-image-figure:focus-within .folio-media-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.folio-media-tb-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  height: 24px;
  min-width: 24px;
  padding: 0 4px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.folio-media-tb-btn:hover,
.folio-media-tb-btn.is-active {
  background-color: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.folio-image-caption {
  padding: 8px;
  font-size: 11.5px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-subcard);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Inline Minimalist Audio Player Card */
.folio-audio-card {
  display: flex;
  /* Room for the button, name, time, progress and actions without overlapping,
     whatever width was saved; a narrower editor still wins */
  min-width: min(360px, 100%);
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  padding: 8px 16px;
  border-radius: 12px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  user-select: none;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.folio-audio-card:hover {
  border-color: var(--border-strong);
}

.folio-audio-play {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 100ms ease, background-color 120ms ease;
}

.folio-audio-play:hover {
  background-color: var(--btn-primary-hover);
  transform: scale(1.04);
}

.folio-audio-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folio-audio-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.folio-audio-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folio-audio-time {
  font-size: 11px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.folio-audio-seek {
  width: 100%;
  height: 4px;
  accent-color: var(--btn-primary-bg);
  cursor: pointer;
  margin: 0;
}

.folio-audio-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Inline PDF & Document Attachment Card */
.folio-doc-card {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 8px 16px;
  border-radius: 12px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  cursor: pointer;
  user-select: none;
  transition: border-color 140ms ease, background-color 140ms ease, transform 100ms ease;
}

.folio-doc-card:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
}

.folio-doc-badge {
  min-width: 38px;
  height: 36px;
  padding: 0 8px;
  border-radius: 9px;
  background-color: var(--bg-active);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.folio-doc-card.is-pdf .folio-doc-badge {
  background-color: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.28);
  color: #DC2626;
}

:root[data-theme="dark"] .folio-doc-card.is-pdf .folio-doc-badge {
  color: #F87171;
}

.folio-doc-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folio-doc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folio-doc-sub {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.folio-doc-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Organized Note Attachments Section */
.note-attachments-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subcard);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-attachments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-attachments-head-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.note-attachments-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.note-attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.att-tray-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  cursor: pointer;
  min-width: 0;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.att-tray-card:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-hover);
}

.att-tray-thumb {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  object-fit: cover;
  background-color: var(--bg-active);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
}

.att-tray-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.att-tray-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.att-tray-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.att-tray-kind {
  font-size: 10.5px;
  color: var(--text-tertiary);
}

.att-tray-btns {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Drag & Drop Overlay */
.editor-drop-overlay {
  position: absolute;
  inset: 10px;
  z-index: 90;
  border-radius: 14px;
  background-color: rgba(15, 15, 18, 0.45);
  backdrop-filter: blur(4px);
  border: 2px dashed var(--btn-primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.editor-drop-card {
  padding: 24px;
  border-radius: 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  max-width: 360px;
}

.editor-drop-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background-color: var(--bg-subcard);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.editor-drop-card strong {
  font-size: 14px;
  color: var(--text-primary);
}

.editor-drop-card span {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Built-in Media Viewer Lightbox & Embedded PDF Viewer */
.media-viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 280;
  background-color: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.media-viewer-card {
  width: min(1100px, 96vw);
  height: min(860px, 92vh);
  border-radius: 16px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.media-viewer-header {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subcard);
  background-color: var(--bg-card);
}

.media-viewer-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.media-viewer-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.media-viewer-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.media-viewer-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mv-zoom-label {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 42px;
  text-align: center;
}

.media-viewer-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-stage);
  position: relative;
}

.media-viewer-img {
  max-width: 96%;
  max-height: 94%;
  object-fit: contain;
  border-radius: 8px;
  transition: transform 140ms ease;
  transform-origin: center center;
}

.media-viewer-pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #2B2B2E;
}

.media-viewer-text {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 24px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  box-sizing: border-box;
}

/* Custom Hotkey Modal Recorder Button */
.hotkey-modal-recorder {
  width: 100%;
  min-height: 38px;
  padding: 8px 16px;
  border-radius: var(--r-btn);
  border: 1px dashed var(--border-strong);
  background-color: var(--bg-subcard);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
}

.hotkey-modal-recorder.is-recording {
  border-style: solid;
  border-color: var(--btn-primary-bg);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Quick Link Icon Picker (Lucide Icons first + optional custom emoji) */
.ql-icon-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.ql-icon-chip {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.ql-icon-chip:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.ql-icon-chip.is-active {
  background-color: var(--bg-active);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.home-template-emoji {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subcard);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.folio-wikilink {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: baseline;
}

/* ============================================================================
   Inline Text Color & Highlight Controls + Craft-Inspired Page Style Inspector
   ============================================================================ */

.text-color-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.text-color-btn {
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
}

.text-color-glyph {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  font-family: var(--font-sans);
}

.text-color-bar {
  width: 13px;
  height: 2.5px;
  border-radius: 999px;
  background-color: var(--text-primary);
}

.text-color-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 236px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.workspace-card[data-tools-layout="figma"] .text-color-popover {
  top: auto;
  bottom: calc(100% + 8px);
}

.workspace-card[data-tools-layout="photoshop"] .text-color-popover {
  top: 0;
  left: calc(100% + 8px);
  transform: none;
}

.tc-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tc-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.tc-swatch-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tc-swatch {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border-card);
  background-color: var(--bg-subcard);
  color: var(--tc, var(--text-primary));
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 120ms var(--ease-out), background-color 120ms var(--ease-out);
}

.tc-swatch:hover {
  border-color: var(--text-primary);
  background-color: var(--bg-hover);
}

.tc-swatch.is-reset {
  color: var(--text-secondary);
  font-weight: 500;
}

.tc-swatch-custom {
  background: var(--bg-subcard);
  border: 1px dashed var(--border-strong);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
}

.craft-color-dot.is-custom {
  background: var(--bg-subcard) !important;
  border: 1px dashed var(--border-strong);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
}

.tc-swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.tc-hl-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border-card);
  background-color: var(--hl, transparent);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: border-color 120ms var(--ease-out);
}

.tc-hl-swatch:hover {
  border-color: var(--text-primary);
}

.tc-hl-swatch.is-reset {
  background: linear-gradient(135deg, transparent 44%, var(--text-tertiary) 45%, var(--text-tertiary) 55%, transparent 56%);
}

.folio-text-hl {
  border-radius: 4px;
  padding: 0 4px;
  color: inherit;
}

/* Craft-Inspired Editorial Cover Banner */
.note-page-cover {
  position: relative;
  width: 100%;
  height: 112px;
  border-radius: 12px;
  margin-bottom: 16px;
  background: var(--cover-bg, linear-gradient(135deg, #6366F1, #8B5CF6));
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border-card) 70%, transparent);
  flex-shrink: 0;
}

.note-cover-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 130ms ease;
}

.note-page-cover:hover .note-cover-actions,
.note-page-cover:focus-within .note-cover-actions {
  opacity: 1;
}

.note-cover-btn {
  height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background-color: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(8px);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 110ms ease;
}

.note-cover-btn:hover {
  background-color: rgba(15, 23, 42, 0.72);
}

/* Per-Note Craft Central Canvas Customizations */
.editor-split[data-page-surface="custom"] {
  background-color: var(--page-surface-bg);
}

.editor-split[data-page-font="sans"] .editor-measure {
  --page-font-family: var(--font-sans);
}

.editor-split[data-page-font="serif"] .editor-measure {
  --page-font-family: var(--font-serif);
}

.editor-split[data-page-font="rounded"] .editor-measure {
  --page-font-family: var(--font-rounded);
}

.editor-split[data-page-font="mono"] .editor-measure {
  --page-font-family: var(--font-mono);
}

.editor-split[data-page-font] .editor-title,
.editor-split[data-page-font] .editor-title-fx,
.editor-split[data-page-font] .rich-editor,
.editor-split[data-page-font] .live-editor,
.editor-split[data-page-font] .editor-body,
.editor-split[data-page-font] .markdown-preview {
  font-family: var(--page-font-family, var(--editor-font));
}

.editor-split[data-page-width="narrow"] .editor-measure {
  max-width: min(62ch, 100%);
}

.editor-split[data-page-width="balanced"] .editor-measure {
  max-width: var(--editor-measure);
}

.editor-split[data-page-width="wide"] .editor-measure,
.editor-split[data-page-width="full"] .editor-measure {
  max-width: 100%;
}

.editor-split[data-page-scale="sm"] .editor-measure {
  --editor-font-size: 14px;
}

.editor-split[data-page-scale="lg"] .editor-measure {
  --editor-font-size: 17px;
}

.editor-split[data-page-text="custom"] .editor-title,
.editor-split[data-page-text="custom"] .editor-title-fx,
.editor-split[data-page-text="custom"] .rich-editor,
.editor-split[data-page-text="custom"] .live-editor,
.editor-split[data-page-text="custom"] .editor-body,
.editor-split[data-page-text="custom"] .markdown-preview {
  color: var(--page-text-color);
}

.editor-split[data-page-text="custom"] .note-title-input-wrap.has-fx .editor-title {
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--page-text-color);
}

/* Craft-Inspired Right Inspector Tabs & Style Panel */
/* Always laid out. The zone starts 152px wide (window controls) and the panel
   starts at 0, so the tabs are offset by that much and ride the panel's edge */
.inspector-top-tabs {
  position: absolute;
  left: 7px;
  top: 50%;
  display: flex;
  align-items: center;
  transform: translate(152px, -50%);
  opacity: 0;
  visibility: hidden;
  transition:
    transform var(--panel-time) var(--panel-ease),
    opacity 120ms linear,
    visibility 0s linear var(--panel-time);
}

.command-card.has-outline-open .inspector-top-tabs {
  transform: translate(0, -50%);
  opacity: 1;
  visibility: visible;
  transition:
    transform var(--panel-time) var(--panel-ease),
    opacity var(--panel-time) var(--panel-ease),
    visibility 0s;
}

.inspector-seg {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
}

.command-card .inspector-top-tabs .icon-btn,
.command-card .note-header-actions .icon-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 7px;
}

.icon-btn > [data-icon] {
  display: inline-flex;
}

.command-card .inspector-top-tabs .icon-btn svg,
.command-card .note-header-actions .icon-btn svg {
  width: 15px;
  height: 15px;
}

.command-card.has-outline-open .cmd-main-zone {
  padding-right: 8px;
}

/* Same spot open or closed: aligned cleanly with the 32px header row of every inspector section */
#btn-collapse-outline {
  position: fixed;
  top: 66px;
  right: 20px;
  width: 28px;
  height: 28px;
  pointer-events: auto;
}

#btn-collapse-outline[hidden] {
  display: none;
}

#titlebar[data-nav-mode="tabs"]:not(.has-outline-open) ~ .workspace-row .note-title-bar {
  padding-right: 48px;
}

/* The top toolbars sit below the floating note actions too */
#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .workspace-card[data-tools-layout="word"]:is([data-tools-open="true"], [data-tools-anim]) .quick-actions-wrap {
  margin-top: var(--row-top-h);
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .workspace-card[data-tools-layout="word"][data-tools-open="true"] :is(.draw-tools-tab, .note-title-bar) {
  margin-top: 0;
}

/* When the top row has room, the ribbon moves into it as a single line beside
   the note actions (see placeTopRibbon, which sets the free space) */
#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .workspace-card[data-tools-layout="word"][data-ribbon-top="true"]:is([data-tools-open="true"], [data-tools-anim]) .quick-actions-wrap {
  margin-top: 0;
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .workspace-card[data-tools-layout="word"][data-ribbon-top="true"] .quick-actions-bar {
  height: var(--row-top-h);
  flex-wrap: nowrap;
  padding: 0 var(--ribbon-right, 0px) 0 var(--ribbon-left, 0px);
}

#titlebar[data-nav-mode="sidebar"] ~ .workspace-row .workspace-card[data-tools-layout="word"][data-tools-open="true"] .note-title-bar {
  padding-right: 0;
}

/* The drag strip would sit on top of the ribbon; the ribbon drags instead */
.app-stage:has(.workspace-card[data-ribbon-top="true"]) #titlebar[data-nav-mode="sidebar"] :is(.cmd-drag-flex, .cmd-leading) {
  pointer-events: none;
}

.app-stage:has(.workspace-card[data-ribbon-top="true"]) #titlebar[data-nav-mode="sidebar"] .cmd-leading button {
  pointer-events: auto;
}

/* One line only: tools that do not fit move into the "more" flyout */
.qa-group-overflow {
  display: none;
}

.workspace-card[data-tools-layout="word"] .quick-actions-bar {
  flex-wrap: nowrap;
}

.workspace-card[data-tools-layout="word"] .qa-group {
  flex-shrink: 0;
}

.workspace-card[data-tools-layout="word"] .quick-actions-bar.has-overflow > .qa-group-overflow {
  display: flex;
}

.workspace-card[data-tools-layout="word"] .quick-actions-bar .is-overflowed {
  display: none !important;
}

.qa-sub-tray-inner.qa-overflow {
  display: grid;
  grid-template-columns: repeat(6, auto);
}

/* The window drag strip overlaps the note title: over a note only its top edge drags,
   so the title below can be clicked and selected */
.app-stage:has(#editor-split:not([hidden])):not(:has([data-ribbon-top="true"])) #titlebar[data-nav-mode="sidebar"] .cmd-leading {
  position: relative;
  pointer-events: none;
}

.app-stage:has(#editor-split:not([hidden])):not(:has([data-ribbon-top="true"])) #titlebar[data-nav-mode="sidebar"] .cmd-leading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 14px;
  pointer-events: auto;
}

.app-stage:has(#editor-split:not([hidden])):not(:has([data-ribbon-top="true"])) #titlebar[data-nav-mode="sidebar"] .cmd-leading button {
  pointer-events: auto;
}

/* With the panel closed its toggle floats over the editor's top-right corner */
#titlebar:not(.has-outline-open) ~ .workspace-row .draw-tools-tab,
#titlebar:not(.has-outline-open) ~ .workspace-row .workspace-card[data-tools-layout="word"] .quick-actions-bar {
  padding-left: 48px;
  padding-right: 48px;
}

/* Keep the first row of each panel section clear of and vertically aligned with #btn-collapse-outline */
.workspace-row :is(
  #inspector-pane-outline > .outline-block:first-child > .outline-head,
  #inspector-pane-calendar > .cal-scope-seg,
  #inspector-pane-files > .outline-head,
  #inspector-pane-style > .outline-head
) {
  min-height: 32px;
  margin-right: 48px;
}

.inspector-tab-btn.is-active {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

.command-card.is-on-home [data-inspector-tab="outline"],
.command-card.is-on-home [data-inspector-tab="style"],
.is-user-hidden {
  display: none !important;
}

.sidebar-icon-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.sidebar-icon-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.sidebar-icon-option:hover {
  background-color: var(--bg-hover);
}

.sidebar-icon-option input {
  margin-left: auto;
}

.inspector-accordion {
  border: none;
  border-radius: 10px;
  background-color: color-mix(in srgb, var(--bg-subcard) 58%, transparent);
  overflow: hidden;
}

.inspector-acc-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: color 120ms ease, background-color 120ms ease;
}

.inspector-acc-summary::-webkit-details-marker {
  display: none;
}

.inspector-acc-summary:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.inspector-acc-chevron {
  display: inline-flex;
  color: var(--text-tertiary);
  transition: transform 160ms var(--ease-out);
}

.inspector-accordion[open] > .inspector-acc-summary .inspector-acc-chevron {
  transform: rotate(90deg);
}

.inspector-acc-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 16px 16px;
  border-top: 1px solid var(--border-subcard);
}

.inspector-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
}

.craft-style-pane {
  gap: 8px;
  padding-bottom: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

/* Sections keep their natural height and the pane scrolls, instead of every
   accordion being squeezed and clipped to fit the panel */
.craft-style-pane > * {
  flex-shrink: 0;
}

.craft-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.craft-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.craft-sec-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.craft-sub-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.craft-sub-label {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Craft 2x3 Visual Page Style Cards */
.craft-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.craft-preset-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  border: 1.5px solid var(--border-subcard);
  background-color: var(--bg-subcard);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease, transform 100ms ease, background-color 120ms ease;
}

.craft-preset-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.craft-preset-card.is-active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 1px var(--text-primary);
}

.craft-preset-thumb {
  height: 44px;
  border-radius: 7px;
  border: 1px solid rgba(128, 128, 128, 0.22);
  background-color: var(--bg-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px;
  gap: 4px;
  position: relative;
}

.craft-preset-cover-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 11px;
}

.craft-preset-aa {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.craft-preset-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.craft-preset-lines span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background-color: currentColor;
  opacity: 0.25;
}

.craft-preset-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
}

/* Craft 4 Typography Aa Cards */
.craft-font-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.craft-font-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 9px;
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.craft-font-card:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.craft-font-card.is-active {
  background-color: var(--bg-card);
  border-color: var(--text-primary);
  color: var(--text-primary);
  box-shadow: var(--top-highlight);
}

.craft-font-aa {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.1;
}

.craft-font-name {
  font-size: 10px;
  font-weight: 500;
}

/* Craft Cover Banner Selector */
.craft-cover-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.craft-cover-chip {
  height: 28px;
  border-radius: 8px;
  border: 1.5px solid var(--border-subcard);
  background: var(--cover-swatch, var(--bg-subcard));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  padding: 0;
  transition: transform 100ms ease, border-color 120ms ease;
}

.craft-cover-chip:hover {
  transform: scale(1.04);
  border-color: var(--border-strong);
}

.craft-cover-chip.is-active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 1.5px var(--bg-card), 0 0 0 3px var(--text-primary);
}

/* Swatches Row (Surface & Page Text Color) */
.craft-swatch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.craft-inline-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.craft-color-dot {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1.5px solid var(--border-card);
  background-color: var(--dot, var(--bg-card));
  cursor: pointer;
  padding: 0;
  transition: transform 100ms ease, box-shadow 120ms ease;
}

.craft-color-dot.is-default {
  background: linear-gradient(135deg, var(--bg-card) 48%, var(--text-tertiary) 49%, var(--text-tertiary) 52%, var(--bg-card) 53%);
}

.craft-color-dot.is-custom {
  background-color: var(--bg-subcard);
  border: 1px dashed var(--border-strong);
  overflow: hidden;
}

.craft-color-dot.is-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.craft-color-dot:hover {
  border-color: var(--text-primary);
}

.craft-color-dot.is-active {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3.5px var(--text-primary);
}

/* Segmented Controls in Craft Inspector */
.craft-pill-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.craft-pill-seg.craft-pill-wrap {
  grid-auto-flow: row;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-columns: unset;
  gap: 4px;
  padding: 4px;
}

.craft-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease;
}

.craft-seg-btn:hover {
  color: var(--text-primary);
}

.craft-seg-btn.is-active {
  background-color: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--top-highlight);
}

.craft-layout-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.craft-layout-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.craft-layout-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.craft-reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 30px;
  margin-top: 4px;
  border: 1px solid var(--border-subcard);
  border-radius: var(--r-btn);
  background-color: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.craft-reset-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-card);
  color: var(--text-primary);
}

/* Compact Note Color Strip inside the 3-Dots More Menu */
.menu-color-strip {
  padding: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border-subcard);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-color-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.menu-color-custom-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subcard);
  font-size: 10.5px;
  color: var(--text-secondary);
  cursor: pointer;
  overflow: hidden;
}

.menu-color-custom-pill:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.menu-color-custom-pill input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ============================================================================
   Floating Toolbar Popovers (Portaled to Body — Never Clipped by Rail/Dock)
   ============================================================================ */

.folio-floating-popover {
  position: fixed !important;
  z-index: 290 !important;
  transform-origin: top left;
}

/* ============================================================================
   Rich Media Blocks: Video, PDF First-Page Thumb, Text Preview, Free Resize,
   Text Wrap (Float Left/Right), Over-Text & Behind-Text Layers
   ============================================================================ */

.rich-editor,
.markdown-preview {
  position: relative;
}

.rich-editor > *:not(.folio-media-block),
.markdown-preview > *:not(.folio-media-block) {
  position: relative;
  z-index: 2;
}

.rich-editor::after,
.markdown-preview::after {
  content: "";
  display: table;
  clear: both;
}

.folio-media-block {
  position: relative;
  max-width: 100%;
  box-sizing: border-box;
  z-index: 4;
}

.folio-media-block[data-media-layout="left"] {
  margin-left: 0;
  margin-right: auto;
}

.folio-media-block[data-media-layout="center"],
.folio-media-block[data-media-layout="full"] {
  margin-left: auto;
  margin-right: auto;
}

.folio-media-block[data-media-layout="right"] {
  margin-left: auto;
  margin-right: 0;
}

.folio-media-block[data-media-layout="float-left"] {
  float: left;
  margin: 8px 16px 16px 0;
  max-width: 75%;
  z-index: 5;
}

.folio-media-block[data-media-layout="float-right"] {
  float: right;
  margin: 8px 0 16px 16px;
  max-width: 75%;
  z-index: 5;
}

.folio-media-block[data-media-layout="over-text"] {
  position: absolute;
  z-index: 18;
  margin: 0;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.folio-media-block[data-media-layout="behind-text"] {
  position: absolute;
  z-index: 0;
  margin: 0;
  opacity: 0.42;
  transition: opacity 150ms ease, border-color 140ms ease;
}

.folio-media-block[data-media-layout="behind-text"]:hover,
.folio-media-block[data-media-layout="behind-text"].is-resizing,
.folio-media-block[data-media-layout="behind-text"].is-dragging-media {
  opacity: 0.88;
  z-index: 14;
}

.folio-media-block.is-resizing,
.folio-media-block.is-dragging-media {
  outline: 2px solid var(--accent-primary, #6366F1);
  outline-offset: 2px;
  user-select: none;
  transition: none !important;
}

.folio-media-block:hover .folio-media-toolbar,
.folio-media-block:focus-within .folio-media-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.folio-doc-card.folio-media-block {
  overflow: visible;
}

.folio-doc-card.folio-media-block .folio-media-toolbar {
  top: -36px;
  right: 4px;
}

.folio-media-toolbar {
  z-index: 25;
  flex-wrap: wrap;
  max-width: calc(100% - 12px);
}

.folio-media-tb-sep {
  width: 1px;
  height: 14px;
  background-color: rgba(255, 255, 255, 0.22);
  margin: 0 4px;
}

.folio-media-tb-btn.is-danger:hover {
  background-color: rgba(239, 68, 68, 0.55);
  color: #FFFFFF;
}

.folio-media-drag-handle {
  cursor: grab;
  background-color: rgba(99, 102, 241, 0.45);
}

.folio-media-drag-handle:active {
  cursor: grabbing;
}

.folio-media-dim-badge {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Interactive Drag-to-Resize Handle */
.folio-media-resize-handle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 26;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 130ms ease, background-color 130ms ease;
  background:
    linear-gradient(135deg, transparent 48%, rgba(255, 255, 255, 0.72) 48%, rgba(255, 255, 255, 0.72) 58%, transparent 58%),
    linear-gradient(135deg, transparent 72%, rgba(255, 255, 255, 0.72) 72%, rgba(255, 255, 255, 0.72) 82%, transparent 82%);
  background-color: rgba(20, 20, 24, 0.62);
}

.folio-media-block:hover .folio-media-resize-handle,
.folio-media-block.is-resizing .folio-media-resize-handle {
  opacity: 1;
}

/* Anchored to the right, the free corner is the left one */
.folio-media-block:is([data-media-layout="right"], [data-media-layout="float-right"]) .folio-media-resize-handle {
  left: 2px;
  right: auto;
  cursor: nesw-resize;
  transform: scaleX(-1);
}

.folio-media-block:is([data-media-layout="over-text"], [data-media-layout="behind-text"]) {
  cursor: grab;
  touch-action: none;
}

.folio-media-block.is-dragging-media {
  cursor: grabbing;
}

/* Video Preview */
.folio-video-wrap {
  background-color: #09090B;
  display: flex;
  align-items: center;
  justify-content: center;
}

.folio-media-video {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: var(--media-max-h, 480px);
  background-color: #09090B;
  outline: none;
}

.media-viewer-video {
  max-width: 100%;
  max-height: calc(86vh - 80px);
  border-radius: 10px;
  background-color: #000000;
  outline: none;
}

.folio-doc-card.is-video .folio-doc-badge {
  background-color: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.3);
  color: #6366F1;
}

/* PDF First-Page Thumbnail Preview */
.folio-pdf-preview-wrap {
  position: relative;
  width: 100%;
  height: var(--media-max-h, 480px);
  background-color: var(--bg-stage);
  overflow: hidden;
  cursor: pointer;
}

.folio-pdf-thumb-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background-color: #FFFFFF;
}

/* The top strip stays free so the viewer's own notices (such as the digital
   signature warning) can be closed; the rest of the preview opens the file */
.folio-pdf-thumb-overlay {
  position: absolute;
  inset: 72px 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(to top, rgba(12, 12, 16, 0.62) 0%, transparent 40%);
  opacity: 0;
  transition: opacity 160ms ease;
}

.folio-pdf-preview-wrap:hover .folio-pdf-thumb-overlay {
  opacity: 1;
}

.folio-pdf-pill {
  padding: 4px 8px;
  border-radius: 999px;
  background-color: rgba(20, 20, 24, 0.84);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 500;
  backdrop-filter: blur(8px);
}

/* On a PDF the actions sit over the file name, never over the viewer */
.folio-pdf-figure .folio-media-toolbar {
  top: auto;
  right: 22px;
  bottom: 4px;
  max-width: calc(100% - 44px);
}

.folio-pdf-figure:is([data-media-layout="right"], [data-media-layout="float-right"]) .folio-media-toolbar {
  right: 4px;
  max-width: calc(100% - 30px);
}

/* Text / Code First-Page Miniature Preview */
.folio-text-preview-wrap {
  position: relative;
  width: 100%;
  max-height: 260px;
  overflow: hidden;
  padding: 16px;
  background-color: var(--bg-stage);
  cursor: pointer;
}

.folio-text-preview-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44px;
  background: linear-gradient(to top, var(--bg-stage), transparent);
  pointer-events: none;
}

.folio-text-preview-body {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================================
   Nota Geral & Modo Calendário (Issues #1 & #2)
   ============================================================================ */

.note-general-pill {
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

/* Calendar Note Date Square on Left of Note Cards */
.note-card-main.has-cal-badge {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.note-cal-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--border-card);
  background-color: var(--bg-card);
  line-height: 1;
  gap: 4px;
}

.note-cal-day {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.note-cal-month {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.note-card-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  gap: 4px;
}

.notes-list[data-display-mode="compact"] .note-cal-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.notes-list[data-display-mode="compact"] .note-cal-day {
  font-size: 11.5px;
}

.notes-list[data-display-mode="compact"] .note-cal-month {
  font-size: 7.5px;
}

/* Contextual Editor Strips (Nota Geral & Calendar Note) */
.note-context-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 8px;
  border-radius: 10px;
  background-color: var(--bg-subcard);
  border: 1px solid var(--border-subcard);
}

.note-context-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.note-context-pill.is-fallback {
  padding: 4px 8px;
  border-radius: 999px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  font-size: 11px;
  color: var(--text-secondary);
}

.note-context-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.note-context-btn {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 110ms ease, border-color 110ms ease;
}

.note-context-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.note-context-btn.is-subtle {
  background-color: transparent;
  color: var(--text-secondary);
}

/* Right Sidebar Calendar Inspector */
.calendar-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cal-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.cal-nav-btn {
  width: 26px;
  height: 26px;
}

.cal-month-label {
  flex: 1 1 auto;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.cal-month-label:hover {
  background-color: var(--bg-hover);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cal-day-spacer {
  height: 30px;
}

.cal-day-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 100ms ease, border-color 100ms ease;
}

.cal-day-btn:hover {
  background-color: var(--bg-hover);
}

.cal-day-btn.is-today {
  border-color: var(--border-strong);
  font-weight: 700;
}

.cal-day-btn.is-selected {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: transparent;
  font-weight: 600;
}

.cal-day-dot {
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background-color: var(--text-primary);
}

.cal-day-btn.is-selected .cal-day-dot {
  background-color: var(--btn-primary-text);
}

.cal-selected-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subcard);
}

.cal-selected-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cal-day-notes-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-scope-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 9px;
  background-color: var(--bg-subcard);
}

.cal-scope-btn {
  height: 26px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.cal-scope-btn.is-active {
  background-color: var(--bg-active);
  color: var(--text-primary);
}

.cal-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cal-view[hidden] {
  display: none;
}

.cal-month-group {
  margin-top: 4px;
}

.cal-day-note-item.has-date {
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding: 8px;
}

.cal-day-note-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.cal-day-empty {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

.cal-day-note-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-subcard);
  border-radius: 8px;
  background-color: var(--bg-subcard);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background-color 110ms ease, border-color 110ms ease;
}

.cal-day-note-item:hover,
.cal-day-note-item.is-active {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.cal-day-note-title {
  width: 100%;
  font-size: 12.5px;
  font-weight: 600;
}

.cal-day-note-meta {
  width: 100%;
  font-size: 11px;
  color: var(--text-tertiary);
}

.cal-create-btn {
  width: 100%;
  justify-content: center;
}

/* ============================================================================
   Real Organic Grain, Rough Fibrous Paper, Paper Overlay, Ribbon & Tables
   ============================================================================ */

:root {
  /* True high-frequency photographic/film grain via SVG fractalNoise */
  --tex-grain-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
  /* True tactile rough cotton/watercolor paper surface via lit fractalNoise */
  --tex-rough-paper-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.045 0.065' numOctaves='5' result='n' stitchTiles='stitch'/%3E%3CfeDiffuseLighting in='n' lighting-color='%23ffffff' surfaceScale='2.2' result='lit'%3E%3CfeDistantLight azimuth='45' elevation='56'/%3E%3C/feDiffuseLighting%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23p)'/%3E%3C/svg%3E");
}

.system-texture-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 180ms ease;
}

/* Dark specks on a light page stand out far more, so the light theme uses a
   lower gain. */
:root {
  --tex-gain: 0.5;
  --tex-speck-soft: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.45 0 0 0 0 0.45 1.8 0 0 0 -0.7'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --tex-speck-heavy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.8 0 0 0 -0.7'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* Frosted glass: a fine, even tooth, barely there */
  --tex-frost: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.4 0 0 0 -1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  --tex-gain: 1;
  --tex-speck-soft: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.55 0 0 0 0 0.55 1.8 0 0 0 -0.7'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --tex-speck-heavy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1.8 0 0 0 -0.7'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* Frosted glass: a fine, even tooth, barely there */
  --tex-frost: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 2.4 0 0 0 -1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.system-texture-layer[data-sys-texture="grain-soft"] {
  opacity: calc(var(--sys-tex-level, 0.28) * 0.36 * var(--tex-gain));
  background-image: var(--tex-speck-soft);
  background-size: 180px 180px;
}

.system-texture-layer[data-sys-texture="grain-heavy"] {
  opacity: calc(var(--sys-tex-level, 0.28) * 0.55 * var(--tex-gain));
  background-image: var(--tex-speck-heavy);
  background-size: 180px 180px;
}

.system-texture-layer[data-sys-texture="frosted"] {
  opacity: calc((0.012 + var(--sys-tex-level, 0.28) * 0.075) * var(--tex-gain));
  background-image: var(--tex-frost);
  background-size: 160px 160px;
}

/* The window behind is blurred by Windows; only the large surfaces let it
   through, so menus, flyouts and dialogs stay solid and readable */
:root[data-frosted]:not([data-platform="pwa"]),
:root[data-frosted]:not([data-platform="pwa"]) body {
  background: transparent;
}

:root[data-frosted]:not([data-platform="pwa"]) .app-stage {
  /* Hole under the window controls, so their notch is not tinted twice */
  -webkit-mask: linear-gradient(#000 0 0) top right / 152px 36px no-repeat, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) top right / 152px 36px no-repeat, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

/* Each card is a pane of glass: light catches its upper edge, a soft sheen
   fades down it and a shadow lifts it off the window */
:root[data-frosted]:not([data-platform="pwa"]) {
  --glass-edge: rgba(255, 255, 255, 0.75);
  --glass-rim: rgba(255, 255, 255, 0.45);
  --glass-sheen: rgba(255, 255, 255, 0.28);
  --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

:root[data-theme="dark"][data-frosted]:not([data-platform="pwa"]) {
  --glass-edge: rgba(255, 255, 255, 0.16);
  --glass-rim: rgba(255, 255, 255, 0.09);
  --glass-sheen: rgba(255, 255, 255, 0.045);
  --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

:root[data-frosted]:not([data-platform="pwa"]) .app-stage .card:is(.sidebar-stack, .main-stack) {
  border-color: var(--glass-rim);
  background-image: linear-gradient(180deg, var(--glass-sheen), transparent 220px);
  box-shadow: inset 0 1px 0 var(--glass-edge), var(--glass-shadow);
}

:root[data-frosted]:not([data-platform="pwa"]) .workspace-card:not([data-tools-layout="word"]) .quick-actions-bar {
  box-shadow: inset 0 1px 0 var(--glass-edge), var(--glass-shadow);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
}

/* Whatever floats over text keeps enough body to be read, with its own blur */
:root[data-frosted]:not([data-platform="pwa"]) :is(.popover-card, .modal-card, .icon-picker-sheet, .media-viewer-card, .settings-modal-dialog, #find-bar, #toast:not([hidden])) {
  background-color: color-mix(in srgb, var(--solid-card) 86%, transparent);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
}

/* The bar and its flyouts share one tint, so their joins stay invisible */
:root[data-frosted]:not([data-platform="pwa"]) .workspace-card .quick-actions-bar,
:root[data-frosted]:not([data-platform="pwa"]) .workspace-card[data-tools-layout] .qa-sub-tray {
  --qa-fly-bg: color-mix(in srgb, var(--solid-card) 90%, transparent);
}

:root[data-frosted]:not([data-platform="pwa"]) .workspace-card:not([data-tools-layout="word"]) .quick-actions-bar {
  background-color: var(--qa-fly-bg);
}

/* Keep only the notch's border lines: a translucent fill would stack on the card */
:root[data-frosted]:not([data-platform="pwa"]) .win-notch-fillet-left,
:root[data-frosted]:not([data-platform="pwa"]) .win-notch-fillet-right {
  box-shadow: none;
}

:root[data-frosted]:not([data-platform="pwa"]) .editor-split ~ .workspace-footer {
  background-image: none;
}

:root[data-frosted]:not([data-platform="pwa"]) .app-stage .card:is(.sidebar-stack, .main-stack) {
  background-color: color-mix(in srgb, var(--bg-card) var(--frost-card, 52%), transparent);
}

:root[data-platform="pwa"] [data-sys-texture="frosted"]:is(button) {
  display: none;
}

/* Paper texture: one generated tile (see buildPaperTexture in app.js) painted on
   the whole page. Without side margins it covers the scrolling canvas; with them
   it lives on the floating sheet. `local` keeps ruled/dot guides glued to text. */
.editor-split[data-paper-on="true"]:not([data-has-backdrop="true"]):not([data-paper-photo="true"]) .editor-canvas {
  background-image: var(--paper-tex);
  background-size: var(--paper-tex-size);
  background-position: center;
  background-attachment: local;
}

.editor-split[data-paper-on="true"][data-paper-photo="true"]:not([data-has-backdrop="true"]),
.editor-split[data-has-backdrop="true"][data-backdrop-photo="true"] {
  isolation: isolate;
}

.editor-split[data-paper-on="true"][data-paper-photo="true"]:not([data-has-backdrop="true"]) > *,
.editor-split[data-has-backdrop="true"][data-backdrop-photo="true"] > * {
  position: relative;
  z-index: 1;
}

.editor-split[data-paper-on="true"][data-paper-photo="true"]:not([data-has-backdrop="true"])::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--paper-tex);
  background-size: var(--paper-tex-size, cover);
  background-position: center;
  filter: var(--paper-tex-filter, none);
  opacity: var(--paper-tex-opacity, 1);
  mix-blend-mode: var(--paper-tex-blend, multiply);
  pointer-events: none;
  z-index: 0;
}

.editor-split[data-paper-on="true"][data-has-backdrop="true"]:not([data-paper-photo="true"]) .editor-measure {
  background-image: var(--paper-tex);
  background-size: var(--paper-tex-size);
  background-position: center;
}

.editor-split[data-paper-on="true"][data-paper-photo="true"][data-has-backdrop="true"] .editor-measure {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.editor-split[data-paper-on="true"][data-paper-photo="true"][data-has-backdrop="true"] .editor-measure::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--paper-tex);
  background-size: var(--paper-tex-size, cover);
  background-position: center;
  filter: var(--paper-tex-filter, none);
  opacity: var(--paper-tex-opacity, 1);
  mix-blend-mode: var(--paper-tex-blend, multiply);
  pointer-events: none;
  z-index: 0;
}

.editor-split[data-paper-on="true"][data-paper-photo="true"][data-has-backdrop="true"] .editor-measure > * {
  position: relative;
  z-index: 1;
}

/* A coloured page that does not match the app theme gets its own ink so text,
   borders and blocks stay readable (light paper in dark mode and vice versa). */
.editor-split[data-page-tone="light"] .editor-measure {
  --text-primary: #1D1D1F;
  --text-secondary: #4B4B52;
  --text-tertiary: #86868D;
  --border-card: rgba(0, 0, 0, 0.1);
  --border-subcard: rgba(0, 0, 0, 0.07);
  --bg-hover: rgba(0, 0, 0, 0.045);
  --bg-subcard: rgba(0, 0, 0, 0.035);
  --bg-card: color-mix(in srgb, var(--page-surface-bg) 90%, #FFFFFF);
  color-scheme: light;
}

.editor-split[data-page-tone="dark"] .editor-measure {
  --text-primary: #ECECEE;
  --text-secondary: #B4B4BA;
  --text-tertiary: #7E7E86;
  --border-card: rgba(255, 255, 255, 0.11);
  --border-subcard: rgba(255, 255, 255, 0.07);
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-subcard: rgba(255, 255, 255, 0.045);
  --bg-card: color-mix(in srgb, var(--page-surface-bg) 88%, #FFFFFF);
  color-scheme: dark;
}

.editor-split[data-page-spacing="compact"] .rich-editor,
.editor-split[data-page-spacing="compact"] .editor-body,
.editor-split[data-page-spacing="compact"] .live-editor {
  line-height: 1.45;
}

.editor-split[data-page-spacing="airy"] .rich-editor,
.editor-split[data-page-spacing="airy"] .editor-body,
.editor-split[data-page-spacing="airy"] .live-editor {
  line-height: 2.02;
}

/* Craft-style colour tiles (paper + side margins) */
.craft-tile-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.craft-tile {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(128, 128, 128, 0.28);
  background-color: var(--tile, var(--bg-card));
  cursor: pointer;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: transform 100ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.craft-tile:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.craft-tile.is-active {
  border-color: transparent;
  box-shadow: 0 0 0 1.5px var(--bg-card), 0 0 0 3px var(--text-primary);
}

.craft-tile.is-default::after {
  content: "";
  position: absolute;
  width: 140%;
  height: 1.5px;
  background-color: color-mix(in srgb, var(--text-tertiary) 70%, transparent);
  transform: rotate(-45deg);
}

.craft-tile.is-custom {
  background: conic-gradient(from 180deg, #F87171, #FBBF24, #34D399, #38BDF8, #A78BFA, #F472B6, #F87171);
  border-color: transparent;
}

.craft-tile.is-custom.has-value {
  background: var(--tile);
  border-color: rgba(128, 128, 128, 0.28);
}

.craft-tile.is-custom > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.92);
  color: #3F3F46;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}

.craft-tile.is-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

/* Texture tiles: real preview of each texture over the current paper colour */
.craft-tex-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.craft-tex-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
}

.craft-tex-swatch {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: block;
  height: 38px;
  border-radius: 8px;
  border: 1px solid rgba(128, 128, 128, 0.28);
  background-color: var(--tex-bg, var(--bg-card));
  transition: transform 100ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.craft-tex-swatch::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--tex-img, none);
  background-size: var(--tex-size, auto);
  background-position: center;
  filter: var(--tex-filter, none);
  opacity: var(--tex-opacity, 1);
  mix-blend-mode: var(--tex-blend, normal);
  pointer-events: none;
}

.craft-tex-grid.is-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.craft-tex-grid.is-compact .craft-tex-swatch {
  height: 24px;
}

.craft-tex-name {
  font-size: 10.5px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}

.craft-tex-card:hover .craft-tex-swatch {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.craft-tex-card:hover {
  color: var(--text-primary);
}

.craft-tex-card.is-active {
  color: var(--text-primary);
}

.craft-tex-card.is-active .craft-tex-swatch {
  border-color: transparent;
  box-shadow: 0 0 0 1.5px var(--bg-card), 0 0 0 3px var(--text-primary);
}

.craft-range-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.craft-range-row[hidden] {
  display: none;
}

.craft-range-row input[type="range"] {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.craft-range-value {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  text-align: right;
}

.craft-scale-aa {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.craft-scale-aa.is-sm {
  font-size: 10px;
}

.craft-scale-aa.is-lg {
  font-size: 14.5px;
}

.spell-menu-heading {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 4px 8px;
  user-select: none;
}

/* Side Backdrop Overlay (Paper floats cleanly over textured/colored empty sides) */
/* Side margins: the paper floats as a sheet over a coloured / textured desk */
.editor-split[data-has-backdrop="true"] {
  background-color: var(--page-backdrop-bg, var(--bg-stage));
}

.editor-split[data-has-backdrop="true"]:not([data-backdrop-photo="true"]) .editor-canvas {
  background-color: var(--page-backdrop-bg, var(--bg-stage));
  background-image: var(--backdrop-tex, none);
  background-size: var(--backdrop-tex-size, auto);
  background-position: center;
  background-attachment: local;
  padding: 32px 32px 48px;
}

.editor-split[data-has-backdrop="true"][data-backdrop-photo="true"] .editor-canvas {
  background-color: transparent;
  padding: 32px 32px 48px;
}

.editor-split[data-has-backdrop="true"][data-backdrop-photo="true"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--backdrop-tex, none);
  background-size: var(--backdrop-tex-size, cover);
  background-position: center;
  filter: var(--backdrop-tex-filter, none);
  opacity: var(--backdrop-tex-opacity, 0.55);
  mix-blend-mode: var(--backdrop-tex-blend, multiply);
  pointer-events: none;
  z-index: 0;
}

.editor-split[data-has-backdrop="true"] .editor-measure {
  background-color: var(--page-surface-bg, var(--bg-card));
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  padding: 48px 48px 56px;
  min-height: calc(100% - 8px);
  box-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.04),
    0 1px 2px rgba(0, 0, 0, 0.05),
    0 10px 32px -8px rgba(0, 0, 0, 0.14);
}

:root[data-theme="dark"] .editor-split[data-has-backdrop="true"] .editor-measure {
  border-color: rgba(255, 255, 255, 0.07);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 12px 36px -8px rgba(0, 0, 0, 0.55);
}

.editor-split[data-page-width="full"] .editor-measure {
  max-width: 100%;
}

.paper-defaults-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.paper-default-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Fixed Word/Docs-Style Formatting Ribbon */
.docs-format-ribbon {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-subcard);
  background-color: var(--bg-card);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.docs-format-ribbon::-webkit-scrollbar {
  display: none;
}

.docs-ribbon-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.docs-ribbon-sep {
  width: 1px;
  height: 18px;
  background-color: var(--border-subcard);
  margin: 0 4px;
  flex-shrink: 0;
}

.docs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease;
}

.docs-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.docs-color-dot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border-subcard);
  background-color: var(--bg-subcard);
  color: var(--dc, var(--text-primary));
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.docs-color-dot:hover {
  border-color: var(--border-strong);
}

.docs-color-dot.is-custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ============================================================================
   DESKTOP COMPLETE INTERACTIVE TABLE EDITOR MODULE
   ============================================================================ */
.qa-table-group[hidden] {
  display: none !important;
}

.qa-tbl-trigger {
  color: var(--accent, var(--text-primary));
}

.qa-tbl-tray {
  padding: 8px;
}

.qa-tbl-tray-rich {
  padding: 8px;
}

.qa-tbl-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.qa-tbl-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.qa-tbl-mini-lbl {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 0 4px;
  user-select: none;
}

.tbl-tray-sep {
  width: 1px;
  height: 16px;
  background-color: var(--border-subcard);
  margin: 0 4px;
  flex-shrink: 0;
}

.tbl-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border-card);
  border-radius: 7px;
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease, border-color 110ms ease, transform 90ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .tbl-pill-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
  }
}

.tbl-pill-btn.is-active {
  background-color: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.tbl-pill-btn.is-danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.tbl-color-dot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1.5px solid var(--border-card);
  background-color: var(--tc, var(--bg-subcard));
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.tbl-color-dot.is-custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.table-accent-dot {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  border: 2px solid transparent;
  background-color: var(--ta);
  cursor: pointer;
  flex-shrink: 0;
}

.table-accent-dot.is-active {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3.5px var(--ta);
}

/* Interactive Table Wrapper with Edge Add Controls + Horizontal Scroll + Alignment */
.folio-table-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  grid-template-rows: auto 24px;
  gap: 4px;
  margin: 16px 0;
  max-width: 100%;
  width: 100%;
  border-radius: 12px;
  transition: box-shadow 140ms ease;
}

.folio-table-wrap[data-table-align="left"] {
  width: fit-content;
  margin-left: 0;
  margin-right: auto;
}

.folio-table-wrap[data-table-align="center"] {
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.folio-table-wrap[data-table-align="right"] {
  width: fit-content;
  margin-left: auto;
  margin-right: 0;
}

.folio-table-wrap.is-table-selected > .ft-scroll-area {
  box-shadow: 0 0 0 2px var(--accent, #2563EB);
  border-radius: 10px;
}

.ft-corner-select {
  position: absolute;
  top: -11px;
  left: -11px;
  z-index: 6;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  box-shadow: var(--shadow-card);
  transition: opacity 140ms ease, background-color 120ms ease, color 120ms ease;
}

.ft-corner-select:hover,
.ft-corner-select:focus-visible {
  opacity: 1;
}

.folio-table-wrap.is-table-selected .ft-corner-select {
  background-color: var(--accent, #2563EB);
  color: #ffffff;
  border-color: transparent;
}

.ft-scroll-area {
  grid-column: 1;
  grid-row: 1;
  overflow-x: auto;
  max-width: 100%;
  border-radius: 10px;
  scrollbar-width: thin;
}

.ft-edge-add-col {
  grid-column: 2;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background-color: transparent;
  color: var(--text-tertiary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.ft-edge-add-row {
  grid-column: 1;
  grid-row: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background-color: transparent;
  color: var(--text-tertiary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.ft-edge-add-col:hover,
.ft-edge-add-row:hover,
.ft-edge-add-col:focus-visible,
.ft-edge-add-row:focus-visible {
  opacity: 1;
}

/* Touch screens have no hover: show them while the table is in use */
@media (hover: none) {
  .folio-table-wrap.is-table-active .ft-edge-add-col,
  .folio-table-wrap.is-table-active .ft-edge-add-row,
  .folio-table-wrap.is-table-active .ft-corner-select {
    opacity: 0.92;
  }
}

@media (hover: hover) and (pointer: fine) {
  .ft-edge-add-col:hover,
  .ft-edge-add-row:hover {
    opacity: 1;
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-style: solid;
  }
}

/* Enhanced Folio Table Variants */
.folio-table {
  width: 100%;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-card);
  margin: 0;
  table-layout: fixed;
}

.folio-table th,
.folio-table td {
  position: relative;
  padding: 8px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-subcard);
  vertical-align: top;
  min-width: 80px;
  word-wrap: break-word;
}

.folio-table th {
  font-weight: 600;
  background-color: var(--bg-subcard);
}

.folio-table th.is-cell-selected,
.folio-table td.is-cell-selected {
  box-shadow: inset 0 0 0 2px var(--accent, #2563EB);
}

/* The frame hugs the table: no outer margin from the generic editor table rule */
.rich-editor .folio-table-wrap .folio-table {
  margin: 0;
}

/* Spreadsheet-like selection zones: top of a header cell, start of a row */
.rich-editor.is-zone-col,
.rich-editor.is-zone-col * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M10 18 4 10h4V2h4v8h4z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 10 18, s-resize !important;
}

.rich-editor.is-zone-row,
.rich-editor.is-zone-row * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M18 10 10 16v-4H2V8h8V4z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 18 10, e-resize !important;
}

::highlight(folio-find) {
  background-color: rgba(250, 204, 21, 0.35);
}

::highlight(folio-find-current) {
  background-color: #F59E0B;
  color: #171717;
}

.ft-col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 4;
  user-select: none;
}

.folio-table th:last-child > .ft-col-resizer {
  right: 0;
}

.folio-table th:last-child > .ft-col-resizer:hover::after,
.folio-table th:last-child > .ft-col-resizer.is-resizing::after {
  left: 5px;
}

.folio-table-wrap.is-sized {
  width: fit-content;
}

.ft-col-resizer:hover::after,
.ft-col-resizer.is-resizing::after {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: 2px;
  border-radius: 2px;
  background-color: var(--accent, #2563EB);
}

/* Interactive Checkbox inside Table Cell */
.ft-cell-check {
  width: 15px;
  height: 15px;
  margin: 4px 8px 0 0;
  vertical-align: middle;
  accent-color: var(--accent, #2563EB);
  cursor: pointer;
}

/* Interactive Dropdown Pill inside Table Cell */
.ft-dropdown {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  margin: 4px 4px 4px 0;
  border-radius: 999px;
  background-color: color-mix(in srgb, var(--accent, #2563EB) 14%, var(--bg-subcard));
  border: 1px solid color-mix(in srgb, var(--accent, #2563EB) 28%, var(--border-card));
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  vertical-align: middle;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.ft-dropdown::after {
  content: "▾";
  font-size: 10px;
  opacity: 0.7;
}

@media (hover: hover) and (pointer: fine) {
  .ft-dropdown:hover {
    background-color: color-mix(in srgb, var(--accent, #2563EB) 22%, var(--bg-hover));
  }
}

.ft-dropdown-popover {
  position: fixed;
  z-index: 130;
  min-width: 210px;
  max-width: 280px;
  padding: 8px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ft-dropdown-popover[hidden] {
  display: none !important;
}

.ft-drop-opt-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ft-drop-opt-btn {
  flex: 1 1 auto;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px;
  border-radius: 7px;
  cursor: pointer;
}

.ft-drop-opt-btn:hover,
.ft-drop-opt-btn.is-active {
  background-color: var(--bg-hover);
}

.ft-drop-opt-del {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.ft-drop-opt-del:hover {
  color: var(--danger);
  background-color: var(--bg-hover);
}

.ft-drop-add-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subcard);
}

.ft-drop-add-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border-card);
  background: var(--bg-subcard);
  color: var(--text-primary);
  font-size: 12px;
}

.folio-table[data-table-compact="true"] th,
.folio-table[data-table-compact="true"] td {
  padding: 4px 8px;
  font-size: 0.92em;
}

.folio-table[data-table-style="striped"] tbody tr:nth-child(even) td {
  background-color: color-mix(in srgb, var(--bg-subcard) 65%, transparent);
}

.folio-table[data-table-style="grid"] th,
.folio-table[data-table-style="grid"] td {
  border-right: 1px solid var(--border-subcard);
}

.folio-table[data-table-style="grid"] th:last-child,
.folio-table[data-table-style="grid"] td:last-child {
  border-right: none;
}

.folio-table[data-table-style="editorial"] {
  border: none;
  border-radius: 0;
  border-top: 2px solid var(--text-primary);
  border-bottom: 1.5px solid var(--text-primary);
}

.folio-table[data-table-style="editorial"] th {
  background-color: transparent;
  border-bottom: 1.5px solid var(--border-strong);
}

.folio-table[data-table-accent="blue"] th { background-color: rgba(37, 99, 235, 0.14); color: #1D4ED8; }
.folio-table[data-table-accent="emerald"] th { background-color: rgba(5, 150, 105, 0.14); color: #047857; }
.folio-table[data-table-accent="amber"] th { background-color: rgba(217, 119, 6, 0.14); color: #B45309; }
.folio-table[data-table-accent="rose"] th { background-color: rgba(225, 29, 72, 0.14); color: #BE123C; }
.folio-table[data-table-accent="violet"] th { background-color: rgba(124, 58, 237, 0.14); color: #6D28D9; }

:root[data-theme="dark"] .folio-table[data-table-accent="blue"] th { color: #93C5FD; }
:root[data-theme="dark"] .folio-table[data-table-accent="emerald"] th { color: #6EE7B7; }
:root[data-theme="dark"] .folio-table[data-table-accent="amber"] th { color: #FCD34D; }
:root[data-theme="dark"] .folio-table[data-table-accent="rose"] th { color: #FDA4AF; }
:root[data-theme="dark"] .folio-table[data-table-accent="violet"] th { color: #C4B5FD; }

[hidden] { display: none !important; }

/* ============================================================================
   AI & MCP Settings Section
   ============================================================================ */
.ai-master-group {
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 4px 16px;
  background: color-mix(in srgb, var(--bg-subcard) 72%, var(--bg-card));
  margin-bottom: 16px;
}

.ai-master-row {
  border-bottom: none !important;
  padding: 16px 4px !important;
}

.ai-master-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.ai-master-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--text-tertiary);
  transition: background-color 180ms ease, box-shadow 180ms ease;
}

.ai-master-dot.is-on {
  background: #10B981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.ai-mcp-options-wrap {
  transition: opacity 160ms ease, filter 160ms ease;
}

.ai-mcp-options-wrap.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}

.ai-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.ai-input-row .text-input {
  flex: 1 1 auto;
  min-width: 0;
}

.ai-model-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.ai-model-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-preset-chip {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-card);
  background: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 11.5px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.ai-preset-chip:hover,
.ai-preset-chip.is-active {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.mcp-port-input {
  width: 110px !important;
  text-align: center;
  font-family: var(--font-mono);
}

.mcp-snippet-box {
  position: relative;
  width: 100%;
}

.mcp-snippet-pre {
  margin: 0;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background: var(--bg-subcard);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-x: auto;
  user-select: text;
}

.mcp-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  font-size: 11.5px;
}

.settings-group-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.settings-group-head-row .settings-subhead {
  margin: 0;
}

.mcp-servers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mcp-server-empty {
  padding: 16px;
  border-radius: 10px;
  border: 1px dashed var(--border-strong);
  color: var(--text-tertiary);
  font-size: 12.5px;
  text-align: center;
}

.mcp-server-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background: var(--bg-subcard);
}

.mcp-server-info {
  min-width: 0;
  flex: 1 1 auto;
}

.mcp-server-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mcp-server-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.mcp-server-meta {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
}

.mcp-server-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================================================
   VS Code / Obsidian Command Palette & Quick Switcher
   ============================================================================ */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: min(14vh, 112px);
}

.cmd-palette-backdrop[hidden] {
  display: none !important;
}

.cmd-palette-dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: min(480px, 72vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.32);
}

.cmd-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border-card);
}

.cmd-palette-icon {
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
}

.cmd-palette-input {
  flex: 1 1 auto;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14.5px;
  font-family: inherit;
}

.cmd-palette-esc {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--border-card);
  background: var(--bg-subcard);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.cmd-palette-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
}

.cmd-palette-section-lbl {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: 8px 8px 4px;
}

.cmd-palette-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-size: 13.5px;
  transition: background-color 80ms ease;
}

.cmd-palette-item:hover,
.cmd-palette-item.is-selected {
  background: var(--bg-hover);
}

.cmd-palette-item.is-selected {
  box-shadow: inset 2px 0 0 var(--accent);
}

.cmd-palette-item-icon {
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.cmd-palette-item-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cmd-palette-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.cmd-palette-item-sub {
  font-size: 11.5px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmd-palette-item-kbd {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  background: var(--bg-subcard);
  border: 1px solid var(--border-card);
  padding: 4px 8px;
  border-radius: 5px;
  flex-shrink: 0;
}

.cmd-palette-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.cmd-palette-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border-card);
  background: var(--bg-subcard);
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.cmd-palette-footer kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  margin-right: 4px;
}

/* Vim Status Pill */
.vim-status-pill {
  position: fixed;
  right: 16px;
  bottom: 14px;
  z-index: 160;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

.vim-status-pill[hidden] {
  display: none !important;
}

.vim-mode-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #2563EB;
  color: #fff;
  letter-spacing: 0.04em;
}

.vim-mode-badge[data-mode="insert"] {
  background: #059669;
}

.vim-mode-badge[data-mode="visual"] {
  background: #7C3AED;
}

.vim-cmd-buffer {
  color: var(--text-secondary);
}

/* ============================================================================
   Syntax-Highlighted Code Blocks
   ============================================================================ */
.folio-code-block {
  position: relative;
  margin: 16px 0;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background: var(--bg-subcard);
  overflow: hidden;
}

.folio-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border-subcard);
  background: color-mix(in srgb, var(--bg-subcard) 60%, var(--bg-stage));
  user-select: none;
}

.folio-code-lang-select {
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

.folio-code-lang-select:hover,
.folio-code-lang-select:focus {
  border-color: var(--border-card);
  background: var(--bg-card);
  color: var(--text-primary);
}

.folio-code-lang-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 8px;
}

.folio-code-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11.5px;
  padding: 4px 8px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.folio-code-copy:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Setting: hide language header when show_code_language is false */
:root[data-show-code-lang="false"] .folio-code-header {
  display: none !important;
}

.folio-code-block pre {
  margin: 0 !important;
  padding: 16px !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9em;
  line-height: 1.55;
  tab-size: 2;
}

.folio-code-block pre code {
  display: block;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  font-family: inherit;
  white-space: pre;
  outline: none;
}

/* Light theme syntax tokens */
:root[data-theme="light"] .tok-kw { color: #cf222e; font-weight: 600; }
:root[data-theme="light"] .tok-str { color: #0a3069; }
:root[data-theme="light"] .tok-num { color: #0550ae; }
:root[data-theme="light"] .tok-com { color: #6e7781; font-style: italic; }
:root[data-theme="light"] .tok-fn { color: #8250df; }
:root[data-theme="light"] .tok-type { color: #953800; }
:root[data-theme="light"] .tok-op { color: #57606a; }
:root[data-theme="light"] .tok-attr { color: #116329; }
:root[data-theme="light"] .tok-tag { color: #116329; font-weight: 600; }

/* Dark theme syntax tokens */
:root[data-theme="dark"] .tok-kw { color: #ff7b72; font-weight: 600; }
:root[data-theme="dark"] .tok-str { color: #a5d6ff; }
:root[data-theme="dark"] .tok-num { color: #79c0ff; }
:root[data-theme="dark"] .tok-com { color: #8b949e; font-style: italic; }
:root[data-theme="dark"] .tok-fn { color: #d2a8ff; }
:root[data-theme="dark"] .tok-type { color: #ffa657; }
:root[data-theme="dark"] .tok-op { color: #c9d1d9; }
:root[data-theme="dark"] .tok-attr { color: #7ee787; }
:root[data-theme="dark"] .tok-tag { color: #7ee787; font-weight: 600; }

/* ============================================================================
   Excel / Google Sheets Table Selection, Headers & Context Menu
   ============================================================================ */
/* Google Docs Table Selection & Clickable Borders (clean, no Excel A/B/C bars) */
.folio-table-wrap {
  padding-top: 0;
  padding-left: 0;
}

.ft-col-headers,
.ft-row-headers {
  display: none !important;
}

.folio-table-wrap .ft-corner-select {
  top: -10px;
  left: -10px;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 11px;
  box-shadow: var(--shadow-card);
}

.folio-table.is-dragging-cells {
  user-select: none !important;
}

/* Google Docs blue cell block fill when multiple cells or whole table are selected */
.folio-table.has-multi-cell-selection th.is-cell-selected,
.folio-table.has-multi-cell-selection td.is-cell-selected {
  background-image: linear-gradient(rgba(59, 130, 246, 0.24), rgba(59, 130, 246, 0.24)) !important;
  box-shadow: none !important;
}

.folio-table:not(.has-multi-cell-selection) th.is-cell-selected,
.folio-table:not(.has-multi-cell-selection) td.is-cell-selected {
  box-shadow: none !important;
  background-image: none !important;
}

/* Selected border highlight (Google Docs blue line on clicked border) */
.folio-table th.is-border-top-selected,
.folio-table td.is-border-top-selected {
  box-shadow: inset 0 2.5px 0 0 #3B82F6 !important;
}
.folio-table th.is-border-bottom-selected,
.folio-table td.is-border-bottom-selected {
  box-shadow: inset 0 -2.5px 0 0 #3B82F6 !important;
}
.folio-table th.is-border-left-selected,
.folio-table td.is-border-left-selected {
  box-shadow: inset 2.5px 0 0 0 #3B82F6 !important;
}
.folio-table th.is-border-right-selected,
.folio-table td.is-border-right-selected {
  box-shadow: inset -2.5px 0 0 0 #3B82F6 !important;
}

/* Contextual Toolbar: Media replaces text tools, Table stays ALONGSIDE text tools (like Google Docs!) */
#format-bar[data-context-mode="media"] .qa-group:not(.qa-media-group):not(.qa-group-meta) {
  display: none !important;
}

.qa-media-group[hidden] {
  display: none !important;
}

.qa-contextual-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.qa-ctx-back {
  font-weight: 600 !important;
  color: var(--text-secondary) !important;
}

/* Hide floating hover toolbars on media blocks — all media controls live in the main toolbar */
.folio-media-toolbar {
  display: none !important;
}

.folio-media-block.is-media-selected {
  outline: 2px solid var(--accent, #2563EB);
  outline-offset: 3px;
  border-radius: 10px;
}

/* ============================================================================
   Google Docs / Microsoft Word Style Color Picker inside .qa-sub-tray
   ============================================================================ */
.docs-color-panel {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 8px !important;
  padding: 8px !important;
  width: 244px;
}

.docs-color-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.docs-color-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.docs-color-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.docs-color-reset {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 110ms ease, color 110ms ease;
}

.docs-color-reset:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.docs-color-matrix {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}

.docs-swatch {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1px solid rgba(128, 128, 128, 0.28);
  background-color: var(--sw, #000);
  padding: 0;
  cursor: pointer;
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.docs-swatch:hover {
  transform: scale(1.18);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3.5px var(--text-primary);
  z-index: 2;
}

.docs-color-custom-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 24px;
  border-radius: 6px;
  border: 1px dashed var(--border-strong);
  background: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 110ms ease, color 110ms ease;
}

.docs-color-custom-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.docs-color-custom-btn input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.docs-color-sep {
  height: 1px;
  background: var(--border-card);
  margin: 4px 0;
}

.docs-hl-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.docs-hl-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(128, 128, 128, 0.28);
  background-color: var(--hl, transparent);
  padding: 0;
  cursor: pointer;
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.docs-hl-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3.5px var(--text-primary);
}

/* Dynamic Model Discovery & Local / ACP Detection */
.ai-detected-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-detected-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-subcard);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.ai-detected-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.ai-detected-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #10B981;
}

.ai-detected-dot.is-acp {
  background: #3B82F6;
}

.ai-discovered-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.ai-model-filter {
  font-size: 12.5px !important;
  padding: 8px !important;
}

.ai-discovered-wrap .ai-model-presets {
  max-height: 150px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

/* ============================================================================
   Instant Sidebar Drag-to-Reorder Live Preview & Note Cut State
   ============================================================================ */
.note-card.is-dragging {
  opacity: 0.35;
  transform: scale(0.98);
  outline: 1.5px dashed var(--accent, #2563EB);
  outline-offset: -1px;
  background: color-mix(in srgb, var(--accent, #2563EB) 8%, var(--bg-subcard)) !important;
}

.note-card.is-drop-before,
.note-card.is-drop-after {
  position: relative;
}

.note-card.is-drop-before::before,
.note-card.is-drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2.5px;
  border-radius: 999px;
  background: var(--accent, #2563EB);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent, #2563EB) 55%, transparent);
  pointer-events: none;
  z-index: 10;
}

.note-card.is-drop-before::before {
  top: -3px;
}

.note-card.is-drop-after::after {
  bottom: -3px;
}

.note-card.is-cut-pending {
  opacity: 0.48;
  border-style: dashed !important;
}

/* ============================================================================
   Windows-Style Marquee / Rubber-Band Multi-Select Box
   ============================================================================ */
.folio-marquee-box {
  position: fixed;
  z-index: 240;
  pointer-events: none;
  border: 1px solid rgba(59, 130, 246, 0.88);
  background: rgba(59, 130, 246, 0.16);
  border-radius: 4px;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.2);
}

.note-card.is-marquee-hit {
  outline: 1.5px solid var(--accent, #2563EB);
  outline-offset: -1px;
  background: color-mix(in srgb, var(--accent, #2563EB) 14%, var(--bg-subcard)) !important;
}

#sidebar-search-wrap[hidden] {
  display: none !important;
}

/* ============================================================================
   Tables v2: Notion-like typed columns, task tables, completed sections,
   cell editors, table right-click menu, size picker and the table toolbar.
   Spacing follows the 4 / 8 / 16 / 24 / 32 / 48 scale.
   ============================================================================ */

/* Option chips use Google's dropdown colors, identical in light and dark themes */
:root {
  --ft-sel: #2383E2;
  --ft-tag-default-bg: #E8EAED;
  --ft-tag-default-fg: #3C4043;
  --ft-tag-gray-bg: #D9D9D9;
  --ft-tag-gray-fg: #3D3D3D;
  --ft-tag-brown-bg: #E9D5C3;
  --ft-tag-brown-fg: #5B3A1E;
  --ft-tag-orange-bg: #FFC8AA;
  --ft-tag-orange-fg: #753800;
  --ft-tag-yellow-bg: #FFE5A0;
  --ft-tag-yellow-fg: #473821;
  --ft-tag-green-bg: #D4EDBC;
  --ft-tag-green-fg: #11734B;
  --ft-tag-blue-bg: #BFE1F6;
  --ft-tag-blue-fg: #0A53A8;
  --ft-tag-purple-bg: #E6CFF2;
  --ft-tag-purple-fg: #5A3286;
  --ft-tag-pink-bg: #F8D0E4;
  --ft-tag-pink-fg: #8A1B52;
  --ft-tag-red-bg: #FFCFC9;
  --ft-tag-red-fg: #B10202;
  --ft-overdue: #D44C47;
}

:root[data-theme="dark"] {
  --ft-sel: #529CCA;
  --ft-overdue: #FF7369;
}

/* --- Selection: a single clicked cell is visibly selected too ----------- */
.folio-table-wrap.is-table-active .folio-table:not(.has-multi-cell-selection) th.is-cell-selected,
.folio-table-wrap.is-table-active .folio-table:not(.has-multi-cell-selection) td.is-cell-selected {
  box-shadow: inset 0 0 0 2px var(--ft-sel) !important;
}

.folio-table td.is-editing-cell {
  box-shadow: inset 0 0 0 2px var(--ft-sel) !important;
}

/* The wrapper grows downward only (the completed section sits in row 3) */
.folio-table-wrap {
  align-content: start;
}

.folio-table-wrap > .ft-done-section {
  grid-column: 1;
  grid-row: 3;
}

/* --- Header cells: type icon + column menu button ------------------------ */
.folio-table[data-cols] th::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  vertical-align: -2px;
  background-color: currentColor;
  opacity: 0.55;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.ft-th-menu {
  position: absolute;
  top: 50%;
  right: 4px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background-color: var(--bg-subcard);
  color: var(--text-tertiary);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 120ms ease, background-color 120ms ease, color 120ms ease;
}

.folio-table th:hover .ft-th-menu {
  opacity: 1;
}

@media (hover: none) {
  .folio-table th.is-cell-selected .ft-th-menu {
    opacity: 1;
  }
}

@media (hover: hover) and (pointer: fine) {
  .ft-th-menu:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

/* Column type icons (masks so they follow the header text color) */
.folio-table[data-cols] th[data-col-type="text"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 7 4 4 20 4 20 7'/%3E%3Cline x1='9' x2='15' y1='20' y2='20'/%3E%3Cline x1='12' x2='12' y1='4' y2='20'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 7 4 4 20 4 20 7'/%3E%3Cline x1='9' x2='15' y1='20' y2='20'/%3E%3Cline x1='12' x2='12' y1='4' y2='20'/%3E%3C/svg%3E"); }
.folio-table[data-cols] th[data-col-type="number"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='4' x2='20' y1='9' y2='9'/%3E%3Cline x1='4' x2='20' y1='15' y2='15'/%3E%3Cline x1='10' x2='8' y1='3' y2='21'/%3E%3Cline x1='16' x2='14' y1='3' y2='21'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='4' x2='20' y1='9' y2='9'/%3E%3Cline x1='4' x2='20' y1='15' y2='15'/%3E%3Cline x1='10' x2='8' y1='3' y2='21'/%3E%3Cline x1='16' x2='14' y1='3' y2='21'/%3E%3C/svg%3E"); }
.folio-table[data-cols] th[data-col-type="select"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='12' r='1'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='12' r='1'/%3E%3C/svg%3E"); }
.folio-table[data-cols] th[data-col-type="date"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='4' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='4' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E"); }
.folio-table[data-cols] th[data-col-type="check"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E"); }

/* An icon chosen by the user wins over the one of the column type */
.folio-table[data-cols] th[data-col-icon][data-col-type]::before {
  -webkit-mask-image: var(--ft-th-icon);
  mask-image: var(--ft-th-icon);
}

.ctx-chip-row.ctx-icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 32px);
}

/* Empty rows keep the height of a line of text (acts as a minimum in tables) */
.folio-table tbody td {
  height: 40px;
}

.folio-table[data-table-compact="true"] tbody td {
  height: 32px;
}

/* --- Typed cells ---------------------------------------------------------- */
.folio-table td[data-col-type="check"],
.folio-table th[data-col-type="check"] {
  padding-left: 8px;
  padding-right: 8px;
  text-align: center;
}

/* Only the completion column of a task table hides its menu; other checkbox columns keep it */
.folio-table th.is-task-check .ft-th-menu {
  display: none;
}

.folio-table td[data-col-type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.folio-table td[data-col-type="select"],
.folio-table td[data-col-type="date"] {
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .folio-table td[data-col-type="select"]:hover,
  .folio-table td[data-col-type="date"]:hover {
    background-image: linear-gradient(var(--bg-hover), var(--bg-hover));
  }
}

.ft-select {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0 8px;
  border-radius: 4px;
  background-color: var(--ft-tag-default-bg);
  color: var(--ft-tag-default-fg);
  font-size: 13px;
  font-weight: 500;
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  user-select: none;
}

.ft-select[data-color="gray"] { background-color: var(--ft-tag-gray-bg); color: var(--ft-tag-gray-fg); }
.ft-select[data-color="brown"] { background-color: var(--ft-tag-brown-bg); color: var(--ft-tag-brown-fg); }
.ft-select[data-color="orange"] { background-color: var(--ft-tag-orange-bg); color: var(--ft-tag-orange-fg); }
.ft-select[data-color="yellow"] { background-color: var(--ft-tag-yellow-bg); color: var(--ft-tag-yellow-fg); }
.ft-select[data-color="green"] { background-color: var(--ft-tag-green-bg); color: var(--ft-tag-green-fg); }
.ft-select[data-color="blue"] { background-color: var(--ft-tag-blue-bg); color: var(--ft-tag-blue-fg); }
.ft-select[data-color="purple"] { background-color: var(--ft-tag-purple-bg); color: var(--ft-tag-purple-fg); }
.ft-select[data-color="pink"] { background-color: var(--ft-tag-pink-bg); color: var(--ft-tag-pink-fg); }
.ft-select[data-color="red"] { background-color: var(--ft-tag-red-bg); color: var(--ft-tag-red-fg); }

.ft-select.is-empty,
.ft-date.is-empty {
  background: transparent;
  padding: 0;
}

.folio-table td:hover .ft-select.is-empty::before {
  content: "Selecionar";
  color: var(--text-tertiary);
  font-weight: 400;
}

.ft-date {
  display: inline-flex;
  align-items: center;
  line-height: 24px;
  color: var(--text-primary);
  white-space: nowrap;
  user-select: none;
}

.folio-table td:hover .ft-date.is-empty::before {
  content: "Definir data";
  color: var(--text-tertiary);
}

.ft-date.is-today {
  color: var(--ft-sel);
  font-weight: 600;
}

.ft-date.is-overdue {
  color: var(--ft-overdue);
}

/* --- Task tables ------------------------------------------------------------ */
.folio-table tr.is-completing > td:not([data-col-type="check"]) {
  color: var(--text-tertiary);
  transition: color 300ms ease;
}

/* One line across the whole row: each cell draws its segment edge to edge, in sequence */
.folio-table tr.is-completing > td:not([data-col-type="check"])::after,
.folio-table.ft-done-table td:not([data-col-type="check"])::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: 20px;
  z-index: 1;
  height: 1.5px;
  background-color: var(--text-tertiary);
  pointer-events: none;
}

.folio-table[data-table-compact="true"] tr > td::after {
  top: 16px;
}

.folio-table tr.is-completing > td:first-child::after,
.folio-table tr.is-completing > td[data-col-type="check"] + td::after,
.folio-table.ft-done-table td:first-child::after,
.folio-table.ft-done-table td[data-col-type="check"] + td::after {
  left: 8px;
}

.folio-table tr.is-completing > td:last-child::after,
.folio-table.ft-done-table td:last-child::after {
  right: 8px;
}

.folio-table tr.is-completing > td:not([data-col-type="check"])::after {
  transform-origin: left center;
  animation: ft-strike 90ms linear both;
}

.folio-table tr.is-completing > td:nth-child(3)::after { animation-delay: 90ms; }
.folio-table tr.is-completing > td:nth-child(4)::after { animation-delay: 180ms; }
.folio-table tr.is-completing > td:nth-child(5)::after { animation-delay: 270ms; }
.folio-table tr.is-completing > td:nth-child(n + 6)::after { animation-delay: 360ms; }

.folio-table tr.is-completing .ft-select {
  opacity: 0.6;
}

.folio-table tr.is-leaving {
  animation: ft-row-leave 300ms cubic-bezier(0.55, 0, 0.75, 0.2) both;
}

.ft-row-spacer td {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  transition: height 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

tr.is-restored,
li.task-item.is-restored {
  animation: ft-row-restore 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ft-strike {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes ft-row-leave {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(48px); opacity: 0; }
}

@keyframes ft-row-restore {
  from { transform: translateY(-4px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* --- Checklists: same completing behavior ---------------------------------- */
.rich-editor .task-item input[type="checkbox"] {
  flex-shrink: 0;
  accent-color: var(--ft-sel);
  cursor: pointer;
}

.rich-editor .task-item .task-text {
  transition: color 300ms ease;
}

.rich-editor .task-item.is-completing .task-text {
  color: var(--text-tertiary);
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 55%;
  background-size: 100% 1.5px;
  animation: ft-strike-bg 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.rich-editor .task-item.is-leaving {
  animation: ft-row-leave 300ms cubic-bezier(0.55, 0, 0.75, 0.2) both;
}

.rich-editor .task-item.is-collapsing {
  overflow: hidden;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes ft-strike-bg {
  from { background-size: 0 1.5px; }
  to { background-size: 100% 1.5px; }
}

/* --- "Concluídas" sections (lists and task tables) ------------------------- */
.done-section {
  margin: 8px 0 16px;
  user-select: none;
}

.done-section[hidden] {
  display: none;
}

.done-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.done-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 8px;
  margin-left: -8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.done-chevron {
  display: inline-flex;
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.done-section[data-open="true"] .done-chevron {
  transform: rotate(90deg);
}

.done-count {
  min-width: 24px;
  padding: 0 4px;
  border-radius: 999px;
  background-color: var(--bg-subcard);
  color: var(--text-tertiary);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  line-height: 20px;
  text-align: center;
}

.done-count.is-pulsing {
  animation: ft-count-pulse 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes ft-count-pulse {
  0% { transform: scale(1); background-color: var(--bg-subcard); }
  35% { transform: scale(1.24); background-color: color-mix(in srgb, var(--ft-sel) 24%, var(--bg-subcard)); color: var(--text-primary); }
  100% { transform: scale(1); }
}

.done-clear {
  height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, background-color 120ms ease, color 120ms ease;
}

.done-section:hover .done-clear,
.done-section[data-open="true"] .done-clear {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .done-toggle:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
  .done-clear:hover {
    background-color: var(--danger-bg);
    color: var(--danger-text);
  }
}

.done-body {
  display: none;
}

.done-section[data-open="true"] .done-body {
  display: block;
  animation: ft-row-restore 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.task-done-list {
  list-style: none;
  margin: 0;
  padding-left: 4px;
}

.task-done-list .task-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.task-done-list .task-text {
  color: var(--text-tertiary);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--text-tertiary) 70%, transparent);
}

.ft-done-table td:not([data-col-type="check"]),
.ft-done-table .ft-date {
  color: var(--text-tertiary);
}

.ft-done-table td {
  cursor: default !important;
  background-image: none !important;
}

.ft-done-table .ft-select {
  opacity: 0.7;
}

/* --- Select / date editors ------------------------------------------------ */
.ft-cell-popover {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  z-index: 260;
  width: 272px;
  min-width: 0;
  max-height: min(440px, calc(100vh - 16px));
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform-origin: top left;
}

.ft-cell-popover[hidden] {
  display: none;
}

.ftp-input {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.ftp-input:focus {
  border-color: var(--ft-sel);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ft-sel) 20%, transparent);
}

.ftp-sec-lbl {
  padding: 4px 4px 0;
  color: var(--text-tertiary);
  font-size: 11.5px;
  font-weight: 500;
}

.ftp-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ftp-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 4px 0 8px;
  border-radius: 6px;
  cursor: pointer;
}

.ftp-opt.is-hi {
  background-color: var(--bg-hover);
}

.ftp-opt .ft-select {
  min-width: 0;
}

.ftp-opt-check {
  display: inline-flex;
  margin-left: auto;
  color: var(--text-secondary);
}

.ftp-more,
.ftp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.ftp-more {
  opacity: 0;
}

.ftp-opt:hover .ftp-more,
.ftp-opt.is-hi .ftp-more {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .ftp-opt:hover {
    background-color: var(--bg-hover);
  }
  .ftp-more:hover,
  .ftp-icon-btn:hover {
    background-color: var(--bg-active);
    color: var(--text-primary);
  }
}

.ftp-create-lbl {
  color: var(--text-secondary);
  font-size: 13px;
}

.ftp-empty {
  padding: 8px;
  color: var(--text-tertiary);
  font-size: 12.5px;
}

.ftp-clear {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
  margin-top: 4px;
  border: none;
  border-top: 1px solid var(--border-subcard);
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .ftp-clear:hover {
    color: var(--text-primary);
  }
}

.ftp-edit-head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.ftp-colors {
  display: flex;
  flex-direction: column;
}

.ftp-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .ftp-color-row:hover {
    background-color: var(--bg-hover);
  }
}

.ftp-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  background-color: var(--ft-tag-default-bg);
}

.ftp-swatch[data-color="gray"] { background-color: var(--ft-tag-gray-bg); }
.ftp-swatch[data-color="brown"] { background-color: var(--ft-tag-brown-bg); }
.ftp-swatch[data-color="orange"] { background-color: var(--ft-tag-orange-bg); }
.ftp-swatch[data-color="yellow"] { background-color: var(--ft-tag-yellow-bg); }
.ftp-swatch[data-color="green"] { background-color: var(--ft-tag-green-bg); }
.ftp-swatch[data-color="blue"] { background-color: var(--ft-tag-blue-bg); }
.ftp-swatch[data-color="purple"] { background-color: var(--ft-tag-purple-bg); }
.ftp-swatch[data-color="pink"] { background-color: var(--ft-tag-pink-bg); }
.ftp-swatch[data-color="red"] { background-color: var(--ft-tag-red-bg); }

.ftp-delete {
  margin-top: 4px;
}

.ftp-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
}

.ftp-cal-title {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.ftp-cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px 0;
}

.ftp-wd {
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 24px;
  text-align: center;
}

.ftp-day {
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.ftp-day.is-pad {
  pointer-events: none;
}

.ftp-day.is-today {
  color: var(--ft-sel);
  font-weight: 700;
}

.ftp-day.is-current {
  background-color: var(--ft-sel);
  color: #ffffff;
  font-weight: 600;
}

@media (hover: hover) and (pointer: fine) {
  .ftp-day:not(.is-current):hover {
    background-color: var(--bg-hover);
  }
}

.ftp-quick {
  display: flex;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subcard);
  margin-top: 4px;
}

.ftp-quick button {
  flex: 1 1 0;
  height: 32px;
  padding: 0 4px;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .ftp-quick button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
}

/* --- Right-click menu extras --------------------------------------------- */
.ctx-sep {
  height: 1px;
  margin: 4px 0;
  background-color: var(--border-subcard);
}

.ctx-heading {
  padding: 4px 8px 0;
  color: var(--text-tertiary);
  font-size: 11.5px;
  font-weight: 500;
}

.ctx-chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 8px 8px;
}

.ctx-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  cursor: pointer;
}

.ctx-chip.is-active {
  border-color: var(--ft-sel);
  background-color: color-mix(in srgb, var(--ft-sel) 14%, var(--bg-card));
  color: var(--text-primary);
}

.ctx-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  background-color: var(--dot, transparent);
  color: var(--text-tertiary);
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .ctx-chip:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
  }
  .ctx-dot:hover {
    border-color: var(--border-strong);
    transform: scale(1.08);
  }
}

.menu-item:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.menu-item-kbd {
  margin-left: auto;
  padding-left: 16px;
  color: var(--text-tertiary);
  font-size: 11.5px;
}

/* --- Table size picker ---------------------------------------------------- */
.ft-grid-picker {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  z-index: 260;
  width: auto;
  min-width: 0;
  padding: 8px;
  transform-origin: top left;
}

.ft-grid-picker[hidden] {
  display: none;
}

.ftg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.ftg-size {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: pre;
}

.ftg-grid {
  display: grid;
  grid-template-columns: repeat(var(--ftg-cols, 10), 20px);
  gap: 4px;
  padding: 0 4px 8px;
}

.ftg-cell {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background-color: var(--bg-card);
  cursor: pointer;
  transition: background-color 80ms ease, border-color 80ms ease;
}

.ftg-cell.is-on {
  border-color: var(--ft-sel);
  background-color: color-mix(in srgb, var(--ft-sel) 22%, var(--bg-card));
}

.ftg-option {
  align-items: flex-start;
  white-space: normal;
}

.ftg-option .menu-item-icon {
  padding-top: 4px;
}

.ftg-option-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.35;
}

.ftg-option-text small {
  color: var(--text-tertiary);
  font-size: 11.5px;
}

/* --- Table toolbar panels ------------------------------------------------- */
.qa-sub-tray-inner.qa-tbl-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
  white-space: nowrap;
}

.qa-sub-tray-inner.qa-tbl-panel-cols {
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
}

.qa-tbl-list {
  display: flex;
  flex-direction: column;
  min-width: 176px;
}

.qa-tbl-sec-lbl {
  padding: 4px 8px 0;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  user-select: none;
}

.qa-tbl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.qa-tbl-ico {
  display: inline-flex;
  color: var(--text-secondary);
}

.qa-tbl-item.is-danger,
.qa-tbl-item.is-danger .qa-tbl-ico,
.qa-tbl-chip.is-danger,
.qa-tbl-chip.is-danger .qa-tbl-ico {
  color: var(--danger-text);
}

.qa-tbl-item:disabled,
.qa-tbl-chip:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.qa-tbl-chips {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 4px 8px;
}

.qa-tbl-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background-color: var(--bg-subcard);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.qa-tbl-chip.is-icon {
  width: 32px;
  justify-content: center;
  padding: 0;
}

.qa-tbl-chip.is-active {
  border-color: var(--ft-sel);
  background-color: color-mix(in srgb, var(--ft-sel) 14%, var(--bg-card));
  color: var(--text-primary);
}

.qa-tbl-seg {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 8px;
  background-color: var(--bg-subcard);
}

.qa-tbl-seg-wide {
  margin: 4px 8px;
}

.qa-tbl-seg button {
  min-width: 32px;
  height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.qa-tbl-seg button.is-active {
  background-color: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.qa-tbl-styles {
  display: grid;
  grid-template-columns: repeat(4, 72px);
  gap: 8px;
  padding: 4px 8px;
}

.qa-tbl-style {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  cursor: pointer;
}

.qa-tbl-style.is-active {
  border-color: var(--ft-sel);
  color: var(--text-primary);
}

.qa-tbl-thumb {
  display: grid;
  grid-template-rows: repeat(3, 8px);
  width: 56px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background-color: var(--bg-card);
}

.qa-tbl-thumb i {
  display: block;
  border-bottom: 1px solid var(--border-subcard);
}

.qa-tbl-thumb i:first-child {
  background-color: var(--bg-active);
}

.qa-tbl-thumb i:last-child {
  border-bottom: none;
}

.qa-tbl-thumb[data-thumb="striped"] i:nth-child(3) {
  background-color: var(--bg-subcard);
}

.qa-tbl-thumb[data-thumb="grid"] {
  background-image: linear-gradient(90deg, transparent calc(50% - 0.5px), var(--border-strong) calc(50% - 0.5px), var(--border-strong) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}

.qa-tbl-thumb[data-thumb="grid"] i {
  border-bottom-color: var(--border-strong);
}

.qa-tbl-thumb[data-thumb="editorial"] {
  border-color: transparent;
  border-top: 2px solid var(--text-secondary);
}

.qa-tbl-thumb[data-thumb="editorial"] i:first-child {
  background-color: transparent;
  border-bottom: 1px solid var(--text-secondary);
}

.qa-tbl-toggles {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.qa-tbl-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.qa-tbl-toggle-txt {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.qa-tbl-toggle-txt small {
  color: var(--text-tertiary);
  font-size: 11.5px;
}

.qa-tbl-switch {
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 16px;
  margin-left: auto;
  border-radius: 999px;
  background-color: var(--border-strong);
  transition: background-color 160ms ease;
}

.qa-tbl-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background-color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.qa-tbl-toggle.is-active .qa-tbl-switch {
  background-color: var(--ft-sel);
}

.qa-tbl-toggle.is-active .qa-tbl-switch::after {
  transform: translateX(16px);
}

.tbl-color-dot.is-text {
  background-color: var(--bg-card);
  color: var(--tc);
  font-weight: 700;
}

.tbl-color-dot.is-reset {
  background-color: var(--bg-card);
}

@media (hover: hover) and (pointer: fine) {
  .qa-tbl-item:hover,
  .qa-tbl-toggle:hover,
  .qa-tbl-style:hover {
    background-color: var(--bg-hover);
  }
  .qa-tbl-chip:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
  }
  .qa-tbl-item.is-danger:hover,
  .qa-tbl-chip.is-danger:hover {
    background-color: var(--danger-bg);
  }
  .qa-tbl-seg button:not(.is-active):hover {
    color: var(--text-primary);
  }
  .tbl-color-dot:hover {
    transform: scale(1.1);
  }
}

/* Table options: one flyout, one page per subject */
.qa-tbl-tabs {
  align-self: stretch;
}

.qa-tbl-tabs button {
  flex: 1;
  padding: 0 8px;
}

.qa-tbl-tabs button[aria-pressed="true"] {
  background-color: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

.qa-tbl-page {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  max-height: min(420px, calc(100vh - 240px));
  overflow-y: auto;
}

.qa-tbl-page[hidden] {
  display: none;
}

.qa-tbl-page.qa-tbl-panel-cols {
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
}

/* The left rail (photoshop layout) stacks the panels vertically */
.workspace-card[data-tools-layout="photoshop"] .qa-sub-tray-inner.qa-tbl-panel-cols {
  flex-direction: column;
  gap: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .folio-table tr.is-completing > td::after,
  .rich-editor .task-item.is-completing .task-text,
  .folio-table tr.is-leaving,
  .rich-editor .task-item.is-leaving,
  tr.is-restored,
  li.task-item.is-restored,
  .done-count.is-pulsing {
    animation: none;
  }
}

/* --- Checkboxes in the app's own style (task tables and checklists) -------- */
.ft-cell-check,
.rich-editor .task-item input[type="checkbox"],
.markdown-preview .task-item input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  display: inline-block;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid var(--text-tertiary);
  border-radius: 4px;
  background-color: transparent;
  vertical-align: middle;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, transform 100ms cubic-bezier(0.23, 1, 0.32, 1);
}

.rich-editor .task-item input[type="checkbox"],
.markdown-preview .task-item input[type="checkbox"] {
  align-self: flex-start;
  font: inherit;
  line-height: inherit;
  margin-top: calc((1lh - 16px) / 2);
}

.ft-cell-check::after,
.rich-editor .task-item input[type="checkbox"]::after,
.markdown-preview .task-item input[type="checkbox"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--btn-primary-text);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat;
  transform: scale(0.4);
  opacity: 0;
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 120ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .ft-cell-check:hover,
  .rich-editor .task-item input[type="checkbox"]:hover {
    border-color: var(--text-secondary);
  }
}

.ft-cell-check:active,
.rich-editor .task-item input[type="checkbox"]:active {
  transform: scale(0.9);
}

.ft-cell-check:checked,
.rich-editor .task-item input[type="checkbox"]:checked,
.markdown-preview .task-item input[type="checkbox"]:checked {
  border-color: var(--btn-primary-bg);
  background-color: var(--btn-primary-bg);
}

.ft-cell-check:checked::after,
.rich-editor .task-item input[type="checkbox"]:checked::after,
.markdown-preview .task-item input[type="checkbox"]:checked::after {
  transform: scale(1);
  opacity: 1;
}

.ft-cell-check:focus-visible,
.rich-editor .task-item input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--ft-sel);
}

/* --- Color box: cell fill and text color ----------------------------------- */
.ft-color-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 232px;
  padding: 4px 8px 8px;
}

.ft-color-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ft-color-head .qa-tbl-seg {
  padding: 4px;
}

.ft-color-head .qa-tbl-seg button[aria-pressed="true"] {
  background-color: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ft-color-panel .docs-swatch.is-active {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--ft-sel);
}

.ft-cell-popover.is-color {
  width: auto;
  padding: 4px;
}

.ft-cell-popover.is-color .ft-color-panel {
  padding: 8px;
}

/* ============================================================================
   Phone web app (kept last so it wins over the desktop layout rules)
   ============================================================================ */

@media (max-width: 760px) {
  :root[data-platform="pwa"] .app-stage {
    height: var(--app-height, 100dvh);
  }

  :root[data-platform="pwa"].has-keyboard .app-stage {
    padding-bottom: 4px;
  }

  :root[data-platform="pwa"].has-keyboard .workspace-footer {
    display: none;
  }

  /* Drawer: dimmed page behind it, its own toggle stays reachable on top */
  :root[data-platform="pwa"] .app-stage:not(.sidebar-collapsed)::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 155;
    background: rgba(0, 0, 0, 0.36);
  }

  :root[data-platform="pwa"] .leading-dock {
    z-index: 170;
  }

  :root[data-platform="pwa"] .engraved-hotkey-stamp {
    display: none;
  }

  /* Room for six note actions: the calendar stays on the home screen, and the
     toolbar has a single position on a phone */
  :root[data-platform="pwa"] #btn-calendar-today,
  :root[data-platform="pwa"] #btn-qa-dock,
  :root[data-platform="pwa"] #btn-qa-layout {
    display: none !important;
  }

  :root[data-platform="pwa"] #titlebar .cmd-leading {
    flex: 0 0 auto;
    padding-left: 0;
  }

  :root[data-platform="pwa"] #titlebar .note-header-actions {
    margin-left: auto;
  }

  /* The top line only has room for the dock and the note actions */
  :root[data-platform="pwa"] #titlebar .topbar-sidebar-only,
  :root[data-platform="pwa"] #toolbar-breadcrumb,
  :root[data-platform="pwa"] #top-tabs-bar,
  :root[data-platform="pwa"] .cmd-trailing-zone {
    display: none !important;
  }

  :root[data-platform="pwa"] #titlebar .note-header-actions {
    gap: 0;
    padding-right: 4px;
  }

  :root[data-platform="pwa"] .leading-dock .icon-btn,
  :root[data-platform="pwa"] .note-header-actions .icon-btn {
    width: 36px;
    height: 36px;
  }

  :root[data-platform="pwa"] .leading-dock {
    gap: 0;
    top: calc(12px + env(safe-area-inset-top, 0px));
  }

  /* Title always on its own line, under the buttons */
  :root[data-platform="pwa"] .app-stage #titlebar ~ .workspace-row .note-title-bar {
    margin-top: 40px;
    padding-right: 0;
  }

  /* Below 16px iOS zooms the page when a field gets focus */
  :root[data-platform="pwa"] :is(input, textarea, select, [contenteditable="true"]) {
    font-size: max(16px, 1em);
  }

  :root[data-platform="pwa"] .editor-title {
    font-size: 22px;
  }

  /* Wide tables scroll sideways instead of squeezing their text */
  :root[data-platform="pwa"] .folio-table-wrap .ft-scroll-area {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  :root[data-platform="pwa"] .folio-table-wrap table.folio-table {
    table-layout: auto !important;
    width: max-content !important;
    min-width: 100% !important;
  }

  :root[data-platform="pwa"] .folio-table-wrap table.folio-table :is(th, td) {
    min-width: 112px;
  }

  :root[data-platform="pwa"] .folio-table-wrap table.folio-table :is(th, td)[data-col-type="check"] {
    min-width: 44px;
  }

  :root[data-platform="pwa"] .popover-card {
    max-width: calc(100vw - 32px);
    max-height: calc(var(--app-height, 100dvh) - 120px);
    overflow-y: auto;
  }

  :root[data-platform="pwa"] .menu-item {
    min-height: 44px;
  }

  :root[data-platform="pwa"] .quick-actions-bar .tool-btn {
    min-width: 36px;
    height: 36px;
  }

  /* Keyboard shortcuts mean nothing on a phone */
  :root[data-platform="pwa"] :is(.home-scroll kbd, .home-guide-item) {
    display: none;
  }

  /* Settings: categories become a strip above the page */
  :root[data-platform="pwa"] .settings-modal-dialog {
    flex-direction: column;
  }

  :root[data-platform="pwa"] .settings-modal-rail {
    width: 100%;
    flex: 0 0 auto;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--border-subcard);
  }

  :root[data-platform="pwa"] .settings-modal-rail-head {
    padding-right: 40px;
  }

  :root[data-platform="pwa"] .settings-cat-list {
    flex: 0 0 auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }

  :root[data-platform="pwa"] .settings-cat-btn {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  :root[data-platform="pwa"] .settings-modal-main {
    min-height: 0;
  }

  /* A control that does not fit beside its label goes under it */
  :root[data-platform="pwa"] .settings-modal-main .settings-row {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  :root[data-platform="pwa"] .settings-modal-main .settings-row > .settings-row-info {
    flex: 1 1 200px;
  }

  :root[data-platform="pwa"] .settings-modal-main .settings-row > :not(.settings-row-info) {
    max-width: 100%;
    overflow-x: auto;
  }
}
