/* ========================================================================
KEEPIT — NOTE-TAKING TOOL FOR TOOLHUB
Cross-Cultural Design System · DE / EN / RO
Flat colors only · No gradients · CSS Custom Properties
======================================================================== */

/* 1. VARIABLES & THEME =================================================== */
:root {
  /* Colors */
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-surface: #F1F5F9;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --warm: #D97706;
  --success: #10B981;
  --error: #EF4444;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.12);
  --focus-ring: 0 0 0 3px rgba(37,99,235,0.25);
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  /* Layout */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --max-width: 1200px;
  --header-height: 64px;
  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.8125rem, 0.75rem + 0.3vw, 0.9375rem);
  --text-base: clamp(0.875rem, 0.8rem + 0.3vw, 1rem);
  --text-lg: clamp(1rem, 0.9rem + 0.4vw, 1.125rem);
  --text-xl: clamp(1.25rem, 1rem + 1vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.5vw, 2.25rem);
  /* Motion */
  --ease: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-slow: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  /* Note Colors (flat, no gradients) */
  --note-default: #FFFFFF;
  --note-red: #FACDCD;
  --note-orange: #F9D0A8;
  --note-yellow: #FFF3B0;
  --note-green: #C8F7C5;
  --note-teal: #B2DFDB;
  --note-blue: #AECCF5;
  --note-darkblue: #C5CAE9;
  --note-purple: #D1C4E9;
  --note-pink: #F8BBD0;
  --note-brown: #D7CCC8;
  --note-gray: #CFD8DC;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #0B1120;
    --bg-card: #111827;
    --bg-surface: #1E293B;
    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #64748B;
    --border: #334155;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --note-default: #1E293B;
    --note-red: #3E1C1C;
    --note-orange: #3E2A15;
    --note-yellow: #3E3A10;
    --note-green: #1A3E1A;
    --note-teal: #0E3535;
    --note-blue: #152E4A;
    --note-darkblue: #1A1F4A;
    --note-purple: #2A1F4A;
    --note-pink: #3E1A30;
    --note-brown: #2E2520;
    --note-gray: #2A3038;
  }
}
/* Manual dark theme override */
html.theme-dark {
  --bg-page: #0B1120;
  --bg-card: #111827;
  --bg-surface: #1E293B;
  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #64748B;
  --border: #334155;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --note-default: #1E293B;
  --note-red: #3E1C1C;
  --note-orange: #3E2A15;
  --note-yellow: #3E3A10;
  --note-green: #1A3E1A;
  --note-teal: #0E3535;
  --note-blue: #152E4A;
  --note-darkblue: #1A1F4A;
  --note-purple: #2A1F4A;
  --note-pink: #3E1A30;
  --note-brown: #2E2520;
  --note-gray: #2A3038;
}

/* 2. BASE & RESET ======================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 90px; /* footer + donate button space */
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; }
ul, ol { list-style: none; }

/* 3. LAYOUT & CONTAINERS ================================================ */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-inline: var(--space-lg);
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-primary);
  font-size: var(--text-lg);
  line-height: 1.2;
  transition: opacity var(--ease);
}
.logo:hover { opacity: 0.9; }
.logo-img {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: block;
  border-radius: var(--radius-sm);
}
.logo strong {
  font-weight: 700;
  letter-spacing: -0.02em;
}
main { flex: 1; padding-block: var(--space-xl); }

/* 4. TYPOGRAPHY & UTILITY =============================================== */
h1, h2, h3, h4 {
  text-wrap: balance;
  line-height: 1.2;
  font-weight: 600;
}
h1 { font-size: var(--text-3xl); margin-bottom: var(--space-md); }
h2 { font-size: var(--text-2xl); margin-bottom: var(--space-lg); }
h3 { font-size: var(--text-xl); }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* 5. COMPONENTS ========================================================= */
/* Language Switcher — Pill Design */
.lang-switch {
  display: inline-flex;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: 999px;
  gap: 4px;
  align-items: center;
  width: auto;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}
