/* Author: Dave Greenlaw — BizBarrel global shell / tokens */

:root {
  color-scheme: light;
  --border: #d2d2d2;
  --accent: #2a4d8f;
  --bg: #ffffff;
  --text: #1f2937;
  --surface: #ffffff;
  --surface-muted: #f4f6f9;
  --text-muted: #64748b;
  --dialog-border: rgba(0, 0, 0, 0.12);
  --dialog-surface:
    linear-gradient(180deg, rgba(248, 250, 252, 0.92) 0%, rgba(255, 255, 255, 0.96) 55%, rgba(255, 255, 255, 1) 100%);
  --dialog-shadow:
    0 28px 80px rgba(0, 0, 0, 0.22),
    0 10px 26px rgba(0, 0, 0, 0.14);
  --dialog-header-bg: linear-gradient(180deg, rgba(42, 77, 143, 0.1), rgba(42, 77, 143, 0.03));

  /* Content cards — Archive / Group / Photo Album / Blog / Forums */
  --bb-card-radius: 12px;
  --bb-card-padding: 14px 16px;
  --bb-card-border: color-mix(in srgb, var(--border) 62%, var(--accent) 38%);
  --bb-card-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 4px 10px rgba(15, 23, 42, 0.06),
    0 10px 28px rgba(15, 23, 42, 0.1);
  --bb-card-shadow-hover:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 2px 6px rgba(15, 23, 42, 0.07),
    0 8px 18px rgba(15, 23, 42, 0.09),
    0 16px 36px rgba(15, 23, 42, 0.14);
  --bb-owner-actions-gap: 8px;
  --bb-owner-action-danger: #b91c1c;
}

html, body {
  height: 100%;
}

#noteBody ::selection {
  background: yellow;
  color: black;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

/* ============================================================
   Dialog Design System
   NOTE: all dialogs/popups should inherit these styles by default.
   Use an explicit override class only when needed.
============================================================ */
:root {
  /* Logo bar + mode bar — keep modals / floating windows below this offset */
  --bb-chrome-top: 152px;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 18, 25, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100150;
  padding: var(--bb-chrome-top) 18px 24px;
  box-sizing: border-box;
  overflow-y: auto;
}

.modal > .modal-content {
  margin: 0 auto;
  max-height: calc(100vh - var(--bb-chrome-top) - 32px);
  overflow-y: auto;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: var(--dialog-surface);
  padding: 18px;
  border-radius: 14px;
  box-shadow: var(--dialog-shadow);
  border: 1px solid var(--dialog-border);
}

.modal-content h2 {
  margin: 0 0 12px 0;
  font-size: 18px;
  letter-spacing: 0.2px;
  color: var(--text);
}

.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

/* Header */

.header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 8px;
  border-bottom: 2px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
}

/* Fixed site header: collapse on scroll, footprint + proximity expand.
   Fixed + spacer keeps the Menu footprint visible during continuous scroll. */
.bb-header-autohide-spacer {
  width: 100%;
  flex-shrink: 0;
  pointer-events: none;
}

.bb-header-autohide {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Match pre-autohide .header (100100) so account menu / notif panels
     stack above page chrome; stay below true modals (100150+). */
  z-index: 100100;
  width: 100%;
}

.bb-header-autohide .header {
  max-height: 220px;
  /* Visible while expanded so .header-dropdown is not clipped. */
  overflow: visible;
  transition:
    max-height 0.3s ease,
    padding 0.28s ease,
    opacity 0.22s ease,
    border-bottom-width 0.28s ease,
    box-shadow 0.28s ease;
  box-shadow: 0 0 0 transparent;
}

.bb-header-autohide.is-pinned .header {
  box-shadow:
    0 6px 18px rgba(15, 23, 42, 0.1),
    0 1px 0 rgba(15, 23, 42, 0.06);
}

.bb-header-autohide.is-minimized .header {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-bottom-width: 0;
  box-shadow: none;
  pointer-events: none;
  overflow: hidden;
}

