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

:root {
  --bg: #0a0a1a;
  --bg2: #0f1025;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-hover: rgba(255, 255, 255, 0.18);
  --text: #e8eaf6;
  --text2: rgba(255, 255, 255, 0.5);
  --text3: rgba(255, 255, 255, 0.3);
  --accent: #667eea;
  --accent2: #764ba2;
  --accent-glow: rgba(102, 126, 234, 0.3);
  --green: #56ab2f;
  --green-glow: rgba(86, 171, 47, 0.25);
  --orange: #f59e0b;
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.15);
  --yellow: #eab308;
  --blue: #3b82f6;
  --radius: 16px;
  --radius-sm: 12px;
}

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Animated Background ── */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-glow .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: orbFloat 20s ease-in-out infinite;
}

.bg-glow .orb:nth-child(1) {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(102,126,234,0.4), transparent 70%);
  top: -10%; left: -5%;
  animation-delay: 0s;
}

.bg-glow .orb:nth-child(2) {
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(118,75,162,0.3), transparent 70%);
  bottom: -5%; right: -5%;
  animation-delay: -7s;
}

.bg-glow .orb:nth-child(3) {
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(56,171,47,0.2), transparent 70%);
  top: 40%; left: 50%;
  animation-delay: -14s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ── Container ── */
.container {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 20px 12px;
  background: rgba(10, 10, 26, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon:hover {
  background: var(--surface-hover);
  border-color: var(--glass-border-hover);
  color: var(--text);
  transform: translateY(-1px);
}

.btn-icon:active { transform: scale(0.95); }

.btn-icon.syncing {
  animation: spin 1s linear infinite;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 6px;
  padding: 0 20px 14px;
  background: rgba(10, 10, 26, 0.8);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 72px;
  z-index: 90;
}

.tab {
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text3);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.tab.active {
  background: linear-gradient(135deg, rgba(102,126,234,0.2), rgba(118,75,162,0.15));
  border-color: rgba(102,126,234,0.3);
  color: var(--text);
  box-shadow: 0 0 20px rgba(102,126,234,0.1);
}

.tab:not(.active):hover {
  color: var(--text2);
  background: var(--surface);
}

/* ── Input Area ── */
.input-area {
  padding: 12px 20px 8px;
}

.input-wrap {
  display: flex;
  gap: 8px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 5px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrap:focus-within {
  border-color: rgba(102, 126, 234, 0.4);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.08), 0 8px 30px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.06);
}

.input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  font-family: inherit;
}

.input-wrap input::placeholder { color: var(--text3); }

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px var(--accent-glow);
}

.btn-send:active { transform: scale(0.95); }
.btn-send:disabled { opacity: 0.3; cursor: default; transform: none; box-shadow: none; }

/* ── Task List ── */
.task-list {
  padding: 4px 20px 120px;
  flex: 1;
}

.context-group { margin-bottom: 8px; }

.context-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 14px 0 6px;
}

/* ── Task Card ── */
.task-card {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: cardIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.task-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
}

.task-card:hover {
  background: var(--surface-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.task-card.completing {
  animation: cardOut 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes cardOut {
  to { opacity: 0; transform: translateX(80px) scale(0.95); height: 0; padding: 0; margin: 0; border-width: 0; }
}

/* ── Check circle ── */
.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--glass-border-hover);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.task-check:hover {
  border-color: var(--green);
  background: var(--green-glow);
  box-shadow: 0 0 12px var(--green-glow);
}

.task-check.checked {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 15px var(--green-glow);
}

.task-check.checked::after {
  content: "✓";
  color: white;
  font-size: 12px;
  font-weight: 800;
}

/* ── Task body ── */
.task-body { flex: 1; min-width: 0; }

.task-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  word-break: break-word;
  color: var(--text);
}

.task-meta {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  letter-spacing: 0.02em;
}

.badge-deadline {
  background: rgba(245, 158, 11, 0.12);
  color: var(--orange);
  border: 1px solid rgba(245, 158, 11, 0.15);
}

.badge-deadline.overdue {
  background: var(--red-glow);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.2);
  animation: pulse-red 2s ease infinite;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  50% { box-shadow: 0 0 8px 2px rgba(239,68,68,0.15); }
}

.priority-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.p1 { background: var(--red); box-shadow: 0 0 8px rgba(239,68,68,0.4); }
.p2 { background: var(--orange); box-shadow: 0 0 8px rgba(245,158,11,0.4); }
.p3 { background: var(--yellow); }
.p4 { background: var(--blue); }
.p5 { background: var(--text3); }

.task-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.task-card:hover .task-actions { opacity: 1; }

@media (hover: none) {
  .task-actions { opacity: 1; }
}

.btn-sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-sm:hover { background: var(--surface-hover); color: var(--text2); }
.btn-sm.danger:hover { background: var(--red-glow); color: var(--red); }

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 16px;
  padding: 8px 20px 4px;
  font-size: 12px;
  color: var(--text3);
}

.stats-bar .stat {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stats-bar .stat-num {
  font-weight: 700;
  color: var(--text2);
}

/* ── AI Panel ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.overlay.open { opacity: 1; pointer-events: auto; }

.ai-panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 520px;
  background: rgba(15, 16, 37, 0.95);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  max-height: 75vh;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.35s;
  z-index: 200;
  display: flex;
  flex-direction: column;
  visibility: hidden;
}

.ai-panel.open {
  transform: translateX(-50%) translateY(0);
  visibility: visible;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
}

.ai-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.ai-panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ai-panel-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  color: var(--text2);
}

.ai-panel-body .loading {
  color: var(--text3);
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ── Empty State ── */
.empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--text3);
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty p { font-size: 14px; line-height: 1.6; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  z-index: 300;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }
