@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --brand:       #5b6ef5;
  --brand-dark:  #4a5ce0;
  --brand-light: #eef0ff;
  --brand-grad:  linear-gradient(135deg, #5b6ef5 0%, #7c4dbc 100%);
  --sidebar-w:   240px;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 10px 40px rgba(0,0,0,.14);
  --text:        #111827;
  --text-2:      #374151;
  --text-muted:  #6b7280;
  --border:      #e5e7eb;
  --border-2:    #f3f4f6;
  --bg:          #f6f7fb;
  --white:       #ffffff;
  --danger:      #ef4444;
  --success:     #22c55e;
  --warning:     #f59e0b;
  /* Heatmap colors */
  --heat-0: #e5e7eb;
  --heat-1: #c7d2fe;
  --heat-2: #a5b4fc;
  --heat-3: #818cf8;
  --heat-4: #4f46e5;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: width .2s;
}
.sidebar-brand {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: .75rem;
  text-decoration: none; flex-shrink: 0;
}
.brand-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand-grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .9rem; flex-shrink: 0;
}
.brand-name {
  font-weight: 800; font-size: .95rem;
  color: var(--text); letter-spacing: -.025em;
  white-space: nowrap;
}
.sidebar-nav {
  flex: 1; padding: .75rem .65rem;
  display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto;
}
.sidebar-section {
  font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: #c4c9d4; padding: .75rem .75rem .25rem;
}
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem; border-radius: 8px;
  text-decoration: none; color: var(--text-muted);
  font-size: .83rem; font-weight: 500;
  transition: all .15s;
}
.nav-item i { width: 16px; text-align: center; font-size: .85rem; flex-shrink: 0; }
.nav-item span { white-space: nowrap; }
.nav-item:hover { background: var(--bg); color: var(--text-2); }
.nav-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.nav-item.active i { color: var(--brand); }
.sidebar-footer {
  border-top: 1px solid var(--border-2);
  padding: .65rem;
}
.user-cell {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .65rem; border-radius: 8px;
  cursor: pointer; text-decoration: none; color: var(--text);
  transition: background .15s;
}
.user-cell:hover { background: var(--bg); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-grad);
  color: #fff; font-weight: 700; font-size: .8rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name { font-size: .8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-hint { font-size: .7rem; color: var(--text-muted); white-space: nowrap; }

/* ─── Main layout ───────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 2rem 2.25rem;
}
.page-header { margin-bottom: 1.5rem; }
.page-title {
  font-size: 1.35rem; font-weight: 800;
  letter-spacing: -.03em; color: var(--text);
}
.page-subtitle { font-size: .82rem; color: var(--text-muted); margin-top: 3px; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.tk-card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.tk-card-body { padding: 1.25rem; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn-brand {
  background: var(--brand-grad); color: #fff;
  border: none; border-radius: 8px;
  padding: .58rem 1.2rem; font-size: .83rem; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s;
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: inherit; line-height: 1;
}
.btn-brand:hover { opacity: .88; color: #fff; }
.btn-brand:active { transform: scale(.98); }
.btn-brand-sm { padding: .42rem .9rem; font-size: .78rem; }

.btn-ghost {
  background: transparent; border: 1.5px solid var(--border);
  color: var(--text-muted); border-radius: 8px;
  padding: .52rem 1.1rem; font-size: .83rem; font-weight: 500;
  cursor: pointer; transition: all .15s; font-family: inherit;
  display: inline-flex; align-items: center; gap: .45rem; line-height: 1;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

.btn-danger-ghost {
  background: transparent; border: 1.5px solid #fecaca;
  color: var(--danger); border-radius: 8px;
  padding: .52rem 1.1rem; font-size: .83rem; font-weight: 500;
  cursor: pointer; transition: all .15s; font-family: inherit;
  display: inline-flex; align-items: center; gap: .45rem;
}
.btn-danger-ghost:hover { background: #fef2f2; border-color: var(--danger); }

.btn-icon {
  background: none; border: none; border-radius: 7px;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); font-size: .8rem;
  transition: all .15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { background: #fef2f2; color: var(--danger); }

/* ─── Form controls ─────────────────────────────────────────────────────── */
.tk-input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 8px;
  padding: .6rem .85rem; font-size: .875rem; font-family: inherit;
  color: var(--text); background: var(--white); outline: none;
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
.tk-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(91,110,245,.12);
}
.tk-input::placeholder { color: #b8bec9; }
.tk-input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }

