/**
 * SECTION: DESIGN TOKENS & VARIABLES
 * We use CSS variables to define our color palette, shadows, and timing. 
 * This makes it easy to switch themes and maintain consistency.
 */
:root {
  /* --- Color Palette (Light Theme - Refined) --- */
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --text: #1d1d1f;
  --text-soft: #3a3a3c;
  --muted: #636366;
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.16);
  --accent: #8b6f47;
  --accent-soft: rgba(139, 111, 71, 0.12);
  --accent-hover: #7a5a39;
  --danger: #e03131;
  --danger-soft: rgba(224, 49, 49, 0.1);
  
  /* --- Effects & Shadows (Layered for Depth) --- */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.03);
  --shadow-md: 0 10px 24px -10px rgba(0,0,0,0.1), 0 4px 8px -2px rgba(0,0,0,0.05);
  --shadow-deep: 0 20px 48px -12px rgba(0,0,0,0.15), 0 8px 16px -4px rgba(0,0,0,0.08);
  --glow: rgba(139, 111, 71, 0.15);
  
  /* --- Typography --- */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --fs-base: 16px;
  --fs-sm: 0.875rem;
  --fs-xs: 0.75rem;
  --fs-lg: 1.125rem;
  --fs-xl: 2rem;

  /* --- Spacing System --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* --- Border Radius --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* --- Animation Speeds --- */
  --speed: 0.3s;
  --speed-fast: 0.15s;
  --speed-slow: 0.5s;
  --speed-base: var(--speed);

  /* --- Easing Functions --- */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --stagger: 0ms;
  
  color-scheme: light;
}

/**
 * SECTION: DARK THEME OVERRIDES
 * Updates the CSS variables when the 'dark' class is present on the body.
 */
body.dark {
  --bg: #101113;
  --surface: rgba(26, 27, 30, 0.85);
  --surface-strong: #1a1b1e;
  --text: #c1c2c5;
  --text-soft: #a6a7ab;
  --muted: #5c5f66;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --accent: #d4b483;
  --accent-soft: rgba(212, 180, 131, 0.13);
  --accent-hover: #b89e6f;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow: 0 4px 12px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-deep: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
  --glow: rgba(212, 180, 131, 0.16);
  color-scheme: dark;
}


/**
 * SECTION: BASE STYLES & RESET
 * Fundamental styling for the HTML document and common elements.
 */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background-color: var(--bg);
  /* Sophisticated layered gradients for a premium, non-flat look */
  background-image: 
    radial-gradient(circle at top left, var(--accent-soft), transparent 30%),
    radial-gradient(circle at bottom right, rgba(48, 164, 108, 0.04), transparent 35%),
    radial-gradient(circle at center, rgba(255, 255, 255, 0.5), transparent 80%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-main);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--speed-base) var(--ease-out), color var(--speed-base) var(--ease-out);
}

/* Noise texture overlay for a more organic feel */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.4;
  pointer-events: none;
  background-image: var(--noise);
  mix-blend-mode: overlay;
}

body.dark::before {
  opacity: 0.15;
}

/* Slower transition speed during theme change for a smooth "morph" effect */
body.theme-morphing * {
  transition-duration: var(--speed-slow) !important;
}

/* Custom scrollbar styling */
body::-webkit-scrollbar {
  width: 10px;
}

body::-webkit-scrollbar-track {
  background: var(--bg);
}

body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid var(--bg);
}

body::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Typography resets */
h1, h2, h3, h4, h5, h6, p {
  margin: 0;
}

h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -0.05em;
  color: var(--text);
}

h2 {
  font-size: var(--fs-xl);
  font-weight: 750;
  letter-spacing: -0.03em;
}

h3 {
  font-size: var(--fs-xs);
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* Interactive elements base styling */
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--speed-fast) ease;
}

a:hover {
  color: var(--accent-hover);
}

/* Input and Form Control styling */
input,
textarea,
select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: all var(--speed-fast) var(--ease-out);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), inset 0 1px 2px rgba(0, 0, 0, 0.02);
  transform: translateY(-1px);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--text-soft);
  margin-bottom: var(--space-2);
}

.hidden {
  display: none !important;
}

/**
 * SECTION: GLASSMORPHISM EFFECT
 * Applied to major sections to create a translucent, frosted glass look.
 */
.glass {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform var(--speed-base) var(--ease-out), 
              box-shadow var(--speed-base) var(--ease-out), 
              border-color var(--speed-base) var(--ease-out),
              background-color var(--speed-base) var(--ease-out);
}

/* Subtle inner glow for the glass effect */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), transparent);
  z-index: -1;
}

body.dark .glass::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent);
}

/**
 * SECTION: LAYOUT COMPONENTS
 * Styling for the major containers and structural elements of the app.
 */

/* Custom cursor glow element */
.cursor-glow {
  position: fixed;
  left: -75px;
  top: -75px;
  z-index: 9999;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow), transparent 70%);
  pointer-events: none;
  mix-blend-mode: screen;
  transition: opacity var(--speed-base) ease;
  will-change: transform;
}

/* Application entry loader */
.startup-loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  background: var(--bg);
  transition: opacity var(--speed-slow) var(--ease-out), visibility var(--speed-slow) var(--ease-out);
}

.startup-loader.loaded {
  opacity: 0;
  visibility: hidden;
}

/* Spinner for the loader */
.loader-orbit {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Skeleton loader placeholders */
.skeleton-stack {
  display: flex;
  flex-direction: column;
  width: min(400px, 90vw);
  gap: var(--space-3);
}

.skeleton-stack span {
  height: 48px;
  background: linear-gradient(90deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  animation: shimmer 1.5s infinite linear;
}

/* Main application shell */
.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-4);
  animation: pageEnter var(--speed-slow) var(--ease-out) both;
}

/* Application header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-10);
  margin-bottom: var(--space-8);
  background: var(--surface-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.app-logo {
  font-size: var(--fs-xl);
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.05em;
  line-height: 1.1;
  margin: 0;
}

body.dark .app-logo {
  color: var(--accent);
  text-shadow: 0 0 20px var(--glow);
}

.hero-copy {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  max-width: 420px;
  margin-top: var(--space-1);
  font-weight: 500;
}

.hero-actions,
.utility-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.hero-actions {
  margin-top: var(--space-3);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 99px;
  border: 1px solid transparent;
  transition: all var(--speed-fast) var(--ease-out);
}

.badge-interactive {
  cursor: pointer;
}

.badge-interactive:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 12px var(--glow);
}

.badge-interactive:active {
  transform: translateY(0) scale(0.98);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-danger:hover {
  background: var(--danger);
  color: #fff;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: all var(--speed-fast) var(--ease-out);
}

.theme-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(8deg) scale(1.1);
  box-shadow: 0 0 15px var(--glow);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Accessibility: Hide text but keep it for screen readers */
.sr-only,
.theme-toggle .theme-icon {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Theme toggle icons */
.theme-toggle::before {
  content: "☀";
  font-size: 1.1rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.5s var(--ease-out);
}

body.dark .theme-toggle::before {
  content: "☾";
  transform: rotate(360deg);
}

/* Consolidate common interactive element transitions and effects */
.button,
.filter-chip,
.note-action,
.theme-toggle,
.badge-interactive {
  transition: all var(--speed-fast) var(--ease-out);
}

.button:hover,
.filter-chip:hover,
.note-action:hover,
.theme-toggle:hover,
.badge-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.button:active,
.filter-chip:active,
.note-action:active,
.theme-toggle:active,
.badge-interactive:active {
  transform: translateY(0) scale(0.98);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  transform: translateY(-1px);
}

/* Stats cards row (compact variant) */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  align-items: center;
}

.stat-card {
  padding: calc(var(--space-2) + 4px) var(--space-3);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all var(--speed-base) var(--ease-out);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 72px;
  border-radius: var(--radius-md);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--accent);
}

.stat-card p {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}

.composer,
.controls,
.notes-panel {
  padding: var(--space-6) var(--space-8);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-md);
}

.composer {
  border-color: var(--accent-soft);
}

.section-heading,
.notes-toolbar,
.composer-footer,
.form-actions,
.note-meta,
.note-actions {
  display: flex;
  align-items: center;
}

.section-heading,
.notes-toolbar,
.composer-footer {
  justify-content: space-between;
  gap: var(--space-4);
  border-top: 1px solid var(--border-weak);
}

.section-heading h2 {
  font-size: var(--fs-xl);
  font-weight: 800;
}

.section-heading p {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

form {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
}

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

/**
 * SECTION: NOTE COLOR SWATCHES
 */
.palette {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.palette-label {
  font-size: 0.65rem;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-right: var(--space-4);
}

/* Ensure label remains readable in all color schemes */
body.dark .palette-label {
  color: var(--muted);
}

.swatch input {
  position: absolute;
  opacity: 0;
}

.swatch span {
  display: block;
  width: 26px;
  height: 26px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--speed-base) var(--ease-out);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.swatch:hover span {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(0,0,0,0.1);
}

.swatch input:checked + span {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
}

.swatch-cyan span { background: #3bc9db; }
.swatch-violet span { background: #be4bdb; }
.swatch-amber span { background: #fab005; }
.swatch-rose span { background: #ff6b6b; }
.swatch-emerald span { background: #51cf66; }

.form-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/**
 * SECTION: BUTTONS & CHIPS
 * Shared base styles for interactive elements to ensure consistency.
 */
.button,
.filter-chip,
.note-action,
.badge-interactive {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: var(--fs-sm);
  font-weight: 650;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.button-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.button-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.button-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
  box-shadow: none;
}

.button-ghost:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.button-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
  box-shadow: none;
}

.button-danger:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
  box-shadow: var(--shadow);
}

.filter-chip {
  border-radius: 99px;
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: none;
}

.filter-chip.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

/**
 * SECTION: CONTROLS & SEARCH
 */
.controls {
  position: sticky;
  top: var(--space-4);
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr auto;
  align-items: flex-end;
  gap: var(--space-6);
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-radius: var(--radius-lg);
}

.search-label, .sort-label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.search-label label, .sort-label label {
  font-size: 0.65rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-4);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  animation: expandIn var(--speed-fast) var(--ease-out) both;
}

.bulk-toolbar span {
  flex: 1;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent);
}

::selection {
  background: var(--accent-soft);
  color: var(--accent);
}

::-webkit-input-placeholder {
  color: var(--muted);
  font-weight: 500;
}

/**
 * SECTION: NOTE CARDS
 * Styling for the individual note elements in the grid.
 */
.note-section {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
}

.note-section h3 {
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.7rem;
}

/* Divider line next to section title */
.note-section h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.note-card {
  --note-accent: var(--accent);
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 220px;
  padding: var(--space-6);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.3s var(--ease-out), 
              box-shadow 0.3s var(--ease-out), 
              border-color 0.3s var(--ease-out);
  animation: cardIn 0.5s var(--ease-out) both;
  animation-delay: var(--stagger, 0ms);
  overflow: hidden;
}

.note-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--note-accent);
}

/* Subtle inner shadow on hover for more depth */
.note-card:hover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.02);
  z-index: 1;
}

/* Colored top border for each note */
.note-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--note-accent);
}

/* Color theme overrides for note cards */
.note-card[data-color="cyan"] { --note-accent: #3bc9db; }
.note-card[data-color="violet"] { --note-accent: #be4bdb; }
.note-card[data-color="amber"] { --note-accent: #fab005; }
.note-card[data-color="rose"] { --note-accent: #ff6b6b; }
.note-card[data-color="emerald"] { --note-accent: #51cf66; }

.note-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  position: relative;
  padding-left: calc(var(--checkbox-size, 12px) + var(--space-6));
}

/* Custom checkbox for note selection */
.note-card input[type="checkbox"] {
  --checkbox-size: 15px;
  position: absolute;
  top: 50%;
  left: var(--space-3);
  width: var(--checkbox-size) !important;
  height: var(--checkbox-size) !important;
  padding: 0 !important;
  margin: 0 !important;
  transform: translateY(-50%);
  cursor: pointer;
  z-index: 10;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  box-sizing: content-box;
  transition: background-color var(--speed-fast) var(--ease), border-color var(--speed-fast) var(--ease), transform var(--speed-fast) var(--ease);
}

.note-card input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.note-card input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 10px;
  font-weight: 900;
}

.note-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.note-badge {
  padding: 0.2rem 0.6rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 6px;
}

.note-card h4 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-2);
  line-height: 1.3;
}

/* Truncate note body text after 4 lines */
.note-body {
  font-size: 0.9375rem;
  color: var(--text-soft);
  line-height: 1.6;
  font-weight: 450;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
}

.note-meta {
  margin-top: auto;
  padding-top: var(--space-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

/* Quick action buttons shown on hover */
.note-actions {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  display: flex;
  gap: var(--space-1);
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--speed-fast) var(--ease-out);
}

.note-card:hover .note-actions {
  opacity: 1;
  transform: translateY(0);
}

.note-action {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.note-action:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.15) rotate(5deg);
}

/**
 * SECTION: OVERLAYS & MODALS
 * Styling for toasts, backdrop, and dialogs.
 */
.toast-stack {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  padding: var(--space-4) var(--space-6);
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: toastIn var(--speed-base) var(--ease-out) both;
}

.toast strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 850;
}

.toast span {
  font-size: 0.8rem;
  color: var(--text-soft);
  font-weight: 600;
}

/* Full-screen blurred backdrop for modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  padding: var(--space-4);
  animation: fadeIn var(--speed-fast) ease both;
}

.modal {
  width: min(100%, 550px);
  max-height: 85vh;
  background: var(--surface-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-deep);
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  animation: modalIn var(--speed-base) var(--ease-out) both;
}

/* Larger width for the note reading modal */
.read-modal-content {
  width: min(100%, 900px);
}

.modal-header {
  padding: var(--space-6) var(--space-10);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h2 {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

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

.modal-footer {
  padding: var(--space-6) var(--space-10);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.note-full-content {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}

.note-meta-modal {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/**
 * SECTION: ANIMATIONS
 * Keyframe definitions for various UI transitions.
 */
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(30px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(50px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Bullet point for markdown lists */
.md-list-item::before {
  content: "•";
  color: var(--accent);
  font-weight: 900;
  margin-right: 0.5rem;
}

/* Ripple effect animation */
.ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 600ms ease-out;
}

@keyframes expandIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ripple {
  to { opacity: 0; transform: translate(-50%, -50%) scale(3); }
}

/**
 * SECTION: FLOATING ACTION BUTTON
 * Mobile-friendly button for quick note creation.
 */
.fab {
  position: fixed;
  right: var(--space-8);
  bottom: var(--space-8);
  z-index: 500;
  width: 60px;
  height: 60px;
  display: none; /* Hidden by default, shown on mobile */
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 10px 25px var(--glow);
  border: none;
  font-size: 28px;
  transition: all var(--speed-base) var(--ease-out);
}

.fab:hover {
  transform: scale(1.1) rotate(90deg) translateY(-5px);
  background: var(--accent-hover);
  box-shadow: 0 15px 30px var(--glow);
}

.fab:active {
  transform: scale(0.9) rotate(90deg);
}

/**
 * SECTION: APP FOOTER
 */
.app-footer {
  margin-top: var(--space-12);
  padding: var(--space-8) 0;
  border-top: 1px solid var(--border-strong);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.app-footer span {
  font-weight: 800;
  color: var(--accent);
}

/**
 * SECTION: TOOLTIPS
 * Custom CSS-only tooltips for buttons.
 */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  padding: 4px 8px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all var(--speed-fast) var(--ease-out);
  box-shadow: var(--shadow-md);
  z-index: 1000;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/**
 * SECTION: EMPTY STATE
 * Shown when no notes are available or match search filters.
 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--muted);
  animation: fadeIn 0.5s var(--ease) both;
}

.empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: var(--fs-lg);
  color: var(--text);
  margin-bottom: var(--space-2);
  font-weight: 750;
}

.empty-state p {
  font-size: var(--fs-sm);
  max-width: 320px;
  line-height: 1.6;
}

/**
 * SECTION: RESPONSIVE DESIGN
 * Media queries for different screen sizes.
 */
@media (max-width: 1024px) {
  .app-shell {
    padding: var(--space-4);
  }
}

@media (max-width: 860px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .controls {
    grid-template-columns: 1fr 1fr;
    padding: var(--space-4);
    position: static;
    gap: var(--space-4);
  }
  
  .search-label {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    padding: var(--space-6) var(--space-4);
    text-align: center;
    gap: var(--space-4);
  }

  .app-logo {
    font-size: 2.25rem;
  }

  .hero-actions {
    justify-content: center;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  /* Horizontal scroll for filter chips on small screens */
  .filter-group {
    display: flex;
    overflow-x: auto;
    padding-bottom: var(--space-4);
    margin: 0 calc(-1 * var(--space-4));
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    gap: var(--space-2);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-group::-webkit-scrollbar {
    display: none;
  }

  .filter-chip {
    flex: 0 0 auto;
    padding: 0.5rem 1.25rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  /* Full-screen modals on mobile */
  .modal {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  /* Show floating action button on mobile */
  .fab {
    display: flex;
  }

  .toast-stack {
    bottom: 100px;
    right: var(--space-4);
    left: var(--space-4);
  }
}

/**
 * SECTION: REDUCED MOTION
 * Respects user's operating system preference for reduced motion.
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
