/* ══════════════════════════════════════════════════
   Theme System – CSS Custom Properties
   ══════════════════════════════════════════════════ */
:root {
  --bg-body: linear-gradient(135deg, #ede9f4, #e8ecf7, #eaf3f0);
  --bg-card: #fff;
  --bg-surface: #fafafa;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --bg-hover: #f7f7fa;
  --bg-input: #fafafa;
  --bg-toolbar: #f7f7f7;
  --bg-modal: #f3f3f3;
  --bg-code: #f5f5f5;
  --bg-code-inline: #eee;
  --text-primary: #111;
  --text-secondary: #222;
  --text-muted: #555;
  --text-faint: #777;
  --text-placeholder: #aaa;
  --text-time: #8a8a8a;
  --text-icon: #6f6f6f;
  --text-code-inline: #d63384;
  --border-light: #eee;
  --border-medium: #ddd;
  --border-default: #ccc;
  --border-strong: #bdbdbd;
  --border-input: #e0e0e0;
  --accent: #343BE0;
  --accent-rgb: 52, 59, 224;
  --accent-hover: #1e22a3;
  --accent-bg: rgba(52, 59, 224, 0.08);
  --accent-secondary: #2d93df;
  --shadow-card: 0 3px 10px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-header: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-drawer: 2px 0 12px rgba(0,0,0,0.08);
  --shadow-modal: 0 18px 40px rgba(0,0,0,0.2);
  --shadow-editor: 0 20px 60px rgba(0,0,0,0.3);
  --shadow-search-inset: inset 0 1px 3px rgba(0,0,0,0.1);
  --shadow-search-focus: 0 0 5px rgba(33,150,243,0.5);
  --tag-dot-bg: rgba(0,0,0,0.04);
  --tag-dot-border: rgba(0,0,0,0.08);
  --tag-dot-text: #444;
  --btn-cancel-bg: #eee;
  --btn-cancel-text: #555;
  --btn-cancel-hover: #ddd;
  --btn-edit-color: #7e57c2;
  --btn-edit-border: #b39ddb;
  --btn-copy-color: #795548;
  --btn-copy-border: #a1887f;
  --btn-danger-color: #d32f2f;
  --btn-danger-border: #e57373;
  --btn-danger-hover-bg: #fbe9e7;
  --fade-gradient: linear-gradient(transparent, #fff);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-body: linear-gradient(135deg, #131216, #13141e, #111514);
  --bg-card: #1c1c26;
  --bg-surface: #1a1a24;
  --bg-overlay: rgba(0,0,0,0.7);
  --bg-hover: #252533;
  --bg-input: #22222e;
  --bg-toolbar: #1a1a24;
  --bg-modal: #1e1e2a;
  --bg-code: #22222e;
  --bg-code-inline: #2a2a3a;
  --text-primary: #e4e4ec;
  --text-secondary: #d0d0dc;
  --text-muted: #a0a0b0;
  --text-faint: #8888a0;
  --text-placeholder: #666680;
  --text-time: #7a7a90;
  --text-icon: #9090a8;
  --text-code-inline: #f0789c;
  --border-light: #2a2a3a;
  --border-medium: #333346;
  --border-default: #3a3a50;
  --border-strong: #444460;
  --border-input: #333346;
  --accent: #5b63f0;
  --accent-rgb: 91, 99, 240;
  --accent-hover: #7a80f4;
  --accent-bg: rgba(91,99,240,0.12);
  --accent-secondary: #4da6f0;
  --shadow-card: 0 3px 10px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-header: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-drawer: 2px 0 12px rgba(0,0,0,0.3);
  --shadow-modal: 0 18px 40px rgba(0,0,0,0.5);
  --shadow-editor: 0 20px 60px rgba(0,0,0,0.6);
  --shadow-search-inset: inset 0 1px 3px rgba(0,0,0,0.3);
  --shadow-search-focus: 0 0 5px rgba(91,99,240,0.4);
  --tag-dot-bg: rgba(255,255,255,0.06);
  --tag-dot-border: rgba(255,255,255,0.1);
  --tag-dot-text: #c0c0d0;
  --btn-cancel-bg: #2a2a3a;
  --btn-cancel-text: #a0a0b0;
  --btn-cancel-hover: #333346;
  --btn-edit-color: #b39ddb;
  --btn-edit-border: #7e57c2;
  --btn-copy-color: #bcaaa4;
  --btn-copy-border: #795548;
  --btn-danger-color: #ef5350;
  --btn-danger-border: #c62828;
  --btn-danger-hover-bg: rgba(239,83,80,0.12);
  --fade-gradient: linear-gradient(transparent, #1c1c26);
  color-scheme: dark;
}

/* ══════════════════════════════════════════════════ */
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: var(--bg-body);
  background-attachment: fixed;
  color: var(--text-primary);
}
#__next { display: flex; flex-direction: column; min-height: 100vh; }

/* Editor page only: on tablet/mobile (<=1024px), lock the window scroll
   so the editor owns the viewport. Scrolling happens inside the editor. */
@media (max-width: 1024px) {
  html.editor-page-active,
  body.editor-page-active {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  body.editor-page-active #__next {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
}
.container {
  background: transparent;
  width: 100%; margin-left: 0; flex: 1;
  height: auto; box-sizing: border-box; overflow-y: visible;
  transition: margin-left 0.3s ease, width 0.3s ease;
}
h1 { margin: 0; font-size: 20px; }

.page-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.88), rgba(247,245,252,0.72), rgba(245,247,253,0.78));
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06), inset 0 -1px 0 rgba(255,255,255,0.5);
  border-bottom: 1px solid rgba(200,190,220,0.25);
  position: static;
  box-sizing: border-box; max-width: 100%; flex-wrap: wrap; overflow: visible;
}
.header-left { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: visible; order: 1; }
.header-logo-mark {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
  box-sizing: border-box;
  border: 1px solid rgba(167, 139, 250, 0.28);
  border-radius: 7px;
  filter: drop-shadow(0 2px 6px rgba(168, 85, 247, 0.28));
}
[data-theme="dark"] .header-logo-mark {
  border-color: rgba(196, 181, 253, 0.25);
  filter: drop-shadow(0 2px 6px rgba(168, 85, 247, 0.4));
}
.page-header > .add-note-btn { order: 2; }
.header-right { order: 3; }
.header-left h1 {
  margin: 0; white-space: nowrap;
  padding: 0 4px;
  font-family: 'Pinyon Script', cursive;
  font-size: 26px;
  line-height: 1.3;
  background: linear-gradient(
    110deg,
    #ec4899 0%,
    #a855f7 25%,
    #1e6dd9 50%,
    #a855f7 75%,
    #ec4899 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
  animation: logo-shimmer 8s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .header-left h1 { animation: none; }
}
.header-divider {
  display: none;
}
.header-right {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; min-width: 0; margin-left: auto;
}

.editable {
  border: 1px solid var(--border-default); border-radius: 8px;
  padding: 10px; margin-bottom: 8px; font-size: max(16px, 14px);
  background: var(--bg-card); color: var(--text-primary);
  height: auto; min-height: unset; max-height: none;
  white-space: pre-wrap; word-break: break-word;
}
.clipboard .message-view,
.clipboard .task-list-view { overflow: hidden; flex: 1; min-height: 0; }

button {
  padding: 6px 12px; border: none; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: #fff;
  background: #4caf50; margin-right: 5px;
}
.blue-btn { background: var(--accent); }
/* ── Add Note button (header pill) ── */
.add-note-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  border: 1px solid rgba(var(--accent-rgb, 66,133,244), 0.1); border-radius: 24px;
  background: transparent;
  color: var(--accent); font-size: 12.5px; font-weight: 600;
  cursor: pointer; position: relative;
  transition: background 0.2s, box-shadow 0.2s;
  white-space: nowrap; flex-shrink: 0;
  letter-spacing: 0.02em;
}
.add-note-btn::before { display: none; }
.add-note-btn::after {
  content: '';
  position: absolute; inset: -1.5px; border-radius: 25px; padding: 1.5px;
  background: conic-gradient(from var(--border-angle, 0deg), transparent 60%, rgba(var(--accent-rgb, 66,133,244), 0.3) 78%, transparent 95%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  animation: borderTrace 4s linear infinite;
  pointer-events: none;
}
.add-note-btn:hover {
  background: transparent;
}
.add-note-btn:active { transform: scale(0.98); }
.add-note-btn svg { flex-shrink: 0; fill: var(--accent); }
@property --border-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
@keyframes btnBreathe {
  0%, 100% { background-color: rgba(var(--accent-rgb, 66,133,244), 0.08); }
  50% { background-color: rgba(var(--accent-rgb, 66,133,244), 0.15); }
}
@keyframes borderTrace {
  to { --border-angle: 360deg; }
}
@keyframes btnShimmer {
  0% { left: -100%; }
  50%, 100% { left: 150%; }
}

/* ── Fancy search bar (below header) ── */
.search-bar-container {
  width: fit-content; margin: 14px auto 12px;
  position: sticky; top: 0; z-index: 199;
}
/* Sentinel sits right above the search bar; when it scrolls out of view the bar is "stuck" */
.search-sticky-sentinel { height: 0; margin: 0; padding: 0; pointer-events: none; }

.search-bar-fancy {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, rgba(255,255,255,0.35), rgba(247,245,252,0.18), rgba(245,247,253,0.25));
  backdrop-filter: blur(44px) saturate(2.2);
  -webkit-backdrop-filter: blur(44px) saturate(2.4);
  border: 1px solid rgba(255,255,255,0.45);
  border-top-color: rgba(255,255,255,0.85);
  border-left-color: rgba(255,255,255,0.7);
  border-radius: 10px;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.05),
    0 10px 48px rgba(0,0,0,0.03),
    inset 0 1px 0 rgba(255,255,255,0.85),
    inset 0 -1px 0 rgba(0,0,0,0.03),
    inset 0 0 0 1px rgba(255,255,255,0.08);
  cursor: text;
  transition: box-shadow 0.3s, background 0.3s, transform 0.2s;
  animation: pulseGlow 4s ease-in-out infinite;
}
/* Glossy top sheen — classic glass reflection */
.search-bar-fancy::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.35), rgba(255,255,255,0));
  pointer-events: none;
  border-radius: 10px 10px 0 0;
  z-index: 0;
}
.search-bar-fancy > * { position: relative; z-index: 1; }
.search-bar-fancy::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #a855f7, var(--accent));
  background-size: 200% 100%;
  animation: shimmerLine 4s linear infinite;
}
.search-bar-fancy:focus-within {
  background: linear-gradient(135deg, rgba(255,255,255,0.45), rgba(248,246,253,0.25), rgba(246,248,254,0.32));
  box-shadow:
    0 6px 28px rgba(0,0,0,0.07),
    0 14px 56px rgba(0,0,0,0.04),
    inset 0 1px 0 rgba(255,255,255,0.95),
    inset 0 -1px 0 rgba(0,0,0,0.03),
    inset 0 0 0 1px rgba(255,255,255,0.12);
  transform: translateY(-1px);
  animation: none;
}
.search-bar-icon {
  display: flex; align-items: center; flex-shrink: 0;
  color: var(--accent);
}
.search-bar-icon svg { stroke: var(--accent); }
.search-bar-fancy #searchInput {
  flex: 1; width: 280px; border: none; background: transparent;
  font-size: max(16px, 13px); font-weight: 500;
  color: var(--text-primary);
  outline: none; padding: 0; min-width: 0;
  box-shadow: none; backdrop-filter: none;
  text-align: left;
}
.search-bar-fancy #searchInput::placeholder {
  color: transparent;
}
.search-placeholder-fade {
  position: absolute;
  left: 42px; top: 50%; transform: translateY(-50%) scale(1.03);
  font-size: 13px; font-weight: 500;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  filter: blur(6px);
  transform-origin: left center;
  transition: opacity 5s ease, filter 5s ease, transform 5s ease;
}
.search-placeholder-fade.phrase-visible {
  opacity: 1;
  filter: blur(0px);
  transform: translateY(-50%) scale(1);
}
.search-bar-fancy #clearSearch {
  position: static; transform: none;
  cursor: pointer; flex-shrink: 0;
  display: none; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  color: var(--text-placeholder);
  background: transparent;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.search-bar-fancy #clearSearch:hover {
  color: var(--text-primary);
  background: rgba(0,0,0,0.08);
  transform: scale(1.08);
}
.search-bar-fancy #clearSearch:active { transform: scale(0.94); }
[data-theme="dark"] .search-bar-fancy #clearSearch:hover {
  background: rgba(255,255,255,0.12);
}
.search-bar-container .search-wrapper {
  padding: 6px 8px 0;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.18), 0 8px 32px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.3); }
  50% { box-shadow: 0 4px 20px rgba(var(--accent-rgb, 66,133,244),0.2), 0 8px 36px rgba(var(--accent-rgb, 66,133,244),0.1), inset 0 1px 0 rgba(255,255,255,0.3); }
}
@keyframes shimmerLine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Dark mode glass overrides ── */
[data-theme="dark"] .page-header {
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-bottom-color: rgba(255,255,255,0.08);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3), inset 0 -1px 0 rgba(255,255,255,0.05);
}
[data-theme="dark"] .search-bar-fancy {
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.015));
  backdrop-filter: blur(44px) saturate(1.8);
  -webkit-backdrop-filter: blur(44px) saturate(1.8);
  border-color: rgba(255,255,255,0.14);
  border-top-color: rgba(255,255,255,0.28);
  border-left-color: rgba(255,255,255,0.2);
  box-shadow:
    0 4px 24px rgba(0,0,0,0.55),
    0 10px 48px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -1px 0 rgba(0,0,0,0.25),
    inset 0 0 0 1px rgba(255,255,255,0.04);
}
[data-theme="dark"] .search-bar-fancy::before {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0));
}
[data-theme="dark"] .search-bar-fancy:focus-within {
  background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03));
  box-shadow:
    0 6px 32px rgba(0,0,0,0.65),
    0 14px 56px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.22),
    inset 0 -1px 0 rgba(0,0,0,0.25),
    inset 0 0 0 1px rgba(255,255,255,0.06);
}
[data-theme="dark"] .search-bar-icon {
  color: #7b83f8;
}
[data-theme="dark"] .search-bar-icon svg { stroke: #7b83f8; }
[data-theme="dark"] .search-bar-fancy #searchInput { color: var(--text-primary); }
/* Native placeholder stays transparent in dark mode too — the crossfading
   .search-placeholder-fade overlays handle the visible placeholder text.
   Without this, background-clip: text would reveal a gradient through the
   transparent-colored placeholder, stacking on top of the overlay labels. */
[data-theme="dark"] .search-bar-fancy #searchInput::placeholder {
  color: transparent;
  background: none;
  -webkit-text-fill-color: transparent;
}
[data-theme="dark"] .add-note-btn {
  color: #a5abff;
}
[data-theme="dark"] .add-note-btn svg { fill: #a5abff; }
[data-theme="dark"] .clipboard {
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
}
[data-theme="dark"] .clipboard:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}
[data-theme="dark"] .clipboard-select-btn {
  background: var(--bg-primary); box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
[data-theme="dark"] #drawer {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-right-color: rgba(255,255,255,0.08);
  box-shadow: 2px 0 16px rgba(0,0,0,0.4);
}
[data-theme="dark"] .drawer-header {
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-bottom-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .fs-editor-wrap {
  background: var(--bg-card);
  border-color: var(--border-medium);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
[data-theme="dark"] .fs-editor-header {
  background: transparent;
  border-bottom-color: var(--border-light);
}
[data-theme="dark"] .fs-task-action-toolbar {
  background: transparent;
  border-color: var(--border-light);
}
[data-theme="dark"] .fs-editor-wrap .md-editor-toolbar,
[data-theme="dark"] .md-editor-toolbar {
  background: transparent;
  border-bottom-color: var(--border-light);
}
[data-theme="dark"] .md-editor-container {
  border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] .tags-modal {
  background: linear-gradient(135deg, #1b1920, #191c26, #171b19);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-modal);
}
[data-theme="dark"] .tags-modal-header {
  background: rgba(123,131,248,0.12);
  border-bottom-color: rgba(123,131,248,0.18);
}
[data-theme="dark"] .tags-modal-header h2 { color: #a5abff; }
[data-theme="dark"] .tags-modal-close-btn { background: rgba(123,131,248,0.18); color: #a5abff; }
[data-theme="dark"] .tags-modal-close-btn:hover { background: rgba(123,131,248,0.3); }
[data-theme="dark"] #tagsModalName,
[data-theme="dark"] #sectionModalName {
  background: var(--bg-input);
  border-color: var(--border-medium);
}
[data-theme="dark"] .filter-chip {
  background: linear-gradient(135deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.04);
}
[data-theme="dark"] .filter-chip:hover {
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
}
[data-theme="dark"] .fs-editor-cancel {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.1);
  color: var(--text-secondary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
[data-theme="dark"] .fs-editor-cancel:hover {
  background: rgba(255,255,255,0.14);
  color: var(--text-primary);
}
[data-theme="dark"] .fs-editor-save {
  background: rgba(123,131,248,0.15);
  color: #a5abff;
}
[data-theme="dark"] .fs-editor-save:hover {
  background: rgba(123,131,248,0.25);
}
[data-theme="dark"] .fs-editor-save svg { fill: #a5abff; }
[data-theme="dark"] .fs-editor-title {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .fs-editor-title:focus {
  background: transparent;
  border-color: transparent;
}
[data-theme="dark"] .fs-editor-title.fs-editor-title-inline,
[data-theme="dark"] .fs-editor-title.fs-editor-title-inline:focus {
  background: transparent;
  border-color: transparent;
}
[data-theme="dark"] .fs-footer-btn {
  background: var(--bg-hover);
  border-color: var(--border-medium);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
[data-theme="dark"] .fs-footer-btn:hover {
  background: var(--bg-input);
}
[data-theme="dark"] #drawerToggle {
  background: linear-gradient(135deg, rgba(91,99,240,0.18), rgba(168,85,247,0.1));
  border-color: rgba(91,99,240,0.28);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
}
[data-theme="dark"] #drawerToggle:hover {
  background: linear-gradient(135deg, rgba(91,99,240,0.26), rgba(168,85,247,0.16));
  border-color: rgba(91,99,240,0.4);
  box-shadow: 0 4px 14px rgba(91,99,240,0.25), inset 0 1px 0 rgba(255,255,255,0.08);
}

.tag {
  display: inline-block; padding: 3px 8px; border-radius: 12px;
  font-size: 12px; text-transform: lowercase; margin-right: 5px; color: var(--text-secondary);
  border: 1px solid rgba(0,0,0,0.08);
}
[data-theme="dark"] .tag { border-color: rgba(255,255,255,0.08); }
.tag.tag-simple {
  display: inline-flex; align-items: center;
  background: transparent !important; color: #555;
  padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-weight: 500; margin-right: 4px;
}
[data-theme="dark"] .tag.tag-simple { color: #aaa; }
.tag.tag-dot {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--tag-dot-bg) !important; color: var(--tag-dot-text);
  padding: 4px 10px 4px 6px; border-radius: 20px;
  font-size: 12px; font-weight: 500; margin-right: 4px;
  border: 1px solid var(--tag-dot-border);
}
.tag.tag-dot::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0; background: var(--tag-color, #ccc);
}

.message { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.message-view {
  margin-top: 8px; margin-bottom: 5px; flex: 1; min-height: 0;
  overflow: hidden; position: relative; color: var(--text-secondary);
  font-size: 13px;
}
.message-view::after {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0;
  height: 40px; background: var(--fade-gradient); pointer-events: none;
  display: none;
}
.message-view.truncated::after { display: block; }
.message-view strong { display: block; margin-bottom: 6px; font-size: 1em; }

input[type="date"], select {
  padding: 5px; border-radius: 6px; border: 1px solid var(--border-default);
  background: var(--bg-input); color: var(--text-primary);
}
.search-wrapper {
  display: flex; justify-content: flex-start; align-items: center;
  gap: 8px; flex-wrap: wrap; width: 100%;
}
.search-wrapper:empty { display: none; }

.filters { display: flex; flex-direction: column; align-items: center; }
.filter-block {
  text-align: left; display: flex; align-items: center; justify-content: center;
  padding-left: 20px; margin-left: 4px; border-left: 1px solid var(--border-medium); flex-shrink: 0;
}
.sort-by-label { margin-right: 6px; font-size: inherit; font-family: inherit; color: inherit; }
#filterTags { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.date-row { display: flex; justify-content: center; gap: 12px; overflow: visible; }
.date-row label {
  display: flex; flex-direction: row; justify-content: center; align-items: center;
  font-size: inherit; font-family: inherit; color: inherit; white-space: nowrap; flex-shrink: 0;
}
#sortBy { display: block; margin: 0 auto; }

#clipboardsContainer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 16px 12px 0; padding: 14px 14px 0;
  align-items: start;
}
.clipboard {
  width: 100%; height: 280px; padding: 15px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(254,253,255,0.93), rgba(253,254,255,0.94));
  backdrop-filter: blur(8px) saturate(1.08);
  -webkit-backdrop-filter: blur(8px) saturate(1.08);
  border: 1px solid var(--border-light);
  box-sizing: border-box;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.5);
  display: flex; flex-direction: column; overflow: visible;
  transition: box-shadow 0.3s ease, transform 0.25s ease;
  animation: cardFadeIn 0.35s ease both;
  position: relative;
}
.clipboard:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.4);
  transform: translateY(-1px);
}
.clipboard-topbar {
  display: flex; justify-content: flex-start; align-items: center; gap: 8px; margin-bottom: 2px;
}
.clipboard-topbar.is-editing { justify-content: space-between; }
.clipboard-topbar-title { flex: 1; min-width: 0; }
.clipboard-topbar-title .editable-title { width: 100% !important; box-sizing: border-box; }
.clipboard .editable { width: calc(100% - 30px); box-sizing: border-box; margin-top: 8px; }

.clipboard-title {
  font-size: 13.5px; font-weight: 700; line-height: 1.15; color: var(--text-primary);
  margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: calc(100% - 28px);
}
.clipboard-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.clipboard-footer-left { display: flex; align-items: center; gap: 4px; }
.clipboard-time { margin: 0; color: var(--text-time); font-size: 12px; }

.clipboard-icon-btn {
  background: transparent !important; border: none !important; color: var(--text-icon);
  width: 22px !important; min-width: 22px !important; height: 22px !important;
  padding: 0 !important; margin: 0 !important; border-radius: 6px !important;
  display: inline-flex; align-items: center; justify-content: center;
}
.clipboard-icon-btn svg { fill: currentColor !important; }
.clipboard-copy-btn { color: var(--text-time); }
.clipboard-edit-btn { color: var(--text-icon); }
.clipboard-delete-btn { color: #d14a4a; }
.clipboard .tag { border-radius: 999px; }

/* ── Select button on card (top-left corner, Google Keep style) ── */
.clipboard-select-btn {
  position: absolute; top: -8px; left: -8px; z-index: 2;
  background: #fff; border: 1.5px solid var(--text-placeholder); color: var(--text-placeholder);
  width: 24px; height: 24px; min-width: 24px; padding: 0;
  border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: color 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.15s;
  opacity: 0;
}
.clipboard-select-btn svg { width: 14px; height: 14px; }
@media (hover: hover) {
  .clipboard:hover .clipboard-select-btn { opacity: 0.45; }
  .clipboard:hover .clipboard-select-btn:hover { opacity: 1; background: #fff; border-color: var(--text-primary); color: var(--text-primary); transform: scale(1.1); }
}
@media (hover: none) {
  .clipboard-select-btn { opacity: 0.35; }
}
.clipboard.is-selected .clipboard-select-btn {
  opacity: 1; background: var(--text-primary); border-color: var(--text-primary); color: #fff;
}

/* ── Pin button on card (top-right corner, Google Keep style) ── */
.clipboard-pin-btn {
  position: absolute; top: -10px; right: -10px; z-index: 2;
  background: var(--bg-card, #fff); border: 1.5px solid var(--text-placeholder); color: var(--text-placeholder);
  width: 26px; height: 26px; min-width: 26px; padding: 0;
  border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.15s;
  opacity: 0.5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}
.clipboard-pin-btn svg { width: 16px; height: 16px; }
@media (hover: hover) {
  .clipboard:hover .clipboard-pin-btn { opacity: 0.8; }
  .clipboard-pin-btn:hover { opacity: 1 !important; background: #fff; border-color: var(--text-primary); color: var(--text-primary); transform: scale(1.1); }
}
@media (hover: none) {
  .clipboard-pin-btn { opacity: 0.35; }
}
.clipboard-pin-btn.pinned { opacity: 1; background: var(--text-primary); border-color: var(--text-primary); color: #fff; }

/* ── More button — also faded, visible on hover ── */
.clipboard-more-btn {
  background: transparent; border: none; color: var(--text-placeholder);
  width: 26px; height: 26px; min-width: 26px; padding: 0;
  border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
  opacity: 1;
}
.clipboard-more-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Pin button in fullscreen editor ── */
.fs-editor-pin-btn {
  background: transparent; border: none; color: var(--text-placeholder);
  width: 28px; height: 28px; min-width: 28px; padding: 0;
  border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
  flex-shrink: 0;
  opacity: 0.55;
}
.fs-editor-pin-btn:hover { background: var(--bg-hover); color: var(--text-primary); opacity: 1; }
.fs-editor-pin-btn.pinned { color: var(--text-primary); opacity: 1; }

/* Header-mounted pin & copy: more prominent than the toolbar pin */
.fs-editor-header-right .fs-editor-pin-btn {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 8px;
  background: rgba(52, 59, 224, 0.08);
  border: 1.5px solid rgba(52, 59, 224, 0.2);
  color: var(--accent);
  opacity: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.fs-editor-header-right .fs-editor-pin-btn:hover {
  background: rgba(52, 59, 224, 0.15);
  color: var(--accent);
}
.fs-editor-header-right .fs-editor-pin-btn.pinned {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* Reading-mode toggle lives in the header; shares the pin-btn shell and
   mirrors the "pinned" visual state when reading mode is active. */
.fs-editor-header-right .fs-editor-read-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.fs-editor-copy-btn.copied { color: var(--accent); opacity: 1; }
.fs-editor-copy-btn.failed { color: #d33; opacity: 1; }

/* ── Section labels (Pinned / Others) ── */
.section-label {
  width: fit-content; display: flex; align-items: center;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  padding: 6px 10px; margin: 0;
  border-left: 4px solid var(--section-color, var(--text-muted));
  border-radius: 6px;
  gap: 8px;
  background: color-mix(in srgb, var(--section-color, var(--text-muted)) 12%, transparent);
}

.clipboard-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.delete-btn {
  background: transparent; border: 1.5px solid #f44336; color: #f44336;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.delete-btn:hover { background: rgba(244,67,54,0.08); }
.top-actions { display: flex; flex-direction: row; justify-content: space-between; gap: 8px; margin-bottom: 15px; }

/* ===== Left Drawer ===== */
#drawer {
  position: fixed; top: 0; left: -240px; width: 240px; height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(247,245,252,0.8), rgba(245,247,253,0.84));
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-right: 1px solid rgba(200,190,220,0.25);
  box-shadow: 2px 0 16px rgba(0,0,0,0.05);
  box-sizing: border-box; transition: left 0.3s ease; z-index: 1002;
  overflow-y: auto; overflow-x: hidden; padding: 0 0 24px; font-family: inherit;
}
#drawer.open { left: 0; }

.drawer-header {
  position: sticky; top: 0; z-index: 2;
  background: linear-gradient(135deg, rgba(255,255,255,0.75), rgba(247,245,252,0.55));
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px; border-bottom: 1px solid rgba(200,190,220,0.2);
}
.drawer-header h1 { color: var(--text-primary); }

.drawer-label-row { display: flex; align-items: center; justify-content: space-between; }
.drawer-label-row .drawer-label { flex: 1; }

.drawer-section-clear {
  background: none; border: none; color: #9b3a3a;
  font-size: 12px; font-weight: 500; cursor: pointer;
  padding: 2px 6px; border-radius: 4px; transition: background 0.15s;
}
.drawer-section-clear:hover { background: rgba(123, 31, 31, 0.12); }

.drawer-label {
  font-size: 13px; font-weight: 800; color: var(--text-primary);
  text-transform: uppercase; letter-spacing: 0.6px; margin: 0; padding: 16px 16px 8px;
}

#drawer .manage-tags-btn {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%;
  padding: 0; margin: 0; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent);
}
#drawer .manage-tags-btn svg { width: 14px; height: 14px; fill: #fff; }

/* Drawer backdrop — hidden by default, shown on tablet/phone via media queries */
.drawer-backdrop {
  display: none;
}

#drawerToggle {
  position: fixed; top: 11px; left: 12px; z-index: 1003;
  background: linear-gradient(135deg, rgba(52,59,224,0.14), rgba(168,85,247,0.08));
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(52,59,224,0.22);
  color: var(--accent); font-size: 18px;
  height: 32px; min-width: 36px; padding: 0 10px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(52,59,224,0.1), inset 0 1px 0 rgba(255,255,255,0.35);
  transition: all 0.2s ease, left 0.3s ease; line-height: 1;
}
body.drawer-open #drawerToggle { left: 196px; background: linear-gradient(135deg, rgba(52,59,224,0.18), rgba(168,85,247,0.12)); }
#drawerToggle:hover { background: linear-gradient(135deg, rgba(52,59,224,0.22), rgba(168,85,247,0.14)); border-color: rgba(52,59,224,0.32); box-shadow: 0 4px 14px rgba(52,59,224,0.18); }
body:not(.drawer-open) .page-header { padding-left: 52px; }
body.drawer-open .container { margin-left: 240px; width: calc(100% - 240px); }

#activeSectionFilters,
#activeTagFilters,
#activeOtherFilters {
  display: none; justify-content: flex-start; flex-wrap: wrap;
  gap: 8px; margin-bottom: 0; align-items: center;
}

/* ── Search chips dropdown panel (Google Keep style) ── */
#filterChips {
  display: none; position: absolute;
  left: 0; right: 0; top: 100%;
  margin-top: 6px; padding: 12px 14px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  z-index: 100; min-width: 280px;
  max-height: 360px; overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.25s ease;
}
#filterChips.open { display: block; }
#filterChips.open:empty { display: none; }
[data-theme="dark"] #filterChips {
  background: rgba(30,30,36,0.96);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
}

.chip-group { margin-bottom: 8px; }
.chip-group:last-child { margin-bottom: 0; }
.chip-group-heading {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-placeholder);
  margin-bottom: 6px; padding-left: 2px;
}
.chip-group-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}

.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 500; cursor: pointer;
  border: 1px solid rgba(0,0,0,0.1);
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(246,244,252,0.7));
  color: var(--text-secondary);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.filter-chip:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(108,99,255,0.08), rgba(192,132,252,0.06));
  color: var(--text-primary);
}
.filter-chip.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; box-shadow: 0 2px 6px rgba(108,99,255,0.3);
}
.filter-chip svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }
.chip-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.filter-chip-more {
  color: var(--accent); border-style: dashed; font-weight: 600;
}
.search-wrapper.chips-visible #activeSectionFilters,
.search-wrapper.chips-visible #activeTagFilters,
.search-wrapper.chips-visible #activeOtherFilters {
  display: flex;
}
.chip-group-divider {
  width: 90%; border: none; border-top: none;
  height: 1px; margin: 2px auto;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.12) 30%, rgba(0,0,0,0.12) 70%, transparent);
  opacity: 0.7;
}
[data-theme="dark"] .chip-group-divider {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12) 30%, rgba(255,255,255,0.12) 70%, transparent);
}
.active-tag {
  display: inline-flex; align-items: center; gap: 6px;
  text-transform: capitalize; padding: 4px 10px 4px 8px; border-radius: 20px;
  font-size: 12px; font-weight: 500; color: var(--tag-dot-text);
  background: var(--tag-dot-bg) !important; border: 1px solid var(--tag-dot-border);
}
.active-tag::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--tag-color, #ccc); flex-shrink: 0;
}
.active-tag.active-tag-simple {
  text-transform: lowercase;
  color: #555;
  background: var(--tag-dot-bg) !important;
}
[data-theme="dark"] .active-tag.active-tag-simple { color: #aaa; }
.active-tag.active-tag-simple::before { display: none; }
.active-tag span { cursor: pointer; }
.active-tag span:last-child { color: var(--text-placeholder); font-size: 10px; margin-left: 2px; }
.active-tag span:last-child:hover { color: #e53935; }

.active-filter-chip { --tag-color: transparent; }
.active-filter-chip::before { display: none !important; }

#drawerFilterTags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; }

.drawer-tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 8px;
  border: 1.5px solid var(--border-default); background: transparent;
  color: var(--text-secondary); font-size: 12.5px; font-weight: 500;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: all 0.15s; line-height: 1.3;
}
.drawer-tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.drawer-tag-chip.selected {
  background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600;
}

.drawer-section { margin: 0; padding: 0 16px; }
.drawer-section .drawer-label { padding: 16px 0 8px; }

.drawer-tag-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: nowrap;
}
.drawer-add-tag-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 6px;
  border: none; background: rgba(0,137,123,0.08);
  color: #00897b; font-size: 11.5px; font-weight: 600;
  font-family: inherit; white-space: nowrap;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.drawer-edit-tags-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 6px;
  border: none; background: rgba(123,31,162,0.08);
  color: #7b1fa2; font-size: 11.5px; font-weight: 600;
  font-family: inherit; white-space: nowrap;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.drawer-add-tag-btn svg, .drawer-edit-tags-btn svg { fill: currentColor; flex-shrink: 0; }
.drawer-add-tag-btn:hover { background: #00897b; color: #fff; }
.drawer-edit-tags-btn:hover { background: #7b1fa2; color: #fff; }

/* Manage tags modal mode */
.tags-modal-overlay.manage-mode #tagsModalFormWrap { display: none; }
.tags-modal-overlay:not(.manage-mode) #tagsManageList { display: none; }

#tagsManageList {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 320px; overflow-y: auto;
}
.manage-tag-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-radius: 8px; transition: background 0.15s;
}
.manage-tag-row:hover { background: var(--bg-hover); }
.manage-tag-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: #ccc;
}
.manage-tag-name {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 500;
  color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.manage-tag-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; margin-left: auto; }
.manage-tag-btn {
  width: 28px; height: 28px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-placeholder);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; transition: all 0.15s;
}
.manage-tag-btn svg { width: 15px; height: 15px; fill: currentColor; }
.manage-tag-edit { color: var(--accent); background: var(--accent-bg); }
.manage-tag-edit:hover { background: var(--accent); color: #fff; }
.manage-tag-delete { color: #e53935; background: rgba(229,57,53,0.1); }
.manage-tag-delete:hover { background: #e53935; color: #fff; }
.manage-tag-empty {
  padding: 16px 4px; font-size: 13px; color: var(--text-placeholder); text-align: center;
}

.drawer-date-row { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
.drawer-date-row label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
.drawer-date-row label span:not(.date-display) { min-width: 34px; flex-shrink: 0; font-weight: 500; font-size: 12px; color: var(--text-faint); }
/* Clip the native date input inside the wrap — Firefox/Safari give
   input[type="date"] a larger intrinsic min-width than our declared
   width: 100%, so without overflow: hidden the spinner/controls can
   spill past the drawer's right edge. border-radius matches the input
   so the clipping stays visually seamless. */
.date-input-wrap {
  position: relative; flex: 1 1 0; min-width: 0; max-width: 100%;
  box-sizing: border-box; overflow: hidden; border-radius: 8px;
}
.date-input-wrap::after {
  content: "";
  position: absolute;
  right: 8px; top: 50%;
  width: 16px; height: 16px;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='18' rx='2' ry='2'/><line x1='16' y1='2' x2='16' y2='6'/><line x1='8' y1='2' x2='8' y2='6'/><line x1='3' y1='10' x2='21' y2='10'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  pointer-events: none;
  opacity: 0.8;
}
[data-theme="dark"] .date-input-wrap::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b0b3d9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='18' rx='2' ry='2'/><line x1='16' y1='2' x2='16' y2='6'/><line x1='8' y1='2' x2='8' y2='6'/><line x1='3' y1='10' x2='21' y2='10'/></svg>");
}
.drawer-date-row input[type="date"] {
  /* !important on min-width: Firefox gives input[type="date"] an
     intrinsic min-width (spinner + localized MM/DD/YYYY text) that
     otherwise overrides our width: 100% and pushes the control past
     the drawer edge. */
  width: 100%; min-width: 0 !important; max-width: 100%;
  box-sizing: border-box;
  padding: 6px 30px 6px 8px; border-radius: 8px;
  border: 1px solid var(--border-medium); font-size: max(16px, 13px);
  background: var(--bg-input); color: transparent;
  -webkit-text-fill-color: transparent;
}
.drawer-date-row input[type="date"]::-webkit-date-and-time-value {
  color: transparent; -webkit-text-fill-color: transparent;
}
.drawer-date-row input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0; cursor: pointer;
  position: absolute; right: 0; top: 0;
  width: 30px; height: 100%; padding: 0; margin: 0;
}
.date-display {
  position: absolute; top: 0; left: 0; right: 30px; bottom: 0;
  display: flex; align-items: center; padding-left: 8px;
  font-size: 13px; pointer-events: none;
  color: var(--text-primary);
}
.date-display.placeholder { color: var(--text-placeholder); }

#drawer select {
  width: 100%; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border-medium); font-size: 13px;
  background: var(--bg-input); color: var(--text-secondary);
}
.drawer-divider { height: 1px; margin: 12px 16px; background: linear-gradient(90deg, transparent, var(--border-strong) 30%, var(--border-strong) 70%, transparent); opacity: 0.7; }

#drawer #clearAllBtn.drawer-clear-btn {
  background: rgba(123, 31, 31, 0.12) !important; color: #9b3a3a !important; border: none !important;
  border-radius: 8px; margin: 16px 16px 0; width: calc(100% - 32px);
  padding: 8px 12px; font-size: 13px; font-weight: 500; cursor: pointer;
}
#drawer #clearAllBtn.drawer-clear-btn:hover { background: rgba(123, 31, 31, 0.2) !important; }

.border-btn {
  background: transparent !important; border: 1.5px solid var(--accent);
  color: var(--accent); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.border-btn:hover { background: var(--accent-bg); }

.top { margin-top: 50px; }
.right { margin-right: 10px; }
.row { display: flex; flex-direction: row; align-items: center; justify-content: space-between; margin-top: 20px; }
.delete-btn svg { fill: currentColor; }
.delete-btn:hover svg { color: #f44336; }
.border-btn svg { fill: var(--accent); }
.clipboard-add-tag-btn { border: none !important; }
.clipboard-tags-picker label { padding: 4px 2px; border-radius: 6px; }
.clipboard-tags-picker input { cursor: pointer; }
.clipboard.editing { border: 2px solid var(--accent); }
.editing { border: 2px solid var(--accent) !important; }
.new-clipboard .editing { border: 1px solid var(--border-strong) !important; }

/* Tags modal */
.tags-modal-overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0,0,0,0.4); z-index: 2000;
}
.tags-modal-overlay.open { display: flex; }
.tags-modal {
  width: min(440px, 100%);
  background: linear-gradient(135deg, #f5f3fa, #f2f4fb, #f3f7f5);
  border: 1px solid var(--border-medium);
  border-radius: 16px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: tagsModalIn 0.22s ease-out;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
@keyframes tagsModalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.tags-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(var(--accent-rgb, 66,133,244), 0.08);
  border-bottom: 1px solid rgba(var(--accent-rgb, 66,133,244), 0.12);
}
.tags-modal-header h2 {
  margin: 0; color: var(--accent); font-size: 14px; font-weight: 500; line-height: 1.2;
  letter-spacing: 0.2px;
}
.tags-modal-header h2.is-edit-title { font-size: 14px; }
.tags-modal-header-actions { display: flex; align-items: center; gap: 6px; }
.tags-modal-close-btn {
  width: 26px; min-width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(var(--accent-rgb, 66,133,244), 0.12); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0;
  cursor: pointer; transition: background 0.2s;
}
.tags-modal-close-btn:hover { background: rgba(var(--accent-rgb, 66,133,244), 0.22); }
.tags-modal-close-btn svg { width: 14px; height: 14px; fill: currentColor; }
.tags-modal-delete-btn {
  width: 26px; min-width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.15); color: #fff;
  display: none; align-items: center; justify-content: center; padding: 0; margin: 0;
  cursor: pointer; transition: background 0.2s;
}
.tags-modal-delete-btn:hover { background: rgba(239,68,68,0.5); }
.tags-modal-delete-btn svg { width: 14px; height: 14px; fill: currentColor; }
.tags-modal-overlay.editing-tag .tags-modal-delete-btn,
.tags-modal-overlay.editing-section .tags-modal-delete-btn { display: inline-flex; }
.tags-modal-divider { display: none; }
.tags-modal-body { padding: 16px 20px 18px; }
.tags-modal-form-row { display: flex; align-items: flex-end; gap: 10px; }

.tags-modal-form-row label {
  display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0;
}
.tags-modal-form-row .tags-modal-label {
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}

#tagsModalName,
#sectionModalName {
  flex: 1; min-width: 0; border: 1px solid var(--border-input, var(--border-strong));
  border-radius: 8px; padding: 8px 12px; font-size: 16px;
  color: var(--text-primary); background: #fff; box-sizing: border-box;
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
#tagsModalName:focus, #sectionModalName:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
#tagsModalName::placeholder, #sectionModalName::placeholder { font-size: 14px; color: var(--text-placeholder); }

.settings-form input::placeholder { font-size: 13px; color: var(--text-placeholder); }

#tagsModalColor,
#sectionModalColor {
  width: 34px; min-width: 34px; height: 34px; padding: 0;
  border: 1.5px solid var(--border-light, #eee); border-radius: 8px;
  background: transparent; overflow: hidden; cursor: pointer;
  transition: border-color 0.2s;
}
#tagsModalColor:hover, #sectionModalColor:hover { border-color: var(--accent); }
#tagsModalColor::-webkit-color-swatch-wrapper, #sectionModalColor::-webkit-color-swatch-wrapper { padding: 2px; border-radius: 8px; }
#tagsModalColor::-webkit-color-swatch, #sectionModalColor::-webkit-color-swatch { border: none; border-radius: 6px; }
#tagsModalColor::-moz-color-swatch, #sectionModalColor::-moz-color-swatch { border: none; border-radius: 6px; }

.tags-modal-actions { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.tags-modal-actions button {
  cursor: pointer; transition: all 0.15s;
  border-radius: 8px; font-size: 12px; font-weight: 500; padding: 8px 24px;
}
#tagsModalSaveBtn,
#sectionModalSaveBtn {
  border: none;
  background: rgba(76,175,80,0.12); color: #2e7d32;
  margin: 0; gap: 6px;
}
#tagsModalSaveBtn:hover,
#sectionModalSaveBtn:hover { background: rgba(76,175,80,0.2); }
.edit-close-mode { color: #e53935; border-color: #e53935; }
.edit-close-mode svg { fill: #e53935; }

/* ── Theme Toggle ── */
#themeToggle {
  width: 32px; height: 32px; min-width: 32px; padding: 0; margin: 0 0 0 6px;
  border-radius: 10px; border: 1.5px solid var(--border-default);
  background: var(--accent-bg); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s, border-color 0.2s; flex-shrink: 0;
  position: relative;
}
#themeToggle:hover,
#themeToggle.tap-hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }
#themeToggle svg { width: 18px; height: 18px; fill: currentColor; }


/* ── Desktop (769-1200px) ── */
@media (max-width: 1200px) {
  #clipboardsContainer {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  .section-group .section-group-body {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  .fs-editor-wrap { max-width: 95vw; }
  .fs-editor-wrap .md-editor-content { padding: 16px 18px 16px 38px; }
}

/* Mobile editor layout lives after the base .fs-editor-wrap rules
   (later in this file) so it can actually override them — media query
   rules here would lose the cascade to the base definitions below. */

/* ── Tablet (481-768px) ── */
@media (max-width: 768px) {
  #clipboardsContainer {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    margin-left: 8px; margin-right: 8px; gap: 12px;
  }
  .section-group .section-group-body {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
  }
  .clipboard { height: 250px; }
  /* Drawer is overlay on tablet — content doesn't shift */
  #drawer { left: -260px; width: 260px; }
  #drawer.open { left: 0; }
  body.drawer-open .container { margin-left: 0; width: 100%; }
  body.drawer-open #drawerToggle { left: 216px; }
  body:not(.drawer-open) .page-header { padding-left: 52px; }
  .page-header { flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
  .header-left { flex-wrap: wrap; }
  .header-right { min-width: 0; }
  .search-bar-container { margin: 12px auto; max-width: calc(100vw - 140px); }
  .search-bar-fancy #searchInput { width: 200px; }
  .search-wrapper { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 0; }
  .fs-editor-overlay { padding: 10px; }
  .fs-editor-wrap { max-width: 100%; border-radius: 10px; }
  .fs-editor-header { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .fs-editor-header-right { order: -1; width: 100%; gap: 6px; align-items: center; }
  .fs-editor-header-right .fs-editor-cancel { order: -1; margin-right: auto; }
  .fs-editor-title { font-size: 16px; min-width: 0; flex: 1 1 100%; }
  .fs-editor-title.fs-editor-title-inline { font-size: 18px; padding: 14px 14px 4px 32px; }
  .fs-editor-btn { padding: 6px 14px; font-size: 13px; min-height: 44px; }
  .fs-editor-footer { flex-wrap: wrap; gap: 8px; padding: 8px 14px; }
  .fs-editor-footer-left { flex-wrap: wrap; gap: 6px; }
  .fs-editor-tags { padding: 8px 14px; }
  .fs-footer-btn { min-height: 44px; }
  /* Drawer overlay backdrop */
  .drawer-backdrop {
    display: block;
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 1001; opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
  }
  body.drawer-open .drawer-backdrop {
    opacity: 1; pointer-events: auto;
  }
  .section-group-header { max-width: 100%; }
}

/* ── Phone (<=480px) ── */
@media (max-width: 480px) {
  :root { --task-indent: 14px; --task-indent-editor: 18px; }
  #drawer { left: -84vw; width: 84vw; }
  #drawer.open { left: 0; }
  body.drawer-open #drawerToggle { left: calc(84vw - 44px); }
  body.drawer-open .container { margin-left: 0; width: 100%; }
  .container { overflow-x: clip; max-width: 100vw; }
  .page-header { flex-direction: row; align-items: center; padding: 8px 10px; gap: 4px; flex-wrap: nowrap; }
  body:not(.drawer-open) .page-header { padding-left: 54px; }
  h1 { font-size: 16px; }
  .header-left { gap: 3px; flex: 0 0 auto; order: 1; min-width: 0; }
  .header-left h1 { font-size: 17px; }
  .header-logo-mark { width: 26px; height: 26px; }
  .header-divider { display: none; }
  .page-header > .add-note-btn { order: 2; }
  .add-note-btn { padding: 5px 10px; gap: 4px; font-size: 11.5px; }
  .add-note-btn span { display: inline; }
  .add-note-btn svg { width: 12px; height: 12px; }
  .header-right { min-width: 0; gap: 3px; order: 3; flex-basis: auto; justify-content: flex-end; margin-left: auto; }
  .header-actions { gap: 3px; }
  .refresh-btn, .view-toggle-btn { width: 30px; height: 30px; border-radius: 8px; }
  .refresh-btn svg, .view-toggle-btn svg { width: 16px; height: 16px; }
  .settings-btn { padding: 3px 5px; border-radius: 8px; }
  .settings-btn svg { width: 16px; height: 16px; }
  .search-bar-container { margin: 12px auto; max-width: calc(100vw - 140px); }
  .search-bar-fancy { padding: 12px 16px; min-height: 44px; }
  .search-bar-fancy #searchInput { font-size: 16px; width: 160px; }
  .search-wrapper { margin: 0; gap: 6px; }
  #clipboardsContainer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-left: 0; margin-right: 0;
    padding: 6px 8px 0;
    gap: 8px;
    overflow-x: clip;
    box-sizing: border-box;
    max-width: 100%;
  }
  .section-group .section-group-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 6px 8px 0;
    overflow-x: clip;
    box-sizing: border-box;
    max-width: 100%;
  }
  .clipboard {
    height: 180px;
    padding: 10px; border-radius: 10px;
    overflow: hidden;
    box-sizing: border-box;
    min-width: 0;
  }
  .clipboard-title {
    font-size: 12.5px; max-width: calc(100% - 22px);
    white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; line-height: 1.3;
  }
  .clipboard .editable { width: 100%; padding: 6px; font-size: max(16px, 12px); }
  .clipboard-topbar { gap: 4px; margin-bottom: 0; }
  .message-view {
    font-size: 12px; line-height: 1.5; margin-top: 4px; margin-bottom: 2px;
    overflow: hidden; word-break: break-word;
    flex: 1; min-height: 0;
  }
  .clipboard .task-list-view {
    flex: 1; min-height: 0; overflow: hidden;
  }
  .message-view.truncated::after { height: 25px; }
  .clipboard-footer { margin-top: auto; padding-top: 2px; }
  .clipboard-actions { gap: 3px; margin-top: 2px; }
  .clipboard-time { font-size: 9px; }
  .clipboard .tag { font-size: 9px; padding: 0px 4px; margin-right: 2px; margin-bottom: 0; border: 1px solid rgba(0,0,0,0.08); line-height: 1.4; }
  .clipboard .tag.tag-dot { padding: 1px 5px 1px 3px; font-size: 9px; gap: 2px; margin-bottom: 0; border: 1px solid rgba(0,0,0,0.08); }
  .clipboard .tag.tag-dot::before { width: 4px; height: 4px; }
  [data-theme="dark"] .clipboard .tag,
  [data-theme="dark"] .clipboard .tag.tag-dot { border-color: rgba(255,255,255,0.08); }
  .clipboard-footer-left { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .fs-editor-overlay { padding: 8px; }
  .fs-editor-wrap { border-radius: 14px; width: calc(100% - 16px); max-width: none; }
  .fs-editor-header { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .fs-editor-header-right { order: -1; width: 100%; gap: 6px; align-items: center; }
  .fs-editor-header-right .fs-editor-cancel { order: -1; margin-right: auto; }
  .fs-editor-title { font-size: 16px; min-width: 0; flex: 1 1 100%; }
  .fs-editor-title.fs-editor-title-inline { font-size: 17px; padding: 10px 12px 2px 30px; }
  .fs-editor-btn { padding: 6px 12px; font-size: 12px; gap: 4px; min-height: 44px; }
  .fs-editor-pin-btn { width: 36px; height: 36px; min-width: 36px; }
  .fs-editor-wrap .md-editor-content { padding: 12px 14px 12px 32px; font-size: 16px; }
  .fs-editor-footer { padding: 8px 10px; flex-wrap: wrap; gap: 6px; }
  .fs-editor-footer-left { flex-wrap: wrap; gap: 6px; }
  .fs-footer-btn { padding: 6px 10px; font-size: 12px; gap: 4px; min-height: 44px; }
  .fs-footer-btn .label-full { display: none; }
  .fs-footer-btn .label-short { display: inline; }
  .fs-editor-tags { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .fs-editor-tags-label { font-size: 12px; }
  .fs-editor-tag-picker { gap: 6px; }
  .fs-editor-wrap .md-editor-toolbar {
    padding: 4px 6px; gap: 2px;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .fs-editor-wrap .md-editor-toolbar::-webkit-scrollbar { display: none; }
  .fs-editor-wrap .md-editor-toolbar button { min-height: 32px; }
  /* Reset actions group to inline for horizontal-scroll toolbar */
  .fs-editor-wrap .md-toolbar-group--actions {
    flex-basis: auto; border-top: none; margin-top: 0; padding-top: 0;
    margin-left: auto;
  }
  .tags-modal { width: calc(100% - 16px); border-radius: 14px; max-height: 90vh; overflow-y: auto; }
  .tags-modal-overlay { padding: 8px; }
  .tags-modal-header { padding: 16px 16px 14px; }
  .tags-modal-header h2 { font-size: 16px; }
  .tags-modal-body { padding: 16px 16px 18px; }
  .tags-modal-form-row { gap: 8px; flex-wrap: wrap; }
  .tags-modal-actions { flex-wrap: wrap; }
  .tags-modal-actions button { min-height: 44px; flex: 1; min-width: 100px; }
  #tagsModalName, #sectionModalName { font-size: 16px; padding: 10px 12px; min-height: 44px; }
  #tagsModalName::placeholder, #sectionModalName::placeholder { font-size: 16px; }
  #tagsModalSaveBtn, #sectionModalSaveBtn { font-size: 13px; padding: 8px 16px; min-height: 44px; }
  #tagsModalColor, #sectionModalColor { width: 44px; min-width: 44px; height: 44px; }
  .md-editor-toolbar { gap: 2px; padding: 3px 4px; }
  .md-toolbar-group { gap: 0; padding: 1px; }
  .md-toolbar-btn { padding: 4px 6px; min-height: 32px; }
  .md-toolbar-btn svg { width: 13px; height: 13px; }
  .md-toolbar-label { font-size: 10px; }
  .md-toolbar-btn-task { padding: 4px 8px; min-height: 32px; }
  .md-toolbar-btn-task span { font-size: 10px; }
  .md-toolbar-btn-highlight { padding: 4px 8px; min-height: 32px; }
  .md-toolbar-btn-highlight span { font-size: 10px; }
  .md-toolbar-btn-dictate { padding: 4px 8px; min-height: 32px; }
  .md-toolbar-btn-dictate span { font-size: 10px; }
  .section-group-header { margin-left: 0; max-width: 100%; }
  .section-group-name { font-size: 11.5px; }
  .section-label { font-size: 10px; padding: 5px 8px; }
  .drawer-add-tag-btn, .drawer-edit-tags-btn { min-height: 44px; }
  #drawer .manage-tags-btn { width: 36px; height: 36px; min-width: 36px; }
  .drawer-tag-edit-btn {
    width: 36px !important; min-width: 36px !important; height: 36px !important;
  }
  #themeToggle { width: 36px; height: 36px; min-width: 36px; }
  #drawerToggle { top: 4px; padding: 0 12px; height: 40px; min-width: 44px; min-height: 40px; }
  .filter-block { padding-left: 0; margin-left: 0; border-left: none; }
  .active-tag { padding: 5px 12px 5px 10px; }
  .active-tag span:last-child { font-size: 12px; padding: 2px; }
  /* Drawer overlay backdrop on phone */
  .drawer-backdrop {
    display: block;
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 1001; opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
  }
  body.drawer-open .drawer-backdrop {
    opacity: 1; pointer-events: auto;
  }
}

/* ── MD Editor ── */
.md-editor-container {
  position: relative;
  display: flex; flex-direction: column; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 10px; overflow: hidden; margin-top: 4px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.md-editor-container:focus-within {
  border-color: rgba(52,59,224,0.12);
  box-shadow: 0 0 0 2px rgba(52,59,224,0.04);
}
[data-theme="dark"] .md-editor-container:focus-within {
  border-color: rgba(91,99,240,0.14);
  box-shadow: 0 0 0 2px rgba(91,99,240,0.06);
}
.md-editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(255,255,255,0.08));
  border-bottom: 1px solid rgba(255,255,255,0.2);
  position: sticky; top: 0; z-index: 10;
  align-items: center;
}
@media (max-width: 768px) {
  .md-editor-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .md-editor-toolbar::-webkit-scrollbar { display: none; }
}
.md-toolbar-group {
  display: inline-flex; align-items: center; gap: 1px;
  background: transparent; border-radius: 8px; padding: 2px;
  flex-shrink: 0;
}
.md-toolbar-btn {
  background: transparent; border: none;
  border-radius: 6px; padding: 4px 8px; cursor: pointer;
  color: var(--text-muted);
  line-height: 1; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 3px;
  white-space: nowrap;
}
.md-toolbar-btn svg { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.md-toolbar-label { font-size: 11px; font-weight: 500; pointer-events: none; }
.md-toolbar-btn:hover { box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.md-toolbar-btn.active { color: #fff; box-shadow: 0 1px 4px rgba(52,59,224,0.3); }

/* ── Per-group color tints (always visible) ── */
.md-toolbar-group--text .md-toolbar-btn { background: rgba(33,150,243,0.10); color: #1976D2; }
.md-toolbar-group--text .md-toolbar-btn:hover { background: rgba(33,150,243,0.20); color: #1565C0; }
.md-toolbar-group--text .md-toolbar-btn.active { background: #2196F3; color: #fff; box-shadow: 0 1px 4px rgba(33,150,243,0.3); }

.md-toolbar-group--heading .md-toolbar-btn { background: rgba(91,99,240,0.10); color: #5B63F0; }
.md-toolbar-group--heading .md-toolbar-btn:hover { background: rgba(91,99,240,0.20); color: #4850d8; }
.md-toolbar-group--heading .md-toolbar-btn.active { background: #5B63F0; color: #fff; box-shadow: 0 1px 4px rgba(91,99,240,0.3); }

.md-toolbar-group--list .md-toolbar-btn { background: rgba(255,152,0,0.10); color: #E68900; }
.md-toolbar-group--list .md-toolbar-btn:hover { background: rgba(255,152,0,0.20); color: #E65100; }
.md-toolbar-group--list .md-toolbar-btn.active { background: #FF9800; color: #fff; box-shadow: 0 1px 4px rgba(255,152,0,0.3); }

.md-toolbar-group--block .md-toolbar-btn { background: rgba(126,87,194,0.10); color: #7E57C2; }
.md-toolbar-group--block .md-toolbar-btn:hover { background: rgba(126,87,194,0.20); color: #6A3FB5; }
.md-toolbar-group--block .md-toolbar-btn.active { background: #7E57C2; color: #fff; box-shadow: 0 1px 4px rgba(126,87,194,0.3); }

.md-toolbar-group--insert .md-toolbar-btn { background: rgba(0,151,167,0.10); color: #0097A7; }
.md-toolbar-group--insert .md-toolbar-btn:hover { background: rgba(0,151,167,0.20); color: #00838F; }
.md-toolbar-group--insert .md-toolbar-btn.active { background: #0097A7; color: #fff; box-shadow: 0 1px 4px rgba(0,151,167,0.3); }

/* ── Gutter handle: indent/outdent floating in the left gutter of the
   focused or hovered task/list line (Notion/Craft-style). ── */
.md-line-gutter {
  position: absolute;
  left: 4px;
  top: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
  z-index: 4;
}
.md-line-gutter.visible { opacity: 1; pointer-events: auto; }

.md-line-gutter-btn {
  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-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.md-line-gutter-btn svg { display: block; }
.md-line-gutter-btn:hover { background: rgba(76,175,80,0.18); color: #2E7D32; }
.md-line-gutter-btn:active { transform: scale(0.9); }
.md-line-gutter-btn:disabled { opacity: 0.25; cursor: default; }
.md-line-gutter-btn:disabled:hover { background: transparent; color: var(--text-muted); }

[data-theme="dark"] .md-line-gutter {
  background: var(--bg-card);
  box-shadow: 0 1px 4px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06);
}
[data-theme="dark"] .md-line-gutter-btn:hover { background: rgba(76,175,80,0.25); color: #81C784; }

/* Larger tap targets on touch devices — feels native without looking chunky */
@media (max-width: 600px) {
  .md-line-gutter { left: 2px; gap: 1px; padding: 3px; border-radius: 9px; }
  .md-line-gutter-btn { width: 22px; height: 22px; border-radius: 6px; }
  .md-line-gutter-btn svg { width: 14px; height: 14px; }
}

/* ── Prominent Checklist button (Apple Notes-style) ── */
.md-toolbar-btn-task {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: none; border-radius: 8px;
  background: rgba(168, 107, 148, 0.12); color: #A86B94;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
  line-height: 1; font-family: inherit;
  margin-right: 2px; flex-shrink: 0;
}
.md-toolbar-btn-task svg { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.md-toolbar-btn-task span { pointer-events: none; font-size: 11px; }
.md-toolbar-btn-task:hover {
  background: rgba(168, 107, 148, 0.22);
  box-shadow: 0 1px 4px rgba(168, 107, 148, 0.18);
}
.md-toolbar-btn-task.active {
  background: #A86B94; color: #fff;
  box-shadow: 0 2px 8px rgba(168, 107, 148, 0.3);
}

.md-editor-content {
  border: none; outline: none; min-height: 120px; max-height: 400px;
  overflow-y: auto; padding: 14px 16px 14px 36px;
  font-family: inherit;
  font-size: max(16px, 14px); line-height: 1.7;
  background: var(--bg-card); color: var(--text-secondary); cursor: text;
  transition: background 0.2s;
}

/* Keep-style: title + body share one scroll region.  When the wrapper is
   present it owns the max-height + overflow; the content flows naturally. */
.md-editor-scroll {
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 120px; max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
}
.fs-editor-wrap .md-editor-scroll .md-editor-content,
.md-editor-scroll .md-editor-content {
  max-height: none;
  overflow-y: visible;
  flex: 1 0 auto;
  min-height: 160px;
}
.md-editor-scroll .fs-editor-title-inline {
  flex: 0 0 auto;
}
.md-editor-content:focus,
.md-editor-content:focus-visible { outline: none; }
.md-editor-content:empty::before {
  content: attr(data-placeholder); color: var(--text-placeholder); pointer-events: none;
  font-size: 15px; font-weight: 300;
  display: block;
  opacity: 0.7;
}

.md-editor-content h1 { font-size: 1.5em; font-weight: 700; margin: 0.4em 0 0.2em; border-bottom: 1px solid var(--border-medium); padding-bottom: 0.15em; }
.md-editor-content h2 { font-size: 1.25em; font-weight: 700; margin: 0.35em 0 0.15em; border-bottom: 1px solid var(--border-light); padding-bottom: 0.1em; }
.md-editor-content h3 { font-size: 1.1em; font-weight: 600; margin: 0.3em 0 0.1em; }
.md-editor-content blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-muted); margin: 0.4em 0; }
.md-editor-content pre {
  background: var(--bg-code); border: 1px solid var(--border-medium);
  border-radius: 8px; padding: 0; overflow: hidden; margin: 0.5em 0;
  position: relative;
}
.md-editor-content pre code {
  background: none; padding: 12px 14px; display: block;
  color: var(--text-secondary); overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.88em; line-height: 1.6;
}
.md-editor-content code { background: var(--bg-code-inline); padding: 2px 6px; border-radius: 4px; font-size: 0.88em; font-family: 'JetBrains Mono', monospace; color: var(--text-code-inline); }
.md-editor-content hr { border: none; border-top: 1px solid var(--border-medium); margin: 0.8em 0; }
.md-editor-content a { color: var(--accent); text-decoration: underline; }
.md-editor-content p { margin: 0.3em 0; }
/* ── Custom circle checkbox (Apple Notes-style) ── */
.md-editor-content .cb-line { padding: 3px 0; display: flex; align-items: flex-start; gap: 8px; cursor: text; line-height: 1.6; transition: margin-left 0.15s ease; }
.md-editor-content .cb-line input[type=checkbox] {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; min-width: 20px;
  border: 2px solid var(--text-placeholder); border-radius: 50%;
  background: transparent; cursor: pointer; position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0; margin-top: 2px;
}
.md-editor-content .cb-line .cb-text { flex: 1; min-width: 0; min-height: 1.6em; }
.md-editor-content .cb-line input[type=checkbox]:hover {
  border-color: var(--accent);
}
.md-editor-content .cb-line input[type=checkbox]:checked {
  background: #4CAF50; border-color: #4CAF50;
}
.md-editor-content .cb-line input[type=checkbox]:checked::after {
  content: '';
  position: absolute; top: 2px; left: 5px;
  width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
/* Animated strikethrough + fade for completed tasks */
.md-editor-content .cb-line.cb-checked .cb-text {
  color: var(--text-placeholder);
  text-decoration: line-through;
  text-decoration-color: var(--text-placeholder);
  transition: color 0.3s, text-decoration-color 0.3s, opacity 0.3s;
  opacity: 0.55;
}

.md-editor-content .li-line { padding: 3px 0; line-height: 1.6; transition: margin-left 0.15s ease; }
.md-editor-content s { color: var(--text-placeholder); }
.md-editor-content ul, .md-editor-content ol { margin: 0.3em 0; padding-left: 24px; }
.md-editor-content li { padding: 1px 0; }

/* ── Highlight / mark styles ── */
.md-editor-content mark, .message-view mark {
  padding: 1px 4px; border-radius: 3px; color: inherit;
}
mark[data-color="yellow"], mark:not([data-color]) { background: #fff3aa; }
mark[data-color="pink"] { background: #ffd6e0; }
mark[data-color="purple"] { background: #e8d5f5; }
mark[data-color="orange"] { background: #ffdab3; }
mark[data-color="mint"] { background: #c8f7dc; }
mark[data-color="blue"] { background: #d4e4ff; }
[data-theme="dark"] mark[data-color="yellow"], [data-theme="dark"] mark:not([data-color]) { background: rgba(255,243,170,0.35); }
[data-theme="dark"] mark[data-color="pink"] { background: rgba(255,214,224,0.35); }
[data-theme="dark"] mark[data-color="purple"] { background: rgba(232,213,245,0.35); }
[data-theme="dark"] mark[data-color="orange"] { background: rgba(255,218,179,0.35); }
[data-theme="dark"] mark[data-color="mint"] { background: rgba(200,247,220,0.30); }
[data-theme="dark"] mark[data-color="blue"] { background: rgba(212,228,255,0.35); }

/* ── Highlight toolbar button ── */
.md-toolbar-btn-highlight {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: none; border-radius: 8px;
  background: rgba(255,193,7,0.12); color: #F9A825;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
  line-height: 1; font-family: inherit;
  margin-left: 2px; flex-shrink: 0;
}
.md-toolbar-btn-highlight svg { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.md-toolbar-btn-highlight span { pointer-events: none; font-size: 11px; }
.md-toolbar-btn-highlight:hover {
  background: rgba(255,193,7,0.22);
  box-shadow: 0 1px 4px rgba(255,193,7,0.18);
}
.md-toolbar-btn-highlight.active {
  background: #FFC107; color: #fff;
  box-shadow: 0 2px 8px rgba(255,193,7,0.3);
}

/* ── Toolbar action buttons (Tag, Section, Copy, Delete) ── */
.md-toolbar-group--actions {
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  /* Desktop: own row below formatting buttons, left-aligned */
  flex-basis: 100%;
  justify-content: flex-start;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
}
.md-toolbar-btn-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: none; border-radius: 8px;
  background: rgba(52, 59, 224, 0.12); color: #343BE0;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
  line-height: 1; font-family: inherit; flex-shrink: 0;
}
.md-toolbar-btn-tag svg { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.md-toolbar-btn-tag span { pointer-events: none; font-size: 11px; }
.md-toolbar-btn-tag:hover { background: rgba(52, 59, 224, 0.22); box-shadow: 0 1px 4px rgba(52, 59, 224, 0.2); }
.md-toolbar-btn-tag.active { background: #343BE0; color: #fff; box-shadow: 0 2px 8px rgba(52, 59, 224, 0.35); }

.md-toolbar-btn-section {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: none; border-radius: 8px;
  background: rgba(255, 152, 0, 0.12); color: #E69900;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
  line-height: 1; font-family: inherit; flex-shrink: 0;
}
.md-toolbar-btn-section svg { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.md-toolbar-btn-section span { pointer-events: none; font-size: 11px; }
.md-toolbar-btn-section:hover { background: rgba(255, 152, 0, 0.22); box-shadow: 0 1px 4px rgba(255, 152, 0, 0.2); }
.md-toolbar-btn-section.active { background: #FF9800; color: #fff; box-shadow: 0 2px 8px rgba(255, 152, 0, 0.35); }

/* ── Toolbar dropdown panels (appended to body, positioned via JS) ── */
.toolbar-dropdown-panel {
  display: none;
  position: fixed;
  min-width: 220px;
  max-width: 320px;
  max-height: 260px;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 200;
  flex-wrap: wrap;
  gap: 8px;
}
.toolbar-dropdown-panel.open {
  display: flex;
}
[data-theme="dark"] .toolbar-dropdown-panel {
  background: var(--bg-card);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.md-toolbar-btn-copy {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: none; border-radius: 8px;
  background: rgba(121, 85, 72, 0.12); color: #795548;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
  line-height: 1; font-family: inherit; flex-shrink: 0;
}
.md-toolbar-btn-copy svg { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.md-toolbar-btn-copy span { pointer-events: none; font-size: 11px; }
.md-toolbar-btn-copy:hover { background: rgba(121, 85, 72, 0.22); box-shadow: 0 1px 4px rgba(121, 85, 72, 0.2); }

.md-toolbar-btn-delete {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: none; border-radius: 8px;
  background: rgba(211, 47, 47, 0.12); color: #D32F2F;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
  line-height: 1; font-family: inherit; flex-shrink: 0;
}
.md-toolbar-btn-delete svg { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.md-toolbar-btn-delete span { pointer-events: none; font-size: 11px; }
.md-toolbar-btn-delete:hover { background: rgba(211, 47, 47, 0.22); box-shadow: 0 1px 4px rgba(211, 47, 47, 0.2); }

/* Date/time in word-count bar */
.md-wordcount-time {
  margin-right: auto; opacity: 0.8;
}

/* ── Task-type action toolbar (no md-editor, standalone bar) ── */
.fs-task-action-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(255,255,255,0.08));
  border-bottom: 1px solid rgba(255,255,255,0.2);
  align-items: center; flex-shrink: 0;
}
/* Actions group inside task toolbar doesn't need separator */
.fs-task-action-toolbar .md-toolbar-group--actions {
  flex-basis: auto; border-top: none; margin-top: 0; padding-top: 0;
}
[data-theme="dark"] .fs-task-action-toolbar {
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-bottom-color: rgba(255,255,255,0.08);
}

/* ── Reading / Preview mode: dim toolbar, hide cursor, tighten reading ── */
.md-editor-container.md-reading-mode .md-editor-toolbar > *:not(.md-toolbar-group--history):not(.md-toolbar-group--actions) {
  opacity: 0.35; pointer-events: none;
}
.md-editor-container.md-reading-mode .md-editor-toolbar .md-toolbar-group--history .md-toolbar-btn:not([title="Reading Mode"]) {
  opacity: 0.35; pointer-events: none;
}
.md-editor-container.md-reading-mode .md-editor-content {
  caret-color: transparent; cursor: default;
  user-select: text;
}
.md-editor-container.md-reading-mode .md-editor-content [contenteditable="true"] {
  cursor: default;
}

/* ── Dictate (voice-to-text) button ── */
.md-toolbar-btn-dictate {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: none; border-radius: 8px;
  background: rgba(233, 30, 99, 0.12); color: #E91E63;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
  line-height: 1; font-family: inherit;
  margin-left: 2px; flex-shrink: 0;
}
.md-toolbar-btn-dictate svg { width: 14px; height: 14px; fill: currentColor; display: block; flex-shrink: 0; }
.md-toolbar-btn-dictate span { pointer-events: none; font-size: 11px; }
.md-toolbar-btn-dictate:hover {
  background: rgba(233, 30, 99, 0.22);
  box-shadow: 0 1px 4px rgba(233, 30, 99, 0.18);
}
.md-toolbar-btn-dictate.active {
  background: #E91E63; color: #fff;
  box-shadow: 0 2px 8px rgba(233, 30, 99, 0.3);
}

/* Pulsing animation when listening */
.md-dictate-listening {
  animation: md-dictate-pulse 1.2s ease-in-out infinite;
}
@keyframes md-dictate-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(233, 30, 99, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(233, 30, 99, 0); }
}

/* Interim (live preview) text while speaking */
.md-dictate-interim {
  color: var(--text-faint, #999);
  font-style: italic;
  opacity: 0.6;
}

/* ── Highlight color picker popover ── */
.md-highlight-picker {
  position: fixed; z-index: 100000;
  background: var(--bg-card); border: 1px solid var(--border-medium);
  border-radius: 12px; padding: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}
.md-highlight-grid {
  display: flex; gap: 6px; align-items: center;
}
.md-highlight-swatch {
  width: 28px; height: 28px; border: 2px solid transparent;
  border-radius: 50%; cursor: pointer; padding: 0;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.md-highlight-swatch:hover {
  transform: scale(1.15);
  border-color: var(--text-muted);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.md-highlight-remove {
  background: var(--bg-surface); border: 1px solid var(--border-default);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text-muted); font-weight: 700;
}
.md-highlight-remove:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Collapsible heading toggle ── */
.heading-toggle {
  display: inline-block; cursor: pointer; user-select: none;
  width: 1em; text-align: center; color: var(--text-placeholder);
  font-size: 0.75em; margin-right: 4px;
  transition: color 0.15s;
  opacity: 0.5;
  vertical-align: middle;
}
.heading-toggle:hover { color: var(--text-primary); opacity: 1; }
.heading-collapsed { opacity: 0.6; }
.heading-collapsed .heading-toggle { opacity: 1; color: var(--accent); }

/* ── Table styles ── */
.md-table-wrap {
  position: relative; margin: 0.6em 0; padding: 22px 0 4px 24px;
  display: inline-block; max-width: 100%;
}
.md-table-wrap:hover .md-table-col-handle,
.md-table-wrap:hover .md-table-row-handle {
  opacity: 1;
}
.md-table {
  border-collapse: collapse; width: auto;
  font-size: 0.92em; line-height: 1.5;
}
.md-table td, .md-table th {
  border: 1px solid var(--border-default);
  padding: 5px 10px; min-width: 60px;
  vertical-align: top; outline: none;
  transition: background 0.12s;
}
.md-table td:focus,
.md-table td:focus-visible {
  background: rgba(52, 59, 224, 0.04);
  outline: none;
}
.md-table tr:first-child td {
  font-weight: 600;
  background: var(--bg-surface);
  position: relative;
}
.md-table tr:first-child td[data-placeholder]:empty::before,
.md-table tr:first-child td[data-placeholder]:has(br:only-child)::before {
  content: attr(data-placeholder);
  color: var(--text-placeholder);
  font-weight: 400;
  pointer-events: none;
  opacity: 0.7;
}
[data-theme="dark"] .md-table td, [data-theme="dark"] .md-table th {
  border-color: rgba(255,255,255,0.12);
}
[data-theme="dark"] .md-table tr:first-child td {
  background: rgba(255,255,255,0.04);
}

/* Table column/row handles */
.md-table-col-handle, .md-table-row-handle {
  position: absolute; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--text-placeholder);
  cursor: pointer; border-radius: 4px;
  opacity: 0; transition: opacity 0.15s, background 0.12s;
  user-select: none; z-index: 2;
}
.md-table-col-handle:hover, .md-table-row-handle:hover {
  background: var(--accent-bg); color: var(--accent);
}

/* Table context menu */
.md-table-menu {
  background: var(--bg-card); border: 1px solid var(--border-medium);
  border-radius: 8px; padding: 4px; min-width: 130px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.md-table-menu-item {
  display: block; width: 100%; text-align: left;
  padding: 6px 12px; border: none; background: transparent;
  font-size: 12px; font-weight: 500; cursor: pointer;
  border-radius: 5px; color: var(--text-secondary);
  transition: background 0.1s;
}
.md-table-menu-item:hover { background: var(--accent-bg); color: var(--accent); }
.md-table-menu-item.danger { color: var(--btn-danger-color); }
.md-table-menu-item.danger:hover { background: rgba(211,47,47,0.08); }

/* Message-view table styles */
.message-view .md-table-wrap { padding: 0; margin: 0.5em 0; display: block; }
.message-view .md-table { width: 100%; }
.message-view .md-table td, .message-view .md-table th {
  border: 1px solid var(--border-default);
  padding: 4px 8px;
}
.message-view .md-table tr:first-child td { font-weight: 600; background: var(--bg-surface); }
.message-view .md-table-col-handle,
.message-view .md-table-row-handle { display: none; }

/* ── Code block header (language badge + copy) ── */
.code-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 10px; background: var(--border-light);
  border-bottom: 1px solid var(--border-medium);
  font-size: 11px; user-select: none;
}
[data-theme="dark"] .code-block-header { background: rgba(255,255,255,0.04); }
.code-lang-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--accent); background: var(--accent-bg); padding: 2px 8px; border-radius: 4px;
}
.code-copy-btn {
  background: transparent; border: 1px solid var(--border-default); border-radius: 4px;
  padding: 2px 8px; font-size: 10px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); transition: all 0.15s; margin: 0;
}
.code-copy-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Word count bar ── */
.md-editor-wordcount {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 4px 12px; font-size: 11px; color: var(--text-placeholder);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  letter-spacing: 0.3px; user-select: none;
}

/* ── Floating bubble toolbar ── */

/* ── Slash command menu ── */
.md-slash-menu {
  position: absolute; z-index: 100002;
  min-width: 220px; max-width: 280px; max-height: 260px; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border-medium);
  border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  opacity: 0; visibility: hidden;
  transition: opacity 0.12s, visibility 0.12s;
}
.md-slash-menu.visible { opacity: 1; visibility: visible; }
.md-slash-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  transition: background 0.1s;
}
.md-slash-item:hover, .md-slash-item.active { background: var(--accent-bg); }
.md-slash-icon {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover); border-radius: 6px; flex-shrink: 0;
  color: var(--accent);
}
.md-slash-icon svg { width: 16px; height: 16px; fill: currentColor; }
.md-slash-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.md-slash-desc { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.md-slash-empty { padding: 12px; text-align: center; font-size: 12px; color: var(--text-placeholder); }
[data-theme="dark"] .md-slash-menu {
  background: var(--bg-surface);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}

/* ── Slash command category headers ── */
.md-slash-category {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-placeholder);
  padding: 8px 12px 2px; pointer-events: none; user-select: none;
}
.md-slash-category:first-child { padding-top: 4px; }

/* ── Undo/Redo button group ── */
.md-toolbar-group--history .md-toolbar-btn { background: rgba(120,120,140,0.10); color: #78788C; }
.md-toolbar-group--history .md-toolbar-btn:hover { background: rgba(120,120,140,0.20); color: #5A5A6E; }
.md-toolbar-group--history .md-toolbar-btn.active { background: #78788C; color: #fff; box-shadow: 0 1px 4px rgba(120,120,140,0.3); }

/* ── Heading picker popover ── */
.md-heading-picker {
  background: var(--bg-card); border: 1px solid var(--border-medium);
  border-radius: 12px; padding: 6px; min-width: 200px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}
[data-theme="dark"] .md-heading-picker {
  background: var(--bg-surface);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.md-heading-picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
  background: transparent; border: none; width: 100%;
  transition: background 0.1s; text-align: left;
  color: var(--text-secondary);
}
.md-heading-picker-item:hover { background: var(--accent-bg); }
.md-heading-picker-icon { display: flex; align-items: center; width: 22px; justify-content: center; color: var(--accent); flex-shrink: 0; }
.md-heading-picker-icon svg { width: 16px; height: 16px; fill: currentColor; }
.md-heading-picker-label { flex: 1; line-height: 1.3; }

/* ── "Aa" format picker popover ── */
.md-aa-picker {
  background: var(--bg-card); border: 1px solid var(--border-medium);
  border-radius: 12px; padding: 6px; min-width: 180px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}
[data-theme="dark"] .md-aa-picker {
  background: var(--bg-surface);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.md-aa-picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  background: transparent; border: none; width: 100%;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  transition: background 0.1s; text-align: left;
}
.md-aa-picker-item:hover { background: var(--accent-bg); }
.md-aa-picker-icon { display: flex; align-items: center; width: 20px; justify-content: center; color: var(--accent); }
.md-aa-picker-icon svg { width: 16px; height: 16px; fill: currentColor; }
.md-aa-picker-label { flex: 1; }
.md-aa-picker-sep { height: 1px; background: var(--border-light); margin: 4px 8px; }

/* ── Callout blocks ── */
.md-callout {
  display: flex; gap: 10px; border-left: 4px solid; border-radius: 8px;
  padding: 12px 16px; margin: 8px 0; position: relative;
}
.md-callout-icon {
  flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
}
.md-callout-icon svg { width: 18px; height: 18px; }
.md-callout-content { flex: 1; min-width: 0; }
.md-callout-title {
  font-weight: 700; font-size: 0.95em; margin-bottom: 2px;
  outline: none; min-height: 1.2em;
}
.md-callout-body {
  font-size: 0.92em; line-height: 1.6;
  outline: none; min-height: 1.2em;
}

/* Callout type colors */
.md-callout--info { border-color: #2196F3; background: rgba(33,150,243,0.06); }
.md-callout--info .md-callout-icon { color: #2196F3; }
.md-callout--info .md-callout-title { color: #1976D2; }

.md-callout--tip { border-color: #4CAF50; background: rgba(76,175,80,0.06); }
.md-callout--tip .md-callout-icon { color: #4CAF50; }
.md-callout--tip .md-callout-title { color: #388E3C; }

.md-callout--warning { border-color: #FF9800; background: rgba(255,152,0,0.06); }
.md-callout--warning .md-callout-icon { color: #FF9800; }
.md-callout--warning .md-callout-title { color: #E65100; }

.md-callout--danger { border-color: #F44336; background: rgba(244,67,54,0.06); }
.md-callout--danger .md-callout-icon { color: #F44336; }
.md-callout--danger .md-callout-title { color: #C62828; }

.md-callout--success { border-color: #4CAF50; background: rgba(76,175,80,0.06); }
.md-callout--success .md-callout-icon { color: #4CAF50; }
.md-callout--success .md-callout-title { color: #2E7D32; }

/* Dark mode callouts */
[data-theme="dark"] .md-callout--info { background: rgba(33,150,243,0.08); }
[data-theme="dark"] .md-callout--info .md-callout-title { color: #64B5F6; }
[data-theme="dark"] .md-callout--tip { background: rgba(76,175,80,0.08); }
[data-theme="dark"] .md-callout--tip .md-callout-title { color: #81C784; }
[data-theme="dark"] .md-callout--warning { background: rgba(255,152,0,0.08); }
[data-theme="dark"] .md-callout--warning .md-callout-title { color: #FFB74D; }
[data-theme="dark"] .md-callout--danger { background: rgba(244,67,54,0.08); }
[data-theme="dark"] .md-callout--danger .md-callout-title { color: #EF5350; }
[data-theme="dark"] .md-callout--success { background: rgba(76,175,80,0.08); }
[data-theme="dark"] .md-callout--success .md-callout-title { color: #81C784; }

/* ── Callout picker popover ── */
.md-callout-picker {
  background: var(--bg-card); border: 1px solid var(--border-medium);
  border-radius: 10px; padding: 6px; min-width: 160px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}
[data-theme="dark"] .md-callout-picker {
  background: var(--bg-surface);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.md-callout-picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  background: transparent; border: none; width: 100%;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  transition: background 0.1s; text-align: left;
}
.md-callout-picker-item:hover { background: var(--accent-bg); }
.md-callout-picker-icon { display: flex; align-items: center; }
.md-callout-picker-icon svg { width: 18px; height: 18px; }

/* ── Toggle / Collapsible blocks ── */
.md-toggle {
  border: 1px solid var(--border-light); border-radius: 8px;
  margin: 8px 0; overflow: hidden;
}
.md-toggle summary {
  padding: 10px 14px; cursor: pointer; font-weight: 600;
  font-size: 0.95em; list-style: none;
  display: flex; align-items: center; gap: 6px;
  user-select: none; transition: background 0.12s;
}
.md-toggle summary::-webkit-details-marker { display: none; }
.md-toggle summary::before {
  content: ""; display: inline-block; width: 0; height: 0;
  border-left: 6px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  transition: transform 0.2s; flex-shrink: 0;
}
.md-toggle[open] summary::before { transform: rotate(90deg); }
.md-toggle summary:hover { background: var(--bg-hover); }
.md-toggle-body {
  padding: 4px 14px 12px; border-top: 1px solid var(--border-light);
  font-size: 0.92em; line-height: 1.6;
  outline: none; min-height: 1.2em;
}
[data-theme="dark"] .md-toggle { border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .md-toggle-body { border-color: rgba(255,255,255,0.06); }

/* ── Reorder mode ──
 * Entered from a card's ⋯ menu. One section-group is "active" and every
 * card inside becomes pointer-draggable. Cards outside the active group
 * are dimmed and non-interactive until the user taps "Done reordering".
 */
body.reorder-mode-on .section-group:not(.reorder-active-group) {
  opacity: 0.35;
  pointer-events: none;
  filter: saturate(0.5);
}
.section-group.reorder-active-group .section-group-header {
  pointer-events: none;
}
.section-group.reorder-active-group .section-group-body {
  padding: 4px;
  border-radius: 10px;
  background: var(--accent-bg, rgba(52, 59, 224, 0.06));
  outline: 2px dashed var(--accent, #343BE0);
  outline-offset: -2px;
}
.section-group.reorder-active-group .clipboard.reorder-draggable {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* prevent scroll / long-press menus during drag */
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.section-group.reorder-active-group .clipboard.reorder-draggable:active {
  cursor: grabbing;
}
.clipboard.reorder-dragging {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.12) !important;
  transform: scale(1.02);
  opacity: 0.96;
  cursor: grabbing !important;
}
.reorder-placeholder {
  border: 2px dashed var(--accent, #343BE0);
  border-radius: 10px;
  background: var(--accent-bg, rgba(52, 59, 224, 0.08));
  margin: 6px 0;
  box-sizing: border-box;
}

/* Hide interactive affordances on cards while reordering, so users don't
 * accidentally pin/select mid-drag. The ⋯ menu is also hidden to make the
 * card a single drag target. */
.section-group.reorder-active-group .clipboard .clipboard-pin-btn,
.section-group.reorder-active-group .clipboard .clipboard-select-btn,
.section-group.reorder-active-group .clipboard .clipboard-more-btn {
  pointer-events: none;
  opacity: 0.35;
}

/* Floating "Done reordering" pill — accent outline on card fill, bottom-center on all devices. */
.reorder-done-pill {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 10010;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px 9px 16px;
  border-radius: 999px;
  background: var(--bg-card, #fff);
  border: 1.5px solid var(--accent, #343BE0);
  color: var(--accent, #343BE0);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1px;
  box-shadow:
    0 6px 18px rgba(var(--accent-rgb, 52, 59, 224), 0.22),
    0 14px 36px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease;
}
.reorder-done-pill .reorder-done-icon {
  flex-shrink: 0;
  stroke: var(--accent, #343BE0);
  transition: stroke 0.25s ease;
}
.reorder-done-pill .reorder-done-label {
  line-height: 1;
}
.reorder-done-pill:hover {
  background: var(--accent, #343BE0);
  color: #fff;
  transform: translateX(-50%) translateY(-1px);
  box-shadow:
    0 8px 22px rgba(var(--accent-rgb, 52, 59, 224), 0.32),
    0 18px 44px rgba(0,0,0,0.12);
}
.reorder-done-pill:hover .reorder-done-icon {
  stroke: #fff;
}
.reorder-done-pill:active {
  transform: translateX(-50%) scale(0.97);
}
@media (max-width: 600px) {
  .reorder-done-pill {
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    padding: 10px 20px 10px 18px;
    font-size: 14px;
  }
}

/* Dark mode — dark card fill with accent outline */
[data-theme="dark"] .reorder-done-pill {
  background: var(--bg-card, #1c1c26);
  box-shadow:
    0 6px 20px rgba(var(--accent-rgb, 91, 99, 240), 0.38),
    0 14px 40px rgba(0,0,0,0.5);
}
[data-theme="dark"] .reorder-done-pill:hover {
  box-shadow:
    0 8px 24px rgba(var(--accent-rgb, 91, 99, 240), 0.48),
    0 18px 46px rgba(0,0,0,0.55);
}

/* Rendered markdown in view mode */
.message-view h1, .message-view h2, .message-view h3,
.message-view h4, .message-view h5, .message-view h6 { margin: 0.4em 0 0.2em; color: var(--text-secondary); }
.message-view h1 { font-size: 1.4em; border-bottom: 1px solid var(--border-medium); padding-bottom: 0.2em; }
.message-view h2 { font-size: 1.2em; border-bottom: 1px solid var(--border-light); padding-bottom: 0.15em; }
.message-view h3 { font-size: 1.05em; }
.message-view blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-muted); margin: 0.4em 0; }
.message-view pre { background: var(--bg-code); border: 1px solid var(--border-medium); border-radius: 5px; padding: 10px 14px; overflow-x: auto; margin: 0.5em 0; }
.message-view code { background: var(--bg-code-inline); padding: 1px 5px; border-radius: 3px; font-size: 0.9em; font-family: 'JetBrains Mono', monospace; }
.message-view pre code { background: none; padding: 0; }
.message-view hr { border: none; border-top: 1px solid var(--border-medium); margin: 0.8em 0; }
.message-view a { color: var(--accent); text-decoration: underline; }
.message-view input[type=checkbox] { accent-color: var(--accent); margin-right: 5px; }
.message-view s { color: var(--text-placeholder); }
.message-view p { margin: 0.3em 0; }
.message-view .cb-line, .message-view .li-line { padding: 1px 0; }
.message-view .cb-line { display: flex; align-items: flex-start; gap: 6px; }
.message-view .cb-line input[type=checkbox] {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; min-width: 16px;
  border: 2px solid var(--text-placeholder); border-radius: 50%;
  background: transparent; cursor: default; position: relative;
  flex-shrink: 0; margin-top: 2px;
}
.message-view .cb-line .cb-text { flex: 1; min-width: 0; }
.message-view .cb-line input[type=checkbox]:checked {
  background: #4CAF50; border-color: #4CAF50;
}
.message-view .cb-line input[type=checkbox]:checked::after {
  content: '';
  position: absolute; top: 1px; left: 3.5px;
  width: 4px; height: 7px;
  border: solid #fff; border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.message-view .cb-line.cb-checked .cb-text {
  color: var(--text-placeholder); text-decoration: line-through; opacity: 0.55;
}

/* ── Fullscreen Editor ── */
.fs-editor-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.fs-editor-wrap {
  background: var(--bg-body);
  border: 1px solid var(--border-medium);
  border-radius: 16px; width: 100%; max-width: 900px;
  height: 90vh;
  /* dvh excludes mobile browser chrome so the wrap fits the visible
     viewport instead of overflowing behind iOS Safari's address bar */
  height: 90dvh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-editor);
  overflow: hidden;
}
.fs-editor-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 20px;
  background: transparent;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.fs-editor-title {
  flex: 1 1 100%; font-family: 'Poppins', sans-serif; font-size: 18px; font-weight: 600; outline: none;
  background: transparent;
  padding: 10px 16px; color: var(--text-primary);
  border-radius: 10px;
  border: 1px solid transparent;
  transition: all 0.3s ease;
}
.fs-editor-title:empty::before {
  content: attr(data-placeholder);
  color: var(--text-placeholder); font-weight: 400;
  pointer-events: none;
  display: block;
}
.fs-editor-title:focus,
.fs-editor-title:focus-visible {
  background: transparent;
  border-color: transparent;
  outline: none;
}
.fs-editor-title:focus:empty::before { opacity: 0.5; }

/* Google Keep-style: title sits between toolbar and body, sharing the body's
   visual surface — no border, transparent bg, aligned padding, larger font.
   Horizontal padding matches .md-editor-content so title and body text align
   at the same x-position. */
.fs-editor-title.fs-editor-title-inline {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  padding: 16px 24px 4px 24px;
  border: none;
  border-radius: 0;
  outline: none;
  transition: none;
  word-break: break-word;
}
.fs-editor-title.fs-editor-title-inline:focus,
.fs-editor-title.fs-editor-title-inline:focus-visible {
  background: transparent;
  border: none;
  outline: none;
}
[data-theme="dark"] .fs-editor-title.fs-editor-title-inline,
[data-theme="dark"] .fs-editor-title.fs-editor-title-inline:focus {
  background: transparent;
  border: none;
}

.fs-editor-header-right { display: flex; order: -1; width: 100%; gap: 8px; align-items: center; }
.fs-editor-header-right .fs-editor-cancel { order: -1; margin-right: auto; }

.fs-editor-btn {
  padding: 8px 18px; border-radius: 24px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; display: flex; align-items: center; gap: 6px;
  transition: all 0.2s;
}
.fs-editor-cancel {
  background: rgba(52, 59, 224, 0.08); color: var(--accent);
  border: 1.5px solid rgba(52, 59, 224, 0.2);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-radius: 8px;
  padding: 8px 12px;
}
.fs-editor-cancel:hover { background: rgba(52, 59, 224, 0.15); color: var(--accent); }
.fs-editor-save {
  background: rgba(var(--accent-rgb, 66,133,244), 0.1);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb, 66,133,244), 0.1);
  box-shadow: 0 1px 4px rgba(var(--accent-rgb, 66,133,244), 0.15);
  animation: btnBreathe 3s ease-in-out infinite;
  position: relative;
  border-radius: 8px;
}
.fs-editor-save::before { display: none; }
.fs-editor-save::after {
  content: '';
  position: absolute; inset: -1.5px; border-radius: inherit; padding: 1.5px;
  background: conic-gradient(from var(--border-angle, 0deg), transparent 60%, rgba(var(--accent-rgb, 66,133,244), 0.3) 78%, transparent 95%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  animation: borderTrace 4s linear infinite;
  pointer-events: none;
}
.fs-editor-save:hover {
  background: rgba(var(--accent-rgb, 66,133,244), 0.18);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb, 66,133,244), 0.2);
}
.fs-editor-save svg { width: 16px; height: 16px; fill: var(--accent); }

.fs-editor-wrap .md-editor-container {
  flex: 1; border: none; border-radius: 0; margin: 0;
  overflow: hidden; display: flex; flex-direction: column;
  min-height: 0;
}
.fs-editor-wrap .md-editor-container:focus-within {
  box-shadow: none;
  border-color: transparent;
}
/* Kill any lingering blue focus outline/border between title and body.
   Keeps a very subtle separator if browsers still render a default focus
   indicator on the contenteditable body. */
.fs-editor-wrap .md-editor-scroll,
.fs-editor-wrap .md-editor-scroll:focus-within,
.fs-editor-wrap .md-editor-content,
.fs-editor-wrap .md-editor-content:focus,
.fs-editor-wrap .md-editor-content:focus-visible,
.fs-editor-wrap .fs-editor-title-inline,
.fs-editor-wrap .fs-editor-title-inline:focus {
  outline: none;
  box-shadow: none;
  border-top-color: transparent;
  border-bottom-color: transparent;
}
.fs-editor-wrap .md-editor-wordcount {
  background: transparent; border-top: 1px solid var(--border-light);
}
.fs-editor-wrap .md-editor-toolbar {
  position: sticky; top: 0; z-index: 10; padding: 6px 12px; gap: 4px;
  background: transparent;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.fs-editor-wrap .md-editor-content {
  flex: 1; overflow-y: auto; max-height: none; padding: 20px 24px; font-size: 15px; min-height: 0;
  background: transparent;
}
/* Title + body share one scroll region. Base .md-editor-scroll caps height
   at 400px which leaves the wrap half-empty on the editor page; remove the
   cap so the white card surface fills the full wrap height. */
.fs-editor-wrap .md-editor-scroll {
  max-height: none;
  flex: 1 1 auto;
  min-height: 200px;
}

.fs-editor-tags {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  border-top: 1px solid var(--border-light);
  background: transparent;
  flex-wrap: wrap; flex-shrink: 0;
}
.fs-editor-tags-label { font-size: 13px; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.fs-editor-tag-picker { display: flex; flex-wrap: wrap; gap: 8px; }

.fs-editor-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-top: 1px solid var(--border-light);
  background: transparent;
  flex-shrink: 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.fs-editor-footer-left { display: flex; align-items: center; gap: 10px; }

.fs-footer-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  border-radius: 10px; border: 1px solid var(--border-light);
  background: var(--bg-hover);
  font-size: 13px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.fs-footer-btn:hover { background: var(--bg-hover); }
.fs-footer-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.fs-footer-btn .label-short { display: none; }
.fs-footer-btn .label-full { display: inline; }

.fs-footer-btn-danger { background: rgba(211,47,47,0.12); color: var(--btn-danger-color); }
.fs-footer-btn-danger:hover { background: rgba(211,47,47,0.2); }
.fs-footer-btn-danger svg { fill: var(--btn-danger-color); }

.fs-footer-btn-edit { background: rgba(126,87,194,0.12); color: var(--btn-edit-color); }
.fs-footer-btn-edit:hover { background: rgba(126,87,194,0.2); }
.fs-footer-btn-edit svg { fill: var(--btn-edit-color); }

.fs-footer-btn-copy { background: rgba(121,85,72,0.12); color: var(--btn-copy-color); }
.fs-footer-btn-copy:hover { background: rgba(121,85,72,0.2); }
.fs-footer-btn-copy svg { fill: var(--btn-copy-color); }

.fs-footer-btn-tag { background: rgba(52,59,224,0.12); color: var(--accent); }
.fs-footer-btn-tag:hover { background: rgba(52,59,224,0.2); }
.fs-footer-btn-tag svg { fill: var(--accent); }

.tag-picker-label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

/* ── Inline "+ New" creator for tag & section pickers ──
   Each creator is tinted to match its parent footer button so it reads
   clearly against the neutral picker pills: tag = accent blue, section
   = orange. Dashed border keeps the "draft / not yet created" feel. */
.picker-create-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
  font-family: inherit;
  border: 1px dashed transparent;
}

/* Tag creator — accent blue tint (matches .fs-footer-btn-tag) */
.fs-editor-tag-picker .picker-create-btn {
  color: var(--accent);
  background: rgba(52, 59, 224, 0.12);
  border-color: rgba(52, 59, 224, 0.45);
}
.fs-editor-tag-picker .picker-create-btn:hover {
  background: rgba(52, 59, 224, 0.22);
  border-color: var(--accent);
}
.fs-editor-tag-picker .picker-create-btn:focus,
.fs-editor-tag-picker .picker-create-btn:focus-visible,
.fs-editor-section-picker .picker-create-btn:focus,
.fs-editor-section-picker .picker-create-btn:focus-visible {
  outline: none;
}

/* Section creator — orange tint (matches .fs-footer-btn-section) */
.fs-editor-section-picker .picker-create-btn {
  color: #FF9800;
  background: rgba(255, 152, 0, 0.14);
  border-color: rgba(255, 152, 0, 0.5);
}
.fs-editor-section-picker .picker-create-btn:hover {
  background: rgba(255, 152, 0, 0.24);
  border-color: #FF9800;
}

.picker-create-input {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  outline: none;
  min-width: 120px;
  max-width: 180px;
  line-height: 1.4;
  font-family: inherit;
}
.fs-editor-section-picker .picker-create-input {
  border-color: #FF9800;
}
.picker-create-input:disabled { opacity: 0.6; }

/* Theme toggle icon visibility: light = show sun, dark = show moon */
#themeToggle .theme-icon-sun { display: block; }
#themeToggle .theme-icon-moon { display: none; }
[data-theme="dark"] #themeToggle .theme-icon-sun { display: none; }
[data-theme="dark"] #themeToggle .theme-icon-moon { display: block; }

/* ══════════════════════════════════════════════════
   Task List Styles
   ══════════════════════════════════════════════════ */

/* ── Add button dropdown ── */
.add-dropdown {
  position: fixed;
  background: var(--bg-card); border: 1px solid var(--border-medium);
  border-radius: 10px; box-shadow: var(--shadow-card);
  z-index: 1100; overflow: hidden; min-width: 150px;
}
.add-dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 16px; margin: 0; border: none; border-radius: 0;
  background: transparent; color: var(--text-primary);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background 0.12s;
}
.add-dropdown-item:hover { background: var(--bg-hover); }
.add-dropdown-item svg { width: 18px; height: 18px; fill: var(--text-muted); }

/* ── Note Actions Menu (Download dropdown) ── */
.note-actions-menu {
  position: fixed;
  z-index: 1100;
  min-width: 236px;
  background: var(--bg-card);
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(17,24,39,0.06), 0 2px 6px rgba(17,24,39,0.04);
  padding: 8px;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
[data-theme="dark"] .note-actions-menu {
  border-color: rgba(255,255,255,0.05);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.25);
}
.note-actions-menu.nam-up { transform-origin: bottom right; transform: translateY(4px) scale(0.98); }
.note-actions-menu.nam-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.note-actions-menu .nam-header {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px 12px;
  margin-bottom: 4px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.1px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
[data-theme="dark"] .note-actions-menu .nam-header { border-bottom-color: rgba(255,255,255,0.06); }
.note-actions-menu .nam-header svg {
  width: 18px; height: 18px; padding: 4px;
  box-sizing: content-box; border-radius: 8px;
  background: rgba(52,59,224,0.1); color: #343BE0;
  opacity: 1;
}
[data-theme="dark"] .note-actions-menu .nam-header svg { background: rgba(110,118,255,0.18); color: #9aa3ff; }

.note-actions-menu .nam-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 8px 10px;
  border: none; border-radius: 12px;
  background: transparent; color: var(--text-primary);
  font-size: 14px; text-align: left; cursor: pointer;
  transition: background 0.18s ease;
}
.note-actions-menu .nam-item:hover { background: var(--bg-hover); }
.note-actions-menu .nam-item + .nam-item { margin-top: 1px; }

.note-actions-menu .nam-badge {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 11px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.3px;
}
[data-theme="dark"] .note-actions-menu .nam-badge { filter: brightness(0.85) saturate(0.9); }

.note-actions-menu .nam-text {
  display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0;
}
.note-actions-menu .nam-label { font-weight: 500; line-height: 1.25; }
.note-actions-menu .nam-sub {
  font-size: 11px; color: var(--text-muted); opacity: 0.75;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-top: 1px;
}

.note-actions-menu .nam-chev {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  color: var(--text-muted); opacity: 0;
  transition: opacity 0.18s ease;
}
.note-actions-menu .nam-item:hover .nam-chev { opacity: 0.5; }

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

.note-actions-menu .nam-header-actions {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 2px solid rgba(52,59,224,0.18);
}
[data-theme="dark"] .note-actions-menu .nam-header-actions {
  border-top-color: rgba(110,118,255,0.28);
}
.note-actions-menu .nam-badge-icon { padding: 0; }
.note-actions-menu .nam-badge-icon svg {
  width: 18px; height: 18px; fill: currentColor;
}

/* ── Task indent levels ── */
:root { --task-indent: 20px; --task-indent-editor: 24px; }

/* ── Task list on card ── */
.task-list-view { margin-top: 8px; margin-bottom: 5px; }
.task-item {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0; cursor: default;
  transition: padding-left 0.15s ease;
}
.task-checkbox {
  width: 16px; height: 16px; cursor: pointer; margin: 0;
  accent-color: var(--accent); flex-shrink: 0;
}
.task-text { font-size: 13px; color: var(--text-secondary); line-height: 1.3; }
.task-completed {
  opacity: 0.45;
}
.task-completed .task-text {
  text-decoration: line-through; color: var(--text-placeholder);
}

/* ── Task priority badge (card view) ── */
.task-priority-badge {
  font-size: 10px; font-weight: 800; line-height: 1;
  padding: 1px 5px; border-radius: 4px;
  flex-shrink: 0; margin-right: 1px;
  letter-spacing: -0.5px;
}
.task-priority-1 { color: #4caf50; background: rgba(76, 175, 80, 0.1); }
.task-priority-2 { color: #ff9800; background: rgba(255, 152, 0, 0.1); }
.task-priority-3 { color: #f44336; background: rgba(244, 67, 54, 0.12); }

/* ── Task note icon (card view) ── */
.task-note-icon {
  margin-left: auto; flex-shrink: 0;
  display: inline-flex; align-items: center;
}

/* ── Task editor in fullscreen ── */
.fs-task-editor {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  background: var(--bg-card);
}
.fs-task-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0; border-bottom: 1px solid var(--border-light);
  transition: padding-left 0.15s ease;
}
.fs-task-input {
  flex: 1; border: none; outline: none; padding: 8px 4px;
  font-size: max(16px, 15px); font-family: inherit;
  background: transparent; color: var(--text-primary);
}
.fs-task-input::placeholder { color: var(--text-placeholder); }
.fs-task-completed { opacity: 0.45; }
.fs-task-completed .fs-task-input { text-decoration: line-through; color: var(--text-placeholder); }
.fs-task-remove {
  width: 24px; height: 24px; min-width: 24px; padding: 0; margin: 0;
  border: none; border-radius: 50%; background: transparent;
  color: var(--text-placeholder); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color 0.12s, background 0.12s;
}
.fs-task-remove:hover { color: var(--btn-danger-color); background: var(--btn-danger-hover-bg); }
.fs-task-add {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px; padding: 8px 14px; border: none; border-radius: 8px;
  background: transparent; color: var(--accent); font-size: 14px;
  font-weight: 500; cursor: pointer; transition: background 0.12s;
}
.fs-task-add:hover { background: var(--accent-bg); }

/* ── Task priority button (editor) ── */
.fs-task-priority-btn {
  width: 24px; height: 24px; min-width: 24px; padding: 0;
  border: 1.5px solid var(--border-light); border-radius: 50%;
  background: transparent; cursor: pointer;
  font-size: 11px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
  color: var(--text-placeholder); flex-shrink: 0;
}
.fs-task-priority-0 { color: var(--text-placeholder); border-color: var(--border-light); }
.fs-task-priority-1 { color: #4caf50; border-color: #4caf50; background: rgba(76, 175, 80, 0.08); }
.fs-task-priority-2 { color: #ff9800; border-color: #ff9800; background: rgba(255, 152, 0, 0.08); }
.fs-task-priority-3 { color: #f44336; border-color: #f44336; background: rgba(244, 67, 54, 0.08); }
.fs-task-priority-btn:hover { transform: scale(1.1); }

/* ── Task note toggle (editor) ── */
.fs-task-note-toggle {
  width: 24px; height: 24px; min-width: 24px; padding: 0;
  border: none; border-radius: 50%; background: transparent;
  color: var(--text-placeholder); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.12s, background 0.12s; flex-shrink: 0;
}
.fs-task-note-toggle:hover { background: var(--bg-hover); color: var(--text-muted); }
.fs-task-note-toggle.has-note { color: var(--accent); }

/* ── Task note area (editor) ── */
.fs-task-note-area {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
  padding: 0 0 0 62px;
}
.fs-task-note-area.visible {
  max-height: 120px; opacity: 1;
  padding: 4px 0 8px 62px;
}
.fs-task-note-input {
  width: 100%; border: 1px solid var(--border-light); border-radius: 6px;
  padding: 6px 8px; font-size: max(16px, 12px); font-family: inherit;
  background: var(--bg-input, var(--bg-surface)); color: var(--text-secondary);
  resize: vertical; min-height: 36px;
  transition: border-color 0.15s;
}
.fs-task-note-input:focus { outline: none; border-color: var(--accent); }
.fs-task-note-input::placeholder { color: var(--text-placeholder); }

/* ── Task drag reorder (editor) ── */
.fs-task-drag-grip {
  cursor: grab; color: var(--text-placeholder);
  font-size: 12px; letter-spacing: -3px;
  user-select: none; flex-shrink: 0;
  opacity: 0.35; transition: opacity 0.15s;
  padding: 0 2px; line-height: 1;
}
.fs-task-drag-grip:active { cursor: grabbing; }
.fs-task-row:hover .fs-task-drag-grip { opacity: 0.7; }
.fs-task-row.fs-task-dragging { opacity: 0.35; background: var(--accent-bg, rgba(52,59,224,0.06)); border-radius: 6px; }
.fs-task-row.fs-task-drag-over { border-top: 2px solid var(--accent); }

/* ══════════════════════════════════════════════════
   Section Styles
   ══════════════════════════════════════════════════ */

/* ── Section group wrapper ── */
.section-group {
  width: 100%;
  grid-column: 1 / -1;
}
.section-group + .section-group {
  border-top: none;
  padding-top: 16px;
  margin-top: 4px;
  position: relative;
}
.section-group + .section-group::before {
  content: "";
  position: absolute;
  top: 0;
  left: 5%;
  right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong) 30%, var(--border-strong) 70%, transparent);
  opacity: 0.7;
}
.section-group:empty + .section-group::before,
.section-group + .section-group:empty::before,
.section-group:empty::before {
  display: none;
}

/* ── Section group header (in clipboards container) ── */
.section-group-header {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin: 0;
  border-left: 4px solid var(--section-color, #6C63FF);
  border-radius: 6px;
  background: color-mix(in srgb, var(--section-color, #6C63FF) 12%, transparent);
}
.section-group-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--section-color, #6C63FF);
  flex-shrink: 0;
}
.section-group-name {
  font-size: 13.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}
.section-group-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--bg-hover);
  padding: 1px 7px;
  border-radius: 10px;
}

/* ── Collapsible sections ── */
.section-collapsible {
  cursor: pointer;
  user-select: none;
}
.section-chevron {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform 0.2s ease;
}
.section-chevron svg {
  width: 14px;
  height: 14px;
}
.section-collapsible.collapsed .section-chevron {
  transform: rotate(-90deg);
}
.section-body {
  display: contents;
}
.section-collapsible.collapsed + .section-body {
  display: none;
}
.section-group .section-group-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 8px; padding: 14px 14px 0;
  overflow: visible;
  transition: max-height 0.35s ease, opacity 0.3s ease;
}
@media (max-width: 480px) {
  .section-group .section-group-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 6px 8px 0;
    overflow-x: clip;
    box-sizing: border-box;
    max-width: 100%;
  }
}
@media (max-width: 360px) {
  .section-group .section-group-body {
    gap: 6px;
    padding: 6px 6px 0;
  }
}
.section-group .section-group-header.collapsed + .section-group-body {
  display: none;
}
.section-label.section-collapsible {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Card with section indicator ── */
.clipboard.has-section {
  padding-left: 18px;
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--section-color, #6C63FF) 8%, var(--bg-card)) 0%,
    color-mix(in srgb, var(--section-color, #6C63FF) 3%, var(--bg-card)) 40%,
    var(--bg-card) 100%
  );
}
.clipboard.has-section::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
  background: linear-gradient(to bottom, var(--section-color, #6C63FF), transparent);
  z-index: 1;
}

/* ── Grid (date-wise) view ── */
.grid-view-mode {
  display: block !important;
}
.grid-date-group {
  margin-bottom: 8px;
}
.grid-date-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 10px 14px 4px;
  position: relative;
}
.grid-date-header::after {
  content: "";
  display: inline-block;
  vertical-align: middle;
  width: calc(100% - 120px);
  max-width: 400px;
  height: 1px;
  margin-left: 10px;
  background: linear-gradient(90deg, var(--border-default), transparent);
}
.grid-date-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 8px 14px 0;
}
.grid-view-mode > .load-more-group-btn {
  display: flex;
  margin: 36px auto 16px;
}
.grid-view-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
  font-size: 15px;
}
@media (max-width: 480px) {
  .grid-date-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 6px 8px 0;
  }
}

/* ── Hide section filters & sort in grid view ── */
body.view-mode-grid .drawer-section:has(#sortBy) {
  display: none;
}

/* ── Grid view: Created / Modified date-field toggle ── */
.grid-date-field-toggle {
  display: none;
}
body.view-mode-grid .grid-date-field-toggle {
  display: inline-flex;
  gap: 2px;
  margin: 8px 14px 0;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-subtle, rgba(127, 127, 127, 0.08));
  border: 1px solid var(--border-default);
}
.grid-date-field-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.2;
}
.grid-date-field-btn:hover {
  color: var(--text-primary);
}
.grid-date-field-btn.is-active {
  background: var(--bg-primary, #fff);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
@media (max-width: 480px) {
  body.view-mode-grid .grid-date-field-toggle {
    margin: 6px 8px 0;
  }
}

/* ── Drawer section filter ── */
#drawerFilterSections {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0;
}
.drawer-section-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 8px;
  border: 1.5px solid var(--border-default); background: transparent;
  color: var(--text-secondary); font-size: 12.5px; font-weight: 500;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: all 0.15s; line-height: 1.3;
}
.drawer-section-chip:hover { border-color: var(--accent); color: var(--accent); }
.drawer-section-chip.selected {
  background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600;
}
.drawer-section-chip-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}

/* Section modal manage mode */
#sectionModalOverlay.manage-mode #sectionModalFormWrap { display: none; }
#sectionModalOverlay:not(.manage-mode) #sectionsManageList { display: none; }
#sectionsManageList {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 320px; overflow-y: auto;
}

/* ── Section picker in fullscreen editor ── */
.fs-editor-section-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.section-picker-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.section-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  transition: all 0.15s;
}
.section-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--section-color, #999);
  flex-shrink: 0;
}
.section-picker-label input:checked + .section-pill {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* Style the checkbox as a radio button — only inside the editor section picker.
   Sections are single-select (radio-like), so the visual should match. We keep
   the checkbox input type so clicking a selected item can still toggle it off. */
.fs-editor-section-picker .section-picker-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-light);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.fs-editor-section-picker .section-picker-label input[type="checkbox"]:hover {
  border-color: var(--accent);
}
.fs-editor-section-picker .section-picker-label input[type="checkbox"]:checked {
  border-color: var(--accent);
}
.fs-editor-section-picker .section-picker-label input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

/* ── Section footer button ── */
.fs-footer-btn.fs-footer-btn-section {
  background: rgba(255, 152, 0, 0.12) !important;
  color: #FF9800 !important;
}
.fs-footer-btn.fs-footer-btn-section:hover {
  background: rgba(255, 152, 0, 0.2) !important;
}
.fs-footer-btn.fs-footer-btn-section svg {
  fill: #FF9800 !important;
}

/* ── Add Task footer button ── */

/* ── Active/selected state for footer buttons ── */
.fs-footer-btn-tag.active {
  background: rgba(52, 59, 224, 0.3) !important;
  box-shadow: inset 0 0 0 1.5px rgba(52, 59, 224, 0.5);
}
.fs-footer-btn-section.active {
  background: rgba(255, 152, 0, 0.3) !important;
  box-shadow: inset 0 0 0 1.5px rgba(255, 152, 0, 0.5);
}
/* ══════════════════════════════════════════════════
   Editor Page (full-page mode)
   ══════════════════════════════════════════════════ */
.editor-page-root {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-body);
  box-sizing: border-box;
}
/* Hide word-count footer when the soft keyboard is open (mobile/iPad) */
.editor-page-root.keyboard-open .md-editor-wordcount { display: none; }
.editor-page-wrap {
  width: 100%;
  max-width: 900px;
  height: 90vh;
  height: 90dvh;
}

/* Editor-page toolbar inherits scroll from base .md-editor-toolbar */

/* Task editor inside editor-page: prevent overflow */
.editor-page-wrap .fs-task-editor {
  min-height: 0;
}
.editor-page-wrap .fs-task-row {
  min-width: 0;
}
.editor-page-wrap .fs-task-input {
  min-width: 0;
}

/* Section picker inside editor-page */
.editor-page-wrap .fs-editor-section-picker {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Tablet (editor page) ── */
@media (max-width: 768px) {
  /* Lock html/body scroll so iOS doesn't scroll behind the editor */
  html:has(.editor-page-root) {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
  .editor-page-root {
    position: fixed;
    inset: 0;
    padding: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .editor-page-wrap {
    flex: 1;
    max-width: 100%;
    min-height: 0;
    border-radius: 0;
    border: none;
  }
  /* Google Keep-style: clean flat backgrounds */
  .editor-page-wrap .fs-editor-wrap {
    background: var(--bg-body);
    box-shadow: none;
    border: none;
    /* Fill the JS-resized root (visualViewport.height) instead of 90dvh,
       otherwise the wrap stays full-screen when the keyboard opens and its
       rounded bottom corners show through the visible area. */
    height: 100%;
    border-radius: 0;
  }
  .editor-page-wrap .fs-editor-header {
    background: var(--bg-body);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    border-bottom: 1px solid var(--border-light);
  }
  .editor-page-wrap .fs-editor-title {
    background: transparent;
    backdrop-filter: none;
    border-color: transparent;
    padding-left: 4px;
  }
  .editor-page-wrap .fs-editor-title.fs-editor-title-inline {
    padding: 12px 14px 4px 32px;
  }
  .editor-page-wrap .fs-editor-title:focus,
  .editor-page-wrap .fs-editor-title:focus-visible {
    background: transparent;
    border-color: transparent;
  }
  .editor-page-wrap .md-editor-toolbar {
    background: var(--bg-body);
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .editor-page-wrap .md-editor-toolbar::-webkit-scrollbar { display: none; }
  .editor-page-wrap .md-toolbar-group {
    background: transparent;
  }
  /* Reset actions group to inline for horizontal-scroll toolbar */
  .editor-page-wrap .md-toolbar-group--actions {
    flex-basis: auto; border-top: none; margin-top: 0; padding-top: 0;
    margin-left: auto;
  }
  .editor-page-wrap .md-editor-content {
    background: transparent;
  }
  .editor-page-wrap .fs-task-action-toolbar {
    background: var(--bg-body);
    flex-shrink: 0;
  }
  /* Dark theme: same flat look on tablet/mobile */
  [data-theme="dark"] .editor-page-wrap .fs-editor-wrap {
    background: var(--bg-body); box-shadow: none; border: none;
  }
  [data-theme="dark"] .editor-page-wrap .fs-editor-header {
    background: var(--bg-body); backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none; border-bottom: 1px solid var(--border-light);
  }
  [data-theme="dark"] .editor-page-wrap .md-editor-toolbar {
    background: var(--bg-body);
  }
  [data-theme="dark"] .editor-page-wrap .fs-task-action-toolbar {
    background: var(--bg-body);
  }
}

/* ── Phone (editor page) ── */
@media (max-width: 480px) {
  /* Toolbar: fixed above content, scrolls horizontally */
  .editor-page-wrap .md-editor-toolbar {
    padding: 4px 6px;
    gap: 2px;
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .editor-page-wrap .md-editor-toolbar::-webkit-scrollbar { display: none; }
  .editor-page-wrap .md-toolbar-btn {
    padding: 4px 6px;
    min-height: 32px;
  }
  .editor-page-wrap .md-toolbar-label { font-size: 10px; }
  .editor-page-wrap .md-toolbar-btn-task {
    padding: 4px 8px; min-height: 32px;
  }
  .editor-page-wrap .md-toolbar-btn-task span { font-size: 10px; }
  .editor-page-wrap .md-toolbar-btn-highlight {
    padding: 4px 8px; min-height: 32px;
  }
  .editor-page-wrap .md-toolbar-btn-highlight span { font-size: 10px; }
  .editor-page-wrap .md-toolbar-btn-dictate {
    padding: 4px 8px; min-height: 32px;
  }
  .editor-page-wrap .md-toolbar-btn-dictate span { font-size: 10px; }
  /* Action toolbar buttons: compact on phone */
  .editor-page-wrap .md-toolbar-btn-tag,
  .editor-page-wrap .md-toolbar-btn-section,
  .editor-page-wrap .md-toolbar-btn-copy,
  .editor-page-wrap .md-toolbar-btn-delete {
    padding: 4px 8px; min-height: 32px;
  }
  .editor-page-wrap .md-toolbar-btn-tag span,
  .editor-page-wrap .md-toolbar-btn-section span,
  .editor-page-wrap .md-toolbar-btn-copy span,
  .editor-page-wrap .md-toolbar-btn-delete span { font-size: 10px; }
  .editor-page-wrap .fs-task-action-toolbar {
    padding: 4px 6px; gap: 2px; flex-shrink: 0;
  }
  /* Header buttons: compact */
  .editor-page-wrap .fs-editor-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  /* Task rows: comfortable touch targets */
  .editor-page-wrap .fs-task-row {
    gap: 8px;
    padding: 6px 0;
  }
  .editor-page-wrap .fs-task-input {
    font-size: 16px;
    padding: 8px 4px;
  }
  .editor-page-wrap .task-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
  }
  .editor-page-wrap .fs-task-remove {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }
  .editor-page-wrap .fs-task-add {
    padding: 10px 14px;
    font-size: 14px;
  }
  /* Tag & section pickers: scrollable */
  .editor-page-wrap .fs-editor-tag-picker {
    max-height: 100px;
    overflow-y: auto;
  }
  .editor-page-wrap .fs-editor-section-picker {
    max-height: 100px;
    overflow-y: auto;
  }
  /* Breathing space below content to dismiss keyboard */
  .editor-page-wrap .md-editor-content {
    padding-bottom: 120px;
  }
}

/* ══════════════════════════════════════════════════
   RESPONSIVE ENHANCEMENTS & ANIMATIONS
   ═════════════════════════════════��════════════════ */

/* ── Large Desktop (1200px+) ── */
@media (min-width: 1201px) {
  #clipboardsContainer {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    padding-left: 16px;
    padding-right: 16px;
  }
  .section-group .section-group-body {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
  .search-bar-container { max-width: 520px; }
}

/* ── Prevent horizontal overflow globally ── */
html { overflow-x: hidden; }
body { overflow-x: hidden; }
* { box-sizing: border-box; }

/* ══════════════════════════════════════════════════
   KEYFRAME ANIMATIONS (Formal / Subtle)
   ══════════════════════════════════════════════════ */

/* Card fade-in with subtle slide-up */
@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered card entrance — nth-child delays */
.clipboard:nth-child(1) { animation-delay: 0s; }
.clipboard:nth-child(2) { animation-delay: 0.04s; }
.clipboard:nth-child(3) { animation-delay: 0.08s; }
.clipboard:nth-child(4) { animation-delay: 0.12s; }
.clipboard:nth-child(5) { animation-delay: 0.16s; }
.clipboard:nth-child(6) { animation-delay: 0.2s; }
.clipboard:nth-child(7) { animation-delay: 0.24s; }
.clipboard:nth-child(8) { animation-delay: 0.28s; }
.clipboard:nth-child(9) { animation-delay: 0.32s; }
.clipboard:nth-child(10) { animation-delay: 0.36s; }
.clipboard:nth-child(n+11) { animation-delay: 0.4s; }

/* Modal fade-in with scale */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Overlay fade-in */
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Fullscreen editor entrance */
@keyframes editorSlideIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ══════════════════════════════════════════════════
   ANIMATION APPLICATIONS
   ══════════════════════════════════════════════════ */

/* Refine drawer slide transition */
#drawer {
  transition: left 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.5s ease;
}
#drawer.open {
  box-shadow: 2px 0 22px rgba(52, 59, 224, 0.08),
              2px 0 8px rgba(0, 0, 0, 0.04);
}

/* Subtle staggered fade-in for drawer contents on open */
@keyframes drawerItemIn {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
#drawer.open .drawer-header,
#drawer.open .drawer-section {
  animation: drawerItemIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
#drawer.open .drawer-header              { animation-delay: 0.12s; }
#drawer.open .drawer-section:nth-of-type(1) { animation-delay: 0.20s; }
#drawer.open .drawer-section:nth-of-type(2) { animation-delay: 0.28s; }
#drawer.open .drawer-section:nth-of-type(3) { animation-delay: 0.36s; }
#drawer.open .drawer-section:nth-of-type(4) { animation-delay: 0.44s; }
#drawer.open .drawer-section:nth-of-type(5) { animation-delay: 0.52s; }
#drawer.open .drawer-section:nth-of-type(6) { animation-delay: 0.60s; }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  #drawer.open .drawer-header,
  #drawer.open .drawer-section {
    animation: none;
  }
}

/* Tags/Section modal overlay animation */
.tags-modal-overlay.open {
  animation: overlayFadeIn 0.2s ease;
}
.tags-modal {
  animation: modalFadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fullscreen editor animation */
.fs-editor-overlay {
  animation: overlayFadeIn 0.2s ease;
}
.fs-editor-wrap {
  animation: editorSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Section collapse/expand with smooth transition */
.section-group-header.collapsed + .section-group-body {
  max-height: 0 !important;
  opacity: 0;
  margin-top: 0;
  overflow: hidden;
  pointer-events: none;
  display: grid;
}
.section-group .section-group-body {
  max-height: 5000px;
  opacity: 1;
}

/* ══════════════════════════════════════════════════
   SMOOTH THEME TRANSITION (avoids flash on load)
   ══════════════════════════════════════════════════ */
html.theme-ready,
html.theme-ready *,
html.theme-ready *::before,
html.theme-ready *::after {
  transition:
    background-color 0.3s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease !important;
}
/* Exclude properties that shouldn't transition on theme change */
html.theme-ready .clipboard,
html.theme-ready .fs-editor-wrap,
html.theme-ready .tags-modal,
html.theme-ready #drawer {
  transition:
    background-color 0.3s ease,
    border-color 0.25s ease,
    box-shadow 0.3s ease,
    transform 0.25s ease !important;
}
html.theme-ready #drawer {
  transition:
    left 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.3s ease,
    border-color 0.25s ease,
    box-shadow 0.5s ease !important;
}

/* ══════════════════════════════════════════════════
   BUTTON HOVER CONSISTENCY
   ══════════════════════════════════════════════════ */
button,
.fs-editor-btn,
.fs-footer-btn,
.clipboard-icon-btn,
.clipboard-pin-btn,
.fs-editor-pin-btn,
.drawer-add-tag-btn,
.drawer-tag-edit-btn,
.tags-modal-close-btn,
.tags-modal-delete-btn,
#themeToggle,
#drawerToggle,
.md-toolbar-btn,
.border-btn,
.delete-btn,
.code-copy-btn {
  transition: all 0.2s ease;
}

/* ══════════════════════════════════════════════════
   LOADING SKELETON PLACEHOLDER
   ══════════════════════════════════════════════════ */
@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: 15px;
  height: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.skeleton-line {
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--bg-hover) 25%,
    var(--border-light) 50%,
    var(--bg-hover) 75%
  );
  background-size: 200% 100%;
  animation: skeletonPulse 1.8s ease-in-out infinite;
}
.skeleton-title {
  height: 16px;
  width: 60%;
}
.skeleton-body {
  height: 10px;
  width: 100%;
}
.skeleton-body:nth-child(3) { width: 90%; }
.skeleton-body:nth-child(4) { width: 75%; }
.skeleton-body:nth-child(5) { width: 85%; }
.skeleton-footer {
  height: 12px;
  width: 40%;
  margin-top: auto;
}

/* ══════════════════════════════════════════════════
   UI BEAUTIFICATION — Formal consistency
   ══════════════════════════════════════════════════ */

/* Consistent border-radius scale */
/* 6px = small (buttons, inputs) */
/* 10px = medium (toolbar, containers) */
/* 16px = large (cards, modals, editor) */


/* Sticky footer */
#__next {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.container { flex: 1; }


/* Tag and section pill consistency */
.tag.tag-dot,
.active-tag,
.section-pill {
  border-radius: 20px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Section pill checked state refinement */
.section-picker-label input:checked + .section-pill {
  font-weight: 600;
}

/* Ensure tag-picker labels have consistent sizing */
.tag-picker-label,
.section-picker-label {
  border-radius: 20px;
  transition: all 0.15s ease;
}


/* Filter chip consistent styling */
/* filter-chip styles are in the search-chips-panel block above */

/* Ensure no horizontal scrollbar on main content */
.container {
  overflow-x: clip;
}

/* Refined drawer toggle animation */
#drawerToggle {
  transition: all 0.2s ease, left 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Smooth container margin shift when drawer opens/closes */
body.drawer-open .container {
  transition: margin-left 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Refined card hover shadow for dark theme */
[data-theme="dark"] .clipboard:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(-1px);
}

/* Accessibility: focus-visible outlines */
button:focus-visible,
input:focus-visible,
select:focus-visible,
[contenteditable]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Prevent layout shift on page header */
.page-header {
  min-height: 48px;
}

/* Ensure search bar doesn't overflow */
.search-bar-container {
  min-width: 0;
}

/* Smooth header background on scroll */
.page-header {
  transition: box-shadow 0.3s ease, background 0.3s ease;
}

/* Card content overflow protection */
.clipboard .message-view {
  word-break: break-word;
}
.clipboard .message-view pre {
  overflow-x: auto;
  max-width: 100%;
}
.clipboard .message-view img {
  max-width: 100%;
  height: auto;
}

/* Drawer smooth scroll */
#drawer {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar styling for drawer */
#drawer::-webkit-scrollbar {
  width: 4px;
}
#drawer::-webkit-scrollbar-track {
  background: transparent;
}
#drawer::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}
#drawer::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ── Very small phones (<=360px) ── */
@media (max-width: 360px) {
  .page-header { padding: 6px 8px; gap: 3px; }
  body:not(.drawer-open) .page-header { padding-left: 52px; }
  .header-left h1 { font-size: 16px; }
  .header-logo-mark { width: 24px; height: 24px; }
  .add-note-btn { padding: 4px 8px; gap: 3px; font-size: 11px; }
  .add-note-btn svg { width: 11px; height: 11px; }
  .refresh-btn, .view-toggle-btn { width: 28px; height: 28px; }
  .refresh-btn svg, .view-toggle-btn svg { width: 15px; height: 15px; }
  .settings-btn { padding: 2px 4px; }
  .settings-btn svg { width: 15px; height: 15px; }
  .header-actions { gap: 2px; }
  .header-right { gap: 2px; }
  .search-bar-container { margin: 10px auto; max-width: calc(100vw - 120px); }
  .search-bar-fancy { padding: 10px 12px; }
  .search-bar-fancy #searchInput { font-size: 16px; width: 120px; }
  .clipboard { padding: 8px; border-radius: 10px; height: 160px; overflow: hidden; }
  .clipboard-title { font-size: 11.5px; -webkit-line-clamp: 2; }
  .message-view { font-size: 11px; -webkit-line-clamp: 3; }
  #clipboardsContainer { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 6px 6px 0; }
  .section-group .section-group-body { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 6px 6px 0; }
  .fs-footer-btn { font-size: 0; padding: 6px 8px; gap: 0; }
  .fs-footer-btn svg { width: 18px; height: 18px; }
  .fs-footer-btn-tag,
  .fs-footer-btn-section { font-size: 11px; gap: 3px; }
  .fs-footer-btn .label-full { display: none; }
  .fs-footer-btn .label-short { display: inline; }
  .fs-editor-btn { font-size: 11px; padding: 5px 8px; }
  #drawer { width: 90vw; left: -90vw; }
  #drawer.open { left: 0; }
  body.drawer-open #drawerToggle { left: calc(90vw - 44px); }
}

/* ── Landscape phone fix ── */
@media (max-height: 500px) and (orientation: landscape) {
  .fs-editor-wrap { height: 100%; border-radius: 0; }
  .fs-editor-overlay { padding: 0; }
  .tags-modal { max-height: 85vh; }
}

/* ── Print styles (hide non-essential UI) ── */
@media print {
  .page-header,
  #drawer,
  #drawerToggle,
  .search-bar-container,
  .clipboard-footer,
  .clipboard-actions,
  .fs-editor-overlay { display: none !important; }
  .clipboard {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
    animation: none;
  }
  #clipboardsContainer {
    display: block;
  }
}

/* ── Load More button ── */
.load-more-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 140px; /* ~half of card height (280px) */
  padding: 12px 16px;
  border: 1.5px dashed color-mix(in srgb, var(--section-color, var(--accent, #343BE0)) 55%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--section-color, var(--accent, #343BE0)) 4%, transparent);
  color: var(--section-color, var(--accent, #343BE0));
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.load-more-btn::after {
  content: "↓";
  display: inline-block;
  font-size: 16px;
  line-height: 1;
  transition: transform 0.2s ease;
}
.load-more-btn:hover {
  background: color-mix(in srgb, var(--section-color, var(--accent, #343BE0)) 12%, transparent);
  border-color: var(--section-color, var(--accent, #343BE0));
  border-style: solid;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}
.load-more-btn:hover::after {
  transform: translateY(3px);
}
.load-more-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
  box-shadow: none;
}
.load-more-group-btn {
  /* break onto its own full-width row beneath the cards */
  grid-column: 1 / -1;
  justify-self: center;
  width: auto;
  max-width: 260px;
  height: auto;
  padding: 10px 24px;
  margin-top: 4px;
}
@media (max-width: 600px) {
  .load-more-btn {
    height: 110px;
    font-size: 13px;
    border-radius: 12px;
  }
  .load-more-btn::after { font-size: 14px; }
  .load-more-group-btn {
    height: auto;
    padding: 8px 20px;
    font-size: 12px;
    max-width: 220px;
  }
}

/* ══════════════════════════════════════════════════
   Landing Page — Auth / Hero
   ══════════════════════════════════════════════════ */

.landing-page {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
  gap: 28px;
  background: var(--bg-body);
  background-attachment: fixed;
  position: relative;
  overflow: hidden;
}

/* Phone + tablet: let the landing page itself scroll instead of the
   signup card scrolling internally. Desktop keeps the fixed-viewport layout. */
@media (max-width: 1024px) {
  .landing-page {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
    overflow-x: hidden;
    justify-content: flex-start;
  }
}

/* Hero keeps its natural size so the card (not the page) absorbs overflow */
.landing-hero { flex: 0 0 auto; }

/* Ambient animated gradient blobs */
.landing-page::before,
.landing-page::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: blob-drift 18s ease-in-out infinite;
}

.landing-page::before {
  top: -180px;
  left: -160px;
  background: radial-gradient(circle at 30% 30%, rgba(108,99,255,0.55), transparent 70%);
}

.landing-page::after {
  bottom: -200px;
  right: -180px;
  background: radial-gradient(circle at 70% 70%, rgba(168,85,247,0.45), transparent 70%);
  animation-delay: -9s;
  animation-duration: 22s;
}

[data-theme="dark"] .landing-page::before {
  opacity: 0.22;
  background: radial-gradient(circle at 30% 30%, rgba(108,99,255,0.75), transparent 70%);
}

[data-theme="dark"] .landing-page::after {
  opacity: 0.2;
  background: radial-gradient(circle at 70% 70%, rgba(168,85,247,0.7), transparent 70%);
}

@keyframes blob-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.08); }
  66%      { transform: translate(-30px, 40px) scale(0.95); }
}

.landing-page > * {
  position: relative;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  .landing-page::before,
  .landing-page::after {
    animation: none;
  }
}

/* Theme toggle positioned top-right on landing */
.landing-theme-btn {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 10;
}

/* ── Hero section ─────────────────────────────── */
.landing-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.landing-welcome {
  font-family: 'Poppins', sans-serif;
  font-weight: 300;
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  text-transform: uppercase;
  letter-spacing: 0.45em;
  margin: 0 0 22px 0;
  line-height: 1;
  display: inline-flex;
  padding-left: 0.45em; /* optical centering for tracked text */
  position: relative;
}
.landing-welcome::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -12px;
  transform: translateX(-50%) scaleX(0);
  transform-origin: center;
  width: 40px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #a855f7, transparent);
  animation: welcome-underline 0.6s ease-out 0.9s forwards;
}
@keyframes welcome-underline {
  to { transform: translateX(-50%) scaleX(1); }
}
.landing-welcome span {
  display: inline-block;
  background: linear-gradient(110deg, #a855f7 0%, #a855f7 50%, var(--accent) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0;
  transform: translateY(-14px) rotate(-8deg);
  animation:
    welcome-drop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
    welcome-shimmer 6s ease-in-out infinite;
}
@keyframes welcome-drop {
  to { opacity: 1; transform: translateY(0) rotate(0); }
}
@keyframes welcome-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.landing-logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.5vw, 10px);
}

.landing-logo-mark {
  display: block;
  width: clamp(64px, 14vw, 96px);
  height: clamp(64px, 14vw, 96px);
  object-fit: contain;
  flex-shrink: 0;
  box-sizing: border-box;
  border: 1.5px solid rgba(167, 139, 250, 0.28);
  border-radius: 14px;
  filter: drop-shadow(0 6px 16px rgba(168, 85, 247, 0.28));
  animation: logo-entrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

[data-theme="dark"] .landing-logo-mark {
  border-color: rgba(196, 181, 253, 0.25);
  filter: drop-shadow(0 6px 16px rgba(168, 85, 247, 0.4));
}

.landing-logo {
  font-family: 'Pinyon Script', cursive;
  font-size: clamp(2.4rem, 8vw, 4rem);
  background: linear-gradient(
    110deg,
    #ec4899 0%,
    #a855f7 25%,
    #1e6dd9 50%,
    #a855f7 75%,
    #ec4899 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  line-height: 1.6;
  padding: 0.2em 0.15em 0.35em;
  animation:
    logo-entrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) backwards,
    logo-shimmer 8s ease-in-out 0.8s infinite;
}

@keyframes logo-entrance {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes logo-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.landing-tagline {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  color: var(--text-muted);
  margin: 0;
  max-width: 360px;
  animation: fade-up 0.7s ease-out 0.15s backwards;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .landing-logo,
  .landing-logo-mark,
  .landing-tagline,
  .landing-welcome span,
  .header-welcome-text span,
  .header-welcome-wave {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ── Header greeting (inline) ─────────────────────────────────────── */
.header-welcome {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.header-welcome-text {
  display: inline-flex;
}
.header-welcome-text span {
  display: inline-block;
  background: linear-gradient(110deg, var(--accent) 0%, #a855f7 50%, #a855f7 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0;
  transform: translateY(6px);
  animation:
    welcome-rise 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
    welcome-shimmer 6s ease-in-out infinite;
}
.header-welcome-name {
  opacity: 0;
  animation: welcome-fade 0.5s ease-out 0.55s forwards;
}
.header-welcome-wave {
  display: inline-block;
  margin-left: 4px;
  transform-origin: 70% 70%;
  opacity: 0;
  animation:
    welcome-fade 0.3s ease-out 0.75s forwards,
    welcome-wave 2.2s ease-in-out 1s infinite;
}
@keyframes welcome-rise {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes welcome-fade {
  to { opacity: 1; }
}
@keyframes welcome-wave {
  0%, 60%, 100% { transform: rotate(0); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-4deg); }
  50% { transform: rotate(10deg); }
}

@media (max-width: 480px) {
  .header-welcome-text,
  .header-welcome-name { display: none !important; }
}

.landing-features {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.landing-feature-pill {
  position: relative;
  font-size: 12px;
  padding: 7px 16px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,0.85), rgba(var(--accent-rgb, 66,133,244), 0.04));
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid rgba(var(--accent-rgb, 66,133,244), 0.08);
  transition: background 0.2s, box-shadow 0.2s;
  cursor: default;
  user-select: none;
  animation: pill-float-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.landing-feature-pill:nth-child(1) { animation-delay: 0.05s; }
.landing-feature-pill:nth-child(2) { animation-delay: 0.12s; }
.landing-feature-pill:nth-child(3) { animation-delay: 0.19s; }
.landing-feature-pill:nth-child(4) { animation-delay: 0.26s; }
.landing-feature-pill:nth-child(5) { animation-delay: 0.33s; }

.landing-feature-pill:hover {
  background: rgba(var(--accent-rgb, 66,133,244), 0.12);
  box-shadow: 0 2px 6px rgba(var(--accent-rgb, 66,133,244), 0.12);
}

@keyframes pill-float-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

[data-theme="dark"] .landing-feature-pill {
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(123,131,248,0.06));
  color: #a5abff;
  border-color: rgba(123,131,248,0.08);
}

[data-theme="dark"] .landing-feature-pill:hover {
  background: rgba(123,131,248,0.15);
  box-shadow: 0 2px 6px rgba(123,131,248,0.12);
}

@media (prefers-reduced-motion: reduce) {
  .landing-feature-pill { animation: none; }
}

/* ── Auth card ───────────────────────────────── */
.landing-auth-card {
  width: min(400px, 100%);
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow:
    0 20px 60px rgba(52,59,224,0.14),
    0 8px 24px rgba(0,0,0,0.08),
    0 1px 0 rgba(255,255,255,0.6) inset;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 0 1 auto;
  min-height: 0;
  max-height: 100%;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  animation: card-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.25s backwards;
  transition: box-shadow 0.4s ease, transform 0.4s ease;
}

.landing-auth-card:hover {
  box-shadow:
    0 24px 72px rgba(52,59,224,0.18),
    0 10px 28px rgba(0,0,0,0.1),
    0 1px 0 rgba(255,255,255,0.65) inset;
}

@keyframes card-rise {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .landing-auth-card { animation: none; }
}

/* Phone + tablet: card grows with its content; the landing page scrolls. */
@media (max-width: 1024px) {
  .landing-auth-card {
    overflow-y: visible;
    max-height: none;
    flex: 0 0 auto;
  }
}

/* ── Tabs ────────────────────────────────────── */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
}

.auth-tab {
  flex: 1;
  padding: 14px 0;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.auth-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.auth-tab {
  position: relative;
}

.auth-tab::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  transition: width 0.3s ease, left 0.3s ease;
}

.auth-tab-active {
  color: var(--accent);
  background: var(--accent-bg, rgba(52,59,224,0.05));
}

.auth-tab-active::after {
  width: 100%;
  left: 0;
}

/* ── Form ────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 24px 24px;
}

.auth-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.auth-required {
  color: #e25555;
  margin-left: 2px;
}

.auth-optional {
  color: var(--muted, #888);
  margin-left: 4px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85em;
}

.auth-input-wrap {
  position: relative;
  display: block;
}

.auth-input-wrap .auth-input {
  width: 100%;
  box-sizing: border-box;
}

/* Hide native placeholder — the ghost overlay replaces it */
.auth-input-wrap .auth-input::placeholder {
  color: transparent;
}

.auth-input::placeholder {
  font-size: 12px;
}

.auth-input-ghost {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 13px;
  pointer-events: none;
  font-size: 12px;
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: normal;
  -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,0.15) 100%);
  mask-image: linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,0.15) 100%);
}

/* ── Contact form ─────────────────────────────────
   Unified styles for both the landing-page Contact Us modal and the
   authenticated dashboard Contact Us modal, so every field aligns and
   sizes identically. */
.contact-form {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Override text-align: center inherited from .landing-footer when the
     modal is rendered inside the landing page footer. */
  text-align: left;
}

.contact-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.contact-field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.contact-field-required {
  color: #e25555;
  margin-left: 2px;
}

.contact-field-optional {
  color: var(--muted, #888);
  margin-left: 4px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85em;
}

.contact-input-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.contact-input,
.contact-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease;
}

.contact-input:focus,
.contact-textarea:focus,
.contact-input:focus-visible,
.contact-textarea:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.contact-textarea {
  resize: vertical;
}

.contact-input::placeholder,
.contact-textarea::placeholder {
  font-size: 12px;
}

/* Phone field: hide the native placeholder — the fading ghost overlay replaces it */
.contact-input-wrap .contact-input::placeholder {
  color: transparent;
}

.contact-input-ghost {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 12px;
  pointer-events: none;
  font-size: 12px;
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: normal;
  -webkit-mask-image: linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,0.15) 100%);
  mask-image: linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,0.15) 100%);
}

.auth-input {
  padding: 10px 13px;
  border-radius: 10px;
  border: 1.5px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: max(16px, 14px);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.2s ease, background 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.auth-input:hover:not(:focus) {
  border-color: var(--border-input-hover, rgba(52,59,224,0.3));
}

.auth-input:focus,
.auth-input:focus-visible {
  border-color: rgba(var(--accent-rgb, 52,59,224), 0.35);
  box-shadow: none;
  transform: translateY(-1px);
  outline: none;
}

.auth-btn {
  position: relative;
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #6c63ff);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: transform 0.2s ease, box-shadow 0.3s ease, filter 0.2s ease;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 14px rgba(52,59,224,0.25);
  overflow: hidden;
  isolation: isolate;
}

.auth-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    110deg,
    transparent 0%,
    rgba(255,255,255,0.28) 50%,
    transparent 100%
  );
  transform: skewX(-20deg);
  transition: left 0.6s ease;
  z-index: -1;
}

.auth-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 8px 22px rgba(52,59,224,0.35);
}

.auth-btn:hover:not(:disabled)::before {
  left: 120%;
}

.auth-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(52,59,224,0.25);
}

.auth-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-error {
  margin: 0;
  padding: 9px 16px;
  background: rgba(229, 57, 53, 0.08);
  border-left: 3px solid #e53935;
  color: #c62828;
  font-size: 13px;
  font-weight: 500;
}

.auth-forgot-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  padding: 0;
  margin-top: 2px;
  text-align: center;
  transition: color 0.2s ease;
}

.auth-forgot-link:hover {
  color: #6c63ff;
  text-decoration: underline;
}

/* ── Footer on landing ───────────────────────── */
.landing-footer {
  font-size: 12px;
  color: var(--text-time);
  margin: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: fade-up 0.7s ease-out 0.5s backwards;
}

@media (prefers-reduced-motion: reduce) {
  .landing-footer { animation: none; }
}

/* ── Auth loading spinner ────────────────────── */
.auth-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  background-attachment: fixed;
}

.auth-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Dashboard header additions ──────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* ── View toggle button ── */
.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  background: var(--accent-bg);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.view-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.08);
}
.view-toggle-btn svg { display: none; }
.view-toggle-btn svg[style*="display: block"] { display: block; }

/* ── Refresh button (mirrors view-toggle-btn styling) ── */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  background: var(--accent-bg);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.refresh-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.08);
}
.refresh-btn.is-spinning svg {
  animation: refreshBtnSpin 0.6s linear;
}
@keyframes refreshBtnSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.header-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  max-width: 200px;
  transition: border-color 0.2s, background 0.2s;
}
.header-user-chip:hover {
  border-color: var(--accent);
}
.header-avatar {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}
.header-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.2px;
  line-height: 1;
}
@media (max-width: 480px) {
  .header-username { display: none; }
  .header-user-chip { padding: 4px; }
}

.settings-btn {
  background: var(--accent-bg);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 5px 7px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}

.settings-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.08);
}

@media (max-width: 480px) {
  .landing-page {
    padding: 20px 16px 32px;
    gap: 20px;
  }
  .landing-auth-card {
    border-radius: 16px;
  }
  .auth-form {
    padding: 16px 16px 20px;
  }
  .header-username {
    display: none;
  }
}

/* ── App alert popup (theme-aware, minimal) ── */
:root {
  --alert-info-tint:   #343BE0;
  --alert-info-bg:     rgba(52, 59, 224, 0.10);
  --alert-warn-tint:   #c2410c;
  --alert-warn-bg:     rgba(234, 88, 12, 0.10);
  --alert-error-tint:  #b42318;
  --alert-error-bg:    rgba(220, 38, 38, 0.10);
}
[data-theme="dark"] {
  --alert-info-tint:   #8a92ff;
  --alert-info-bg:     rgba(91, 99, 240, 0.18);
  --alert-warn-tint:   #f59e0b;
  --alert-warn-bg:     rgba(245, 158, 11, 0.14);
  --alert-error-tint:  #f87171;
  --alert-error-bg:    rgba(248, 113, 113, 0.14);
}

.app-alert-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: appAlertFadeIn 0.18s ease-out;
  font-family: inherit;
}
@keyframes appAlertFadeIn { from { opacity: 0; } to { opacity: 1; } }

.app-alert {
  width: min(380px, 100%);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  padding: 22px 22px 16px;
  animation: appAlertIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.05);
  font-family: inherit;
}
@keyframes appAlertIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.app-alert-icon {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--alert-info-bg);
  color: var(--alert-info-tint);
  margin-bottom: 14px;
}
.app-alert-icon svg { width: 22px; height: 22px; fill: currentColor; }

.app-alert-title {
  margin: 0 0 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px; font-weight: 600;
  letter-spacing: -0.1px; line-height: 1.3;
}
.app-alert-body {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px; line-height: 1.5;
  white-space: pre-line;
}
.app-alert-footer {
  display: flex; justify-content: flex-end; gap: 8px;
}
.app-alert-btn {
  min-width: 84px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  font-family: inherit;
  background: var(--text-primary); color: var(--bg-card);
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.app-alert-btn:hover { opacity: 0.88; }
.app-alert-btn:active { transform: scale(0.97); }
.app-alert-btn:focus-visible {
  outline: 2px solid var(--alert-info-tint);
  outline-offset: 2px;
}

/* Variant tints — recolor only the icon chip. */
.app-alert-variant-warn .app-alert-icon {
  background: var(--alert-warn-bg);
  color: var(--alert-warn-tint);
}
.app-alert-variant-error .app-alert-icon {
  background: var(--alert-error-bg);
  color: var(--alert-error-tint);
}

/* Confirm dialog button variants */
.app-confirm-cancel {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}
.app-confirm-cancel:hover { background: var(--bg-hover); color: var(--text-primary); }
.app-confirm-danger {
  background: #f44336; color: #fff;
  border: 1px solid transparent;
}
.app-confirm-danger:hover { opacity: 0.9; }
.app-confirm-danger:focus-visible {
  outline: 2px solid #f44336;
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════
   Multi-select bar (Google Keep style)
   ══════════════════════════════════════════════════ */
.multi-select-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1100;
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--bg-card, #fff);
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.12));
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  animation: msbSlideDown 0.2s ease;
}
@keyframes msbSlideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.msb-close {
  background: transparent; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-primary);
}
.msb-close:hover { background: var(--bg-hover); }
.msb-count {
  font-size: 16px; font-weight: 600; color: var(--text-primary);
}
.msb-actions {
  margin-left: auto; display: flex; align-items: center; gap: 4px;
}
.msb-btn {
  background: transparent; border: none; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary, #5f6368);
  transition: background 0.15s, color 0.15s;
}
.msb-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.msb-btn-danger:hover { color: #d93025; }
.msb-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* When multi-select is active, show select buttons on all cards */
.multi-select-active .clipboard-select-btn { opacity: 0.45; }
.multi-select-active .clipboard.is-selected .clipboard-select-btn {
  opacity: 1; background: var(--text-primary); border-color: var(--text-primary); color: #fff;
}

/* ══════════════════════════════════════════════════
   iPhone 14 / Small Phone Optimization (≤414px)
   ══════════════════════════════════════════════════ */
@media (max-width: 414px) {

  /* ── Drawer: cap width so it doesn't eat the full screen ── */
  #drawer { width: min(78vw, 300px); left: calc(-1 * min(78vw, 300px)); }
  #drawer.open { left: 0; }
  body.drawer-open #drawerToggle { left: calc(min(78vw, 300px) - 44px); }
  .drawer-header { padding: 14px 14px 10px; }
  .drawer-label { font-size: 12px; padding: 14px 0 6px; }
  .drawer-section { padding: 0 12px; }
  #drawer .manage-tags-btn { width: 32px; height: 32px; min-width: 32px; }
  .drawer-tag-edit-btn { width: 32px !important; min-width: 32px !important; height: 32px !important; }

  /* ── Page header: tighter spacing ── */
  .page-header { padding: 8px 10px; gap: 6px; }
  body:not(.drawer-open) .page-header { padding-left: 54px; }
  .header-left h1 { font-size: 18px; }
  /* ── Search bar ── */
  .search-bar-container { margin: 10px auto; max-width: calc(100vw - 130px); }
  .search-bar-fancy { padding: 10px 14px; min-height: 42px; }
  .search-bar-fancy #searchInput { font-size: 16px; width: 180px; }

  /* ── Clipboard cards: Google Keep 2-col style ── */
  .clipboard {
    height: 180px;
    padding: 10px; border-radius: 10px;
    overflow: visible;
    min-width: 0;
  }
  .clipboard-title { font-size: 12px; max-width: calc(100% - 20px); }
  /* Push more-btn inward so its tap zone clears the absolutely-positioned pin-btn in the corner */
  .clipboard-topbar { gap: 4px; margin-bottom: 0; padding-right: 18px; }
  .clipboard-footer { margin-top: auto; padding-top: 2px; }
  .clipboard-actions { gap: 3px; margin-top: 2px; }
  .clipboard-time { font-size: 8.5px; }
  .clipboard-icon-btn { width: 18px !important; height: 18px !important; min-width: 18px !important; }
  .clipboard-icon-btn svg { width: 11px !important; height: 11px !important; }
  .clipboard-more-btn { width: 20px; height: 20px; min-width: 20px; }
  .clipboard-pin-btn { width: 20px; height: 20px; min-width: 20px; top: -5px; right: -5px; }
  .clipboard-pin-btn svg { width: 11px; height: 11px; }
  .clipboard-select-btn { width: 20px; height: 20px; min-width: 20px; top: -5px; left: -5px; }
  .clipboard-select-btn svg { width: 11px; height: 11px; }
  .message-view {
    font-size: 11.5px; line-height: 1.5; margin-top: 3px; margin-bottom: 1px;
    overflow: hidden; word-break: break-word;
    flex: 1; min-height: 0;
  }
  .clipboard .task-list-view {
    flex: 1; min-height: 0; overflow: hidden;
  }
  .message-view.truncated::after { height: 25px; }
  .clipboard .tag { font-size: 8.5px; padding: 0px 4px; margin-right: 2px; line-height: 1.4; border: 1px solid rgba(0,0,0,0.08); }
  .clipboard .tag.tag-dot { padding: 1px 4px 1px 3px; font-size: 8.5px; gap: 2px; border: 1px solid rgba(0,0,0,0.08); }
  .clipboard .tag.tag-dot::before { width: 4px; height: 4px; }

  /* ── Card grid: 2-column Google Keep style ── */
  #clipboardsContainer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 6px 8px 0;
    gap: 8px; margin: 0;
  }
  .section-group .section-group-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 6px 8px 0;
    gap: 8px;
  }

  /* ── Section headers ── */
  .section-label { font-size: 10px; padding: 5px 8px; }
  .section-group-name { font-size: 11px; }
  .section-group-count { font-size: 10px; }

  /* ── Skeleton cards match card height ── */
  .skeleton-card { height: 130px; padding: 8px; }

  /* ── Load more button ── */
  .load-more-btn { height: 44px; font-size: 12px; border-radius: 10px; padding: 8px 12px; gap: 6px; }
  .load-more-btn::after { font-size: 13px; }
  .load-more-group-btn { padding: 6px 16px; font-size: 11px; max-width: 180px; }

  /* ── Multi-select bar ── */
  .multi-select-bar { height: 50px; padding: 0 10px; gap: 8px; }
  .msb-count { font-size: 14px; }
  .msb-btn { width: 36px; height: 36px; }
  .msb-btn svg { width: 18px; height: 18px; }

  /* ── Filter chips panel ── */
  #filterChips {
    min-width: 0; width: 100%; padding: 10px 12px; border-radius: 10px;
    max-height: min(360px, calc(100dvh - 160px));
  }

  /* ── Active filter tags ── */
  .active-tag { padding: 4px 10px 4px 8px; font-size: 11px; }
  .active-tag span:last-child { font-size: 11px; }

  /* ── Context / Action menus ── */
  .note-actions-menu { min-width: 180px; max-width: calc(100vw - 16px); }

  /* ── Fullscreen editor overlay ── */
  .fs-editor-overlay { padding: 8px; }
  .fs-editor-wrap {
    border-radius: 14px;
    width: calc(100% - 16px); max-width: none;
    background: var(--bg-body); box-shadow: none;
  }

  /* ── Editor header ── */
  .fs-editor-header {
    padding: 8px 10px; gap: 6px; flex-wrap: wrap;
    background: var(--bg-body); backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none; border-bottom: 1px solid var(--border-light);
  }
  .fs-editor-header-right { order: -1; width: 100%; gap: 4px; align-items: center; }
  .fs-editor-header-right .fs-editor-cancel { order: -1; margin-right: auto; }
  .fs-editor-title {
    font-size: 16px; min-width: 0; flex: 1 1 100%;
    background: transparent; backdrop-filter: none; border-color: transparent; padding-left: 4px;
  }
  .fs-editor-title:focus, .fs-editor-title:focus-visible {
    background: transparent; border-color: transparent;
  }
  .fs-editor-title.fs-editor-title-inline {
    font-size: 17px; padding: 10px 12px 2px 30px;
  }
  .fs-editor-btn { padding: 6px 10px; font-size: 12px; gap: 3px; min-height: 40px; }
  .fs-editor-pin-btn { width: 34px; height: 34px; min-width: 34px; }

  /* ── Editor toolbar ── */
  .fs-editor-wrap .md-editor-toolbar {
    padding: 4px 6px;
    gap: 3px;
    background: var(--bg-body); flex-shrink: 0;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .fs-editor-wrap .md-editor-toolbar::-webkit-scrollbar { display: none; }
  .fs-editor-wrap .md-editor-toolbar button { min-height: 30px; }
  .md-toolbar-group { gap: 0; padding: 1px; background: transparent; }
  .md-toolbar-btn { padding: 3px 5px; min-height: 30px; }
  .md-toolbar-btn svg { width: 12px; height: 12px; }
  .md-toolbar-label { font-size: 9px; }
  .md-toolbar-btn-task { padding: 3px 6px; min-height: 30px; }
  .md-toolbar-btn-task span { font-size: 9px; }
  .md-toolbar-btn-task svg { width: 12px; height: 12px; }
  .md-toolbar-btn-highlight { padding: 3px 6px; min-height: 30px; }
  .md-toolbar-btn-highlight span { font-size: 9px; }
  .md-toolbar-btn-highlight svg { width: 12px; height: 12px; }
  .md-toolbar-btn-dictate { padding: 3px 6px; min-height: 30px; }
  .md-toolbar-btn-dictate span { font-size: 9px; }
  .md-toolbar-btn-dictate svg { width: 12px; height: 12px; }
  /* Reset actions group to inline for horizontal-scroll toolbar */
  .md-toolbar-group--actions {
    flex-basis: auto; border-top: none; margin-top: 0; padding-top: 0;
    margin-left: auto;
  }
  /* Action toolbar buttons: tiny on small phones */
  .md-toolbar-btn-tag,
  .md-toolbar-btn-section,
  .md-toolbar-btn-copy,
  .md-toolbar-btn-delete { padding: 3px 6px; min-height: 30px; }
  .md-toolbar-btn-tag span,
  .md-toolbar-btn-section span,
  .md-toolbar-btn-copy span,
  .md-toolbar-btn-delete span { font-size: 9px; }
  .md-toolbar-btn-tag svg,
  .md-toolbar-btn-section svg,
  .md-toolbar-btn-copy svg,
  .md-toolbar-btn-delete svg { width: 12px; height: 12px; }
  .fs-task-action-toolbar { padding: 4px 6px; gap: 3px; background: var(--bg-body); }

  /* ── Editor content area ──
     Scroll is owned by .md-editor-scroll so the title scrolls together with
     the body (Keep-style shared scroll region). .md-editor-content must not
     also scroll, otherwise the outer region grows unbounded and content
     spills past the white card while the sticky toolbar gets dragged up. */
  .fs-editor-wrap .md-editor-content {
    padding: 10px 12px 120px 30px; font-size: 16px;
    overflow-y: visible; flex: 1 0 auto;
  }
  .md-editor-content { max-height: none; }
  .md-editor-scroll {
    max-height: none; min-height: 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    overscroll-behavior: contain;
  }

  /* ── Editor tags/sections pickers (inside toolbar dropdowns) ── */
  .fs-editor-tag-picker { gap: 4px; }
  .fs-editor-section-picker { gap: 4px; }
  .toolbar-dropdown-panel { min-width: 180px; max-width: 280px; max-height: 200px; padding: 8px 10px; }
  .tag-picker-label .tag.tag-dot { font-size: 11px; padding: 3px 8px 3px 5px; }
  .section-pill { font-size: 11px; padding: 3px 8px; }
  /* Dark theme: flat overlay editor on small screens */
  [data-theme="dark"] .fs-editor-wrap {
    background: var(--bg-body); box-shadow: none;
  }
  [data-theme="dark"] .fs-editor-header {
    background: var(--bg-body); backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none; border-bottom: 1px solid var(--border-light);
  }
  [data-theme="dark"] .fs-editor-wrap .md-editor-toolbar {
    background: var(--bg-body);
  }
  [data-theme="dark"] .fs-task-action-toolbar {
    background: var(--bg-body);
  }

  /* ── Task editor inside fullscreen editor ── */
  .fs-task-editor { min-height: 0; }
  .fs-task-row { gap: 6px; padding: 5px 0; min-width: 0; }
  .fs-task-input { font-size: 16px; padding: 7px 4px; min-width: 0; }
  .task-checkbox { width: 20px; height: 20px; min-width: 20px; }
  .fs-task-remove { width: 26px; height: 26px; min-width: 26px; }
  .fs-task-add { padding: 8px 12px; font-size: 13px; }

  /* ── New task features: mobile adjustments ── */
  .fs-task-drag-grip { display: none; }
  .fs-task-priority-btn { width: 22px; height: 22px; min-width: 22px; font-size: 10px; }
  .fs-task-note-toggle { width: 22px; height: 22px; min-width: 22px; }
  .fs-task-note-toggle svg { width: 12px; height: 12px; }
  .fs-task-note-area.visible { padding-left: 40px; }

  /* ── Tags/Section modal ── */
  .tags-modal { width: calc(100% - 12px); border-radius: 12px; max-height: 88vh; }
  .tags-modal-overlay { padding: 6px; }
  .tags-modal-header { padding: 14px 14px 12px; }
  .tags-modal-header h2 { font-size: 15px; }
  .tags-modal-body { padding: 14px 14px 16px; }
  .tags-modal-form-row { gap: 6px; flex-wrap: wrap; }
  .tags-modal-actions { flex-wrap: wrap; gap: 6px; }
  .tags-modal-actions button { min-height: 42px; flex: 1; min-width: 80px; font-size: 13px; }
  #tagsModalName, #sectionModalName { font-size: 16px; padding: 9px 10px; min-height: 42px; }
  #tagsModalSaveBtn, #sectionModalSaveBtn { font-size: 13px; padding: 8px 14px; min-height: 42px; }
  #tagsModalColor, #sectionModalColor { width: 42px; min-width: 42px; height: 42px; }

  /* ── App alert modal ── */
  .app-alert { width: min(340px, calc(100% - 12px)); padding: 18px 16px 14px; border-radius: 12px; }
  .app-alert-title { font-size: 15px; }
  .app-alert-body { font-size: 13px; }
  .app-alert-btn { padding: 8px 14px; font-size: 12.5px; min-width: 72px; }

  /* ── Landing page ── */
  .landing-page { padding: 16px 16px 28px; gap: 18px; }
  .landing-page::before,
  .landing-page::after { width: 300px; height: 300px; filter: blur(60px); }
  .landing-welcome { font-size: 0.85rem; letter-spacing: 0.35em; margin-bottom: 16px; }
  .landing-logo { font-size: clamp(2rem, 10vw, 3rem); }
  .landing-tagline { font-size: 0.85rem; }
  .landing-features { gap: 6px; margin-top: 8px; }
  .landing-feature-pill { font-size: 11px; padding: 5px 12px; }
  .landing-auth-card { border-radius: 14px; }
  .auth-form { padding: 14px 14px 18px; gap: 12px; }
  .auth-tab { padding: 12px 0; font-size: 13px; }
  .auth-input { padding: 9px 12px; font-size: 16px; }
  .auth-input::placeholder { font-size: 12px; }
  .auth-input-ghost { font-size: 12px; }
  .auth-btn { padding: 10px 14px; font-size: 14px; }
  .landing-theme-btn { top: 12px; right: 12px; }
  .landing-footer { font-size: 11px; }

  /* ── Editor page (full-page /editor route) ── */
  .editor-page-wrap .md-editor-toolbar {
    padding: 4px 6px; gap: 2px; flex-shrink: 0;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .editor-page-wrap .md-editor-toolbar::-webkit-scrollbar { display: none; }
  .editor-page-wrap .md-toolbar-btn { padding: 3px 5px; min-height: 30px; }
  .editor-page-wrap .md-toolbar-label { font-size: 9px; }
  .editor-page-wrap .md-toolbar-btn-task { padding: 3px 6px; min-height: 30px; }
  .editor-page-wrap .md-toolbar-btn-task span { font-size: 9px; }
  .editor-page-wrap .md-toolbar-btn-highlight { padding: 3px 6px; min-height: 30px; }
  .editor-page-wrap .md-toolbar-btn-highlight span { font-size: 9px; }
  .editor-page-wrap .md-toolbar-btn-dictate { padding: 3px 6px; min-height: 30px; }
  .editor-page-wrap .md-toolbar-btn-dictate span { font-size: 9px; }
  .editor-page-wrap .md-toolbar-btn-tag,
  .editor-page-wrap .md-toolbar-btn-section,
  .editor-page-wrap .md-toolbar-btn-copy,
  .editor-page-wrap .md-toolbar-btn-delete { padding: 3px 6px; min-height: 30px; }
  .editor-page-wrap .md-toolbar-btn-tag span,
  .editor-page-wrap .md-toolbar-btn-section span,
  .editor-page-wrap .md-toolbar-btn-copy span,
  .editor-page-wrap .md-toolbar-btn-delete span { font-size: 9px; }
  .editor-page-wrap .fs-task-action-toolbar { padding: 4px 6px; gap: 2px; }
  .editor-page-wrap .fs-editor-btn { padding: 5px 9px; font-size: 11.5px; }
  .editor-page-wrap .fs-task-row { gap: 6px; padding: 5px 0; }
  .editor-page-wrap .fs-task-input { font-size: 16px; padding: 7px 4px; }
  .editor-page-wrap .task-checkbox { width: 20px; height: 20px; min-width: 20px; }
  .editor-page-wrap .fs-task-remove { width: 26px; height: 26px; min-width: 26px; }
  .editor-page-wrap .fs-task-add { padding: 8px 12px; font-size: 13px; }
  .editor-page-wrap .fs-task-drag-grip { display: none; }
  .editor-page-wrap .fs-task-note-area.visible { padding-left: 40px; }
  .editor-page-wrap .fs-task-priority-btn { width: 22px; height: 22px; min-width: 22px; font-size: 10px; }
  .editor-page-wrap .fs-editor-tag-picker { max-height: 80px; overflow-y: auto; }
  .editor-page-wrap .fs-editor-section-picker { max-height: 80px; overflow-y: auto; }

  /* ── Word count bar ── */
  .md-editor-wordcount { padding: 3px 10px; font-size: 10px; }

  /* ── Slash command menu: prevent overflow ── */
  .slash-menu { max-width: calc(100vw - 24px); min-width: 200px; }

  /* ── Drawer date picker ── */
  .drawer-date-row label { gap: 6px; font-size: 11.5px; }
  .drawer-date-row label span:not(.date-display) { min-width: 28px; font-size: 11px; }
  .drawer-date-row input[type="date"] { padding: 5px 28px 5px 6px; font-size: max(16px, 12px); }
  .date-display { padding-left: 6px; right: 28px; font-size: 12px; }
  .date-input-wrap::after { right: 7px; width: 15px; height: 15px; }

  /* ── Drawer filter sections ── */
  .drawer-section-chip { font-size: 11.5px; padding: 3px 8px; }
  .drawer-section-chip-dot { width: 7px; height: 7px; }
  #drawerFilterTags { gap: 4px; }
  #drawerFilterSections { gap: 4px; }

  /* ── Drawer toggle ── */
  #drawerToggle { top: 5px; left: 8px; height: 38px; min-width: 42px; min-height: 38px; padding: 0 10px; }
  #themeToggle { width: 34px; height: 34px; min-width: 34px; }

  /* ── Typography adjustments ── */
  h1 { font-size: 16px; }
  .message-view strong { font-size: 0.95em; }

  /* ── Prevent any horizontal overflow ── */
  .container { overflow-x: clip; max-width: 100vw; }
  body { overflow-x: hidden; }
}