.bb-header-footprint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  border: 0;
  border-bottom: 0 solid color-mix(in srgb, var(--accent, #2a4d8f) 55%, var(--border, #d2d2d2));
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--accent, #2a4d8f) 14%, var(--surface, #fff)) 0%,
      var(--surface, #fff) 100%
    );
  color: var(--text-muted, #64748b);
  cursor: pointer;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition:
    max-height 0.28s ease,
    opacity 0.22s ease,
    padding 0.28s ease,
    border-bottom-width 0.28s ease,
    background-color 0.2s ease;
}

.bb-header-autohide.is-minimized .bb-header-footprint {
  max-height: 22px;
  opacity: 1;
  padding: 3px 10px 4px;
  border-bottom-width: 2px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.bb-header-footprint:hover,
.bb-header-footprint:focus-visible {
  color: var(--accent, #2a4d8f);
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--accent, #2a4d8f) 22%, var(--surface, #fff)) 0%,
      var(--surface, #fff) 100%
    );
}

.bb-header-footprint:focus-visible {
  outline: 2px solid var(--accent, #2a4d8f);
  outline-offset: -2px;
}

.bb-header-footprint__grip {
  display: block;
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #2a4d8f) 45%, var(--border, #cbd5e1));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #2a4d8f) 18%, transparent);
}

.bb-header-footprint__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.bb-header-autohide--reduced .header,
.bb-header-autohide--reduced .bb-header-footprint {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .bb-header-autohide .header,
  .bb-header-footprint {
    transition: none;
  }
}

.logo {
  height: 60px;
  width: auto;
  margin-right: 12px;
  object-fit: contain;
  display: block;
}

/* Marketing home keeps the full logo bar; all other surfaces stay at current compact height. */
body:not(.index-page) .header {
  padding: 10px 6px;
  gap: 4px;
}

/* Keep collapse padding wins over compact header padding. */
.bb-header-autohide.is-minimized .header,
body:not(.index-page) .bb-header-autohide.is-minimized .header {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-bottom-width: 0;
  box-shadow: none;
  pointer-events: none;
  overflow: hidden;
}

/* Fit logo into the compact bar (home keeps full 60px). */
body:not(.index-page) .logo {
  height: 39px;
  max-height: 39px;
  width: auto;
  margin-right: 4px;
}

body:not(.index-page) .header-logo-link {
  flex-shrink: 0;
  line-height: 0;
}

body:not(.index-page) .index-header {
  gap: 6px;
}

body:not(.index-page) .index-header__brand {
  gap: 6px;
}

body:not(.index-page) .index-header__right {
  gap: 6px;
}

body:not(.index-page) .index-header__nav {
  gap: 2px 6px;
  font-size: 13px;
}

body:not(.index-page) .public-forums-title {
  font-size: 14px;
  letter-spacing: 0;
}

body:not(.index-page) .account-menu-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
}

body:not(.index-page) .gear-icon-btn__svg {
  width: 18px;
  height: 18px;
}

body:not(.index-page) .bb-look-btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  max-width: 26px;
  flex-basis: 26px;
}

body:not(.index-page) .bb-look-btn__icon {
  width: 14px;
  height: 14px;
  font-size: 14px;
  line-height: 14px;
}

body:not(.index-page) .header-logo-link:focus-visible {
  outline-offset: 2px;
  border-radius: 4px;
}

/* Animate logo/bar size when compact state changes (e.g. Cockpit mode switch). */
body:not(.index-page) .header,
body:not(.index-page) .logo,
body:not(.index-page) .public-forums-title,
body:not(.index-page) .index-header__brand,
body:not(.index-page) .index-header__right,
body:not(.index-page) .account-menu-btn {
  transition:
    height 0.22s ease,
    padding 0.22s ease,
    margin 0.22s ease,
    gap 0.22s ease,
    font-size 0.22s ease,
    width 0.22s ease,
    min-width 0.22s ease;
}

@media (prefers-reduced-motion: reduce) {
  body:not(.index-page) .header,
  body:not(.index-page) .logo,
  body:not(.index-page) .public-forums-title,
  body:not(.index-page) .index-header__brand,
  body:not(.index-page) .index-header__right,
  body:not(.index-page) .account-menu-btn {
    transition: none;
  }
}

/* Same-page view transition: quick squeeze on the logo bar */
@keyframes bb-logo-bar-squeeze {
  0% {
    transform: scaleY(1);
  }
  40% {
    transform: scaleY(0.88);
  }
  100% {
    transform: scaleY(1);
  }
}

.header.bb-logo-bar--squeeze {
  transform-origin: top center;
  animation: bb-logo-bar-squeeze 0.28s ease;
}

@media (prefers-reduced-motion: reduce) {
  .header.bb-logo-bar--squeeze {
    animation: none;
  }
}

.header-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.header-logo-link:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 4px;
  border-radius: 8px;
}

html[data-theme="dark"] .header-logo-link:focus-visible,
html[data-theme="soft"] .header-logo-link:focus-visible {
  outline-color: #60a5fa;
}

a.sticky-icon-btn {
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
}

/* Single logo asset (bb_logom22.png) — no theme swap */

.header-title {
  font-size: 20px;
  font-weight: bold;
  color: var(--accent);
}

/* App shell */

.app-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

/* Footer */

.footer {
  border-top: 2px solid var(--border);
  padding: 8px 16px;
  background-color: var(--surface);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  font-size: 14px;
  font-weight: bold;
  color: var(--text-muted);
}

/* ============================================================
   MODE BAR
============================================================ */
.mode-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 6px;
  row-gap: 8px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  align-items: center;
}

.mode-bar-spacer {
  flex: 1 1 12px;
  min-width: 12px;
}

/* ============================================================
   Alpha mode indicator (top bar) — makes it obvious this is a
   pre-release build for testers and dev.
============================================================ */
.mode-bar--alpha {
  background: repeating-linear-gradient(
    135deg,
    #fff4d6 0px,
    #fff4d6 14px,
    #ffe9ad 14px,
    #ffe9ad 28px
  );
  border-bottom: 2px solid #d97706;
  box-shadow: inset 0 -2px 0 rgba(217, 119, 6, 0.25);
}

.mode-bar-alpha-sticker {
  display: inline-flex;
  align-items: center;
  letter-spacing: 0.1em;
  font-weight: 800;
  font-size: 0.65rem;
  line-height: 1;
  color: #7c2d12;
  background: #f59e0b;
  border: 1px solid #b45309;
  border-radius: 5px;
  padding: 4px 7px;
  text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transform: rotate(-3deg);
  user-select: none;
  flex: 0 0 auto;
  font-family: inherit;
  cursor: pointer;
}

html[data-theme="dark"] .mode-bar--alpha {
  background: repeating-linear-gradient(
    135deg,
    #3a2c08 0px,
    #3a2c08 14px,
    #4a3809 14px,
    #4a3809 28px
  );
  border-bottom-color: #f59e0b;
}

html[data-theme="dark"] .mode-bar-alpha-sticker {
  color: #1a1206;
  background: #fbbf24;
  border-color: #f59e0b;
}

.sticky-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   Floating window (non-modal overlay)
============================================================ */
.floating-window {
  position: fixed;
  top: var(--bb-chrome-top);
  left: calc(50vw - 350px);
  width: 700px; /* default ~100px wider */
  height: 600px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--bb-chrome-top));
  min-width: 520px;
  min-height: 460px;
  border-radius: 16px;
  border: 1px solid var(--dialog-border);
  background: var(--dialog-surface);
  box-shadow: var(--dialog-shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100140;
  overflow: hidden;
  resize: both;
}