.tk-label {
  display: block; font-size: .75rem; font-weight: 600;
  color: var(--text-2); margin-bottom: .35rem;
}
.tk-hint { font-size: .72rem; color: var(--text-muted); margin-top: .3rem; }

.input-group { position: relative; }
.input-group .tk-input { padding-left: 2.4rem; }
.input-icon {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .82rem; pointer-events: none;
}

/* ─── Alerts ────────────────────────────────────────────────────────────── */
.tk-alert { border-radius: 8px; padding: .75rem 1rem; font-size: .83rem; margin-bottom: 1.1rem; display: flex; align-items: flex-start; gap: .6rem; }
.tk-alert i { margin-top: 1px; flex-shrink: 0; }
.tk-alert-danger  { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.tk-alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.tk-alert-info    { background: var(--brand-light); color: #3730a3; border: 1px solid #c7d2fe; }
.tk-alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ─── Section label ─────────────────────────────────────────────────────── */
.section-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); margin-bottom: .5rem;
}

/* ─── Task cards ────────────────────────────────────────────────────────── */
.task-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem 1rem;
  display: flex; align-items: flex-start; gap: .75rem;
  transition: box-shadow .15s, border-color .15s; margin-bottom: .4rem;
}
.task-card:hover { box-shadow: var(--shadow-md); border-color: #d1d5db; }
.task-card.done-anim { opacity: 0; transform: translateX(30px); transition: all .3s ease; }
.task-check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #d1d5db; cursor: pointer; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.task-check:hover { border-color: var(--brand); background: var(--brand-light); }
.task-check:hover::after { content: ''; width: 4px; height: 8px; border: 2px solid var(--brand); border-top: 0; border-left: 0; transform: rotate(45deg) translate(-1px,-1px); display: block; }
.task-check.checked { background: var(--brand); border-color: var(--brand); }
.task-check.checked::after { content: ''; width: 4px; height: 8px; border: 2px solid #fff; border-top: 0; border-left: 0; transform: rotate(45deg) translate(-1px,-1px); display: block; }
.task-title { font-size: .88rem; font-weight: 500; color: var(--text); line-height: 1.4; }
.task-title a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.task-meta { font-size: .73rem; color: var(--text-muted); margin-top: 4px; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.meta-time { color: var(--brand); font-weight: 500; }
.meta-time.overdue { color: var(--danger); }
.task-actions { margin-left: auto; display: flex; gap: .15rem; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.task-card:hover .task-actions { opacity: 1; }

/* Priority accent */
.pri-bar { width: 3px; border-radius: 2px; align-self: stretch; flex-shrink: 0; min-height: 18px; }
.pri-0 { background: var(--border); }
.pri-1 { background: var(--warning); }
.pri-2 { background: var(--danger); }

/* List dot */
.list-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 3px; }

/* Recur badge */
.recur-badge { display: inline-flex; align-items: center; gap: 3px; background: var(--brand-light); color: var(--brand); border-radius: 20px; padding: 1px 7px; font-size: .7rem; font-weight: 600; }

/* Bucket headers */
.bucket-header {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  display: flex; align-items: center; gap: .5rem;
  margin: 1.5rem 0 .5rem; padding-bottom: .4rem;
  border-bottom: 1px solid var(--border-2);
}
.bucket-header:first-child { margin-top: 0; }
.bucket-header.overdue { color: var(--danger); }
.bucket-header.today   { color: var(--brand); }
.bucket-count { background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 1px 7px; font-size: .67rem; }

/* ─── Quick-add ─────────────────────────────────────────────────────────── */
.quick-add {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: .8rem 1rem;
  display: flex; align-items: center; gap: .75rem;
  transition: border-color .15s, box-shadow .15s; margin-bottom: 1.5rem;
}
.quick-add:focus-within {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91,110,245,.1);
}
.quick-add input {
  flex: 1; border: none; outline: none; font-size: .875rem;
  font-family: inherit; color: var(--text); background: transparent;
}
.quick-add input::placeholder { color: #b8bec9; }
.preset-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.chip {
  border: 1px solid var(--border); border-radius: 20px;
  padding: .22rem .7rem; font-size: .73rem; font-weight: 500;
  color: var(--text-muted); cursor: pointer; background: var(--white);
  transition: all .15s; display: inline-flex; align-items: center; gap: .3rem;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

/* ─── Snooze menu ───────────────────────────────────────────────────────── */
.snooze-wrap { position: relative; }
.snooze-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 155px; z-index: 50;
}
.snooze-menu.show { display: block; }
.snooze-item {
  display: block; width: 100%; text-align: left; padding: .5rem .85rem;
  font-size: .8rem; border: none; background: none; cursor: pointer;
  color: var(--text-2); transition: background .1s; font-family: inherit;
}
.snooze-item:hover { background: var(--bg); }

/* ─── Heatmap ───────────────────────────────────────────────────────────── */
.heatmap { display: flex; flex-wrap: wrap; gap: 4px; }
.hm-cell { width: 18px; height: 18px; border-radius: 3px; position: relative; cursor: default; }
.hm-cell:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%); background: var(--text);
  color: #fff; font-size: .65rem; padding: 3px 8px; border-radius: 5px;
  white-space: nowrap; z-index: 20;
}

/* ─── History items ─────────────────────────────────────────────────────── */
.hist-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem 1.1rem; border-bottom: 1px solid var(--border-2);
}
.hist-item:last-child { border-bottom: none; }
.hist-icon { color: var(--success); flex-shrink: 0; font-size: .9rem; margin-top: 1px; }

