/* ---------- Design tokens ---------- */
:root {
  --bg: #0D0D0F;
  --card: #18181B;
  --card-2: #1C1C1E;
  --text: #FFFFFF;
  --muted: #A1A1AA;
  --accent: #FFD60A;
  --accent-dim: rgba(255, 214, 10, 0.13);
  --border: rgba(255, 255, 255, 0.07);
  --danger: #FF453A;
  --radius: 16px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

button { font-family: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid rgba(255, 214, 10, 0.5); outline-offset: 2px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 24px 0; }
.sm-text { font-size: 12px; }

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(13, 13, 15, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-title { font-size: 22px; font-weight: 700; margin: 0; }
.logo-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  margin-inline-end: 8px;
  vertical-align: -1px;
}

.header-start { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-titles { min-width: 0; }
.header-titles .app-title {
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* ---------- Buttons ---------- */
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.icon-btn:hover { background: var(--card-2); }
.icon-btn.subtle { border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.subtle:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn svg { width: 20px; height: 20px; }

.btn-accent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #111;
  border: none;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.18s var(--ease), transform 0.18s var(--ease);
}
.btn-accent:hover { filter: brightness(1.06); }
.btn-accent:active { transform: scale(0.97); }
.btn-accent svg { width: 18px; height: 18px; }
.btn-accent.lg { height: 46px; padding: 0 22px; font-size: 15px; }

.btn-ghost {
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); }

.btn-danger {
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(255, 69, 58, 0.15);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(255, 69, 58, 0.24); }

/* ---------- Main layout ---------- */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 56px;
  animation: fade 0.2s var(--ease);
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); } }
@keyframes popin { from { opacity: 0; transform: scale(0.96); } }
@keyframes slideup { from { transform: translateY(30%); } to { transform: translateY(0); } }

/* ---------- Search ---------- */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 6px 0 14px;
  height: 48px;
  margin-bottom: 18px;
  color: var(--muted);
}
.search-bar:focus-within { border-color: rgba(255, 214, 10, 0.4); color: var(--accent); }
.search-bar input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
.search-bar input::placeholder { color: var(--muted); }
.search-bar input::-webkit-search-cancel-button { display: none; }

.section-title { font-size: 14px; color: var(--muted); margin: 20px 0 10px; }

/* ---------- Lists grid & cards ---------- */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 14px;
}

.list-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.list-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.14);
  background: var(--card-2);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}
.card-top .icon-btn { margin: -6px -6px 0 0; }
.card-top-actions { display: flex; align-items: center; gap: 2px; }
.pin-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--accent);
}
.pin-ico svg { width: 15px; height: 15px; }
.pin-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.pin-title svg { width: 14px; height: 14px; color: var(--accent); }

.list-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: var(--c);
  flex: 0 0 auto;
}
.list-icon svg { width: 22px; height: 22px; }
.list-icon.sm { width: 38px; height: 38px; border-radius: 11px; }
.list-icon.sm svg { width: 19px; height: 19px; }

.list-title { margin: 0 0 4px; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.list-count { margin: 0 0 12px; font-size: 13px; color: var(--muted); }

.card-bottom { display: flex; align-items: center; gap: 8px; }
.progress {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--c, var(--accent));
  transition: width 0.25s var(--ease);
}

.card-drag { opacity: 0; transition: opacity 0.18s var(--ease); }
.list-card:hover .card-drag { opacity: 0.55; }
@media (pointer: coarse) { .card-drag { opacity: 0.35; } }

.add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 158px;
  background: transparent;
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.add-card:hover { border-color: rgba(255, 214, 10, 0.5); color: var(--accent); }
.add-card svg { width: 22px; height: 22px; }

/* ---------- Filter chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  margin-bottom: 6px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.chip:hover { color: var(--text); }
.chip.active {
  background: var(--accent-dim);
  border-color: rgba(255, 214, 10, 0.35);
  color: var(--accent);
}

/* ---------- Tasks ---------- */
.tasks { display: flex; flex-direction: column; gap: 8px; }

.task {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  min-height: 52px;
}
.task.clickable { cursor: pointer; }
.task.clickable:hover { background: var(--card-2); }

.drag-handle {
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  opacity: 0.45;
  display: inline-flex;
  flex: 0 0 auto;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 16px; height: 16px; }

.check-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
  transition: all 0.18s var(--ease);
}
.check-btn:hover { border-color: rgba(255, 214, 10, 0.6); }
.check-btn svg { width: 13px; height: 13px; stroke-width: 3; }
.check-btn.static { cursor: default; }
.task.done .check-btn {
  background: var(--accent);
  border-color: var(--accent);
}

.task-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  cursor: text;
  overflow-wrap: anywhere;
}
.task.done .task-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.3);
}

.status-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 99px;
  border: none;
  background: color-mix(in srgb, var(--sc) 13%, transparent);
  color: var(--sc);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s var(--ease);
}
.status-badge:not(.static):hover { filter: brightness(1.25); }
.status-badge.static { cursor: default; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sc); flex: 0 0 auto; }

@media (max-width: 380px) {
  .status-badge { width: 30px; padding: 0; justify-content: center; }
  .status-badge .badge-label { display: none; }
}