.lang-btn:hover { color: var(--text-primary); }
.lang-btn.active {
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}
/* Theme Toggle */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: grid; place-items: center;
  font-size: 1.1rem;
}
/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  transition: var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn--outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}
.btn--outline:hover { background: var(--bg-surface); }
.btn--sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
}
.btn--danger {
  background: var(--error);
  border-color: var(--error);
}
.btn--danger:hover { background: #DC2626; }
.btn--ghost {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-xs);
}
.btn--ghost:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}
/* Forms */
.form-group { margin-bottom: var(--space-md); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-xs);
}
.form-input, .form-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: var(--ease);
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}
.form-input.is-error, .form-textarea.is-error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.2);
}
.form-help { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-xs); }

/* User Badge (header) */
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.user-badge-avatar {
  font-size: 1rem;
}
.user-badge-name {
  font-weight: 600;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Login Prompt (locked state) */
.login-prompt {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  max-width: 400px;
  margin: 0 auto;
}
.login-prompt-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.6;
}
.login-prompt-text {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

/* Auth Modal */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.auth-overlay.is-active {
  opacity: 1;
  visibility: visible;
}
.auth-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  width: 90vw;
  max-width: 420px;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
}
.auth-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
  z-index: 5;
}
.auth-close:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.auth-content {
  padding: var(--space-xl) var(--space-lg);
}
.auth-title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-lg);
  text-align: center;
}
.auth-form-error {
  background: #FEE2E2;
  color: #991B1B;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-bottom: var(--space-md);
  border: 1px solid #FECACA;
}
html.theme-dark .auth-form-error {
  background: #3E1C1C;
  color: #FCA5A5;
  border-color: #5E2020;
}
.auth-switch {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-md);
}
.auth-switch a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.auth-switch a:hover {
  text-decoration: underline;
}

/* 6. TOOL-SPECIFIC — KEEPIT ============================================== */
/* Sub-site Banner */
.subsite-banner {
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.3px;
  position: sticky;
  top: var(--header-height);
  z-index: 49;
}
.subsite-banner a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 700;
}

/* Search Bar */
.keepit-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: 600px;
  margin: 0 auto var(--space-lg);
  position: relative;
}
.keepit-search .form-input {
  padding-left: 40px;
  border-radius: 999px;
  background: var(--bg-surface);
}
.keepit-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

/* Filter Tabs */
.keepit-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  justify-content: center;
}
.keepit-tab {
  padding: var(--space-xs) var(--space-md);
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: var(--ease);
  cursor: pointer;
}
.keepit-tab:hover { color: var(--text-primary); }
.keepit-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* New Note Input Area */
.new-note-area {
  max-width: 600px;
  margin: 0 auto var(--space-xl);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--ease);
}
.new-note-area:focus-within {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.new-note-title {
  width: 100%;
  padding: var(--space-md) var(--space-md) 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 600;
  outline: none;
}
.new-note-body {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 200px;
  font-family: var(--font-sans);
  line-height: 1.5;
}
.new-note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border);
  gap: var(--space-sm);
}
.new-note-actions-left {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}

/* Color Palette */
.color-palette {
  display: flex;
  gap: 4px;
  align-items: center;
  position: relative;
}
.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.color-dot:hover {
  transform: scale(1.15);
}
.color-dot.selected {
  border-color: var(--text-primary);
}
.color-dot.selected::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-primary);
}
.color-dot[data-color="default"] { background: var(--note-default); border-color: var(--border); }
.color-dot[data-color="red"]     { background: var(--note-red); }
.color-dot[data-color="orange"]  { background: var(--note-orange); }
.color-dot[data-color="yellow"]  { background: var(--note-yellow); }
.color-dot[data-color="green"]   { background: var(--note-green); }
.color-dot[data-color="teal"]    { background: var(--note-teal); }
.color-dot[data-color="blue"]    { background: var(--note-blue); }
.color-dot[data-color="darkblue"]{ background: var(--note-darkblue); }
.color-dot[data-color="purple"]  { background: var(--note-purple); }
.color-dot[data-color="pink"]    { background: var(--note-pink); }
.color-dot[data-color="brown"]   { background: var(--note-brown); }
.color-dot[data-color="gray"]    { background: var(--note-gray); }

