* {
  box-sizing: border-box;
}

:root {
  --color-scheme: dark;
  --bg: #0a0f1a;
  --surface: #111827;
  --surface-hover: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --accent: #60a5fa;
  --accent-dark: #3b82f6;
  --accent-soft: #93c5fd;
  --success: #22c55e;
  --success-dark: #16a34a;
  --success-soft: #4ade80;
  --danger: #ef4444;
  --warning: #f59e0b;
  --star: #fbbf24;
  --placeholder: #64748b;
  --hover-border: #475569;
  --task-hover-bg: linear-gradient(to right, #111827, #172033);
  --badge-overdue-bg: #7f1d1d;
  --badge-overdue-text: #fecaca;
  --badge-today-bg: #78350f;
  --badge-today-text: #fde68a;
  --badge-soon-bg: #1e40af;
  --badge-soon-text: #bfdbfe;
  --badge-future-bg: #1e293b;
  --badge-future-text: #cbd5e1;
  --status-bg: rgba(14, 165, 233, 0.12);
  --status-border: rgba(14, 165, 233, 0.4);
  --status-text: #93c5fd;
  --section-bg: rgba(30, 41, 59, 0.45);
  --note-wrapper-bg: #0f172a;
  --note-wrapper-border: #1e293b;
  --note-label: #6b7a8f;
  --note-title-start: #ffffff;
  --note-input-bg: #0b111e;
  --note-input-border: #2d3a4f;
  --checkbox-border: #4b5563;
  --checkbox-bg: #1f2937;
  --preview-text: #d1d9e8;
  --preview-code-bg: #1e293b;
  --preview-code-text: #f472b6;
  --preview-pre-bg: #1a2332;
  --preview-quote-bg: #1e293b;
  --preview-quote-text: #b4c0d0;
  --link: #93c5fd;
  --note-status-bg: #1e293b;
  --note-status-border: #334155;
  --note-status-error-text: #fca5a5;
}

html {
  color-scheme: var(--color-scheme);
}

html[data-theme="blue"] {
  --color-scheme: dark;
}

html[data-theme="dark"] {
  --color-scheme: dark;
  --bg: #0b0d10;
  --surface: #141820;
  --surface-hover: #1b2230;
  --border: #2a3443;
  --text: #e5e7eb;
  --text-secondary: #9aa4b2;
  --accent: #34d399;
  --accent-dark: #10b981;
  --accent-soft: #6ee7b7;
  --success: #22c55e;
  --success-dark: #16a34a;
  --success-soft: #4ade80;
  --danger: #ef4444;
  --warning: #f59e0b;
  --star: #fbbf24;
  --placeholder: #6b7280;
  --hover-border: #3b485c;
  --task-hover-bg: linear-gradient(to right, #141820, #1a2230);
  --badge-overdue-bg: #7f1d1d;
  --badge-overdue-text: #fecaca;
  --badge-today-bg: #78350f;
  --badge-today-text: #fde68a;
  --badge-soon-bg: #1e40af;
  --badge-soon-text: #bfdbfe;
  --badge-future-bg: #1e293b;
  --badge-future-text: #cbd5e1;
  --status-bg: rgba(14, 165, 233, 0.12);
  --status-border: rgba(14, 165, 233, 0.4);
  --status-text: #93c5fd;
  --section-bg: rgba(27, 34, 48, 0.55);
  --note-wrapper-bg: #0f141c;
  --note-wrapper-border: #1f2836;
  --note-label: #7c8797;
  --note-title-start: #ffffff;
  --note-input-bg: #0b1118;
  --note-input-border: #253145;
  --checkbox-border: #3b485c;
  --checkbox-bg: #1b2533;
  --preview-text: #d7dde7;
  --preview-code-bg: #1c2533;
  --preview-code-text: #f472b6;
  --preview-pre-bg: #18202c;
  --preview-quote-bg: #1c2533;
  --preview-quote-text: #b4c0d0;
  --link: #86efac;
  --note-status-bg: #1b2230;
  --note-status-border: #2a3443;
  --note-status-error-text: #fca5a5;
}

html[data-theme="light"] {
  --color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #475569;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #93c5fd;
  --success: #16a34a;
  --success-dark: #15803d;
  --success-soft: #4ade80;
  --danger: #dc2626;
  --warning: #d97706;
  --star: #f59e0b;
  --placeholder: #94a3b8;
  --hover-border: #cbd5e1;
  --task-hover-bg: linear-gradient(to right, #ffffff, #f8fafc);
  --badge-overdue-bg: #fee2e2;
  --badge-overdue-text: #991b1b;
  --badge-today-bg: #fef3c7;
  --badge-today-text: #92400e;
  --badge-soon-bg: #dbeafe;
  --badge-soon-text: #1e40af;
  --badge-future-bg: #e2e8f0;
  --badge-future-text: #475569;
  --status-bg: #e0f2fe;
  --status-border: #7dd3fc;
  --status-text: #0369a1;
  --section-bg: rgba(226, 232, 240, 0.65);
  --note-wrapper-bg: #ffffff;
  --note-wrapper-border: #e2e8f0;
  --note-label: #64748b;
  --note-title-start: #0f172a;
  --note-input-bg: #f8fafc;
  --note-input-border: #e2e8f0;
  --checkbox-border: #cbd5e1;
  --checkbox-bg: #f1f5f9;
  --preview-text: #334155;
  --preview-code-bg: #e2e8f0;
  --preview-code-text: #be185d;
  --preview-pre-bg: #f1f5f9;
  --preview-quote-bg: #f1f5f9;
  --preview-quote-text: #475569;
  --link: #2563eb;
  --note-status-bg: #f1f5f9;
  --note-status-border: #e2e8f0;
  --note-status-error-text: #b91c1c;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 24px 16px;
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 860px;
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.theme-switcher {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-left: auto;
}

.theme-switcher label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.theme-switcher select {
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.35rem 0.7rem;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.theme-switcher select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.18);
}

h1 {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--accent);
}

.auth-block {
  display: flex;
  gap: 0.75rem;
}

.btn {
  padding: 0.6rem 1.3rem;
  border: none;
  border-radius: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface);
  color: var(--text);
}

.btn-xs {
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 0.55rem;
  box-shadow: none;
}

.btn-login {
  background: var(--surface);
  color: var(--text);
}

.btn-login:hover {
  background: var(--surface-hover);
}

.btn-register {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: white;
}

.btn-add {
  background: linear-gradient(135deg, var(--success), var(--success-soft));
  color: white;
  font-weight: 600;
}

.btn-add:hover {
  background: linear-gradient(135deg, var(--success-dark), var(--success));
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  background: var(--surface);
  padding: 1rem 1.2rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
}

.search {
  flex: 1 1 300px;
}

input[type="search"],
input[type="text"],
input[type="datetime-local"] {
  width: 100%;
  padding: 0.8rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.18);
}