.floating-window.hidden {
  display: none !important;
}

.floating-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.10);
  background: var(--dialog-header-bg);
  cursor: grab;
  user-select: none;
}

.floating-window-header:active {
  cursor: grabbing;
}

.floating-window-title {
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #1f2a44;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-header-actions,
.journal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bb-window-header-leading,
.calendar-header-leading,
.journal-header-leading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.bb-window-header-leading .floating-window-title,
.calendar-header-leading .floating-window-title,
.journal-header-leading .floating-window-title {
  flex: 1;
  min-width: 0;
}

/* Top-bar nav icon (calendar back, modal parent-step, teams exit) */
.bb-window-nav-btn,
.calendar-window-nav-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(42, 77, 143, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: #1e3a5f;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.bb-window-nav-btn:hover,
.calendar-window-nav-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(42, 77, 143, 0.38);
  color: #0f2744;
}

.bb-window-nav-btn:focus-visible,
.calendar-window-nav-btn:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
}

.bb-window-nav-btn.hidden,
.calendar-window-nav-btn.hidden {
  display: none !important;
}

.bb-window-nav-btn__icon,
.calendar-window-nav-btn__icon {
  display: block;
  width: 20px;
  height: 20px;
}

/* When a header nav icon is visible, drop the decorative dialog mark */
.dialog-header-main:has(.bb-window-nav-btn:not(.hidden)) > .dialog-header-icon {
  display: none;
}

.dialog-header-main .bb-window-nav-btn {
  margin-right: 2px;
}

/* Journal (rich notes by calendar day) */
.journal-window {
  z-index: 100145;
  left: calc(50vw - 380px);
  width: 760px;
  height: 620px;
  min-width: 560px;
  border-color: rgba(42, 77, 143, 0.18);
  box-shadow:
    0 32px 90px rgba(15, 23, 42, 0.24),
    0 14px 36px rgba(15, 23, 42, 0.14),
    0 0 0 1px rgba(255, 255, 255, 0.65) inset;
}

.journal-window .floating-window-header {
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  border-bottom-color: rgba(42, 77, 143, 0.12);
}

.journal-window-body.floating-window-body {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 42%, #f1f5f9 100%);
}

.journal-window-head-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.journal-header-leading .journal-window-head-text {
  flex: 1;
  min-width: 0;
}

.journal-window-head-text .floating-window-title {
  flex: 0 0 auto;
}

.journal-window-subtitle {
  margin: 0;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  color: #64748b;
  max-width: 42rem;
}

.journal-date-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 10px 12px 0;
  border: 1px solid rgba(42, 77, 143, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 4px 14px rgba(15, 23, 42, 0.07),
    0 1px 3px rgba(15, 23, 42, 0.05);
}

.journal-date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.journal-date-label {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: #1f2a44;
  text-align: center;
}

.journal-date-today {
  flex-shrink: 0;
  margin-left: auto;
}

.journal-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  padding: 10px 12px 14px;
  gap: 10px;
  box-sizing: border-box;
}

