:root {
  --accent: #E24B4A;
  --bg: #100E11;
  --surface: #1C1A1E;
  --surface-2: #262327;
  --border: #322E33;
  --text: #F5F3F2;
  --text-secondary: #A8A3A6;
  --text-muted: #6E6A6D;
  --danger: #E24B4A;
  --success: #3FBF8F;
  --p1: #E8703A;
  --p2: #F2C24C;
  --p3: #4FA8E8;
  --p4: #6E6A6D;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100vh; }
#app:has(.navbar) { padding-bottom: 76px; }

.screen { padding: 20px 16px 8px; max-width: 480px; margin: 0 auto; }

h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin: 20px 0 8px; }
p { margin: 0; }

.muted { color: var(--text-secondary); font-size: 13px; }
.hint { color: var(--text-muted); font-size: 12px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; }
.brand i { color: var(--accent); font-size: 20px; }
.sidebar-brand { display: none; }
.list-title-row { display: flex; align-items: center; justify-content: center; position: relative; margin-bottom: 18px; }
.list-title-row h1 { text-align: center; }
.add-list-btn { position: absolute; right: 0; top: 0; }

.fab-add-task {
  position: fixed; bottom: calc(92px + env(safe-area-inset-bottom)); right: 20px;
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff;
  border: none; font-size: 22px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 14px rgba(226,75,74,0.4); z-index: 90;
}

.task-card {
  background: var(--surface); border-radius: 14px; padding: 14px; margin-bottom: 10px;
}
.task-top { display: flex; align-items: flex-start; gap: 10px; }
.task-checkbox {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-muted);
  flex-shrink: 0; cursor: pointer; margin-top: 1px; background: transparent;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.task-checkbox.checked { background: var(--success); border-color: var(--success); color: var(--bg); }
.task-text { flex: 1; font-size: 14px; cursor: pointer; line-height: 1.4; }
.task-text.done { text-decoration: line-through; color: var(--text-secondary); }

.priority-pill { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 99px; flex-shrink: 0; }
.priority-1 { background: rgba(232,112,58,0.18); color: var(--p1); }
.priority-2 { background: rgba(242,194,76,0.18); color: var(--p2); }
.priority-3 { background: rgba(79,168,232,0.18); color: var(--p3); }
.priority-4 { background: var(--surface-2); color: var(--text-muted); }

.task-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; flex-shrink: 0; }
.task-delete:hover { color: var(--danger); }

.image-row { display: flex; gap: 8px; margin-top: 10px; padding: 8px 0 2px 32px; overflow-x: auto; }
.image-thumb-wrapper { position: relative; flex-shrink: 0; }
.image-thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; display: block; cursor: pointer; background: var(--surface-2); }
.image-delete-btn {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 2px solid var(--surface); font-size: 9px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.image-add-tile {
  width: 64px; height: 64px; border-radius: 8px; border: 1.5px dashed var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; background: none;
}
.add-photo-pill {
  display: inline-flex; align-items: center; gap: 6px; margin: 10px 0 0 32px;
  border: 1.5px dashed var(--border); border-radius: 999px; background: none; color: var(--text-muted);
  font-size: 12px; padding: 6px 12px; cursor: pointer;
}

.priority-pill { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px; flex-shrink: 0; }
.priority-1 { background: rgba(232,112,58,0.18); color: var(--p1); }
.priority-2 { background: rgba(242,194,76,0.18); color: var(--p2); }
.priority-3 { background: rgba(79,168,232,0.18); color: var(--p3); }

.task-row { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 10px; touch-action: pan-y; }
.drag-handle {
  background: none; border: none; color: var(--text-muted); cursor: grab; padding: 14px 4px;
  flex-shrink: 0; touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.task-row .task-card { flex: 1; margin-bottom: 0; }
.task-row.dragging { opacity: 0.5; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 32px; margin-bottom: 10px; }

button, .btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  border-radius: 12px; padding: 13px 16px; border: none; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-secondary { background: var(--surface-2); color: var(--text); width: 100%; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); width: 100%; }
.btn-small { padding: 8px 12px; font-size: 13px; border-radius: 10px; width: auto; }
.btn-icon { background: transparent; color: var(--text-secondary); padding: 6px; font-size: 18px; border: none; cursor: pointer; }

input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 12px 14px; font-size: 15px;
  font-family: inherit; margin-bottom: 12px;
}
label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }

.toggle-row { display: flex; gap: 8px; margin-bottom: 14px; }
.toggle-btn { flex: 1; padding: 10px 6px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary); font-size: 12px; cursor: pointer; }
.toggle-btn.active-1 { background: rgba(232,112,58,0.18); color: var(--p1); border-color: var(--p1); }
.toggle-btn.active-2 { background: rgba(242,194,76,0.18); color: var(--p2); border-color: var(--p2); }
.toggle-btn.active-3 { background: rgba(79,168,232,0.18); color: var(--p3); border-color: var(--p3); }
.toggle-btn.active-4 { background: var(--surface); color: var(--text); border-color: var(--text-muted); }

.error-text { color: var(--danger); font-size: 13px; margin: 8px 0; }

.sidebar-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  color: var(--text-secondary); cursor: pointer; font-size: 14px; margin-bottom: 2px;
}
.sidebar-item.active { background: var(--surface); color: var(--text); }
.sidebar-item i { font-size: 16px; width: 18px; text-align: center; }
.sidebar-count { margin-left: auto; font-size: 12px; color: var(--text-muted); }

.navbar {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border);
  display: flex; padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto;
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: none; color: var(--text-muted); font-size: 10px; padding: 6px 2px; }
.nav-item .nav-icon { font-size: 20px; }
.nav-item.active { color: var(--accent); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: flex-end; justify-content: center; z-index: 200; }
.modal-sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 16px; width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }

#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 12px; font-size: 13px; z-index: 999;
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none;
  max-width: 90%; display: flex; align-items: center; gap: 12px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast button { background: none; border: none; color: var(--accent); font-weight: 700; cursor: pointer; padding: 0; font-size: 13px; }

.lightbox-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 300; display: flex; align-items: center; justify-content: center; }
.lightbox-img { max-width: 92vw; max-height: 80vh; object-fit: contain; border-radius: 8px; }
.lightbox-close { position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.1); border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.1); border: none; color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-counter { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.7); font-size: 13px; }

@media (min-width: 900px) {
  #app:has(.navbar) { padding-left: 220px; padding-bottom: 24px; }
  .screen { max-width: 640px; padding: 36px 40px 16px; }
  .navbar {
    position: fixed; left: 0; top: 0; bottom: 0; right: auto; width: 220px; max-width: none;
    margin: 0; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 28px 12px;
    border-top: none; border-right: 1px solid var(--border);
  }
  .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; font-size: 14px; padding: 13px 16px; border-radius: 12px; width: 100%; }
  .nav-item.active { background: rgba(226,75,74,0.12); }
  .nav-item .nav-icon { font-size: 17px; width: 22px; text-align: center; }
  .sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 6px 16px 22px; font-size: 17px; font-weight: 700; }
  .sidebar-brand i { color: var(--accent); font-size: 18px; }
  .fab-add-task { bottom: 28px; }
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: 20px; max-width: 520px; }
}