/* Expanded color picker for new note */
.color-picker-expanded {
  display: none;
  gap: 4px;
  padding: var(--space-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  z-index: 20;
  flex-wrap: wrap;
  width: 160px;
}
.color-picker-expanded.is-open { display: flex; }

/* Notes Masonry Grid */
.notes-grid {
  columns: 4;
  column-gap: var(--space-md);
}
.notes-grid .note-card {
  break-inside: avoid;
  margin-bottom: var(--space-md);
}

/* Note Card */
.note-card {
  background: var(--note-default);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: box-shadow var(--ease);
  cursor: default;
}
.note-card:hover {
  box-shadow: var(--shadow-md);
}
.note-card[data-color="default"] { background: var(--note-default); border-color: var(--border); }
.note-card[data-color="red"]     { background: var(--note-red); border-color: transparent; }
.note-card[data-color="orange"]  { background: var(--note-orange); border-color: transparent; }
.note-card[data-color="yellow"]  { background: var(--note-yellow); border-color: transparent; }
.note-card[data-color="green"]   { background: var(--note-green); border-color: transparent; }
.note-card[data-color="teal"]    { background: var(--note-teal); border-color: transparent; }
.note-card[data-color="blue"]    { background: var(--note-blue); border-color: transparent; }
.note-card[data-color="darkblue"]{ background: var(--note-darkblue); border-color: transparent; }
.note-card[data-color="purple"]  { background: var(--note-purple); border-color: transparent; }
.note-card[data-color="pink"]    { background: var(--note-pink); border-color: transparent; }
.note-card[data-color="brown"]   { background: var(--note-brown); border-color: transparent; }
.note-card[data-color="gray"]    { background: var(--note-gray); border-color: transparent; }

.note-card-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-xs);
  line-height: 1.3;
  word-break: break-word;
}
.note-card-body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.note-card-body b, .note-card-body strong { font-weight: 700; color: var(--text-primary); }
.note-card-body i, .note-card-body em { font-style: italic; }
.note-card-body u { text-decoration: underline; }
.note-card-body s { text-decoration: line-through; }
.note-card-body ul, .note-card-body ol { margin: 0.3em 0; padding-left: 1.4em; }
.note-card-body li { margin: 0.1em 0; }

/* Note Card Hover Actions */
.note-card-actions {
  display: none;
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}
.note-card:hover .note-card-actions { display: flex; }
.note-card-actions .btn--ghost {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  border-radius: var(--radius-xs);
}
.note-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.note-pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  color: var(--warm);
  font-weight: 600;
}

/* Checklist items in note card */
.note-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.note-checklist li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  word-break: break-word;
}
.note-checklist li.checked {
  text-decoration: line-through;
  opacity: 0.6;
}
.note-checklist input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}
.empty-state p {
  font-size: var(--text-lg);
  margin: 0;
}

/* Edit Modal */
.edit-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.edit-overlay.is-active {
  opacity: 1;
  visibility: visible;
}
.edit-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  width: 90vw;
  max-width: 600px;
  min-height: 70vh;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.edit-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
  z-index: 5;
}
.edit-close:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.edit-content {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.edit-title-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-xl);
  font-weight: 600;
  outline: none;
  margin-bottom: var(--space-md);
  padding: 0;
  flex-shrink: 0;
}
.fmt-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-sm);
}
.fmt-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.fmt-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}
.fmt-btn.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--color-primary);
}
.fmt-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.edit-body-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-base);
  outline: none;
  resize: none;
  min-height: 200px;
  flex: 1;
  font-family: var(--font-sans);
  line-height: 1.5;
  padding: 0;
  overflow-y: auto;
  word-wrap: break-word;
}
.edit-body-input.is-empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.edit-body-input b, .edit-body-input strong { font-weight: 700; }
.edit-body-input i, .edit-body-input em { font-style: italic; }
.edit-body-input u { text-decoration: underline; }
.edit-body-input s { text-decoration: line-through; }
.edit-body-input ul, .edit-body-input ol { margin: 0.4em 0; padding-left: 1.5em; }
.edit-body-input li { margin: 0.15em 0; }
.edit-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--border);
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.edit-footer-left {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  position: relative;
}