.journal-sidebar {
  width: 200px;
  min-width: 180px;
  border: 1px solid rgba(42, 77, 143, 0.12);
  border-radius: 12px;
  padding: 10px 10px 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
  box-shadow:
    0 6px 18px rgba(15, 23, 42, 0.08),
    0 2px 6px rgba(15, 23, 42, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.journal-sidebar .journal-entry-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.journal-sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 6px;
}

.journal-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.journal-entry-item {
  padding: 7px 9px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.journal-entry-item:hover {
  background: #e9f1ff;
  border-color: rgba(42, 77, 143, 0.12);
  box-shadow: 0 2px 6px rgba(42, 77, 143, 0.08);
}

.journal-entry-item.active {
  background: linear-gradient(180deg, #e8f0ff 0%, #d4e3ff 100%);
  font-weight: 600;
  border-color: rgba(42, 77, 143, 0.22);
  box-shadow:
    0 3px 10px rgba(42, 77, 143, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.journal-sidebar .sidebar-footer {
  padding-top: 8px;
  padding-bottom: 2px;
}

.journal-sidebar .sidebar-tree-toolbar {
  padding: 10px 8px 12px;
  margin-top: 8px;
  border-top: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.08),
    0 1px 3px rgba(15, 23, 42, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.journal-sidebar .sidebar-tree-toolbar .pill-btn {
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.journal-sidebar .sidebar-tree-toolbar .pill-btn:hover:not(:disabled) {
  box-shadow: 0 3px 8px rgba(42, 77, 143, 0.16);
}

.journal-editor-pane.note-editor-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(42, 77, 143, 0.14);
  border-radius: 12px;
  background: #ffffff;
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.1),
    0 3px 8px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  overflow: hidden;
}

.journal-note-toolbar {
  flex-wrap: wrap;
  padding: 10px 10px 8px;
  border-bottom: 1px solid rgba(42, 77, 143, 0.1);
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

#journalNoteBodyWrapper {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 10px 12px 14px;
  box-sizing: border-box;
  background: #ffffff;
}

#journalNoteBody {
  min-height: 200px;
  max-height: 100%;
  overflow-y: auto;
}

.floating-window-body {
  height: calc(100% - 52px);
  padding: 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Calendar: full-bleed background below header (tracks window resize) */
.calendar-window-body {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.calendar-content-layer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  padding: 12px;
  box-sizing: border-box;
}

.calendar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

/* Calendar / date step buttons — match budget period ← → controls */
.cal-step-btn {
  min-width: 2.25rem;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: center;
}

.calendar-controls .cal-step-btn,
.dashboard-date-nav .cal-step-btn,
.budget-period .cal-step-btn,
.journal-date-nav .cal-step-btn {
  flex-shrink: 0;
}

.calendar-selectors {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.calendar-selectors select {
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
}

.calendar-grid {
  flex: 1;
  min-height: 0;
}

.calendar-grid-inner {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(58px, 1fr);
  gap: 8px;
  height: 100%;
}

.calendar-cell {
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

/* Weekday row: labels only — not styled like date buttons */
.calendar-dow-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  user-select: none;
  border: none;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.calendar-day {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #1f2a44;
  transition: transform 0.06s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  padding: 6px 4px 4px;
  gap: 2px;
}

.calendar-day:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.12);
  border-color: rgba(42, 77, 143, 0.28);
}

.calendar-day.is-today:hover {
  border-color: rgba(0, 120, 212, 0.58);
  box-shadow:
    inset 0 0 0 1px rgba(0, 120, 212, 0.25),
    0 0 0 2px rgba(0, 120, 212, 0.18),
    0 12px 28px rgba(0,0,0,0.12);
}

.calendar-day.is-outside {
  opacity: 0.45;
}

.calendar-day.is-today {
  border-color: rgba(0, 120, 212, 0.5);
  box-shadow:
    inset 0 0 0 1px rgba(0, 120, 212, 0.2),
    0 0 0 2px rgba(0, 120, 212, 0.14);
}

.calendar-day.is-selected {
  background: rgba(0, 120, 212, 0.10);
  border-color: rgba(0, 120, 212, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.14);
}

.calendar-day.is-today.is-selected {
  border-color: rgba(0, 120, 212, 0.62);
  box-shadow:
    inset 0 0 0 1px rgba(0, 120, 212, 0.22),
    0 0 0 2px rgba(0, 120, 212, 0.18),
    0 0 0 4px rgba(0, 120, 212, 0.08);
}

.calendar-month-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.calendar-day-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.calendar-day-view.hidden {
  display: none !important;
}

.calendar-day-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.calendar-day-canvas {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scroll-behavior: smooth;
}

.calendar-day-toc {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.95);
}

.calendar-day-toc-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 8px;
}

.calendar-day-toc-list {
  margin: 0;
  padding-left: 1.25rem;
}

.calendar-day-toc-item {
  margin-bottom: 6px;
  line-height: 1.35;
}

.calendar-day-toc-item:last-child {
  margin-bottom: 0;
}

.calendar-day-toc-link {
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.calendar-day-toc-link:hover {
  color: #1e3a8a;
}

.calendar-day-toc-kind {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
}

.calendar-day-loading,
.calendar-day-empty {
  padding: 16px 8px;
  color: #64748b;
  font-size: 14px;
}

.calendar-day-api-error {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(185, 28, 28, 0.35);
  background: rgba(254, 226, 226, 0.85);
  color: #7f1d1d;
  font-size: 13px;
  line-height: 1.45;
}

.calendar-day-section {
  margin-bottom: 20px;
}

.calendar-day-section-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
}

.calendar-day-card {
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.92);
  scroll-margin-top: 12px;
}

.calendar-day-card--planned {
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(239, 246, 255, 0.9);
}

.calendar-day-card--task {
  border-color: rgba(124, 58, 237, 0.28);
  background: rgba(245, 243, 255, 0.92);
}

.calendar-day-card-meta {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
}

.calendar-day-card-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: #1f2a44;
}

.calendar-day-card-time {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.calendar-day-card-body {
  font-size: 14px;
  line-height: 1.6;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}

.calendar-day-card-sub {
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}

.calendar-day-muted {
  font-size: 13px;
  color: #94a3b8;
}

.calendar-day-comment-list {
  margin: 0;
  padding-left: 18px;
}

.calendar-day-comment {
  margin-bottom: 8px;
}

.calendar-day-comment-meta {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 2px;
}

.calendar-day-comment-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.55;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}

.calendar-day-num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  font-size: 14px;
  font-weight: 600;
}

.calendar-day-icons {
  display: flex;
  gap: 2px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 14px;
  line-height: 1;
}

.calendar-day-icons--empty {
  min-height: 14px;
}

.calendar-day-icon {
  font-size: 11px;
  line-height: 1;
  opacity: 0.88;
}

