:root {
  --bg: #0f172a;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #3b82f6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #1f2937;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-24: 24px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(1200px 800px at 20% 0%, #111c3a 0%, #0b1224 45%, #080f1d 100%);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

input, button, select, textarea {
  background: #0b1120;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  min-height: 40px;
}
input, select, textarea { width: 100%; }
textarea { min-height: 90px; resize: vertical; }
button { cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
button:hover { background: #162136; border-color: #27324d; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--border); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

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

/* Gate */
body.gate {
  display: grid;
  place-items: center;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: 14px;
  width: min(420px, 92vw);
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.auth-card form { display: grid; gap: 10px; }

/* Navbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-actions { display: flex; align-items: center; gap: var(--space-12); }
.logo { font-weight: 700; letter-spacing: 0.5px; }
.user-pill {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: var(--space-8);
  padding: var(--space-12) 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
}
.tab {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
}
.tab.active { background: #111827; color: var(--text); }

.container { padding: 20px; max-width: 1200px; margin: 0 auto; }
.section { display: none; }
.section.active { display: block; }

.actions-bar {
  display: grid;
  grid-template-columns: 160px 1fr 180px 220px 180px;
  gap: var(--space-12);
  align-items: center;
  margin-bottom: var(--space-16);
}

.focus-grid {
  display: grid;
  gap: var(--space-12);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: var(--space-16);
}
.focus-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: var(--space-16);
  display: grid;
  gap: var(--space-8);
  cursor: pointer;
}
.focus-card h4 { margin: 0; font-size: 14px; color: var(--muted); }
.focus-count { font-size: 20px; font-weight: 700; }
.focus-list { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }

.toggle-row { display: flex; gap: var(--space-16); align-items: center; margin-bottom: var(--space-12); }
.toggle { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
.toggle input { width: auto; }

.filters-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-12);
  margin-bottom: var(--space-16);
  flex-wrap: wrap;
}
.summary { color: var(--muted); font-size: 13px; }
.filters-actions { display: flex; align-items: center; gap: var(--space-8); flex-wrap: wrap; }

.tasks-grid {
  display: grid;
  gap: var(--space-16);
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.task-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}
.task-card:hover { box-shadow: 0 12px 30px rgba(0,0,0,0.25); transform: translateY(-2px); }
.task-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.task-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 13px; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.task-desc { border-top: 1px solid var(--border); padding-top: 8px; font-size: 14px; }
.task-desc pre { white-space: pre-wrap; font-family: inherit; color: var(--muted); }
.task-desc-preview { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-desc-preview { line-height: 1.4; }
.progress { height: 6px; background: #0b1120; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.urgency { font-size: 12px; border-radius: 999px; padding: 2px 8px; border: 1px solid var(--border); }
.urgency.urgent { color: var(--danger); }
.urgency.priority { color: var(--warning); }
.urgency.normal { color: var(--muted); }
.img-count { font-size: 12px; color: var(--muted); }

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge.not-done { background: rgba(59,130,246,0.12); color: var(--accent); }
.badge.in-progress { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge.done { background: rgba(34,197,94,0.12); color: var(--success); }
.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  display: inline-block;
}
.overdue { color: var(--danger); font-weight: 600; }
.overdue-label { color: var(--danger); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
}
.thumb-wrap { position: relative; display: inline-flex; }
.thumb-wrap::after {
  content: "zoom";
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.5);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.thumb-wrap:hover::after { opacity: 1; }
.thumb-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0b1120;
  font-size: 12px;
  line-height: 16px;
  padding: 0;
}

.stack { display: grid; gap: 12px; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.stats-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0b1120;
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.success { border-color: rgba(34,197,94,0.4); }
.toast.error { border-color: rgba(239,68,68,0.4); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  z-index: 30;
}
.modal-overlay.open { display: block; }
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 40;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-content {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  width: min(640px, 95vw);
  box-shadow: 0 25px 70px rgba(0,0,0,0.4);
  transform: scale(0.98);
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.modal.open .modal-content { transform: scale(1); opacity: 1; }
.modal-content.image-modal {
  width: min(900px, 95vw);
  padding: 10px;
  position: relative;
}
.modal-content.image-modal img {
  width: 100%;
  height: auto;
  border-radius: 12px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-body { display: grid; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal-actions.split { justify-content: space-between; }
.inline { display: grid; gap: 8px; }
.label { font-weight: 600; font-size: 13px; color: var(--muted); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

.icon-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 36px;
  min-width: 36px;
  border-radius: 999px;
}
.icon-btn.nav { top: 50%; transform: translateY(-50%); }
.icon-btn.nav.left { left: 10px; right: auto; }
.icon-btn.nav.right { right: 10px; }

.checklist { display: grid; gap: 6px; }
.checklist-item { display: flex; align-items: center; gap: 8px; }
.checklist-row { display: flex; gap: 8px; }
.checklist-row input { flex: 1; }

.palette { display: grid; gap: 6px; }
.palette-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.palette-item.active { border-color: var(--accent); background: rgba(59,130,246,0.1); }

@media (max-width: 980px) {
  .actions-bar {
    grid-template-columns: 1fr;
  }
}