input::placeholder {
  color: var(--placeholder);
}

.sort-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sort-buttons button {
  padding: 0.65rem 1.2rem;
  background: var(--surface-hover);
  color: var(--text-secondary);
  border: none;
  border-radius: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}

.sort-buttons button:hover {
  background: var(--border);
  color: var(--text);
}

.sort-buttons button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: white;
  box-shadow: 0 4px 14px rgba(59,130,246,0.35);
}

.add-task {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 2.2rem;
  flex-wrap: wrap;
}

.add-task input[type="text"] {
  flex: 1 1 340px;
}

.add-task input[type="datetime-local"] {
  flex: 0 0 220px;
  color-scheme: var(--color-scheme);
}

.add-task select {
  flex: 0 0 190px;
  padding: 0.8rem 1.1rem;
  border-radius: 0.875rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.add-task select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.18);
}

.section-title {
  background: var(--section-bg);
  padding: 0.6rem 1.2rem;
  border-radius: 0.875rem;
  border-left: 4px solid var(--accent);
  margin: 2.2rem 0 1.1rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.task {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.1rem 1.3rem;
  display: flex;
  align-items: flex-start;
  gap: 1.1rem;
  transition: all 0.22s ease;
  animation: fadeInUp 0.4s ease-out;
}

.task:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.32);
  border-color: var(--hover-border);
  background: var(--task-hover-bg);
}

.task input[type="checkbox"] {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: 4px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

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

.task input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  color: white;
  font-size: 16px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-content {
  flex: 1;
  cursor: pointer;
}

.task-text {
  font-size: 1.1rem;
  font-weight: 500;
  display: inline-block;
  margin-bottom: 0.2rem;
}

.task-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.task.done .task-text {
  text-decoration: line-through;
  color: var(--text-secondary);
  opacity: 0.78;
}

.due-badge {
  font-size: 0.78rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  margin-right: 0.5rem;
}

.due-badge.overdue { background: var(--badge-overdue-bg); color: var(--badge-overdue-text); }
.due-badge.today   { background: var(--badge-today-bg); color: var(--badge-today-text); }
.due-badge.soon    { background: var(--badge-soon-bg); color: var(--badge-soon-text); }
.due-badge.future  { background: var(--badge-future-bg); color: var(--badge-future-text); }

.due-date {
  font-size: 0.86rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.importance-badge {
  font-size: 0.78rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.importance-low {
  background: rgba(148,163,184,0.12);
  color: #9ca3af;
  border-color: rgba(148,163,184,0.4);
}

.importance-neutral {
  background: rgba(59,130,246,0.10);
  color: #93c5fd;
  border-color: rgba(59,130,246,0.45);
}

.importance-high {
  background: rgba(245,158,11,0.10);
  color: #fbbf24;
  border-color: rgba(245,158,11,0.5);
}

.importance-urgent {
  background: rgba(239,68,68,0.12);
  color: #fecaca;
  border-color: rgba(239,68,68,0.6);
}

.notes-preview {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-top: 0.35rem;
  opacity: 0.93;
}

.notes-preview:empty { display: none; }

.star, .delete {
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.22s;
  padding: 0.35rem;
  border-radius: 50%;
  line-height: 1;
  user-select: none;
}

.star {
  color: var(--text-secondary);
}

.star.favorite {
  color: var(--star);
  animation: star-pop 0.45s ease;
}

.star:hover {
  background: rgba(251,191,36,0.14);
  transform: scale(1.18);
}

.delete {
  color: var(--text-secondary);
}

.delete:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.14);
  transform: scale(1.18);
}

.empty-message {
  text-align: center;
  color: var(--text-secondary);
  padding: 3.5rem 1rem;
  font-style: italic;
  font-size: 1.1rem;
}

.status-message {
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: var(--status-bg);
  border: 1px solid var(--status-border);
  color: var(--status-text);
  font-weight: 500;
}

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

@keyframes star-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.65); }
  100% { transform: scale(1); }
}

/* ===== СТРАНИЦА ЗАМЕТОК (улучшенная) ===== */
.note-page {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem 3rem;
}

