:root {
  --bg: #090a0f;
  --bg-surface: #12151e;
  --bg-card: #171b26;
  --bg-card-hover: #1f2535;
  --border: #23293a;
  --border-focus: #0a84ff;
  
  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-done: #475569;
  
  /* Цветовая палитра Pop!_OS / Apple Design */
  --apple-blue: #0a84ff;
  --apple-purple: #bf5af2;
  --apple-orange: #ff9f0a;
  --apple-green: #30d158;
  --apple-teal: #00c7be;
  --apple-red: #ff453a;
  --apple-yellow: #ffd60a;

  --accent: var(--apple-blue);
  --success: var(--apple-green);
  --warning: var(--apple-orange);
  --purple: var(--apple-purple);
  --danger: var(--apple-red);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --safe-top: env(safe-area-inset-top, 16px);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, textarea, select {
  user-select: auto;
  font-family: inherit;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--safe-bottom) + 85px);
}

/* Toast уведомления */
.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  background: rgba(23, 27, 38, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.toast-error {
  border-color: rgba(255, 69, 58, 0.4);
  color: #fca5a5;
  background: rgba(35, 15, 18, 0.95);
}

.toast.toast-success {
  border-color: rgba(48, 209, 88, 0.4);
  color: #6ee7b7;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 10, 15, 0.90);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  padding: 10px 16px 8px;
  border-bottom: 1px solid rgba(35, 41, 58, 0.5);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.app-title .logo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--apple-green);
  box-shadow: 0 0 10px var(--apple-green);
  transition: all 0.3s;
}

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

.icon-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.icon-btn:active {
  transform: scale(0.92);
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.icon-btn.badge::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--apple-orange);
}

/* Search Bar (Поиск) */
.search-bar-wrap {
  display: none;
  margin-bottom: 10px;
  animation: fadeIn 0.2s;
}

.search-bar-wrap.open {
  display: block;
}

.search-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  gap: 8px;
}

.search-input-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 14px;
}

.search-input-box button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

/* 1. Категории проектов (горизонтальный скролл) */
.project-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.project-pills::-webkit-scrollbar {
  display: none;
}