.completed-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  padding: 0 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.18s var(--ease);
}
.completed-toggle:hover { color: var(--text); }
.completed-toggle svg { width: 16px; height: 16px; }
.completed-count {
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 99px;
  background: rgba(48, 209, 88, 0.14);
  color: #30D158;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.completed-list { margin-top: 6px; }
.completed-list .task { opacity: 0.75; }

.task.dragging {
  position: relative;
  z-index: 60;
  pointer-events: none;
  border-color: rgba(255, 214, 10, 0.4);
  background: var(--card-2);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}
.list-card.dragging {
  z-index: 60;
  pointer-events: none;
  border-color: rgba(255, 214, 10, 0.4);
  background: var(--card-2);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

/* ---------- Add task row ---------- */
.add-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 0 14px;
  height: 52px;
  margin-top: 10px;
  color: var(--muted);
}
.add-task-row:focus-within { border-color: rgba(255, 214, 10, 0.4); color: var(--accent); }
.add-task-row input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  height: 100%;
}
.add-task-row input::placeholder { color: var(--muted); }

/* ---------- Search result chips ---------- */
.list-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  height: 26px;
  padding: 0 9px;
  border-radius: 99px;
  flex: 0 0 auto;
}
.list-chip svg { width: 13px; height: 13px; }
@media (max-width: 480px) { .list-chip { display: none; } }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 64px 16px; }
.empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.empty-icon svg { width: 30px; height: 30px; }
.empty h2 { margin: 0 0 6px; font-size: 18px; }
.empty p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

/* ---------- Overlays ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
  animation: fade 0.18s var(--ease);
}
.backdrop.transparent { background: transparent; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  z-index: 100;
  animation: pop 0.18s var(--ease);
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal > p { margin: 10px 0 0; font-size: 14px; line-height: 1.7; }

.field-label { display: block; font-size: 13px; color: var(--muted); margin: 16px 0 8px; }

.text-input {
  width: 100%;
  height: 46px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s var(--ease);
}
.text-input:focus { border-color: rgba(255, 214, 10, 0.5); }
.text-input.error { border-color: var(--danger); }
.inline-edit { height: 38px; padding: 0 10px; font-size: 15px; }

.color-row { display: flex; flex-wrap: wrap; gap: 10px; }
.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s var(--ease);
}
.color-dot:hover { transform: scale(1.1); }
.color-dot.sel {
  border-color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 40%, transparent);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
}
.icon-choice {
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.icon-choice:hover { color: var(--text); }
.icon-choice.sel {
  border-color: rgba(255, 214, 10, 0.5);
  color: var(--accent);
  background: var(--accent-dim);
}
.icon-choice svg { width: 20px; height: 20px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Recurring toggle ---------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  text-align: start;
}
.toggle-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.toggle-title { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; }
.toggle-title svg { width: 16px; height: 16px; color: var(--accent); }
.toggle-sub { font-size: 12px; color: var(--muted); line-height: 1.6; }

.switch {
  flex: 0 0 auto;
  width: 46px;
  height: 28px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  transition: background 0.2s var(--ease);
}
.switch-knob {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease);
}
.switch.on { background: var(--accent); }
.switch.on .switch-knob { transform: translateX(-18px); }

/* ---------- Start-over button (recurring lists) ---------- */
.start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 214, 10, 0.35);
  border-radius: 14px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.18s var(--ease), transform 0.18s var(--ease);
}
.start-btn:hover { filter: brightness(1.12); }
.start-btn:active { transform: scale(0.98); }
.start-btn svg { width: 17px; height: 17px; }
.start-sub { font-size: 12px; font-weight: 400; color: var(--muted); }

.repeat-ico {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
  margin-inline-end: 5px;
  color: var(--accent);
}

/* ---------- Popover & menus ---------- */
.popover {
  position: fixed;
  z-index: 100;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  min-width: 190px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  animation: popin 0.15s var(--ease);
}

.menu, .status-list { display: flex; flex-direction: column; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-align: start;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.06); }
.menu-item.danger { color: var(--danger); }
.menu-item svg { width: 17px; height: 17px; }

.status-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 10px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-align: start;
}
.status-option:hover { background: rgba(255, 255, 255, 0.06); }
.status-option.current { color: var(--accent); }
.status-option .dot { width: 9px; height: 9px; }

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: var(--card-2);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--border);
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom));
  animation: slideup 0.22s var(--ease);
  max-width: 560px;
  margin: 0 auto;
}
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
  margin: 4px auto 10px;
}
.sheet-title { margin: 0 0 8px; font-size: 14px; text-align: center; color: var(--muted); font-weight: 500; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: calc(100vh - 61px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 24px;
  text-align: center;
  animation: pop 0.2s var(--ease);
}
.login-card .empty-icon { margin-bottom: 14px; }
.login-title { margin: 0 0 6px; font-size: 24px; }
.login-card > p { margin: 0 0 20px; font-size: 14px; }
.pin-input {
  width: 100%;
  height: 60px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 26px;
  letter-spacing: 10px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s var(--ease);
}
.pin-input:focus { border-color: rgba(255, 214, 10, 0.5); }
.pin-input::placeholder { letter-spacing: 4px; color: var(--muted); }
.login-btn { width: 100%; margin-top: 14px; }
.login-btn:disabled { opacity: 0.6; cursor: wait; }
.login-error { color: var(--danger); font-size: 13px; margin: 12px 0 0; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(6px); }
  50% { transform: translateX(-6px); }
  75% { transform: translateX(4px); }
}
.login-card.shake { animation: shake 0.3s var(--ease); }

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
  .btn-accent .btn-text { display: none; }
  .btn-accent:not(.lg) { width: 40px; padding: 0; }
  .app-title { font-size: 20px; }
  .main { padding: 16px 14px 48px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .icon-btn.sm { min-width: 40px; min-height: 40px; }
  .task { min-height: 56px; }
  .modal-actions .btn-ghost, .modal-actions .btn-accent, .modal-actions .btn-danger { min-height: 44px; }
}