.note-wrapper {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 1.5rem;
  border-radius: 1.25rem;
  background: var(--note-wrapper-bg);
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.45);
  border: 1px solid var(--note-wrapper-border);
  animation: slideUpFade 0.5s ease-out;
  min-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

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

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.note-header-main {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.note-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.note-header .note-label {
  margin: 0;
  font-size: 0.75rem;
  color: var(--note-label);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.note-header h1 {
  margin: 0.2rem 0 0;
  font-size: 2rem;
  background: linear-gradient(135deg, var(--note-title-start), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.note-meta-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.meta-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  opacity: 0.85;
}

.meta-value {
  font-weight: 500;
}

.meta-separator {
  opacity: 0.5;
}

/* Круглая кнопка "Назад" */
.btn-circle {
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn-circle:hover {
  background: var(--surface-hover);
  transform: scale(1.1);
}

.icon-back {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-left: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
  transform: rotate(45deg) translateX(1px);
  margin-right: -2px;
}

.note-editor {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  flex: 1;
}

.editor-panel {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

.editor-live {
  flex: 1 1 520px;
}

.note-live {
  border: 1px solid var(--note-input-border);
  border-radius: 0.9rem;
  background: var(--note-input-bg);
  overflow: hidden;
  transition: border 0.2s, box-shadow 0.2s;
  cursor: text;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.note-live:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.note-live .live-editor {
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 1.1rem 1.2rem;
  border: none;
  background: transparent;
  color: var(--text);
  resize: vertical;
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

.live-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

.note-display {
  padding: 1.1rem 1.2rem;
  flex: 1;
  min-height: 0;
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.sidebar label[for="preview"],
.sidebar #previewLegacy {
  display: none;
}

.sidebar {
  flex: 0 0 280px;
}

.sidebar-section {
  padding: 0.8rem 0.9rem;
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(15, 23, 42, 0.8);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  box-sizing: border-box;
  max-width: 100%;
}

.sidebar-section .input-with-icon,
.sidebar-section select {
  width: 100%;
}

.editor-panel label,
.sidebar label {
  font-weight: 600;
  color: var(--text-secondary);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.preview-hidden {
  display: none;
}

.importance-select {
  padding: 0.55rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid var(--note-input-border);
  background: var(--note-input-bg);
  color: var(--text);
  font-size: 0.9rem;
}

.importance-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* Текстовое поле */
.editor-panel textarea {
  min-height: 320px;
  padding: 1.1rem;
  border-radius: 0.9rem;
  background: var(--note-input-bg);
  border: 1px solid var(--note-input-border);
  color: var(--text);
  resize: vertical;
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  transition: border 0.2s, box-shadow 0.2s;
}

.editor-panel textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
  outline: none;
}

/* Поле даты с иконкой */
.input-with-icon {
  display: flex;
  align-items: center;
  background: var(--note-input-bg);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  transition: border 0.2s, box-shadow 0.2s;
}

.input-with-icon:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.input-with-icon .icon {
  padding: 0 0.5rem 0 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.icon-calendar {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
  border: 2px solid currentColor;
  position: relative;
  box-sizing: border-box;
}

.icon-calendar::before,
.icon-calendar::after {
  content: "";
  position: absolute;
  top: -2px;
  width: 3px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  border: 2px solid currentColor;
  border-bottom: none;
  background: transparent;
}

.icon-calendar::before {
  left: 2px;
}

.icon-calendar::after {
  right: 2px;
}

.input-with-icon input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
}

.input-with-icon input:focus {
  outline: none;
  box-shadow: none;
}

/* Кастомные чекбоксы */
.checkbox-styled {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.checkbox-styled:hover {
  color: var(--text);
}

.checkbox-styled input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-styled .checkmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--checkbox-border);
  border-radius: 0.5rem;
  background: var(--checkbox-bg);
  transition: all 0.2s;
  font-size: 1rem;
  color: white;
}

.checkbox-styled input[type="checkbox"]:checked + .checkmark {
  background: var(--success);
  border-color: var(--success);
}

.checkbox-styled input[type="checkbox"]:checked + .checkmark::after {
  content: "✓";
}

/* Специальный стиль для избранного (звезда) */
.checkbox-styled.favorite .checkmark::before {
  content: "☆";
  font-size: 1.2rem;
  line-height: 1;
}

.checkbox-styled.favorite input[type="checkbox"]:checked + .checkmark::before {
  content: "★";
  color: var(--star);
}

.checkbox-styled.favorite .checkmark {
  border-radius: 50%; /* звёздочка лучше смотрится в круге */
}

.checkbox-styled.favorite input[type="checkbox"]:checked + .checkmark {
  background: transparent;
  border-color: var(--star);
}

.note-meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

/* Предпросмотр Markdown */
.preview-panel {
  min-height: 320px;
  padding: 1.2rem;
  border-radius: 0.9rem;
  border: 1px solid var(--note-input-border);
  background: var(--note-input-bg);
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--preview-text);
}

.preview-panel h1,
.preview-panel h2,
.preview-panel h3 {
  color: var(--accent);
  margin-top: 0.5em;
  margin-bottom: 0.3em;
  font-weight: 600;
}

.preview-panel h1 { font-size: 1.8rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.preview-panel h2 { font-size: 1.5rem; }
.preview-panel h3 { font-size: 1.3rem; }

.preview-panel p { margin: 0.8rem 0; }

.preview-panel ul, 
.preview-panel ol {
  padding-left: 1.8rem;
}

.preview-panel li { margin: 0.3rem 0; }

.preview-panel code {
  background: var(--preview-code-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  color: var(--preview-code-text);
}

.preview-panel pre {
  background: var(--preview-pre-bg);
  padding: 1rem;
  border-radius: 0.8rem;
  overflow-x: auto;
  border: 1px solid var(--border);
}

.preview-panel pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.preview-panel blockquote {
  border-left: 4px solid var(--accent);
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  background: var(--preview-quote-bg);
  border-radius: 0.5rem;
  color: var(--preview-quote-text);
}

.preview-panel a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.note-actions {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

/* Кнопка сохранения с иконкой */
.btn-save {
  background: linear-gradient(135deg, var(--success), var(--success-soft));
  color: white;
  font-weight: 600;
  padding: 0.8rem 2rem;
  border-radius: 2rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-save:hover {
  background: linear-gradient(135deg, var(--success-dark), var(--success));
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(34, 197, 94, 0.4);
}

.btn-save .btn-icon {
  margin-right: 0.45rem;
  display: inline-block;
  font-size: 0;
}

.icon-save {
  width: 1rem;
  height: 1rem;
  border-radius: 2px;
  border: 2px solid currentColor;
  position: relative;
  box-sizing: border-box;
}

.icon-save::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 4px;
  height: 2px;
  background: currentColor;
}

.icon-save::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 3px;
  right: 3px;
  height: 4px;
  border-radius: 1px;
  border: 2px solid currentColor;
  border-top: none;
}

.note-status-message {
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  background: var(--note-status-bg);
  border: 1px solid var(--note-status-border);
  transition: all 0.3s;
  font-size: 0.95rem;
}

.note-status-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--note-status-error-text);
}

@media (max-width: 640px) {
  .container {
    max-width: 100%;
    padding: 0;
  }
  body {
    padding: 16px 10px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .auth-block {
    width: 100%;
    justify-content: space-between;
  }
  .sort-buttons {
    width: 100%;
  }
  .sort-buttons button {
    flex: 1 1 45%;
    text-align: center;
  }
  .task {
    padding: 0.9rem 1rem;
  }
  .task-header-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .importance-badge {
    margin-top: 0.15rem;
  }
  .add-task {
    flex-direction: column;
  }
  .add-task input[type="datetime-local"] {
    width: 100%;
  }
  .note-editor {
    flex-direction: column;
    gap: 1.2rem;
  }
  .note-header {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-circle {
    align-self: flex-start;
  }
  .theme-switcher {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }
  .note-tools {
    width: 100%;
  }
  .note-page {
    padding: 1.2rem 0.75rem 2.4rem;
  }
  .note-wrapper {
    padding: 1rem;
    border-radius: 1rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.55);
  }
  .editor-panel,
  .sidebar {
    flex: 1 1 100%;
  }
  .preview-panel {
    min-height: 200px;
  }
  .note-live {
    min-height: 220px;
  }
  .note-live .live-editor,
  .note-display {
    min-height: 220px;
  }
  .note-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .note-status-message {
    width: 100%;
  }
  .btn-save {
    width: 100%;
    justify-content: center;
  }
}
