*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --surface: #141414;
  --surface2: #1a1a1a;
  --border: #222;
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --text: #e8e8e8;
  --muted: #888;
  --radius: 12px;
  --state-not-started: #6c63ff;
  --state-in-progress: #f59e0b;
  --state-blocked: #ef4444;
  --state-done: #22c55e;
}

html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── NAV ────────────────────────────────────────────────────────── */
.topnav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 5vw; height: 56px;
  background: rgba(13,13,13,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topnav-logo {
  font-size: 1rem; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text);
  text-decoration: none;
}
.topnav-logo span { color: var(--accent); }
.topnav-right { display: flex; align-items: center; gap: 12px; }

/* ── BUTTONS ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border: none; border-radius: 8px;
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* ── AUTH MODAL ─────────────────────────────────────────────────── */
.auth-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px; max-width: 400px; width: 92%;
}
.auth-card h2 {
  font-size: 1.25rem; margin-bottom: 20px;
  text-align: center;
}
.auth-tabs {
  display: flex; gap: 6px; margin-bottom: 20px;
}
.auth-tab {
  flex: 1; padding: 8px; text-align: center;
  background: transparent; border: 1px solid var(--border);
  border-radius: 8px; color: var(--muted);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.auth-tab.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.auth-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #f87171; border-radius: 8px;
  padding: 10px 12px; font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ── FORMS ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; margin-bottom: 4px;
  font-size: 0.8rem; color: var(--muted);
}
.form-input {
  width: 100%; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-size: 0.9rem; outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }
.form-hint {
  font-size: 0.8rem; color: var(--muted);
  margin-bottom: 14px;
}
.form-submit { width: 100%; margin-top: 8px; }
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 0; color: var(--muted); font-size: 0.8rem;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── HERO (landing page) ───────────────────────────────────────── */
.hero {
  text-align: center; padding: 100px 5vw 60px;
  max-width: 700px; margin: 0 auto;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800; letter-spacing: -0.03em;
  line-height: 1.15; margin-bottom: 16px;
}
.hero h1 span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p {
  font-size: 1.1rem; color: var(--muted);
  max-width: 540px; margin: 0 auto 28px;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; }

/* ── FEATURES ──────────────────────────────────────────────────── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px; padding: 40px 5vw 60px;
  max-width: 960px; margin: 0 auto;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.feature-card h3 { font-size: 1rem; margin-bottom: 8px; }
.feature-card p { font-size: 0.9rem; color: var(--muted); }

/* ── DASHBOARD ─────────────────────────────────────────────────── */
.dashboard-container {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: calc(100vh - 56px);
}

#dashboard-loading {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.95rem;
}

/* Sidebar */
.dashboard-sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 12px;
  background: var(--surface);
}
.sidebar-group-label {
  font-size: 0.7rem; text-transform: uppercase;
  color: var(--muted); letter-spacing: 0.05em;
  margin: 16px 0 6px 8px;
}
.sidebar-item {
  padding: 7px 10px; border-radius: 6px;
  font-size: 0.85rem; cursor: pointer;
  color: var(--text); transition: background 0.1s;
}
.sidebar-item:hover { background: var(--surface2); }
.sidebar-item.active { background: var(--accent); color: #fff; }
.sidebar-empty { color: var(--muted); font-size: 0.85rem; padding: 8px; }

/* Main area */
.dashboard-main {
  overflow-y: auto; padding: 24px 28px;
}

/* Stats bar */
.stats-bar {
  display: flex; gap: 20px; margin-bottom: 24px;
  flex-wrap: wrap;
}
.stat-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 16px;
}
.stat-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.stat-num { font-weight: 700; font-size: 1.1rem; }
.stat-label { font-size: 0.8rem; color: var(--muted); }

/* Task list */
.task-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.task-row:hover { background: var(--surface); }
.task-state-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.task-text { flex: 1; font-size: 0.9rem; }
.task-tag {
  font-size: 0.75rem; color: var(--accent);
  background: rgba(108,99,255,0.1);
  padding: 3px 8px; border-radius: 4px;
}
.task-date { font-size: 0.8rem; color: var(--muted); }
.task-state-label { font-size: 0.75rem; color: var(--muted); min-width: 70px; text-align: right; }
.task-toggle {
  width: 16px; height: 16px; flex-shrink: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.7rem; transition: transform 0.15s;
}
.task-toggle::before { content: '\25B6'; }
.task-toggle.expanded { transform: rotate(90deg); }
.task-toggle:hover { color: var(--fg); }
.task-toggle-spacer { width: 16px; flex-shrink: 0; }

.empty-state {
  text-align: center; color: var(--muted);
  padding: 40px 20px; font-size: 0.95rem;
}

/* ── VIEW TABS ─────────────────────────────────────────────────── */
.view-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border); padding-bottom: 12px;
}
.view-tab {
  padding: 7px 16px; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.view-tab:hover { color: var(--text); background: var(--surface); }
.view-tab.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}