/* Calendar modal — light mode: recessed grid tray + raised day tiles (3D) */
html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window.floating-window {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 24px 52px rgba(15, 23, 42, 0.16),
    0 10px 22px rgba(15, 23, 42, 0.1);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .floating-window-header {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 55%, #e8eef5 100%);
  border-bottom-color: rgba(15, 23, 42, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 2px 6px rgba(15, 23, 42, 0.06);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-grid-inner {
  padding: 8px;
  border-radius: 14px;
  background: linear-gradient(165deg, #e9eef5 0%, #dde5ef 52%, #d2dbe8 100%);
  box-shadow:
    inset 0 2px 7px rgba(15, 23, 42, 0.14),
    inset 0 -1px 0 rgba(255, 255, 255, 0.7);
  gap: 7px;
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-dow-label {
  color: #475569;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
  padding-bottom: 2px;
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window button.calendar-day.calendar-cell {
  background: linear-gradient(168deg, #ffffff 0%, #f8fafc 38%, #edf2f8 100%);
  border: 1px solid rgba(15, 23, 42, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 2px 0 rgba(255, 255, 255, 0.55),
    0 4px 10px rgba(15, 23, 42, 0.1),
    0 1px 3px rgba(15, 23, 42, 0.07);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window button.calendar-day.calendar-cell.is-outside {
  background: linear-gradient(168deg, #f6f8fb 0%, #eef2f7 100%);
  border-color: rgba(15, 23, 42, 0.09);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 1px 4px rgba(15, 23, 42, 0.05);
  opacity: 0.72;
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window button.calendar-day.calendar-cell:hover {
  transform: translateY(-2px);
  background: linear-gradient(168deg, #ffffff 0%, #f8fbff 42%, #e8f0fa 100%);
  border-color: rgba(42, 77, 143, 0.32);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 6px 16px rgba(15, 23, 42, 0.14),
    0 2px 6px rgba(42, 77, 143, 0.12);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window button.calendar-day.calendar-cell.is-today {
  background: linear-gradient(168deg, #f0f9ff 0%, #e0f2fe 48%, #dbeafe 100%);
  border-color: rgba(0, 120, 212, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 0 0 1px rgba(0, 120, 212, 0.12),
    0 0 0 2px rgba(0, 120, 212, 0.14),
    0 4px 12px rgba(0, 120, 212, 0.14);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window button.calendar-day.calendar-cell.is-selected {
  background: linear-gradient(168deg, #e8f4fc 0%, #dbeafe 50%, #cfe4fb 100%);
  border-color: rgba(0, 120, 212, 0.5);
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 6px rgba(0, 90, 180, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 0 0 2px rgba(0, 120, 212, 0.16),
    0 1px 3px rgba(15, 23, 42, 0.08);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window button.calendar-day.calendar-cell.is-today.is-selected {
  background: linear-gradient(168deg, #dff0ff 0%, #cfe8fc 55%, #b9dcfa 100%);
  box-shadow:
    inset 0 2px 7px rgba(0, 90, 180, 0.16),
    inset 0 0 0 1px rgba(0, 120, 212, 0.2),
    0 0 0 2px rgba(0, 120, 212, 0.2),
    0 0 0 4px rgba(0, 120, 212, 0.08);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window button.calendar-day.calendar-cell:active {
  transform: translateY(0);
  box-shadow:
    inset 0 2px 5px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 1px 3px rgba(15, 23, 42, 0.08);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-num {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-selectors select,
html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-controls .cal-step-btn {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 1px 3px rgba(15, 23, 42, 0.08);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-controls .cal-step-btn:hover,
html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-selectors select:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 3px 8px rgba(15, 23, 42, 0.12);
}

/* Light — day detail: recessed canvas + raised panels */
html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-toolbar .cal-step-btn,
html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-toolbar .pill-btn {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 1px 3px rgba(15, 23, 42, 0.08);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-canvas {
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(165deg, #e9eef5 0%, #dde5ef 52%, #d2dbe8 100%);
  box-shadow:
    inset 0 2px 7px rgba(15, 23, 42, 0.12),
    inset 0 -1px 0 rgba(255, 255, 255, 0.65);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-toc {
  background: linear-gradient(168deg, #ffffff 0%, #f8fafc 42%, #edf2f8 100%);
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 4px 12px rgba(15, 23, 42, 0.09),
    0 1px 3px rgba(15, 23, 42, 0.06);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-section-title {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-card {
  background: linear-gradient(168deg, #ffffff 0%, #f8fafc 40%, #f1f5f9 100%);
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 3px 10px rgba(15, 23, 42, 0.09),
    0 1px 3px rgba(15, 23, 42, 0.06);
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-card:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 6px 14px rgba(15, 23, 42, 0.12),
    0 2px 5px rgba(15, 23, 42, 0.08);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-card--planned {
  background: linear-gradient(168deg, #f8fbff 0%, #eff6ff 55%, #dbeafe 100%);
  border-color: rgba(37, 99, 235, 0.28);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-card--task {
  background: linear-gradient(168deg, #faf5ff 0%, #f5f3ff 55%, #ede9fe 100%);
  border-color: rgba(124, 58, 237, 0.28);
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-comment {
  padding: 8px 10px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.07);
  list-style: none;
  margin-left: 0;
}

html:not([data-theme="dark"]):not([data-theme="soft"]):not([data-theme="glass"]) .calendar-window .calendar-day-api-error {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 2px 6px rgba(127, 29, 29, 0.12);
}

.sticky-icon-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sticky-icon-btn:hover {
  background: #f0f0f0;
}

.sticky-icon-btn--placeholder {
  opacity: 0.92;
  border-style: dashed;
}

.sticky-icon-btn--tack:hover {
  background: #fef2f2;
}

.sticky-tack-icon {
  font-size: 16px;
  line-height: 1;
}

.sticky-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc3545;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #f5f5f5;
}

/* Sticky modal */
.modal-content.sticky-modal-content {
  width: 560px;
  max-width: calc(100vw - 36px);
}

.sticky-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

#stickyModal .sticky-modal-new-btn.pill-btn.primary {
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent, #2a4d8f) 28%, transparent);
}

#stickyModal .sticky-list-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

#stickyModal .sticky-list-panel-head .dialog-section-title {
  margin: 0;
}

.sticky-panel {
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.sticky-panel + .sticky-panel {
  margin-top: 10px;
}

.sticky-panel-title {
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 8px;
}

/* ============================================================
   Dialog Standardization (used by all popup dialogs going forward)
============================================================ */
.modal-content.dialog-card {
  width: 560px;
  max-width: calc(100vw - 36px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -18px 12px -18px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.10);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  background: var(--dialog-header-bg);
}

.dialog-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.dialog-header-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.dialog-header-main h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
}

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

.dialog-section {
  border: 1px solid rgba(0,0,0,0.09);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.88);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
}

.dialog-section + .dialog-section {
  margin-top: 10px;
}

.dialog-section-title {
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 8px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* System dialogs (alert / confirm / prompt) — sit above feature modals */
.modal.bb-system-modal {
  z-index: 100250;
}

body.bb-system-modal-open {
  overflow: hidden;
}

/* Blocking notice / confirm / session-style: no accidental dismiss affordance */
.modal.bb-blocking-modal {
  pointer-events: auto;
}

.modal-content.dialog-card.bb-system-dialog {
  width: 420px;
}

.bb-system-dialog__message {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
}

.bb-system-dialog__prompt-wrap {
  display: block;
  margin-top: 10px;
}

.bb-system-dialog__prompt-wrap.hidden {
  display: none !important;
}

.bb-system-dialog__input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: var(--text);
  font: inherit;
}

/* Ensure danger CTA works on pages that do not load notepad.css */
.bb-system-dialog .pill-btn--danger {
  border-color: rgba(185, 28, 28, 0.35);
  color: #b91c1c;
  background: rgba(254, 242, 242, 0.9);
}

.bb-system-dialog .pill-btn--danger:hover:not(:disabled) {
  background: rgba(254, 226, 226, 0.95);
}

.account-overlay-card {
  max-width: 640px;
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
}

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

.account-overlay-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.account-overlay-tab {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
}

.account-overlay-tab:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.account-overlay-tab.active {
  border-color: #1e293b;
  background: #1e293b;
  color: #fff;
}

.account-overlay-panels {
  min-height: 0;
  overflow-y: auto;
  max-height: min(62vh, 520px);
}

.account-overlay-panel.dialog-section + .account-overlay-panel.dialog-section {
  margin-top: 0;
}

.account-profile-layout {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 520px) {
  .account-profile-layout {
    grid-template-columns: 1fr;
  }
}

.account-profile-avatar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.account-profile-avatar-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.account-profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.account-profile-avatar-placeholder {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent, #2563eb);
  line-height: 1;
}

.account-profile-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.account-profile-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-top: 4px;
}

.account-profile-hint {
  font-weight: 500;
  font-size: 12px;
  color: #64748b;
}

.account-profile-hint--error {
  color: #b91c1c;
}

.account-profile-fields input,
.account-profile-fields textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
  font-family: inherit;
}

.account-profile-fields textarea {
  resize: vertical;
  min-height: 88px;
}

.account-profile-fields input:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.account-overlay-status {
  margin-top: 10px;
}

.account-overlay-status[data-error="1"] {
  color: #b91c1c;
}

.admin-flagged-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
}

.admin-flagged-item {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.6);
}

.admin-flagged-item__title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.admin-flagged-item__meta {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 8px;
}

.admin-flagged-item__flag-detail {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted, #64748b);
  margin-bottom: 10px;
}

html[data-theme="dark"] .admin-flagged-item__flag-detail,
html[data-theme="soft"] .admin-flagged-item__flag-detail {
  color: var(--text-muted);
}

.admin-flagged-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-analytics-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-analytics-root {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: min(62vh, 640px);
  overflow: auto;
  padding-right: 4px;
}

.admin-analytics-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.admin-analytics-card {
  border: 1px solid var(--dialog-border, rgba(0, 0, 0, 0.12));
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.45);
}

html[data-theme="dark"] .admin-analytics-card,
html[data-theme="soft"] .admin-analytics-card {
  background: rgba(0, 0, 0, 0.18);
}

.admin-analytics-card__value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.admin-analytics-card__label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.admin-analytics-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-analytics-heading {
  margin: 0;
  font-size: 15px;
}

.admin-analytics-subheading {
  margin: 0 0 4px;
  font-size: 14px;
}

.admin-analytics-meta {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

.admin-analytics-subsection + .admin-analytics-subsection {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--dialog-border, rgba(0, 0, 0, 0.08));
}

.admin-analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-analytics-table th,
.admin-analytics-table td {
  padding: 6px 8px;
  vertical-align: middle;
  border-bottom: 1px solid var(--dialog-border, rgba(0, 0, 0, 0.08));
}

.admin-analytics-table__key {
  width: 34%;
  word-break: break-word;
}

.admin-analytics-table__bar {
  width: 46%;
}

.admin-analytics-table__count {
  width: 20%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-analytics-table__props {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  word-break: break-word;
}

.admin-analytics-table--compact th,
.admin-analytics-table--compact td {
  padding: 4px 6px;
}

.admin-analytics-bar {
  display: block;
  height: 8px;
  min-width: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.85), rgba(99, 102, 241, 0.75));
}

.admin-analytics-error-item .admin-flagged-item__title {
  font-size: 13px;
}

/* ---- Admin full-page mode (Cockpit) ---- */
.admin-mode-app {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 0;
  padding: 12px 16px 20px;
  box-sizing: border-box;
}

.admin-mode-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-mode-title {
  margin: 0;
  font-size: 22px;
}

.admin-mode-tagline {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted, #64748b);
}

.admin-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--dialog-border, rgba(0, 0, 0, 0.1));
  padding-bottom: 8px;
}

.admin-mode-tab {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

.admin-mode-tab:hover {
  background: rgba(59, 130, 246, 0.08);
}

.admin-mode-tab.active {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.35);
  font-weight: 600;
}

.admin-mode-panels {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.admin-mode-panel {
  display: block;
}

.beta-analytics-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.beta-analytics-title {
  margin: 0 0 4px;
  font-size: 18px;
}

.beta-analytics-dashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.beta-analytics-row {
  display: grid;
  gap: 14px;
}

.beta-analytics-row--top {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.beta-analytics-row--middle {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.beta-analytics-row--bottom {
  grid-template-columns: 1fr;
}

@media (max-width: 1100px) {
  .beta-analytics-row--top,
  .beta-analytics-row--middle {
    grid-template-columns: 1fr;
  }
}

.beta-panel {
  border: 1px solid var(--dialog-border, rgba(0, 0, 0, 0.12));
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.35);
  min-height: 0;
}

html[data-theme="dark"] .beta-panel,
html[data-theme="soft"] .beta-panel {
  background: rgba(0, 0, 0, 0.16);
}

.beta-panel__title {
  margin: 0;
  font-size: 15px;
}

.beta-panel__hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted, #64748b);
}

.beta-panel__body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.beta-panel--wide {
  grid-column: 1 / -1;
}

.beta-mode-insights summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}

.beta-retention-cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.beta-error-recent {
  max-height: 220px;
  overflow: auto;
}

#adminRoot.mode-root:not(.hidden) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.moderation-alert-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.moderation-alert-item {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.dialog-popover {
  background: var(--dialog-surface);
  border: 1px solid var(--dialog-border);
  border-radius: 12px;
  box-shadow: var(--dialog-shadow);
}

#stickyTitle,
#stickyBody {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
}

#taskTitleInput,
#taskBodyInput,
#tasksModalDate,
#taskRecurrenceInput,
#taskStartDateInput,
#taskEndDateInput,
#smtpRelayTo,
#smtpRelayMessage {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
  margin-bottom: 8px;
}

#tasksModal .tasks-modal-row-flash,
#stickyModal .sticky-modal-row-flash {
  outline: 2px solid rgba(37, 99, 235, 0.75);
  outline-offset: 2px;
  border-radius: 8px;
}

.dashboard-card .sticky-dashboard-flash {
  outline: 2px solid rgba(37, 99, 235, 0.75);
  outline-offset: 2px;
  border-radius: 10px;
}

html[data-theme="dark"] .dashboard-card .sticky-dashboard-flash,
html[data-theme="soft"] .dashboard-card .sticky-dashboard-flash {
  outline-color: rgba(138, 180, 248, 0.65);
}

#stickyTitle:focus,
#stickyBody:focus {
  outline: none;
  border-color: rgba(42, 77, 143, 0.55);
  box-shadow: 0 0 0 3px rgba(42, 77, 143, 0.14);
}

#stickyTitle {
  margin-bottom: 8px;
}

#stickyBody {
  resize: vertical;
}

.sticky-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.sticky-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sticky-empty {
  color: #666;
  font-style: italic;
  padding: 6px 2px;
}

.sticky-item {
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 10px;
  padding: 10px;
  background: #fffbe6;
  cursor: pointer;
}

.sticky-item.is-completed {
  opacity: 0.75;
  background: #f3f3f3;
}

.sticky-item.is-selected {
  border-color: color-mix(in srgb, var(--accent, #2a4d8f) 72%, #facc15);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent, #2a4d8f) 88%, #1e3a5f) 0 4px, transparent 4px),
    linear-gradient(180deg, #fff8c8 0%, #fde68a 100%);
  outline: 2px solid color-mix(in srgb, var(--accent, #2a4d8f) 78%, #fff);
  outline-offset: 0;
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent, #2a4d8f) 22%, transparent),
    0 8px 18px color-mix(in srgb, var(--accent, #2a4d8f) 18%, rgba(15, 23, 42, 0.12));
}

.sticky-item.is-selected .sticky-item-title {
  color: color-mix(in srgb, var(--accent, #2a4d8f) 70%, #1c1917);
}

.sticky-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sticky-item-title {
  font-weight: bold;
}

.sticky-item-body .sticky-video-url {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: #1d4ed8;
  text-decoration: underline;
  cursor: pointer;
  text-align: left;
  word-break: break-all;
}

.sticky-item-body .sticky-video-url:hover {
  color: #1e40af;
}

.sticky-item-body .sticky-video-player,
.sticky-item-body .pf-video-embed {
  margin: 8px 0;
  max-width: 100%;
}

.sticky-item-body .pf-video-embed--youtube,
.sticky-item-body .pf-video-embed--vimeo {
  aspect-ratio: 16 / 9;
}

.sticky-item-body .pf-video-embed__frame {
  display: block;
  width: 100%;
  min-height: 160px;
  border: 0;
}

.sticky-item-body .pf-video-embed--youtube .pf-video-embed__frame,
.sticky-item-body .pf-video-embed--vimeo .pf-video-embed__frame {
  min-height: 0;
  height: 100%;
}

.sticky-item-body .pf-video-embed--tiktok {
  max-width: 280px;
}

.sticky-item-body .pf-video-embed__frame--tiktok {
  min-height: 420px;
}

.sticky-item-body {
  margin-top: 8px;
  word-break: break-word;
  white-space: normal;
  color: #333;
}

.sticky-item-meta {
  margin-top: 8px;
  font-size: 12px;
  color: #666;
}

.sticky-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sticky-small-btn {
  border: 1px solid #bbb;
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.sticky-small-btn:hover {
  background: #f0f0f0;
}

.sticky-small-btn.danger {
  border-color: rgba(220, 53, 69, 0.7);
  color: #b02a37;
}

.sticky-small-btn.danger:hover {
  background: rgba(220, 53, 69, 0.08);
}

.sticky-small-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Persona Manager list rows (reuse .persona-row class from JS) */
#personaList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#personaList .persona-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 12px;
  background: var(--surface-muted, #f8fafc);
  color: var(--text, inherit);
}

#personaList .persona-row input[type="text"] {
  flex: 1;
  color: var(--text, inherit);
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  border-radius: 8px;
  padding: 6px 8px;
}

#personaList .persona-row input[type="color"] {
  width: 44px;
  height: 28px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  cursor: pointer;
  flex: 0 0 auto;
  background: var(--surface, #fff);
}

.mode-btn {
  padding: 5px 10px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.mode-btn.active {
  background: #0078d4;
  color: white;
  border-color: #0078d4;
}

.mode-btn--has-hotkey {
  position: relative;
  padding-right: 1.35rem;
}

.mode-btn__hotkey {
  position: absolute;
  top: 2px;
  right: 5px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.55;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.mode-btn.active .mode-btn__hotkey {
  opacity: 0.85;
}

.mode-btn--hotkey-flash {
  animation: mode-btn-hotkey-flash 420ms ease-out;
}

@keyframes mode-btn-hotkey-flash {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 120, 212, 0.45);
  }
  40% {
    transform: scale(1.04);
    box-shadow: 0 0 0 4px rgba(0, 120, 212, 0.25);
  }
  100% {
    transform: scale(1);
    box-shadow: none;
  }
}

a.mode-btn.mode-btn--link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
  line-height: 1.25;
}

a.mode-btn.mode-btn--link:hover {
  text-decoration: none;
}

/* ============================================================
   MODE ROOTS
============================================================ */
.mode-root {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ============================================================
   ARCHIVE + RESEARCH ROOTS SHARE SAME LAYOUT
============================================================ */
#archiveRoot .archive-app,
#researchRoot .archive-app,
#groupRoot .archive-app,
#chatRoot.archive-app,
#chatRoot .archive-app {
  display: flex;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

/* ============================================================
   SIDEBAR + MAIN PANEL ALIGNMENT
============================================================ */
.archive-sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  border-right: 1px solid #ddd;
  overflow-y: auto;
}

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

.archive-main-header {
  flex-shrink: 0;
}

.main-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

/* ============================================================
   EDITOR + DETAILS PANEL
============================================================ */
.note-editor-container {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#noteBodyWrapper,
#groupThreadBodyWrapper,
#researchNoteBodyWrapper {
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#archiveRoot #noteBody,
#groupRoot #groupThreadBody,
#researchRoot #researchNoteBody {
  flex: 1 1 auto;
  min-height: 5rem;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.editor-image-file-input,
.editor-attach-file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.fmt-btn--image,
.fmt-btn--attach {
  min-width: 3.2rem;
  font-size: 12px;
  font-weight: 700;
}

.note-editor a.editor-file-attach,
.note-editor a[data-editor-file="1"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0.35em 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
  background: var(--surface-muted, rgba(248, 250, 252, 0.95));
  color: var(--accent, #0f766e);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  max-width: 100%;
  word-break: break-word;
}

.note-editor a.editor-file-attach:hover,
.note-editor a[data-editor-file="1"]:hover {
  text-decoration: underline;
  border-color: color-mix(in srgb, var(--accent, #0f766e) 35%, var(--border, #cbd5e1));
}

.note-editor-drop-target--active {
  outline: 2px dashed var(--accent, #0078d4);
  outline-offset: 2px;
  background: color-mix(in srgb, var(--accent, #0078d4) 6%, transparent);
}

.note-editor img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.5em 0;
  border-radius: 4px;
}

.note-editor img.editor-embedded-img {
  cursor: pointer;
}

.bb-editor-insert-caret {
  display: inline;
  width: 0;
  height: 0;
  overflow: hidden;
  font-size: 0;
  line-height: 0;
  vertical-align: baseline;
  pointer-events: none;
}

.note-editor img.editor-img--selected {
  outline: 3px solid var(--accent, #0078d4);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #0078d4) 22%, transparent);
}

.editor-image-selection-chrome {
  position: absolute;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--border, #cbd5e1);
  background: var(--bg, #fff);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
  pointer-events: auto;
}

.editor-image-selection-chrome.hidden {
  display: none;
}

.editor-image-delete-btn {
  font-size: 12px;
  font-weight: 700;
  border-color: #b91c1c !important;
  color: #b91c1c !important;
  background: #fef2f2 !important;
}

.editor-image-delete-btn:hover:not(:disabled) {
  background: #fee2e2 !important;
  color: #991b1b !important;
}

.editor-image-resize-handle {
  position: absolute;
  z-index: 31;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 2px solid var(--bg, #fff);
  border-radius: 3px;
  background: var(--accent, #2563eb);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28);
  cursor: nwse-resize;
  touch-action: none;
}

.editor-image-resize-handle.hidden {
  display: none;
}

body.editor-image-resizing {
  cursor: nwse-resize;
  user-select: none;
}

body.editor-image-resizing .note-editor {
  user-select: none;
}

html[data-theme="dark"] .editor-image-selection-chrome,
html[data-theme="soft"] .editor-image-selection-chrome {
  background: var(--surface, #1c1f28);
  border-color: var(--border, #3d4450);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .editor-image-delete-btn,
html[data-theme="soft"] .editor-image-delete-btn {
  background: rgba(185, 28, 28, 0.2) !important;
  color: #fca5a5 !important;
  border-color: #f87171 !important;
}

html[data-theme="dark"] .note-editor img.editor-img--selected,
html[data-theme="soft"] .note-editor img.editor-img--selected {
  outline-color: var(--accent, #8ab4f8);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #8ab4f8) 28%, transparent);
}

.detail-panel {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  border-left: 1px solid #ddd;
  padding: 10px;
  overflow-y: auto;
}