:root {
  --bg: #1a1b2e;
  --surface: #232540;
  --surface-hover: #2a2d4a;
  --border: #363960;
  --text: #e8e8f0;
  --text-muted: #8888a8;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --danger: #ff4757;
  --warning: #ffa502;
  --success: #2ed573;
  --business: #4facfe;
  --private: #f093fb;
  --priority-high: #ff4757;
  --priority-medium: #ffa502;
  --priority-low: #2ed573;
  --priority-none: #666;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* === Auth Screen === */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
}

.auth-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.auth-box h1 {
  font-size: 24px;
  margin-bottom: 24px;
  text-align: center;
}

.auth-box input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 16px;
}

.auth-box button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
}

.auth-box button:hover { background: var(--accent-hover); }

.auth-error {
  color: var(--danger);
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  display: none;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.header h1 {
  font-size: 18px;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* === Tab Switcher === */
.tab-switcher {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.tab {
  padding: 6px 14px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent);
  color: white;
}

.tab:not(.active):hover {
  color: var(--text);
}

.tab-count {
  font-weight: 500;
  opacity: 0.7;
  font-size: 12px;
}

/* === Filter Bar === */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar input,
.filter-bar select {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}

.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--accent);
}

.search-input {
  flex: 1;
  min-width: 150px;
}

/* === Task List === */
.task-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.task-list.hidden { display: none; }

.cards-container {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* === Cards (compact row) === */
.card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}

.card:hover {
  background: var(--surface-hover);
}

.card.dragging { opacity: 0.4; }
.card.drag-over-above { border-top: 2px solid var(--accent); }
.card.drag-over-below { border-bottom: 2px solid var(--accent); }

/* Type badge: compact dot/label */
.badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-business { background: rgba(79,172,254,0.15); color: var(--business); }
.badge-private { background: rgba(240,147,251,0.15); color: var(--private); }

/* Priority badge */
.badge-priority {
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: center;
}

.priority-high { background: rgba(255,71,87,0.15); color: var(--priority-high); }
.priority-medium { background: rgba(255,165,2,0.15); color: var(--priority-medium); }
.priority-low { background: rgba(46,213,115,0.15); color: var(--priority-low); }
.priority-none { background: rgba(102,102,102,0.1); color: var(--priority-none); }

/* Content: title + subtitle in one truncated line */
.card-content {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  line-height: 1.3;
}

.card-title-text {
  font-weight: 500;
}

.card-sep {
  color: var(--border);
  margin: 0 4px;
}

.card-subtitle-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* Date */
.card-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.due-overdue { color: var(--danger); font-weight: 600; }
.due-soon { color: var(--warning); font-weight: 600; }

/* Actions: right side */
.card-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
  align-items: center;
}

.card:hover .card-actions { display: flex; }

.card-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  border-radius: 3px;
}

.card-action-btn:hover { color: var(--text); background: var(--bg); }

.card-swipe-done {
  display: none;
  padding: 2px 6px;
  background: var(--success);
  color: white;
  border: none;
  border-radius: 3px;
  font-size: 10px;
  cursor: pointer;
  font-weight: 600;
}

.card:hover .card-swipe-done { display: inline-block; }

/* === Load More === */
.load-more {
  padding: 12px 0;
  text-align: center;
}

.load-more button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 24px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

.load-more button:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* === Buttons === */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-done { background: var(--success); color: white; }
.btn-done:hover { background: #28c064; }
.btn-ghost { background: none; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }

.btn-add {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-add:hover { background: var(--accent-hover); }

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 16px; }

.modal-body { padding: 20px; }

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.modal-footer .btn-danger { margin-right: auto; }
.modal-footer .btn-done { margin-right: auto; }

/* === Private Mode === */
.private-mode.task-list .cards-container { display: none; }
.private-mode.filter-bar { display: none; }
.private-mode.tab-switcher { display: none; }

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .header { padding: 10px 12px; }
  .header h1 { font-size: 16px; }

  .filter-bar { padding: 8px 12px; gap: 6px; }

  .task-list { padding: 6px 8px; }

  .card { padding: 6px 8px; gap: 6px; }
  .card-content { font-size: 12px; }
  .card-subtitle-text { display: none; }
  .card-sep { display: none; }
  .card-actions { display: flex; }
  .card-swipe-done { display: inline-block; }

  .tab { padding: 5px 10px; font-size: 12px; }
}

@media (max-width: 480px) {
  .header-actions { flex-wrap: wrap; }
  .form-row { flex-direction: column; gap: 0; }
  .header h1 { font-size: 15px; }
  .card-date { display: none; }
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card { animation: fadeIn 0.15s ease-out; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* === Loading === */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}