/* ── BOARD VIEW (Kanban) ──────────────────────────────────────── */
.board-container {
  display: flex; gap: 14px; overflow-x: auto;
  padding-bottom: 12px; min-height: 300px;
}
.board-column {
  flex: 1; min-width: 220px; max-width: 320px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
}
.board-column-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 0.82rem; font-weight: 600;
}
.board-col-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.board-col-label { flex: 1; }
.board-col-count {
  font-size: 0.75rem; color: var(--muted);
  background: var(--surface2); padding: 2px 7px; border-radius: 10px;
}
.board-column-body {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.board-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
.board-card-text { font-size: 0.85rem; margin-bottom: 6px; }
.board-card-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.board-empty { color: var(--muted); font-size: 0.82rem; text-align: center; padding: 16px 0; }

/* ── TIMELINE VIEW (Gantt) ────────────────────────────────────── */
.timeline-container { overflow-x: auto; }
.timeline-header, .timeline-row {
  display: flex; min-width: 800px;
}
.timeline-header { border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.timeline-label-col {
  width: 200px; min-width: 200px; flex-shrink: 0;
  padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.timeline-task-name { font-size: 0.82rem; }
.timeline-bar-area {
  flex: 1; position: relative; height: 32px;
}
.timeline-header .timeline-bar-area { height: 28px; }
.timeline-bar {
  position: absolute; top: 6px; height: 20px;
  border-radius: 4px; min-width: 6px; opacity: 0.85;
}
.timeline-bar:hover { opacity: 1; }
.timeline-month-marker {
  position: absolute; top: 0; font-size: 0.7rem; color: var(--muted);
  border-left: 1px solid var(--border); padding-left: 4px; height: 100%;
  display: flex; align-items: center;
}
.timeline-today {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--accent); opacity: 0.6; z-index: 1;
}
.timeline-row { border-bottom: 1px solid rgba(255,255,255,0.03); }
.timeline-row:hover { background: var(--surface); }

/* ── CALENDAR VIEW ────────────────────────────────────────────── */
.calendar-nav {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.calendar-month-label { font-size: 1rem; font-weight: 700; min-width: 160px; text-align: center; }
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.calendar-day-header {
  text-align: center; font-size: 0.75rem; font-weight: 600;
  color: var(--muted); padding: 8px 4px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.calendar-day {
  min-height: 100px; padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.calendar-day:nth-child(7n) { border-right: none; }
.calendar-day.empty { background: var(--surface); }
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.calendar-day-num { font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.calendar-day.today .calendar-day-num { color: var(--accent); }
.calendar-task-chip {
  font-size: 0.72rem; padding: 2px 5px; margin-bottom: 3px;
  background: var(--surface); border-radius: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.calendar-more { font-size: 0.7rem; color: var(--muted); }

/* ── TASK DETAIL PANEL ─────────────────────────────────────────── */
.detail-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.6);
  display: flex; justify-content: flex-end;
}
.detail-panel {
  width: 480px; max-width: 92vw; height: 100%;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.detail-header h2 { font-size: 1rem; font-weight: 700; flex: 1; margin-right: 12px; }
.detail-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.detail-meta {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
.detail-state-badge {
  font-size: 0.75rem; color: #fff; padding: 3px 10px;
  border-radius: 10px; font-weight: 600;
}
.detail-dates {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 10px 14px; background: var(--bg); border-radius: 8px;
}
.detail-date-item { display: flex; flex-direction: column; gap: 2px; font-size: 0.82rem; }
.detail-date-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-section { margin-bottom: 20px; }
.detail-section-label {
  font-size: 0.75rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 8px; font-weight: 600;
}
.detail-reflection {
  font-size: 0.88rem; line-height: 1.65; color: var(--text);
  padding: 12px 14px; background: var(--bg); border-radius: 8px;
  white-space: pre-wrap;
}
.detail-checklist { display: flex; flex-direction: column; gap: 6px; }
.detail-check-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; padding: 6px 10px;
  background: var(--bg); border-radius: 6px;
}
.detail-check-box {
  width: 16px; height: 16px; border-radius: 4px;
  border: 2px solid var(--border); flex-shrink: 0;
}
.detail-check-box.checked {
  background: #22c55e; border-color: #22c55e;
}
.detail-check-done { text-decoration: line-through; color: var(--muted); }
.detail-subtasks { display: flex; flex-direction: column; gap: 4px; }
.detail-subtask-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; padding: 7px 10px;
  background: var(--bg); border-radius: 6px; cursor: pointer;
}
.detail-subtask-row:hover { background: var(--surface2); }
.detail-empty { color: var(--muted); font-size: 0.88rem; padding: 20px 0; text-align: center; }
.detail-canvas-wrap {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; padding: 8px;
}
.canvas-svg { width: 100%; height: auto; min-height: 200px; max-height: 360px; display: block; }
.detail-canvas-loading { color: var(--muted); font-size: 0.85rem; padding: 12px 0; }

/* ── FOOTER ────────────────────────────────────────────────────── */
.footer {
  text-align: center; padding: 40px 20px;
  color: var(--muted); font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ── MOBILE ────────────────────────────────────────────────────── */
#sidebar-toggle { display: none; }

@media (max-width: 768px) {
  .dashboard-container { grid-template-columns: 1fr; }
  .dashboard-sidebar {
    display: none; position: fixed;
    inset: 56px 0 0 0; z-index: 100;
    width: 260px;
  }
  .dashboard-sidebar.mobile-open { display: block; }
  #sidebar-toggle { display: inline-flex; }
  .hero { padding: 60px 5vw 40px; }
  .hero-actions { flex-direction: column; align-items: center; }
}