/* ─── Empty state ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; opacity: .2; display: block; }
.empty-state h6 { font-size: .95rem; font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
.empty-state p  { font-size: .82rem; }

/* ─── Welcome banner ────────────────────────────────────────────────────── */
.welcome-banner {
  background: var(--brand-grad); color: #fff; border-radius: var(--radius);
  padding: 1.1rem 1.35rem; margin-bottom: 1.35rem;
}

/* ─── Stat cards ────────────────────────────────────────────────────────── */
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.stat-num  { font-size: 2.1rem; font-weight: 800; letter-spacing: -.04em; }
.stat-label{ font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Lists ─────────────────────────────────────────────────────────────── */
.list-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .8rem 1.1rem; border-bottom: 1px solid var(--border-2); transition: background .1s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg); }
.list-icon-badge {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: .85rem; flex-shrink: 0;
}
.list-info .name   { font-weight: 600; font-size: .875rem; }
.list-info .count  { font-size: .73rem; color: var(--text-muted); }
.icon-picker { display: flex; flex-wrap: wrap; gap: 5px; }
.icon-picker label { cursor: pointer; }
.icon-picker input { display: none; }
.icon-opt { width: 32px; height: 32px; border-radius: 7px; border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: .82rem; transition: all .15s; }
.icon-picker input:checked + .icon-opt { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }

/* ─── Priority buttons ──────────────────────────────────────────────────── */
.pri-btn { border: 1.5px solid var(--border); border-radius: 8px; padding: .42rem .9rem; font-size: .8rem; font-weight: 500; background: var(--white); color: var(--text-muted); cursor: pointer; transition: all .15s; }
.pri-btn:hover { border-color: var(--brand); color: var(--brand); }
.pri-btn.sel-0 { border-color: #94a3b8; background: #f8fafc; color: #475569; }
.pri-btn.sel-1 { border-color: var(--warning); background: #fffbeb; color: #92400e; }
.pri-btn.sel-2 { border-color: var(--danger); background: #fef2f2; color: #b91c1c; }

/* ─── Profile ───────────────────────────────────────────────────────────── */
.profile-avatar {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--brand-grad); color: #fff;
  font-size: 1.6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Pill tabs ─────────────────────────────────────────────────────────── */
.tk-tabs { display: flex; gap: .2rem; background: var(--bg); border-radius: 8px; padding: 3px; margin-bottom: 1.25rem; }
.tk-tab { flex: 1; text-align: center; padding: .38rem; font-size: .8rem; font-weight: 500; border-radius: 6px; color: var(--text-muted); cursor: pointer; text-decoration: none; transition: all .15s; }
.tk-tab.active { background: var(--white); color: var(--text); box-shadow: var(--shadow-sm); }

/* ─── Push banner ───────────────────────────────────────────────────────── */
.push-banner {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 2000;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 1rem 1.25rem; max-width: 320px; display: none;
}

/* ─── Mobile bottom nav ─────────────────────────────────────────────────── */
.mobile-nav { display: none; }

/* ─── Auth pages ────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 1rem; }
.auth-card { background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: 2.25rem 2rem; width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.75rem; }
.auth-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -.025em; color: var(--text); }
.auth-subtitle { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.auth-divider { text-align: center; font-size: .75rem; color: var(--text-muted); margin: 1rem 0; position: relative; }
.auth-divider::before,
.auth-divider::after { content: ''; position: absolute; top: 50%; width: 42%; height: 1px; background: var(--border); }
.auth-divider::before { left: 0; } .auth-divider::after { right: 0; }
.auth-footer { text-align: center; font-size: .78rem; color: var(--text-muted); margin-top: 1.1rem; }
.auth-footer a { color: var(--brand); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

/* ─── Divider ───────────────────────────────────────────────────────────── */
.tk-divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ─── Alert aliases ─────────────────────────────────────────────────────── */
.tk-alert-ok  { display:flex; align-items:flex-start; gap:.6rem; border-radius:8px; padding:.72rem 1rem; font-size:.83rem; margin-bottom:1.1rem; background:#f0fdf4; color:#15803d; border:1px solid #bbf7d0; }
.tk-alert-err { display:flex; align-items:flex-start; gap:.6rem; border-radius:8px; padding:.72rem 1rem; font-size:.83rem; margin-bottom:1.1rem; background:#fef2f2; color:#b91c1c; border:1px solid #fecaca; }
.tk-alert-ok i, .tk-alert-err i { flex-shrink:0; margin-top:1px; }

/* ─── Generic card block ────────────────────────────────────────────────── */
.card-block {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ─── Stat row ──────────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
.stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.04em; color: var(--brand); line-height: 1; }

/* ─── Heatmap aliases ───────────────────────────────────────────────────── */
.heatmap-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.heatmap-legend { display: flex; align-items: center; gap: .35rem; margin-top: .65rem; font-size: .68rem; color: var(--text-muted); }

/* ─── History text ──────────────────────────────────────────────────────── */
.hist-title { font-size: .88rem; color: var(--text-2); }
.hist-meta  { font-size: .73rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 3px; }

/* ─── Lists page aliases ────────────────────────────────────────────────── */
.list-icon-wrap {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: .85rem; flex-shrink: 0;
}
.list-row-name  { font-weight: 600; font-size: .88rem; color: var(--text); }
.list-row-count { font-size: .73rem; color: var(--text-muted); margin-left: 6px; }

/* ─── Icon picker box alias ─────────────────────────────────────────────── */
.ic-box { width: 32px; height: 32px; border-radius: 7px; border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: .82rem; transition: all .15s; }
.icon-picker input:checked + .ic-box { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }

/* ─── NL hint ───────────────────────────────────────────────────────────── */
.nl-hint { font-size: .73rem; color: var(--brand); margin-top: .3rem; min-height: 1rem; }

/* ─── Snooze menu open class (JS uses .open) ────────────────────────────── */
.snooze-menu.open { display: block; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  :root { --sidebar-w: 60px; }
  .brand-name, .nav-item span, .user-name, .user-hint, .sidebar-section { display: none; }
  .sidebar-brand { justify-content: center; padding: 1rem .5rem; }
  .nav-item { justify-content: center; padding: .62rem; }
  .user-cell { justify-content: center; }
}
@media (max-width: 600px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 1rem; padding-bottom: 72px; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--white); border-top: 1px solid var(--border); z-index: 200;
  }
  .mobile-nav a { flex: 1; text-align: center; padding: .65rem .5rem .42rem; color: var(--text-muted); text-decoration: none; font-size: .62rem; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: color .15s; }
  .mobile-nav a.active { color: var(--brand); }
  .mobile-nav a i { font-size: 1.05rem; }
}