.pill {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill .p-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pill .count {
  font-size: 11px;
  opacity: 0.6;
}

.pill.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.pill.active .count {
  opacity: 0.95;
}

/* 2. Статусы: ВСЕ - Беклог - Начал - В Процессе - Готово */
.status-tabs-wrap {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 16px 4px;
  background: var(--bg);
  position: sticky;
  top: 96px;
  z-index: 40;
}
.status-tabs-wrap::-webkit-scrollbar {
  display: none;
}

.status-tab {
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.status-tab .tab-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
}

.status-tab.active {
  color: #fff;
  background: var(--bg-card);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.status-tab[data-status="all"].active {
  border-color: rgba(255, 255, 255, 0.3);
}

.status-tab[data-status="backlog"].active {
  border-color: var(--apple-purple);
  color: #e9d5ff;
}
.status-tab[data-status="backlog"] .sym { color: var(--apple-purple); }

.status-tab[data-status="started"].active {
  border-color: var(--apple-blue);
  color: #bfdbfe;
}
.status-tab[data-status="started"] .sym { color: var(--apple-blue); }

.status-tab[data-status="in_progress"].active {
  border-color: var(--apple-orange);
  color: #fed7aa;
}
.status-tab[data-status="in_progress"] .sym { color: var(--apple-orange); }

.status-tab[data-status="done"].active {
  border-color: var(--apple-green);
  color: #bbf7d0;
}
.status-tab[data-status="done"] .sym { color: var(--apple-green); }

/* Notes Container */
.notes-container {
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

/* Note Card */
.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  position: relative;
}

.note-card:active {
  background: var(--bg-card-hover);
}

.note-card.is-done {
  opacity: 0.55;
  background: rgba(23, 27, 38, 0.45);
  border-color: rgba(35, 41, 58, 0.4);
}

.note-card.is-done .note-text {
  text-decoration: line-through;
  color: var(--text-done);
}

/* Custom Checkbox */
.checkbox-btn {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--text-muted);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.checkbox-btn:active {
  transform: scale(0.85);
}

.checkbox-btn.checked {
  background: var(--apple-green);
  border-color: var(--apple-green);
  transform: scale(1.04);
}

.checkbox-btn svg {
  display: none;
  width: 14px;
  height: 14px;
  stroke: white;
  stroke-width: 3;
}

.checkbox-btn.checked svg {
  display: block;
}

/* Note Content */
.note-body {
  flex: 1;
  min-width: 0;
}

.note-text {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-main);
  word-break: break-word;
  cursor: pointer;
}

/* 3. Описания из карточек майнд-борда */
.note-desc-box {
  background: rgba(18, 21, 30, 0.6);
  border: 1px solid rgba(35, 41, 58, 0.6);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.45;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  cursor: pointer;
}

.note-desc-box.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.desc-expand-btn {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--apple-blue);
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Бейджи статусов с Apple-стилями */
.meta-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-chip:active {
  transform: scale(0.94);
}

.meta-chip.project {
  background: rgba(10, 132, 255, 0.14);
  color: #60a5fa;
  border: 1px solid rgba(10, 132, 255, 0.3);
}

.meta-chip.status-backlog {
  background: rgba(191, 90, 242, 0.16);
  color: #e9d5ff;
  border: 1px solid rgba(191, 90, 242, 0.38);
}

.meta-chip.status-started {
  background: rgba(10, 132, 255, 0.16);
  color: #93c5fd;
  border: 1px solid rgba(10, 132, 255, 0.38);
}

.meta-chip.status-in_progress {
  background: rgba(255, 159, 10, 0.16);
  color: #fed7aa;
  border: 1px solid rgba(255, 159, 10, 0.38);
}

.meta-chip.status-done {
  background: rgba(48, 209, 88, 0.16);
  color: #86efac;
  border: 1px solid rgba(48, 209, 88, 0.38);
}

.note-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Bottom Quick Capture Bar (Fixed above safe area) */
.quick-capture-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(14, 17, 24, 0.95);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(var(--safe-bottom) + 8px);
}

.capture-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.capture-input-wrap {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  padding: 4px 6px 4px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.capture-input-wrap:focus-within {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.2);
}

.capture-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 15px;
  min-width: 0;
}

.capture-input::placeholder {
  color: var(--text-muted);
}

.project-select-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  margin-right: 4px;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

.project-select-btn:active {
  background: var(--bg-card-hover);
}

.capture-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--apple-blue);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, background-color 0.15s;
  box-shadow: 0 2px 10px rgba(10, 132, 255, 0.4);
}

.capture-btn:active {
  transform: scale(0.9);
  background: #0071e3;
}

/* Modal Bottom Sheets */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: flex-end;
}

.modal-overlay.open {
  display: flex;
}

.modal-sheet {
  background: var(--bg-surface);
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 20px calc(var(--safe-bottom) + 20px);
  border-top: 1px solid var(--border);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: -8px auto 6px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 18px;
}

.modal-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: -6px;
}

.modal-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.modal-input:focus {
  border-color: var(--apple-blue);
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-primary {
  flex: 1;
  background: var(--apple-blue);
  color: white;
  border: none;
  padding: 13px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:active {
  background: #0071e3;
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.btn-danger {
  background: rgba(255, 69, 58, 0.15);
  border: 1px solid rgba(255, 69, 58, 0.3);
  color: #ff8b82;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

/* Выбор проекта в модалке */
.project-choice-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.project-choice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 15px;
}

.project-choice-item.selected {
  border-color: var(--apple-blue);
  background: rgba(10, 132, 255, 0.12);
  color: #93c5fd;
}