/* Checklist editor */
.edit-checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.edit-checklist li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.edit-checklist input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.edit-checklist input[type="text"] {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-base);
  padding: var(--space-xs) 0;
  outline: none;
  font-family: var(--font-sans);
}
.edit-checklist input[type="text"]:focus {
  border-bottom-color: var(--accent);
}
.edit-checklist .btn-remove-item {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.edit-checklist li:hover .btn-remove-item { opacity: 1; }
.add-checklist-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-xs) 0;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.add-checklist-item:hover { color: var(--text-primary); }

/* Note count badge */
.note-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg-surface);
  border-radius: 999px;
}

/* Confirm dialog (inline, no alert) */
.confirm-bar {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
}
.confirm-bar.is-active { display: flex; }
.confirm-bar .btn--danger { font-size: var(--text-xs); }
.confirm-bar .btn--outline { font-size: var(--text-xs); }

/* Legal footer */
.subsite-legal-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  z-index: 9998;
  text-align: center;
  font-size: var(--text-sm);
}
.subsite-legal-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

/* 7. STICKY DONATE ======================================================= */
.sticky-donate-wrapper {
  position: fixed;
  bottom: 44px;
  right: 24px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--ease), transform var(--ease);
  pointer-events: none;
}
.sticky-donate-wrapper.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.sticky-donate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #FFDD00;
  color: #111;
  font-weight: 600;
  font-size: var(--text-sm);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  border: none;
  text-decoration: none;
  transition: transform var(--ease), box-shadow var(--ease);
}
.sticky-donate-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 16px rgba(255, 205, 0, 0.3);
}
.sticky-donate-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.donate-icon { font-size: 1.2em; }

/* 8. MODAL =============================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.is-active {
  opacity: 1;
  visibility: visible;
}
.modal-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  z-index: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}
.modal-close:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.modal-content {
  padding: var(--space-2xl);
  overflow-y: auto;
  max-height: 80vh;
}
.modal-loading {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

/* 9. ANIMATIONS ========================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}
.note-card { animation: fadeIn 0.2s ease; }

/* 10. RESPONSIVE ========================================================= */
@media (max-width: 1024px) {
  .notes-grid { columns: 3; }
}
@media (max-width: 768px) {
  .notes-grid { columns: 2; }
}
@media (max-width: 640px) {
  :root {
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
  }
  .notes-grid { columns: 1; }
  .notes-grid .note-card { margin-bottom: var(--space-sm); }
  .new-note-area { max-width: 100%; }
  .keepit-search { max-width: 100%; }
  .lang-btn span { display: none; }
  .lang-btn { padding: 6px 8px; font-size: 1.2rem; }
  .sticky-donate-wrapper { bottom: 44px; right: 16px; }
  .sticky-donate-btn { padding: 8px 14px; font-size: var(--text-xs); border-radius: 999px; }
  .sticky-donate-btn .donate-text { display: inline-flex !important; }
  .edit-container { width: 95vw; max-height: 90vh; }
  .note-card-actions { display: flex; opacity: 0.7; }
  .user-badge-name { max-width: 80px; }
  .auth-container { width: 95vw; }
}

/* 11. REDUCED MOTION ===================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .sticky-donate-wrapper, .sticky-donate-btn {
    transition: none !important;
    animation: none !important;
  }
}

/* 12. PRINT ============================================================== */
@media print {
  .site-header,
  .subsite-banner,
  .btn,
  .theme-toggle,
  .lang-switch,
  .sticky-donate-wrapper,
  .subsite-legal-footer,
  .new-note-area,
  .keepit-search,
  .keepit-tabs,
  .note-card-actions,
  .edit-overlay,
  .auth-overlay,
  .user-badge,
  #loginBtn,
  #loginBtnCenter,
  .login-prompt { display: none !important; }
  body { background: #fff; color: #000; padding-bottom: 0; }
  .note-card { break-inside: avoid; box-shadow: none; border: 1px solid #000; }
  .notes-grid { columns: 3; }
}
