:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #999999);
  --link: var(--tg-theme-link-color, #7c3aed);
  --btn: var(--tg-theme-button-color, #7c3aed);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: var(--tg-theme-button-color, #7c3aed);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
  --section-bg: var(--tg-theme-section-bg-color, var(--secondary-bg));
  --card-shadow: 0 2px 8px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 0;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── Tab bar ────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--secondary-bg);
  position: sticky;
  top: 0;
  padding-top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(128,128,128,0.15);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
/* Fade hint when tabs overflow right */
.tabs-wrap { position: relative; }
.tabs-wrap::after {
  content: "";
  position: absolute;
  inset-inline-end: 0; top: 0; bottom: 1px;
  width: 28px;
  background: linear-gradient(to right, transparent, var(--secondary-bg));
  pointer-events: none;
  z-index: 101;
  opacity: 1;
  transition: opacity 0.2s;
}
.tabs-wrap.scrolled-end::after { opacity: 0; }
.tab {
  flex: 1 0 auto;
  padding: 12px 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--tg-theme-subtitle-text-color, #777777);
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tab.active {
  color: var(--btn);
  border-bottom-color: var(--btn);
}

/* ── Kanban board ───────────────────────────────── */
.kanban {
  display: flex;
  gap: 8px;
  padding: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  min-height: calc(100vh - 100px);
  align-items: flex-start;
}
.column {
  flex: 0 0 280px;
  scroll-snap-align: start;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 120px;
  max-height: none;
}
.column-header {
  padding: 12px;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
}
.column-header .count {
  background: rgba(128,128,128,0.2);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
}
.column-body {
  flex: 1;
  overflow-y: visible;
  padding: 0 8px 72px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* On desktop with wide viewport, cap column height and scroll inside */
@media (min-width: 768px) {
  .column { max-height: calc(100vh - 110px); }
  .column-body { overflow-y: auto; }
}

/* ── Task card ──────────────────────────────────── */
.card {
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  cursor: grab;
  position: relative;
  overflow: hidden;
  min-height: 44px;
  flex-shrink: 0;
}
.card-inner {
  background: var(--bg);
  padding: 10px 12px 10px 16px;
  padding-inline: 16px 12px;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  z-index: 1;
  border-radius: 10px;
}
.card-inner::before {
  content: "";
  position: absolute;
  inset-inline-start: 0; top: 0; bottom: 0;
  width: 5px;
  border-radius: 10px 0 0 10px;
  background: var(--card-accent, rgba(128,128,128,0.25));
}
.card:active .card-inner { transform: scale(0.98); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card.swiped .card-inner { transform: translateX(-152px); }
.card.dragging { opacity: 0.5; transform: scale(0.95); }
/* Swipe hint animation for first-time users */
.card-inner.swipe-hint-anim {
  animation: swipeHint 1.2s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes swipeHint {
  0%   { transform: translateX(0); }
  30%  { transform: translateX(-80px); }
  55%  { transform: translateX(-80px); }
  100% { transform: translateX(0); }
}
/* Swipe actions behind card */
.card-actions {
  position: absolute;
  inset-inline-end: 0; top: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  z-index: 0;
}
.card-actions button {
  border: none;
  color: #fff;
  font-size: 17px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.swipe-done { background: #27ae60; }
.swipe-next { background: #3498db; }
.swipe-del  { background: #e74c3c; }
/* Ghost card for touch drag */
.card-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.85;
  transform: scale(1.04) rotate(2deg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  border-radius: 10px;
  transition: opacity 0.15s;
}
.card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.card-top .card-content { flex: 1; min-width: 0; }
.card-done-btn {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--hint);
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  transition: all 0.15s;
  margin-top: 0;
  padding: 0;
  position: relative;
}
/* Expand touch target to 44px without changing visual size */
.card-done-btn::after {
  content: "";
  position: absolute;
  inset: -9px;
}
.card-done-btn:hover, .card-done-btn:active {
  border-color: #27ae60;
  color: #27ae60;
  background: rgba(39,174,96,0.08);
}

/* ── Completion confetti ──────────────────────── */
.confetti-container {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden;
}
.confetti-particle {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 2px;
  opacity: 1;
  animation: confettiFall 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(120px) rotate(720deg) scale(0); opacity: 0; }
}


.card-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-word;
}
.card-notes {
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
  word-break: break-word;
}
.card-notes br { display: none; }
.card-notes ul, .card-notes ol, .card-notes li, .card-notes pre { display: inline; }
.card-notes a { color: var(--accent); text-decoration: underline; }
.card-notes strong { color: var(--text); font-weight: 600; }
.card-icons {
  display: flex;
  gap: 4px;
  font-size: 11px;
  opacity: 0.6;
  margin-bottom: 3px;
}
.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--hint);
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(128,128,128,0.08);
}
.card-meta .tag {
  background: rgba(128,128,128,0.12);
  border-radius: 4px;
  padding: 1px 5px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta .deadline { color: #e74c3c; font-weight: 500; }
.card-meta .deadline.ok { color: var(--hint); }
.card-meta .start-date-tag { color: #27ae60; font-size: 10px; }

/* ── Deadline countdown badge ──────────────────── */
.dl-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.dl-badge.dl-overdue { background: rgba(231,76,60,0.12); color: #c0392b; }
.dl-badge.dl-today { background: rgba(243,156,18,0.14); color: #b27300; }
.dl-badge.dl-soon { background: rgba(243,156,18,0.10); color: #c87f00; }
.dl-badge.dl-normal { background: rgba(29,158,117,0.10); color: #1d9e75; }
.dl-badge.dl-neutral { background: transparent; color: var(--hint); font-weight: 500; }

/* ── Task age badge ─────────────────────────────── */
.card-age-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-top: 2px;
  line-height: 1.3;
}
.card-age-badge.age-yellow {
  background: rgba(243, 156, 18, 0.15);
  color: #d4a017;
}
.card-age-badge.age-red {
  background: rgba(231, 76, 60, 0.15);
  color: #e74c3c;
}

/* drop target highlight */
.column-body.drag-over, .acc-body.drag-over {
  background: rgba(38, 120, 182, 0.08);
  border-radius: 8px;
}
.acc-header.drag-over {
  background: rgba(38, 120, 182, 0.12);
}

/* ── Calendar view ──────────────────────────────── */
.calendar-wrap { padding: 6px 12px; }
.cal-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}
.cal-nav button {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--btn);
  cursor: pointer;
  padding: 4px 12px;
}
.cal-nav .month-label { font-weight: 700; font-size: 16px; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color 0.15s; }
.cal-nav .month-label.away { color: var(--accent); }
.cal-today-btn {
  display: block; margin: -4px auto 8px; padding: 4px 14px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  cursor: pointer; opacity: 0.9; transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.cal-today-btn:active { opacity: 1; transform: scale(0.96); }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-grid .dow {
  text-align: center;
  font-size: 11px;
  color: var(--hint);
  padding: 3px 0;
  font-weight: 600;
}
.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px 3px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  min-height: 40px;
}
.cal-day:hover { background: var(--secondary-bg); }
.cal-day.in-range { background: rgba(39, 174, 96, 0.08); }
.cal-day.today { font-weight: 700; color: var(--btn); }
.cal-day.today > span {
  background: var(--btn);
  color: var(--btn-text);
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.cal-day.other-month { color: var(--hint); opacity: 0.4; }
.cal-day .dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}
.cal-day .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}
/* Compact calendar on wider screens (laptop/tablet) */
@media (min-width: 500px) {
  .calendar-wrap { padding: 4px 10px; }
  .cal-nav { padding: 4px 0; }
  .cal-nav button { font-size: 18px; padding: 2px 10px; }
  .cal-nav .month-label { font-size: 15px; }
  .cal-grid { gap: 1px; }
  .cal-grid .dow { font-size: 10px; padding: 2px 0; }
  .cal-day { padding: 3px 1px 2px; font-size: 12px; min-height: 36px; }
  .cal-day.today > span { width: 24px; height: 24px; font-size: 12px; }
  .cal-day .dots { gap: 1px; margin-top: 1px; }
}

/* ── Section help icon ─────────────────────────────── */
.section-help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--secondary-bg); border: none; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--hint);
  margin-inline-start: 6px; vertical-align: middle; flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.section-help-btn:active { background: var(--accent); color: var(--btn-text); }
.help-sheet-title {
  font-size: 18px; font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.help-sheet-body { font-size: 14px; line-height: 1.6; color: var(--text); }
.help-sheet-body p { margin: 0 0 10px; }
.help-sheet-body ul { margin: 0 0 10px; padding-inline-start: 20px; }
.help-sheet-body li { margin-bottom: 4px; }
.help-sheet-body .help-tip {
  background: var(--secondary-bg); border-radius: 10px;
  padding: 10px 12px; margin: 10px 0; font-size: 13px;
}

/* ── Settings toggle row ──────────────────────────── */
.settings-toggle-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px; margin: 8px 0; cursor: pointer;
  background: var(--secondary-bg); border-radius: 14px;
}
.settings-toggle-label { font-size: 14px; font-weight: 600; color: var(--text); }
.settings-toggle-desc { font-size: 12px; color: var(--hint); flex: 1; min-width: 120px; }
.settings-toggle {
  width: 44px; height: 26px; border-radius: 13px;
  background: var(--hint); position: relative;
  transition: background 0.2s; flex-shrink: 0;
}
.settings-toggle.on { background: var(--accent, var(--btn)); }
.settings-toggle-knob {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; position: absolute; top: 2px; left: 2px;
  transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.settings-toggle.on .settings-toggle-knob { transform: translateX(18px); }

.day-tasks {
  margin-top: 8px;
  padding: 8px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
}
.day-tasks h3 { font-size: 14px; margin-bottom: 8px; }
.day-task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  cursor: pointer;
}
.day-task-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Modal / bottom sheet ───────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.overlay.show { display: flex; }
.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes slideDown {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(100%); opacity: 0; }
}
.sheet.closing {
  animation: slideDown 0.2s ease forwards;
}
.sheet h2 {
  font-size: 18px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.close-btn {
  font-size: 18px;
  line-height: 1;
  background: var(--secondary-bg);
  border: none;
  color: var(--hint);
  cursor: pointer;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.close-btn:active {
  background: var(--hint);
  color: var(--bg);
}
.close-btn svg {
  pointer-events: none;
}

/* ── Form elements ──────────────────────────────── */
.form-group { margin-bottom: 10px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(128,128,128,0.25);
  border-radius: 8px;
  font-size: 14px;
  background: var(--secondary-bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--btn);
}
/* Create sheet file attach */
.cr-file-btn {
  font-size: 13px; padding: 8px 14px; border-radius: 8px;
  border: 1px dashed var(--hint); background: transparent;
  color: var(--hint); cursor: pointer; transition: all 0.15s;
}
.cr-file-btn:active { background: var(--secondary-bg); }
.cr-file-list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.cr-file-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-radius: 8px; background: var(--secondary-bg);
  font-size: 13px;
}
.cr-file-item-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.cr-file-item-size { color: var(--hint); }
.cr-file-item-remove {
  margin-inline-start: 8px; color: var(--hint); cursor: pointer;
  font-size: 16px; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all 0.15s;
}
.cr-file-item-remove:active { background: rgba(255,59,48,0.15); color: #ff3b30; }
/* Keyboard focus indicator — visible only for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent, var(--btn));
  outline-offset: 2px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--btn); color: var(--btn-text); }
.btn-primary:disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-ghost { background: transparent; color: var(--btn); }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* ── Status picker ──────────────────────────────── */
.status-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.status-picker .chip {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  background: var(--secondary-bg);
  border: 2px solid transparent;
  transition: all 0.15s;
}
.status-picker .chip.active {
  border-color: var(--btn);
  font-weight: 600;
}

/* ── Project chip picker ───────────────────────── */
.project-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.project-picker .chip {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  background: var(--secondary-bg);
  border: 2px solid transparent;
  transition: all 0.15s;
}
.project-picker .chip.active {
  border-color: var(--btn);
  font-weight: 600;
}

/* ── FAB ────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fab:active { transform: scale(0.85); }

/* ── Empty state ────────────────────────────────── */
.empty { text-align: center; color: var(--hint); padding: 40px 20px; font-size: 14px; }
.empty-cta {
  text-align: center;
  padding: 48px 24px;
  color: var(--hint);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}
.empty-cta .empty-icon { font-size: clamp(48px, 12vw, 64px); margin-bottom: 12px; }
.empty-cta .empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-cta .empty-desc { font-size: 13px; margin-bottom: 16px; }
.empty-cta .btn { display: inline-flex; }
.empty-cta .empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.empty-cta .empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.empty-cta .empty-btn:active { transform: scale(0.95); opacity: 0.8; }
.empty-cta .empty-btn.primary { background: var(--btn); color: var(--btn-text); }
.empty-cta .empty-btn.secondary { background: var(--secondary-bg); color: var(--text); }

/* ── Loading / skeleton ────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  font-size: 14px;
  color: var(--hint);
}
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.skeleton-card {
  background: linear-gradient(90deg, var(--secondary-bg) 25%, rgba(128,128,128,0.12) 50%, var(--secondary-bg) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.2s infinite ease-in-out;
  border-radius: 10px;
  height: 64px;
  margin-bottom: 6px;
}
.skeleton-wrap { padding: 8px; }
.skeleton-header {
  height: 18px;
  width: 120px;
  background: linear-gradient(90deg, var(--secondary-bg) 25%, rgba(128,128,128,0.12) 50%, var(--secondary-bg) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.2s infinite ease-in-out;
  border-radius: 6px;
  margin-bottom: 10px;
}
.skeleton-text {
  display: inline-block;
  height: 14px;
  background: linear-gradient(90deg, rgba(128,128,128,0.10) 25%, rgba(128,128,128,0.18) 50%, rgba(128,128,128,0.10) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.2s infinite ease-in-out;
  border-radius: 4px;
}
.skeleton-col .column-body { padding-bottom: 16px; }
.skeleton-col .skeleton-card { box-shadow: none; }

/* ── Projects view ─────────────────────────────────── */
.projects-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.project-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: background .15s;
  position: relative;
  overflow: hidden;
}
.project-card::before {
  content: '';
  position: absolute;
  inset-inline-start: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--proj-color, var(--btn));
  border-radius: 14px 0 0 14px;
}
.project-card:active { background: var(--bg); }
.project-emoji {
  font-size: 28px;
  line-height: 1;
  min-width: 36px;
  text-align: center;
  padding-top: 2px;
}
.project-body { flex: 1; min-width: 0; }
.project-label { font-weight: 600; font-size: 15px; }
.project-desc { font-size: 12px; color: var(--hint); margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.project-progress-wrap {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.project-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--secondary-bg);
  border-radius: 3px;
  overflow: hidden;
}
.project-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--proj-color, var(--btn));
  transition: width .3s ease;
}
.project-progress-text {
  font-size: 11px;
  color: var(--hint);
  white-space: nowrap;
}
.project-stats-row {
  margin-top: 4px;
  font-size: 11px;
  color: var(--hint);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.project-stats-row span { white-space: nowrap; }
.project-chevron {
  color: var(--hint);
  font-size: 18px;
  align-self: center;
  margin-inline-start: 4px;
}
.project-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed var(--hint);
  color: var(--hint);
  font-size: 14px;
  background: transparent;
  cursor: pointer;
  width: 100%;
  transition: border-color .15s, color .15s;
}
.project-add-btn:active { border-color: var(--accent); color: var(--accent); }

/* ── Emoji picker ─────────────────────────────────── */
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 4px;
  margin-top: 6px;
}
.emoji-pick {
  font-size: 20px;
  text-align: center;
  padding: 4px 2px;
  border-radius: 8px;
  background: var(--secondary-bg);
  cursor: pointer;
  transition: background .15s, transform .1s;
  border: 2px solid transparent;
}
.emoji-pick.active { border-color: var(--btn); background: color-mix(in srgb, var(--btn) 15%, transparent); transform: scale(1.1); }
.emoji-pick:active { transform: scale(0.95); }

/* ── Color picker ─────────────────────────────────── */
.color-picker-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color .15s, transform .1s;
}
.color-swatch.active { border-color: var(--text); transform: scale(1.15); }
.color-swatch:active { transform: scale(0.9); }

/* ── Project detail screen ─────────────────────────── */
.proj-detail-header {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(128,128,128,0.15);
}
.proj-detail-emoji { font-size: 36px; }
.proj-detail-info { flex: 1; min-width: 0; }
.proj-detail-name { font-size: 18px; font-weight: 700; }
.proj-detail-desc { font-size: 13px; color: var(--hint); margin-top: 2px; }
.proj-detail-progress {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.proj-detail-bar {
  flex: 1;
  height: 8px;
  background: var(--secondary-bg);
  border-radius: 4px;
  overflow: hidden;
}
.proj-detail-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
}
.proj-detail-pct { font-size: 13px; font-weight: 600; white-space: nowrap; }
.proj-detail-actions {
  padding: 0 16px 12px;
  display: flex;
  gap: 8px;
}
.proj-detail-actions .btn { flex: 1; font-size: 13px; padding: 8px; }
.proj-detail-task-list {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.proj-task-item {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.proj-task-item:active { background: var(--bg); }
.proj-task-status {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  cursor: pointer;
}
.proj-task-info { flex: 1; min-width: 0; }
.proj-task-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-task-title.done { text-decoration: line-through; color: var(--hint); }
.proj-task-deadline { font-size: 11px; color: var(--hint); margin-top: 1px; }
.proj-detail-empty { text-align: center; color: var(--hint); padding: 32px 16px; font-size: 14px; }
.proj-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  padding: 8px 4px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Project tasks view (drag & drop between projects) ─── */
.projects-view { padding: 8px; padding-bottom: 80px; }
.project-tasks-group {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
}
.project-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  min-height: 52px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.project-group-header:active { background: rgba(128,128,128,0.1); }
.project-group-header .acc-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.project-group-header .count {
  background: rgba(128,128,128,0.2);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
}
.project-group-body {
  display: none;
  padding: 0 10px 10px;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
}
.project-tasks-group.open .project-group-body { display: flex; }
.project-group-body.drag-over {
  background: rgba(38, 120, 182, 0.08);
  border-radius: 8px;
}
.project-group-body .empty { padding: 12px; color: var(--hint); font-size: 13px; text-align: center; }
.project-task-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px 10px 16px;
  padding-inline: 16px 12px;
  box-shadow: var(--card-shadow);
  cursor: grab;
  transition: transform 0.15s, box-shadow 0.15s;
  touch-action: none;
  position: relative;
  overflow: hidden;
  min-height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.project-task-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0; top: 0; bottom: 0;
  width: 5px;
  border-radius: 10px 0 0 10px;
  background: var(--card-accent, rgba(128,128,128,0.25));
}
.project-task-card:active { transform: scale(0.98); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.project-task-card.dragging { opacity: 0.5; transform: scale(0.95); }
.project-task-card-content { flex: 1; min-width: 0; }
.project-task-card-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  word-break: break-word;
}
.project-task-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--hint);
}
.project-task-card-meta .tag {
  background: rgba(128,128,128,0.12);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ── Chevron animation for project groups ─── */
.project-group-chevron {
  font-size: 12px;
  color: var(--hint);
  transition: transform 0.2s;
}
.project-tasks-group.open .project-group-chevron { transform: rotate(180deg); }

/* ── View toggle for projects tab ─── */
.projects-view-toggle {
  display: flex;
  gap: 6px;
  padding: 8px;
  margin-bottom: 8px;
}
.projects-view-toggle .btn {
  flex: 1;
  padding: 8px;
  border: 1px solid rgba(128,128,128,0.25);
  border-radius: 8px;
  background: var(--bg);
  color: var(--hint);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.projects-view-toggle .btn.active {
  background: var(--btn);
  color: var(--btn-text);
  border-color: var(--btn);
}

/* ── Attachments ─────────────────────────────────── */
.att-section { margin-bottom: 12px; }
.att-section label { display: block; font-size: 12px; color: var(--hint); margin-bottom: 6px; font-weight: 600; }
.att-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.att-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
}
.att-item .att-icon { font-size: 16px; flex-shrink: 0; }
.att-item .att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--link, var(--btn)); cursor: pointer; text-decoration: none; }
.att-item .att-size { color: var(--hint); font-size: 11px; flex-shrink: 0; }
.att-item .att-del { background: none; border: none; color: var(--hint); font-size: 16px; cursor: pointer; padding: 0 4px; }
.att-item .att-del:active { color: #e74c3c; }
.att-upload-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: 8px; border: 1px dashed var(--hint);
  color: var(--hint); font-size: 13px; background: transparent; cursor: pointer; width: 100%;
}
.att-upload-btn:active { border-color: var(--accent); color: var(--accent); }
.upload-progress {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; font-size: 12px; color: var(--hint);
}
.upload-progress-track {
  flex: 1; height: 4px; background: rgba(128,128,128,0.15);
  border-radius: 2px; overflow: hidden;
}
.upload-progress-fill {
  height: 100%; width: 0; border-radius: 2px;
  background: var(--btn); transition: width 0.15s ease;
}
.upload-progress-name {
  flex-shrink: 0; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-progress-pct { flex-shrink: 0; min-width: 32px; text-align: end; font-weight: 600; }

/* ── Reminder section ───────────────────────────── */
.reminder-section { margin-bottom: 12px; }
.reminder-section label { display: block; font-size: 12px; color: var(--hint); margin-bottom: 6px; font-weight: 600; }
.reminder-existing {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--bg); border-radius: 8px;
  font-size: 13px; margin-bottom: 6px;
}
.reminder-existing .rem-icon { font-size: 16px; }
.reminder-existing .rem-text { flex: 1; }
.reminder-existing .rem-del {
  background: none; border: none; color: var(--hint); font-size: 16px;
  cursor: pointer; padding: 0 4px;
}
.reminder-existing .rem-del:active { color: #e74c3c; }
.reminder-add-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: 8px; border: 1px dashed var(--hint);
  color: var(--hint); font-size: 13px; background: transparent; cursor: pointer; width: 100%;
}
.reminder-add-btn:active { border-color: var(--accent); color: var(--accent); }
.reminder-presets {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
  animation: fadeIn 0.15s ease;
}
.reminder-presets .rem-chip {
  padding: 6px 12px; border-radius: 16px; font-size: 12px; font-weight: 500;
  background: var(--bg); border: 1px solid var(--hint); color: var(--text);
  cursor: pointer; transition: all 0.15s;
}
.reminder-presets .rem-chip:active,
.reminder-presets .rem-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.reminder-presets .rem-custom-row {
  display: flex; gap: 6px; width: 100%; margin-top: 4px; align-items: center;
}
.reminder-presets .rem-custom-row input {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--hint);
  background: var(--bg); color: var(--text); font-size: 13px;
}
.reminder-presets .rem-custom-row button {
  padding: 8px 14px; border-radius: 8px; border: none;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
/* ── Comments section ── */
.comments-section { margin-bottom: 12px; }
.comments-section label { display: block; font-size: 12px; color: var(--hint); margin-bottom: 6px; font-weight: 600; }
.comments-list { max-height: 240px; overflow-y: auto; margin-bottom: 8px; }
.comment-item {
  display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--card-border);
}
.comment-item:last-child { border-bottom: none; }
.comment-ava {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.comment-ava img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.comment-body { flex: 1; min-width: 0; }
.comment-header { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.comment-author { font-size: 12px; font-weight: 600; color: var(--text); }
.comment-time { font-size: 11px; color: var(--hint); }
.comment-del {
  margin-inline-start: auto; background: none; border: none; color: var(--hint);
  font-size: 14px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.comment-del:hover { color: var(--danger, #e53935); }
.comment-text { font-size: 13px; color: var(--text); line-height: 1.4; word-break: break-word; }
.comment-empty { font-size: 13px; color: var(--hint); text-align: center; padding: 12px 0; }
.comment-input-row { display: flex; gap: 6px; align-items: flex-end; }
.comment-input-row textarea {
  flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--hint);
  background: var(--bg); color: var(--text); font-size: 13px; font-family: inherit;
  resize: none; min-height: 36px; max-height: 80px; line-height: 1.4;
}
.comment-input-row button {
  width: 36px; height: 36px; min-width: 36px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--btn-text, #fff); font-size: 16px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0; flex-shrink: 0; transition: opacity 0.15s;
}
.comment-input-row button:disabled { opacity: 0.35; cursor: default; }
.comment-input-wrap { position: relative; }
.mention { color: var(--accent); font-weight: 600; cursor: default; }
.mention-dropdown {
  position: absolute; bottom: 100%; inset-inline-start: 0; inset-inline-end: 0;
  background: var(--secondary-bg, var(--bg)); border: 1px solid var(--card-border);
  border-radius: 10px; box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
  max-height: 180px; overflow-y: auto; z-index: 100;
  margin-bottom: 4px;
}
.mention-option {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  cursor: pointer; transition: background 0.15s;
}
.mention-option:hover, .mention-option:active, .mention-option.active { background: var(--card-border); }
.mention-opt-ava {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.mention-opt-ava img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.mention-opt-name { font-size: 13px; font-weight: 600; color: var(--text); }
.mention-opt-uname { font-size: 12px; color: var(--hint); }
/* ── Onboarding Carousel ── */
.ob-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 10000;
  display: flex; flex-direction: column;
}
.ob-carousel {
  flex: 1; display: flex; overflow: hidden; width: 100%;
}
.ob-slide {
  flex: 0 0 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 24px; text-align: center;
  transition: transform 0.35s ease;
}
/* ── Onboarding animated illustrations ──── */
.ob-anim-wrap {
  width: 160px; height: 160px; margin: 0 auto 28px;
  position: relative; display: flex; align-items: center; justify-content: center;
}
/* Slide 1: Finger tapping FAB */
.ob-anim-tap {
  width: 100%; height: 100%; position: relative;
}
.ob-anim-tap::before {
  content: "+";
  position: absolute; bottom: 12px; right: 24px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 28px; font-weight: 300; line-height: 56px; text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.ob-anim-tap::after {
  content: "👆";
  position: absolute; bottom: 4px; right: 16px;
  font-size: 36px; line-height: 1;
  animation: obTapFinger 2.4s ease-in-out infinite;
  transform-origin: center center;
}
@keyframes obTapFinger {
  0%, 100% { transform: translate(0, 8px) scale(1); opacity: 0.7; }
  30% { transform: translate(0, 0) scale(1); opacity: 1; }
  40% { transform: translate(0, 2px) scale(0.92); opacity: 1; }
  55% { transform: translate(0, 0) scale(1); opacity: 1; }
  75% { transform: translate(0, 8px) scale(1); opacity: 0.7; }
}

/* Slide 2: Finger swiping card left */
.ob-anim-swipe {
  width: 100%; height: 100%; position: relative;
}
.ob-anim-swipe::before {
  content: "";
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 120px; height: 48px; border-radius: 12px;
  background: var(--secondary-bg, rgba(128,128,128,0.12));
  border: 1.5px solid rgba(128,128,128,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.ob-anim-swipe::after {
  content: "👆";
  position: absolute; top: calc(50% - 6px); left: calc(50% + 16px);
  font-size: 32px; line-height: 1;
  animation: obSwipeFinger 2.8s ease-in-out infinite;
  transform-origin: center center;
}
[dir="rtl"] .ob-anim-swipe::after {
  animation-name: obSwipeFingerRTL;
}
@keyframes obSwipeFinger {
  0%, 100% { transform: translate(0, 0); opacity: 0.6; }
  20% { transform: translate(0, 0); opacity: 1; }
  50% { transform: translate(-60px, 0); opacity: 1; }
  65% { transform: translate(-60px, 0); opacity: 0.4; }
  80% { transform: translate(0, 0); opacity: 0.3; }
}
@keyframes obSwipeFingerRTL {
  0%, 100% { transform: translate(0, 0); opacity: 0.6; }
  20% { transform: translate(0, 0); opacity: 1; }
  50% { transform: translate(60px, 0); opacity: 1; }
  65% { transform: translate(60px, 0); opacity: 0.4; }
  80% { transform: translate(0, 0); opacity: 0.3; }
}

.ob-title { font-size: 22px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.ob-desc {
  font-size: 15px; color: var(--hint); line-height: 1.5;
  max-width: 300px; margin: 0 auto;
}
.ob-footer { padding: 20px 24px 32px; }
.ob-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 20px; }
.ob-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(128,128,128,0.3); transition: all 0.3s; cursor: pointer;
}
.ob-dot.active { background: var(--accent); width: 24px; border-radius: 4px; }
.ob-buttons { display: flex; gap: 12px; justify-content: center; }
.ob-btn {
  padding: 14px 28px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.ob-btn-primary { background: var(--accent); color: #fff; flex: 1; }
.ob-btn-secondary { background: var(--card-bg, var(--secondary-bg)); color: var(--hint); }

/* ── Accordion (list) view ──────────────────────── */
.accordion-view { padding: 8px; padding-bottom: 80px; display: flex; flex-direction: column; gap: 6px; }
.acc-section {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  overflow: hidden;
}
.acc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  min-height: 52px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.acc-header:active { background: rgba(128,128,128,0.1); }
.acc-header .acc-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.acc-header .count {
  background: rgba(128,128,128,0.2);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
}
.acc-header .acc-chevron {
  font-size: 12px;
  color: var(--hint);
  transition: transform 0.2s;
}
.acc-section.open .acc-chevron { transform: rotate(180deg); }
.acc-body {
  display: none;
  padding: 0 10px 10px;
  flex-direction: column;
  gap: 6px;
}
.acc-section.open .acc-body { display: flex; }
.acc-body .empty { padding: 12px; color: var(--hint); font-size: 13px; text-align: center; }

/* Archive section — muted, collapsed by default */
.archive-section { margin-top: 8px; }
.archive-section .acc-header { opacity: 0.65; font-weight: 600; font-size: 14px; }
.archive-section .card { opacity: 0.55; }
.archive-section .card:hover { opacity: 0.8; }
.archive-btn-row { display: flex; gap: 8px; padding: 8px 10px 4px; }
.archive-action-btn {
  flex: 1; padding: 8px 12px; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: rgba(128,128,128,0.12); color: var(--text);
  transition: background 0.15s;
}
.archive-action-btn:hover { background: rgba(128,128,128,0.22); }
.archive-action-btn.restore { color: #3498db; }
.archive-action-btn.archive-all { color: #e67e22; }

/* Routines section */
.routine-card {
  background: var(--secondary-bg); border-radius: 10px; padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.routine-info { flex: 1; min-width: 0; }
.routine-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.routine-schedule { font-size: 12px; color: var(--hint); margin-top: 2px; }
.routine-toggle {
  width: 44px; height: 26px; border-radius: 13px; border: none; cursor: pointer;
  position: relative; transition: background 0.2s; flex-shrink: 0;
}
.routine-toggle.on { background: #27ae60; }
.routine-toggle.off { background: rgba(128,128,128,0.3); }
.routine-toggle::after {
  content: ''; position: absolute; top: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: white; transition: inset-inline-start 0.2s;
}
.routine-toggle.on::after { inset-inline-start: 21px; }
.routine-toggle.off::after { inset-inline-start: 3px; }
.routine-actions { display: flex; gap: 6px; }
.routine-del-btn {
  background: none; border: none; font-size: 16px; cursor: pointer; opacity: 0.5;
  padding: 4px; transition: opacity 0.15s;
}
.routine-del-btn:hover { opacity: 1; }

/* ── Routines tab view ────────────────────────── */
.routines-view { padding: 0 12px 100px; }
.routines-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0 8px;
}
.routines-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.routines-add-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--btn); color: var(--btn-text); font-size: 22px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15); transition: transform 0.15s;
}
.routines-add-btn:active { transform: scale(0.9); }

.rtn-card {
  background: var(--secondary-bg); border-radius: 14px; margin-bottom: 8px;
  transition: opacity 0.2s, transform 0.15s;
}
.rtn-card.inactive { opacity: 0.5; }
.rtn-main {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; cursor: pointer;
}
/* Type icon chip — colored rounded square */
.rtn-type-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
}
.rtn-body { flex: 1; min-width: 0; cursor: pointer; }
.rtn-title {
  font-weight: 600; font-size: 15px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rtn-meta {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px;
}
.rtn-sched { font-size: 12px; color: var(--hint); }
.rtn-next-inline { font-size: 11px; color: var(--hint); opacity: 0.7; }
/* Card action buttons (fire + delete) */
.rtn-card-actions {
  display: flex; flex-direction: column; gap: 2px; flex-shrink: 0;
}
.rtn-fire-btn {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(39,174,96,0.12); color: #27ae60;
  font-size: 12px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.2s;
}
.rtn-fire-btn:active { transform: scale(0.85); }
.rtn-fire-btn.firing { animation: rtn-spin 0.6s linear infinite; }
@keyframes rtn-spin { to { transform: rotate(360deg); } }
.rtn-del-btn {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: none; font-size: 14px; cursor: pointer;
  opacity: 0.3; padding: 0; transition: opacity 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.rtn-del-btn:hover { opacity: 0.8; }
/* iOS-style toggle switch */
.rtn-switch {
  position: relative; display: inline-block;
  width: 42px; height: 24px; flex-shrink: 0;
}
.rtn-switch input { opacity: 0; width: 0; height: 0; }
.rtn-switch-slider {
  position: absolute; cursor: pointer;
  inset: 0;
  background: rgba(128,128,128,0.3); border-radius: 24px;
  transition: background 0.25s;
}
.rtn-switch-slider::before {
  content: ""; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.rtn-switch input:checked + .rtn-switch-slider { background: #27ae60; }
.rtn-switch input:checked + .rtn-switch-slider::before { transform: translateX(18px); }

/* ── Routine frequency groups ─────────────────── */
.rtn-group { margin-bottom: 4px; }
.rtn-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px; cursor: pointer; user-select: none;
}
.rtn-group-icon { font-size: 15px; flex-shrink: 0; }
.rtn-group-label {
  font-size: 13px; font-weight: 600; color: var(--text); flex: 1;
}
.rtn-group-count {
  font-size: 11px; color: var(--hint); font-weight: 500;
  background: rgba(128,128,128,0.12); border-radius: 8px; padding: 1px 7px;
}
.rtn-group-chevron {
  font-size: 10px; color: var(--hint); transition: transform 0.2s;
}
.rtn-group.open .rtn-group-chevron { transform: rotate(0deg); }
.rtn-group:not(.open) .rtn-group-chevron { transform: rotate(-90deg); }
.rtn-group-body {
  overflow: hidden; transition: max-height 0.25s ease, opacity 0.2s;
}
.rtn-group.open .rtn-group-body { max-height: 2000px; opacity: 1; }
.rtn-group:not(.open) .rtn-group-body { max-height: 0; opacity: 0; }

/* Routine sheet form */
.rtn-freq-pills {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.rtn-pill {
  padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--hint);
  background: transparent; color: var(--text); font-size: 13px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.rtn-pill.active {
  background: var(--btn); color: var(--btn-text); border-color: var(--btn);
}
.rtn-day-chips {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.rtn-day-chip {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--hint); background: transparent; color: var(--text);
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.rtn-day-chip.active {
  background: var(--btn); color: var(--btn-text); border-color: var(--btn);
}

/* View toggle pill */
.view-toggle {
  display: flex;
  background: var(--secondary-bg);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  margin: 8px 8px 0;
}
.view-toggle-btn {
  flex: 1;
  padding: 6px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  color: var(--hint);
  transition: all 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.view-toggle-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.group-toggle-btn {
  padding: 6px 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  color: var(--hint);
  transition: all 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  margin-inline-start: 4px;
}
.group-toggle-btn::before { content: "⊞"; }
.group-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Project group dividers ─────────────────────── */
.proj-group-divider {
  font-size: 11px;
  font-weight: 600;
  color: var(--hint);
  padding: 6px 4px 3px;
  margin-top: 6px;
  border-inline-start: 3px solid var(--hint);
  padding-inline-start: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj-group-divider:first-child { margin-top: 0; }

/* ── Search bar ─────────────────────────────────── */
.search-bar {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-bar input {
  flex: 1;
  padding: 8px 12px 8px 32px;
  padding-inline: 32px 12px;
  border-radius: 10px;
  border: 1px solid rgba(128,128,128,0.2);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--btn); }
.search-bar .search-icon {
  position: absolute;
  inset-inline-start: 18px;
  font-size: 14px;
  color: var(--hint);
  pointer-events: none;
}
.search-bar { position: relative; }
.search-clear {
  position: absolute;
  inset-inline-end: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(128,128,128,0.2);
  color: var(--hint);
  font-size: 11px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.search-clear.visible { display: flex; }
.search-clear:active { transform: translateY(-50%) scale(0.85); opacity: 0.6; }

/* ── Quick-add inline ─────────────────────────── */
.quick-add-row {
  display: flex;
  gap: 6px;
  padding: 6px 0 2px;
}
.quick-add-row input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(128,128,128,0.25);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.quick-add-row input:focus { border-color: var(--btn); }
.quick-add-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--hint);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.quick-add-trigger:hover, .quick-add-trigger:active { opacity: 1; }

/* ── Search filter chips ─────────────────────── */
.search-filters {
  display: flex;
  gap: 6px;
  padding: 2px 8px 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.search-filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  background: var(--secondary-bg);
  color: var(--hint);
  border: 1.5px solid transparent;
  transition: all 0.15s;
}
.filter-chip.active {
  border-color: var(--btn);
  color: var(--btn);
  background: color-mix(in srgb, var(--btn) 10%, transparent);
}

/* ── Time estimate picker ──────────────────────── */
.est-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.est-picker .est-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.est-picker .chip {
  font-size: 13px;
  padding: 5px 12px;
  min-width: 36px;
  text-align: center;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.est-picker .chip.active {
  border-color: var(--btn);
  font-weight: 600;
}
.est-picker .chip[data-val="custom"] {
  border-style: dashed;
  border-color: var(--secondary-bg);
  color: var(--hint);
  letter-spacing: 1px;
}
.est-picker .chip[data-val="custom"].active {
  border-color: var(--btn);
  border-style: dashed;
  color: var(--text);
}
.remind-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.remind-option {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  background: var(--secondary-bg);
  border: 1.5px solid transparent;
  transition: all 0.15s;
  color: var(--text);
}
.remind-option.active {
  border-color: var(--btn);
  background: color-mix(in srgb, var(--btn) 12%, transparent);
  font-weight: 600;
}

/* ── Overdue card ──────────────────────────────── */
.card.overdue {
  border: 1.5px solid rgba(231,76,60,0.4);
  background: rgba(231,76,60,0.04);
}
.card .overdue-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #e74c3c;
  background: rgba(231,76,60,0.12);
  border-radius: 4px;
  padding: 1px 5px;
  margin-inline-start: 4px;
  animation: overduePulse 2.5s ease-in-out infinite;
}
@keyframes overduePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ── Tab badge ─────────────────────────────────── */
.tab .tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  font-size: 9px;
  font-weight: 700;
  background: var(--btn);
  color: var(--btn-text);
  border-radius: 8px;
  padding: 0 4px;
  margin-inline-start: 2px;
  vertical-align: middle;
}
.tab .tab-badge.muted {
  background: rgba(128,128,128,0.2);
  color: var(--hint);
}

/* ── Long-press status popup ───────────────────── */
.status-popup {
  position: fixed;
  z-index: 300;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  padding: 6px;
  min-width: 180px;
  animation: fadeIn 0.12s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes viewFadeIn { from { opacity: 0; } to { opacity: 1; } }
#kanban-view, #list-view, #calendar-view, #projects-view, #stats-view {
  animation: viewFadeIn 0.15s ease;
}
.status-popup .sp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s;
}
.status-popup .sp-item:active { background: var(--secondary-bg); }
.status-popup .sp-item.current { font-weight: 700; color: var(--btn); }
.status-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(0,0,0,0.15);
}

/* ── Progress widget ───────────────────────────── */
.progress-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 0 8px 8px;
  background: var(--secondary-bg);
  border-radius: 10px;
}
.prog-pct {
  font-size: 22px; font-weight: 600;
  min-width: 48px; flex-shrink: 0;
}
.prog-pct span { font-size: 13px; font-weight: 400; color: var(--hint); }
.prog-right { flex: 1; min-width: 0; }
.prog-bar-track {
  height: 5px; background: rgba(128,128,128,0.15);
  border-radius: 3px; overflow: hidden; margin-bottom: 5px;
}
.prog-bar-fill {
  height: 100%; border-radius: 3px;
  background: var(--btn); transition: width 0.4s ease;
}
.prog-sub { font-size: 12px; color: var(--hint); }
.progress-widget.all-done { background: rgba(39,174,96,0.1); }
.progress-widget.all-done .prog-pct { color: #27ae60; }
.progress-widget.all-done .prog-bar-fill { background: #27ae60; }
.progress-widget.all-done .prog-sub { color: #27ae60; }

/* ── Due today banner ──────────────────────────── */
.sub-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 0 8px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}
.sub-banner.grace {
  background: rgba(243, 156, 18, 0.1);
  border: 1px solid rgba(243, 156, 18, 0.25);
  color: #e67e22;
}
.sub-banner.readonly {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.25);
  color: #c0392b;
}
.sub-banner-icon { font-size: 16px; }

.due-today-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0 8px 8px;
  background: rgba(231, 76, 60, 0.08);
  border: 1px solid rgba(231, 76, 60, 0.2);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #c0392b;
  cursor: pointer;
  transition: opacity 0.2s;
}
.due-today-banner:active { opacity: 0.7; }
.due-today-banner .dtb-icon { font-size: 16px; }
.due-today-banner .dtb-count {
  font-weight: 700;
  margin-inline-start: auto;
  background: #e74c3c;
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
}

/* ── Statistics view ────────────────────────────── */
.stats-view { padding: 12px; display: flex; flex-direction: column; gap: 12px; padding-bottom: 80px; }

/* Stats dynamic section — fade transition on period switch */
#stats-dynamic { transition: opacity 0.18s ease; display: flex; flex-direction: column; gap: 12px; }
#stats-dynamic.fading { opacity: 0; }

/* Trend badges on hero cards */
.stat-card .sc-trend { font-size: 11px; font-weight: 600; margin-inline-start: 2px; }
.stat-card .sc-trend.up { color: #27ae60; }
.stat-card .sc-trend.down { color: #e74c3c; }
.stat-card .sc-trend.neutral { color: var(--hint); }

/* Insights section */
.stats-insights { }
.stats-insights h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.insights-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.insight-card {
  flex: 1 1 calc(50% - 4px); min-width: 120px;
  background: var(--secondary-bg); border-radius: 12px; padding: 12px;
}
.insight-card .ic-icon { font-size: 20px; margin-bottom: 4px; }
.insight-card .ic-value { font-size: 16px; font-weight: 700; color: var(--text); }
.insight-card .ic-label { font-size: 11px; color: var(--hint); margin-top: 2px; }

/* Tasks by project */
.stats-by-project { margin-top: 16px; }
.stats-by-project h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.proj-bar-stacked { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 1px; margin-bottom: 10px; }
.proj-bar-seg { min-width: 4px; transition: width 0.3s; }
.proj-bar-seg:first-child { border-radius: 5px 0 0 5px; }
.proj-bar-seg:last-child { border-radius: 0 5px 5px 0; }
.proj-bar-legend { display: flex; flex-direction: column; gap: 6px; }
.proj-leg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.proj-leg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.proj-leg-name { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-leg-count { font-weight: 600; color: var(--text); min-width: 20px; text-align: right; }
.proj-leg-pct { color: var(--hint); min-width: 32px; text-align: right; }

/* Stale tasks section */
.stats-stale { }
.stats-stale h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.stale-hint { font-size: 11px; color: var(--hint); margin-bottom: 8px; }
.stale-list { display: flex; flex-direction: column; gap: 6px; }
.stale-item {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--secondary-bg); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.stale-item:active { opacity: 0.7; }
.stale-item .si-title { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stale-item .si-meta { display: flex; align-items: center; gap: 6px; }
.stale-item .si-scope {
  font-size: 10px; color: var(--btn); background: color-mix(in srgb, var(--btn) 12%, transparent);
  padding: 1px 6px; border-radius: 4px; white-space: nowrap; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis;
}
.stale-item .si-date { font-size: 11px; color: var(--hint); white-space: nowrap; }
.stale-empty { font-size: 13px; color: var(--hint); padding: 8px 0; }

/* Balance indicator */
.stats-balance { margin-top: 16px; }
.balance-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.balance-indicator {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.balance-indicator.positive { background: rgba(39,174,96,0.12); }
.balance-indicator.negative { background: rgba(231,76,60,0.12); }
.balance-indicator.neutral { background: rgba(128,128,128,0.08); }
.balance-text .bt-value { font-size: 15px; font-weight: 700; color: var(--text); }
.balance-text .bt-label { font-size: 11px; color: var(--hint); }

/* Streak with progress */
.streak-progress { margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.streak-bar-track { flex: 1; height: 4px; border-radius: 2px; background: rgba(128,128,128,0.1); }
.streak-bar-fill { height: 100%; border-radius: 2px; background: var(--btn); transition: width 0.3s; }
.streak-record { font-size: 10px; color: var(--hint); }

/* Period switcher chips */
.stats-period-bar {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.stats-period-bar::-webkit-scrollbar { display: none; }
.stats-period-bar .period-chip {
  flex-shrink: 0;
  padding: 6px 14px; border-radius: 16px; font-size: 12px; font-weight: 600;
  background: var(--secondary-bg); color: var(--hint); cursor: pointer;
  border: 1.5px solid transparent; white-space: nowrap; transition: all 0.15s;
}
.stats-period-bar .period-chip.active {
  background: var(--btn); color: var(--btn-text); border-color: var(--btn);
}

/* Hero KPI cards — 2-column grid */
.stats-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.stat-card .sc-icon { font-size: 22px; margin-bottom: 4px; }
.stat-card .sc-value { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat-card .sc-label { font-size: 11px; color: var(--hint); margin-top: 2px; font-weight: 500; }
.stat-card.accent { background: linear-gradient(135deg, var(--btn), color-mix(in srgb, var(--btn), #000 20%)); }
.stat-card.accent .sc-value,
.stat-card.accent .sc-label { color: var(--btn-text); }
.stat-card.warn { background: rgba(231,76,60,0.06); border-inline-start: 3px solid #e74c3c; }
.stat-card.warn .sc-value { color: #e74c3c; }

/* Donut chart section */
.stats-donut-section {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 16px;
}
.stats-donut-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.stats-donut-wrap { display: flex; align-items: center; gap: 16px; }
.stats-donut-svg { width: 110px; height: 110px; flex-shrink: 0; }
.stats-donut-legend { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.donut-legend-item {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.donut-legend-item .dl-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-item .dl-count { margin-inline-start: auto; font-weight: 600; min-width: 20px; text-align: end; }

/* Weekly progress bar */
.stats-week-section {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 16px;
}
.stats-week-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.stats-week-section .week-sub { font-size: 12px; color: var(--hint); margin-bottom: 10px; }
.week-bar-track {
  height: 12px; border-radius: 6px; background: rgba(128,128,128,0.12); overflow: hidden;
  display: flex;
}
.week-bar-fill {
  height: 100%; border-radius: 6px; transition: width 0.4s ease;
}
.week-bar-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--hint); margin-top: 4px; }

/* Heatmap */
.stats-heatmap-section {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 16px;
}
.stats-heatmap-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: rgba(128,128,128,0.08);
  position: relative;
}
.heatmap-cell.l1 { background: color-mix(in srgb, var(--btn) 25%, transparent); }
.heatmap-cell.l2 { background: color-mix(in srgb, var(--btn) 50%, transparent); }
.heatmap-cell.l3 { background: color-mix(in srgb, var(--btn) 75%, transparent); }
.heatmap-cell.l4 { background: var(--btn); }
.heatmap-dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 4px;
}
.heatmap-dow span { text-align: center; font-size: 10px; color: var(--hint); font-weight: 500; }
.heatmap-footer { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 6px; font-size: 10px; color: var(--hint); }
.heatmap-footer .hf-box { width: 10px; height: 10px; border-radius: 2px; }

/* ── Toast notification ─────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(12px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.2s forwards;
  pointer-events: auto;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }
.toast:has(.toast-undo) {
  animation: toastIn 0.25s ease, toastOut 0.3s ease 3.2s forwards;
}
.toast-undo {
  display: flex; align-items: center; gap: 12px; white-space: nowrap;
}
.toast-undo-btn {
  background: none; border: none; color: var(--btn, #5eafc0); font-weight: 700;
  font-size: 14px; cursor: pointer; padding: 0; text-decoration: underline;
}
/* Onboarding hint banner — persistent until user taps OK */
.hint-banner {
  position: fixed;
  top: calc(12px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  left: 12px; right: 12px;
  z-index: 500;
  background: var(--accent);
  color: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}
.hint-banner-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
}
.hint-banner-ok {
  background: rgba(255,255,255,0.25);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
}
.hint-banner.fade-out {
  animation: toastOut 0.25s ease forwards;
}

/* ── Contextual tooltips (action-triggered) ──── */
.ctx-tip {
  position: fixed;
  z-index: 600;
  background: var(--accent);
  color: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.22);
  animation: ctxTipIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  --arrow-left: 50%;
}
.ctx-tip::after {
  content: "";
  position: absolute;
  left: var(--arrow-left);
  transform: translateX(-50%);
  border: 7px solid transparent;
}
.ctx-tip-above::after {
  bottom: -13px;
  border-top-color: var(--accent);
}
.ctx-tip-below::after {
  top: -13px;
  border-bottom-color: var(--accent);
}
.ctx-tip-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
}
.ctx-tip-ok {
  background: rgba(255,255,255,0.25);
  border: none; color: #fff;
  font-size: 13px; font-weight: 700;
  padding: 6px 14px; border-radius: 8px;
  cursor: pointer; white-space: nowrap;
  flex-shrink: 0;
}
.ctx-tip-out { animation: ctxTipOut 0.25s ease forwards; }
@keyframes ctxTipIn {
  from { opacity: 0; transform: scale(0.85) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes ctxTipOut {
  to { opacity: 0; transform: scale(0.9) translateY(4px); }
}

.confirm-overlay {
  display: none; position: fixed; inset: 0; z-index: 10001;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: 24px;
}
.confirm-overlay.show { display: flex; }
.confirm-box {
  background: var(--bg); border-radius: 14px; padding: 20px;
  max-width: 300px; width: 100%; text-align: center;
  animation: slideUp 0.2s ease;
}
.confirm-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; line-height: 1.4; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions button {
  flex: 1; padding: 11px 0; border-radius: 10px; font-size: 15px;
  font-weight: 600; border: none; cursor: pointer;
}
.confirm-cancel { background: var(--secondary-bg); color: var(--text); }
.confirm-danger { background: #e74c3c; color: #fff; }
.offline-bar {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 9998;
  background: #e74c3c; color: #fff; font-size: 13px; font-weight: 600;
  text-align: center; padding: 6px 12px;
  animation: toastIn 0.3s ease;
}
.offline-bar.show { display: block; }
.offline-badge {
  position: fixed; bottom: 70px; inset-inline-end: 16px; z-index: 499;
  background: #e74c3c; color: #fff; font-size: 11px; font-weight: 700;
  min-width: 22px; height: 22px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  animation: toastIn 0.25s ease;
}

/* Card fade-out animation */
.card.fade-out {
  transition: opacity 0.35s ease, transform 0.35s ease;
  opacity: 0;
  transform: scale(0.92);
}
/* Task completion animation — green glow, scale up then shrink away */
.card.completing {
  transition: opacity 0.45s ease, transform 0.45s ease, box-shadow 0.2s ease;
  opacity: 0;
  transform: scale(0.88);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.5), 0 0 16px rgba(76, 175, 80, 0.3);
}
.card.completing .card-inner {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.08), rgba(76, 175, 80, 0.03));
}

/* ── Profile Settings Menu ─────────────────────────── */
.pm-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 16px;
  gap: 6px;
}
.pm-avatar-wrap { position: relative; }
.pm-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--btn);
}
.pm-avatar-ph {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--btn); color: var(--btn-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
}
.pm-user-name {
  font-size: 20px; font-weight: 700; margin-top: 8px;
  color: var(--text);
}
.pm-user-badge {
  font-size: 12px; color: var(--hint);
  background: var(--secondary-bg); border-radius: 10px;
  padding: 2px 10px; margin-top: 2px;
}
.pm-metrics {
  display: flex; gap: 16px; margin-top: 14px;
  background: var(--secondary-bg); border-radius: 14px;
  padding: 12px 16px; width: 100%;
  justify-content: space-around;
}
.pm-metric {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.pm-metric-val {
  font-size: 18px; font-weight: 800; color: var(--text);
}
.pm-metric-label {
  font-size: 11px; color: var(--hint); white-space: nowrap;
}

/* Menu groups */
.pm-group {
  background: var(--secondary-bg);
  border-radius: 14px;
  margin: 12px 0;
  overflow: hidden;
}
.pm-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.12s;
}
.pm-row:active { background: rgba(128,128,128,0.08); }
.pm-row-left { display: flex; align-items: center; gap: 12px; }
.pm-icon { font-size: 20px; width: 28px; text-align: center; }
.pm-label { font-size: 15px; font-weight: 500; color: var(--text); }
.pm-row-right { display: flex; align-items: center; gap: 6px; }
.pm-value { font-size: 14px; color: var(--hint); }
.pm-chevron { font-size: 20px; color: var(--hint); font-weight: 300; }
.pm-divider { height: 0.5px; background: var(--hint); opacity: 0.15; margin-inline-start: 56px; }

/* Toggle in menu */
.pm-toggle {
  width: 42px; height: 24px; border-radius: 12px;
  background: rgba(128,128,128,0.3); position: relative;
  transition: background 0.2s;
}
.pm-toggle.on { background: #34c759; }
.pm-toggle-knob {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; position: absolute;
  top: 2px; left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.pm-toggle.on .pm-toggle-knob { transform: translateX(18px); }

/* Auto-archive pills */
.aa-pill {
  padding: 6px 14px; border-radius: 16px; font-size: 13px;
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-hint-color);
  border: 1px solid var(--tg-theme-hint-color);
  cursor: pointer; transition: all 0.15s;
}
.aa-pill-active {
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color);
  border-color: var(--tg-theme-button-color);
}

/* Back header for sub-views */
.pm-back-header {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 4px 16px; cursor: pointer;
}
.pm-back-arrow {
  font-size: 28px; font-weight: 300; color: var(--btn);
  line-height: 1;
}
.pm-back-title {
  font-size: 18px; font-weight: 700; color: var(--text);
}

/* Features grid */
.feat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; padding: 4px 0 20px;
}
.feat-card {
  background: var(--secondary-bg); border-radius: 14px;
  padding: 14px; display: flex; flex-direction: column;
  gap: 4px;
}
.feat-icon { font-size: 28px; line-height: 1; margin-bottom: 2px; }
.feat-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  line-height: 1.2;
}
.feat-desc {
  font-size: 12px; color: var(--hint); line-height: 1.35;
}
@media (min-width: 580px) {
  .feat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Language picker — bottom sheet */
.pm-lang-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999; display: flex;
  align-items: flex-end; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.pm-lang-overlay.visible { opacity: 1; }
.pm-lang-sheet {
  background: var(--bg); border-radius: 16px 16px 0 0;
  padding: 0 0 calc(12px + env(safe-area-inset-bottom));
  width: 100%; max-width: 420px;
  max-height: 68vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.pm-lang-overlay.visible .pm-lang-sheet { transform: translateY(0); }
.pm-lang-handle {
  display: flex; justify-content: center; padding: 10px 0 4px;
  cursor: grab; flex-shrink: 0;
}
.pm-lang-handle::after {
  content: ""; width: 36px; height: 4px;
  background: var(--hint); opacity: 0.3; border-radius: 2px;
}
.pm-lang-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  text-align: center; padding: 2px 20px 10px; flex-shrink: 0;
}
.pm-lang-list {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1; min-height: 0;
}
.pm-lang-option {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; cursor: pointer;
  transition: background 0.12s;
}
.pm-lang-option:active { background: rgba(128,128,128,0.08); }
.pm-lang-option.active { background: rgba(var(--btn-rgb, 128,128,128), 0.08); }
.pm-lang-flag { font-size: 22px; }
.pm-lang-name { font-size: 15px; font-weight: 500; color: var(--text); flex: 1; }
.pm-lang-check { font-size: 16px; color: var(--btn); font-weight: 700; }

/* ── User avatar ───────────────────────────────── */
.stats-user-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.stats-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--btn);
}
.stats-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--btn);
  color: var(--btn-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}
.stats-user-info { flex: 1; }
.stats-user-name { font-size: 16px; font-weight: 700; }
.stats-user-sub { font-size: 12px; color: var(--hint); }

/* ── My stats in group ────────────────────────── */
.my-group-stats {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  margin-bottom: 12px;
}
.mgs-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.mgs-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--btn);
}
.mgs-avatar-placeholder {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--btn); color: var(--btn-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
.mgs-info { flex: 1; }
.mgs-name { font-size: 14px; font-weight: 700; }
.mgs-sub { font-size: 11px; color: var(--hint); }
.mgs-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.mgs-cards .stat-card {
  padding: 10px 8px;
}
.mgs-cards .sc-icon { font-size: 16px; }
.mgs-cards .sc-value { font-size: 20px; }
.mgs-cards .sc-label { font-size: 10px; }
.mgs-rate-wrap { padding: 0 2px; }
.mgs-rate-label { font-size: 11px; color: var(--hint); margin-bottom: 4px; }
.mgs-rate-bar {
  height: 6px; border-radius: 3px; background: rgba(128,128,128,0.15); overflow: hidden;
}
.mgs-rate-fill {
  height: 100%; border-radius: 3px; background: var(--btn); transition: width 0.4s ease;
}
.mgs-extra {
  max-height: 0; overflow: hidden; transition: max-height 0.3s ease;
}
.mgs-extra.open { max-height: 200px; }
.mgs-extra-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding-top: 8px;
}
.mgs-toggle {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; color: var(--link); cursor: pointer;
  padding: 6px 0 2px; user-select: none;
}
.mgs-toggle-arrow {
  display: inline-block; transition: transform 0.3s ease; font-size: 10px;
}
.mgs-toggle.open .mgs-toggle-arrow { transform: rotate(180deg); }

/* ── Files view ───────────────────────────────── */
.files-view { padding: 0 16px 100px; }
.files-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0 8px;
}
.files-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.files-count { font-size: 13px; color: var(--hint); }
.file-item {
  display: flex; gap: 12px; padding: 12px;
  background: var(--secondary-bg); border-radius: var(--radius);
  margin-bottom: 8px; align-items: center;
  text-decoration: none; color: var(--text); cursor: pointer;
  transition: opacity 0.15s; -webkit-tap-highlight-color: transparent;
}
.file-item:active { opacity: 0.7; }
.file-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
  background: rgba(128,128,128,0.08);
}
.file-icon.img { background: rgba(59,130,246,0.1); }
.file-icon.doc { background: rgba(37,99,235,0.1); }
.file-icon.audio { background: rgba(168,85,247,0.1); }
.file-icon.video { background: rgba(239,68,68,0.1); }
.file-body { flex: 1; min-width: 0; }
.file-name {
  font-size: 14px; font-weight: 500; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-meta {
  font-size: 11px; color: var(--hint); margin-top: 2px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.file-task-link {
  color: var(--link); cursor: pointer; font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 180px;
}
.file-task-link:hover { text-decoration: underline; }
.file-dl {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
  background: rgba(128,128,128,0.08); cursor: pointer;
  transition: background 0.15s;
}
.file-dl:active { background: rgba(128,128,128,0.18); }
.file-actions { display: flex; gap: 4px; flex-shrink: 0; }
.files-empty {
  text-align: center; color: var(--hint); padding: 40px 20px; font-size: 14px;
}
.files-empty-icon { font-size: 40px; margin-bottom: 12px; }
.files-filters { margin-bottom: 4px; }

/* ── Pins board ───────────────────────────────── */
.pins-view { padding: 0 16px 100px; }
.pins-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0 8px;
}
.pins-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.pins-count { font-size: 13px; color: var(--hint); }
.pin-add-bar {
  display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap;
}
.pin-add-btn {
  padding: 6px 12px; border-radius: 16px; border: 1px solid rgba(128,128,128,0.2);
  background: var(--secondary-bg); color: var(--text); font-size: 13px;
  cursor: pointer; transition: background 0.15s;
}
.pin-add-btn:active { background: rgba(128,128,128,0.15); }
.pin-card {
  background: var(--secondary-bg); border-radius: var(--radius);
  padding: 14px; margin-bottom: 8px;
  position: relative; transition: opacity 0.15s;
}
.pin-card:active { opacity: 0.85; }
.pin-card-top { display: flex; gap: 10px; align-items: flex-start; }
.pin-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  background: rgba(128,128,128,0.08);
}
.pin-icon.link { background: rgba(59,130,246,0.1); }
.pin-icon.note { background: rgba(234,179,8,0.1); }
.pin-icon.file { background: rgba(37,99,235,0.1); }
.pin-icon.task { background: rgba(34,197,94,0.1); }
.pin-body { flex: 1; min-width: 0; }
.pin-title {
  font-size: 14px; font-weight: 600; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pin-url {
  font-size: 12px; color: var(--link); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.pin-url:hover { text-decoration: underline; }
.pin-content {
  font-size: 13px; color: var(--hint); margin-top: 4px;
  line-height: 1.4; white-space: pre-wrap; word-break: break-word;
  max-height: 3.6em; overflow: hidden; transition: max-height 0.2s ease;
}
.pin-task-status {
  font-size: 11px; margin-top: 3px; color: var(--hint);
}
.pin-meta {
  font-size: 11px; color: var(--hint); margin-top: 6px;
  display: flex; gap: 8px; align-items: center;
}
.pin-actions {
  display: flex; gap: 4px; flex-shrink: 0; margin-inline-start: auto;
}
.pin-act-btn {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer;
  background: rgba(128,128,128,0.08);
  transition: background 0.15s; border: none; color: var(--text);
}
.pin-act-btn:active { background: rgba(128,128,128,0.18); }
.pin-act-btn.danger:active { background: rgba(239,68,68,0.2); }
.pins-empty {
  text-align: center; color: var(--hint); padding: 40px 20px; font-size: 14px;
}
.pins-empty-icon { font-size: 40px; margin-bottom: 12px; }
.pins-empty-hint { font-size: 12px; margin-top: 4px; }
.pin-section { margin-bottom: 16px; }
.pin-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px; cursor: pointer; font-size: 14px; font-weight: 600;
  color: var(--text); user-select: none;
}
.pin-section-header:active { opacity: 0.7; }
.pin-section-right { display: flex; align-items: center; gap: 6px; }
.pin-section-count {
  background: var(--secondary-bg); padding: 1px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 500; color: var(--hint);
}
.pin-section-chevron {
  font-size: 10px; color: var(--hint);
  transition: transform 0.2s; display: inline-block;
}
.pin-section-chevron.open { transform: rotate(0deg); }
.pin-section-chevron:not(.open) { transform: rotate(-90deg); }
.pin-color-picker { display: flex; gap: 8px; margin: 10px 0; }
.pin-color-dot {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border-color 0.15s;
}
.pin-color-dot.active { border-color: var(--text); }
.pin-color-dot:active { opacity: 0.7; }
.pin-scope-bar {
  display: flex; gap: 6px; padding: 0 0 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.pin-scope-bar::-webkit-scrollbar { display: none; }
.pin-scope-cnt {
  font-size: 11px; opacity: 0.6; margin-inline-start: 2px;
}
.pin-scope-toggle { display: flex; gap: 6px; margin-bottom: 12px; }
.pin-scope-opt {
  flex: 1; padding: 8px 12px; border-radius: 8px; text-align: center;
  cursor: pointer; font-size: 13px; font-weight: 500;
  background: rgba(128,128,128,0.08); color: var(--hint);
  transition: all 0.15s;
}
.pin-scope-opt.active {
  background: var(--accent, var(--link)); color: #fff;
}

/* ── File preview lightbox ─────────────────────── */
.file-preview-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column;
  opacity: 0; transition: opacity 0.2s ease;
}
.file-preview-overlay.show { opacity: 1; }
.fp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px));
  flex-shrink: 0;
}
.fp-filename {
  color: #fff; font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.fp-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.fp-btn {
  background: rgba(255,255,255,0.15); border: none; border-radius: 50%;
  width: 36px; height: 36px; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; transition: background 0.15s;
}
.fp-btn:active { background: rgba(255,255,255,0.3); }
.fp-close { font-size: 18px; font-weight: 700; }
.fp-content {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: auto; padding: 8px;
}
.fp-image {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 4px; user-select: none;
}
.fp-media {
  max-width: 100%; max-height: 100%; border-radius: 8px;
  background: #000;
}
.fp-audio-wrap {
  background: rgba(255,255,255,0.08); border-radius: 16px;
  padding: 32px 24px; text-align: center; min-width: 280px;
}
.fp-audio-icon { font-size: 48px; margin-bottom: 12px; }
.fp-audio-name { color: #fff; font-size: 14px; margin-bottom: 16px; word-break: break-word; }
.fp-audio { width: 100%; }
.fp-pdf {
  width: 100%; height: 100%; border: none; border-radius: 8px;
  background: #fff;
}
.fp-text {
  width: 100%; height: 100%; margin: 0; padding: 16px; box-sizing: border-box;
  background: #1e1e2e; color: #cdd6f4; border-radius: 8px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 13px; line-height: 1.5;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
  user-select: text; -webkit-user-select: text;
}

.fp-note {
  width: 100%; max-width: 480px; margin: 0 auto; padding: 24px; box-sizing: border-box;
  background: var(--bg); border-radius: 12px;
  max-height: 80vh; overflow: auto;
  user-select: text; -webkit-user-select: text;
}
.fp-note-title {
  font-size: 18px; font-weight: 600; color: var(--text);
  margin-bottom: 12px; line-height: 1.3;
}
.fp-note-body {
  font-size: 15px; color: var(--text); line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}

/* ── File drop overlay ──────────────────────────── */
.file-drop-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; pointer-events: all;
}
.file-drop-overlay.visible { display: flex; }
.file-drop-zone {
  width: 80%; max-width: 320px; padding: 28px 20px;
  background: var(--secondary-bg, #1e1e1e); border: 2px dashed var(--accent, var(--link));
  border-radius: 16px; text-align: center; cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.file-drop-zone:hover, .file-drop-zone.drag-hover {
  transform: scale(1.03); border-color: #22c55e;
  background: rgba(34,197,94,0.08);
}
.file-drop-zone-icon { font-size: 32px; margin-bottom: 8px; }
.file-drop-zone-label { font-size: 15px; font-weight: 600; color: var(--text); }
.file-drop-zone-hint { font-size: 12px; color: var(--hint); margin-top: 4px; }
.file-drop-inline {
  border: 2px dashed rgba(128,128,128,0.3); border-radius: 12px;
  padding: 20px; text-align: center; margin: 8px 0;
  transition: border-color 0.15s, background 0.15s;
  color: var(--hint); font-size: 13px;
}
.file-drop-inline.drag-hover {
  border-color: var(--accent, var(--link));
  background: rgba(59,130,246,0.06);
  color: var(--text);
}
.pin-link-preview {
  display: flex; align-items: center; gap: 8px; margin-top: 2px;
}
.pin-favicon {
  width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0;
  object-fit: contain;
}
.pin-domain {
  font-size: 12px; color: var(--hint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pin-search-wrap {
  padding: 0 0 8px;
}
.pin-search {
  width: 100%; padding: 9px 12px 9px 34px; padding-inline: 34px 12px; border: 1px solid rgba(128,128,128,0.2);
  border-radius: 10px; background: var(--secondary-bg); color: var(--text);
  font-size: 14px; box-sizing: border-box; outline: none;
}
.pin-search:focus { border-color: var(--accent, var(--link)); }
.pin-search-icon {
  position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%);
  font-size: 15px; color: var(--hint); pointer-events: none;
}
.pin-card.dragging {
  opacity: 0.5; transform: scale(0.97);
}
.pin-card.drag-over {
  border-top: 2px solid var(--accent, var(--link));
}

/* ── Activity feed ────────────────────────────── */
.activity-view { padding: 0 16px 100px; }
.act-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0 8px;
}
.act-header h2 { font-size: 18px; font-weight: 700; margin: 0; }
.act-day-label {
  font-size: 12px; font-weight: 600; color: var(--hint);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 12px 0 6px;
}
.act-item {
  display: flex; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid rgba(128,128,128,0.1);
  align-items: flex-start;
}
.act-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
  background: var(--secondary-bg);
}
.act-body { flex: 1; min-width: 0; }
.act-text { font-size: 13px; line-height: 1.4; }
.act-text strong { font-weight: 600; }
.act-task-title {
  color: var(--link); font-weight: 500; cursor: pointer;
}
.act-task-title:hover { text-decoration: underline; }
.act-meta {
  font-size: 11px; color: var(--hint); margin-top: 2px;
}
.act-detail {
  font-size: 12px; color: var(--hint); margin-top: 2px;
  font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.act-load-more {
  display: block; width: 100%; text-align: center;
  padding: 12px; margin-top: 8px; border: none; background: var(--secondary-bg);
  color: var(--link); border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500;
}
.act-load-more:active { opacity: 0.7; }
.act-empty {
  text-align: center; color: var(--hint); padding: 40px 20px;
  font-size: 14px;
}
.act-empty-icon { font-size: 40px; margin-bottom: 12px; }
.act-filters { margin-bottom: 8px; }
.act-action-bar {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.act-action-bar::-webkit-scrollbar { display: none; }
.act-chip {
  flex-shrink: 0; padding: 6px 12px; border-radius: 16px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  background: var(--secondary-bg); color: var(--hint);
  transition: all 0.2s; white-space: nowrap;
}
.act-chip.active {
  background: var(--btn); color: var(--btn-text, #fff);
}
.act-chip:active { opacity: 0.7; }
.act-member-bar {
  display: flex; gap: 8px; overflow-x: auto; padding: 0 0 10px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.act-member-bar::-webkit-scrollbar { display: none; }
.act-member-chip {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 5px 12px 5px 5px; border-radius: 20px;
  background: var(--secondary-bg); cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
}
.act-member-chip.active {
  background: var(--btn); color: var(--btn-text, #fff);
}
.act-member-chip:active { opacity: 0.7; }
.amc-avatar, .amc-avatar-ph {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover;
}
.amc-avatar-ph {
  display: flex; align-items: center; justify-content: center;
  background: rgba(128,128,128,0.2); font-size: 11px; font-weight: 600;
  color: var(--hint);
}
.act-member-chip.active .amc-avatar-ph {
  background: rgba(255,255,255,0.2); color: var(--btn-text, #fff);
}
.amc-icon {
  width: 24px; height: 24px; display: flex; align-items: center;
  justify-content: center; font-size: 15px;
}
.amc-name { font-size: 12px; font-weight: 500; }

/* ── Group stats: leaderboard ────────────────── */
.stats-leaderboard {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 16px;
}
.stats-leaderboard h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.lb-list { display: flex; flex-direction: column; gap: 10px; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
}
.lb-rank {
  width: 22px; font-size: 14px; font-weight: 700; text-align: center; flex-shrink: 0;
  color: var(--hint);
}
.lb-rank.gold { color: #f5a623; }
.lb-rank.silver { color: #a0a0a0; }
.lb-rank.bronze { color: #cd7f32; }
.lb-avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.lb-avatar-placeholder {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--btn); color: var(--btn-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-metrics { display: flex; gap: 8px; font-size: 11px; color: var(--hint); }
.lb-metrics .done { color: #27ae60; font-weight: 600; }
.lb-metrics .active { color: var(--btn); font-weight: 600; }
.lb-row.lb-left-group { opacity: 0.5; }
.lb-badge-left {
  display: inline-block; font-size: 10px; font-weight: 600;
  color: var(--hint); background: var(--bg);
  border: 1px solid var(--hint); border-radius: 6px;
  padding: 1px 6px; margin-inline-start: 6px; vertical-align: middle;
  white-space: nowrap;
}

/* ── Group stats: contribution donut ─────────── */
.stats-contrib-section {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 16px;
}
.stats-contrib-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }

/* ── Subscription card ────────────────────────── */
.sub-card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.sub-card.active {
  background: linear-gradient(135deg, var(--btn), color-mix(in srgb, var(--btn), #000 15%));
  color: var(--btn-text);
}
.sub-card.active .sub-card-hint,
.sub-card.active .sub-card-label { color: color-mix(in srgb, var(--btn-text), transparent 30%); }
.sub-card.expired {
  border: 1.5px solid rgba(231, 76, 60, 0.3);
}
.sub-card.grace {
  border: 1.5px solid rgba(243, 156, 18, 0.3);
}
.sub-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sub-card-info { flex: 1; }
.sub-card-type {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sub-card-type .sub-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(255,255,255,0.2);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.sub-card:not(.active) .sub-badge {
  background: var(--btn);
  color: var(--btn-text);
}
.sub-card.expired .sub-badge { background: #e74c3c; color: #fff; }
.sub-card.grace .sub-badge { background: #f39c12; color: #fff; }
.sub-card-hint {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}
.sub-card-label {
  font-size: 11px;
  color: var(--hint);
  margin-top: 8px;
  margin-bottom: 3px;
  font-weight: 500;
}
.sub-progress {
  height: 6px;
  border-radius: 3px;
  background: rgba(128,128,128,0.15);
  overflow: hidden;
}
.sub-card.active .sub-progress { background: rgba(255,255,255,0.2); }
.sub-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--btn);
  transition: width 0.5s ease;
}
.sub-card.active .sub-progress-fill { background: rgba(255,255,255,0.7); }
.sub-card.expired .sub-progress-fill { background: #e74c3c; }
.sub-card.grace .sub-progress-fill { background: #f39c12; }
.sub-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: var(--btn);
  color: var(--btn-text);
}
.sub-card.active .sub-card-btn {
  background: rgba(255,255,255,0.2);
  color: var(--btn-text);
}
.sub-card-btn:active { opacity: 0.7; }
.sub-card-days {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  text-align: end;
}
.sub-card-days-label {
  font-size: 11px;
  font-weight: 500;
  text-align: end;
  color: var(--hint);
}
.sub-card.active .sub-card-days-label { color: color-mix(in srgb, var(--btn-text), transparent 30%); }

/* ── Theme picker ──────────────────────────────── */
.theme-section {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.theme-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.theme-card {
  cursor: pointer;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: all 0.2s;
  overflow: hidden;
  background: var(--bg);
}
.theme-card:active { transform: scale(0.95); }
.theme-card.active {
  border-color: var(--btn);
  box-shadow: 0 0 0 1px var(--btn);
}
.theme-preview {
  height: 60px;
  border-radius: 8px 8px 0 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.tp-bar {
  height: 6px;
  border-radius: 3px;
  width: 100%;
}
.tp-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.tp-line {
  height: 3px;
  border-radius: 2px;
  opacity: 0.7;
}
.tp-line.sm { height: 2px; }
.tp-system {
  flex-direction: row; padding: 0; gap: 0;
}
.tp-sys-half {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  padding: 6px; justify-content: center;
}
.tp-sys-light { background: #ffffff; border-radius: 8px 0 0 0; }
.tp-sys-dark  { background: #000000; border-radius: 0 8px 0 0; }
.tp-card {
  border-radius: 4px;
  padding: 4px 5px;
}
.theme-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 4px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.custom-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary-bg);
  position: relative;
}
.custom-color-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px dashed var(--hint);
  position: relative;
  pointer-events: none;
}
.custom-color-circle::after {
  content: "✏️";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.hidden-color-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

/* ── Assignee badge ────────────────────────────── */
.assignee-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.assignee-badges {
  display: flex;
  align-items: center;
}
.assignee-badge {
  display: inline-flex;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--btn);
  color: var(--btn-text);
  align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 1.5px var(--card-bg, #fff);
  margin-inline-start: -5px;
  position: relative;
}
.assignee-badges .assignee-badge:first-child { margin-inline-start: 0; }
.assignee-avatar {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.assignee-name {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  line-height: 1;
}
/* ── Assignee picker in task sheet ──────────────── */
.assignee-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.assignee-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 5px;
  border: 2px solid rgba(128,128,128,0.18);
  border-radius: 20px;
  background: var(--secondary-bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.assignee-chip.active {
  border-color: var(--btn);
  background: color-mix(in srgb, var(--btn) 12%, transparent);
}
.assignee-chip.left {
  opacity: 0.45;
}
.assignee-chip-ava {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--btn);
  color: var(--btn-text);
  font-weight: 600;
  font-size: 10px;
  overflow: hidden;
  flex-shrink: 0;
}
.assignee-chip-ava img {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.assignee-chip-name {
  font-size: 13px;
  white-space: nowrap;
}
/* ── Filter bar ────────────────────────────────── */
.filter-bar { display: none; gap: 6px; padding: 6px 12px; }
.filter-bar.visible { display: flex; }
.filter-bar.visible + .tabs-wrap .tabs { padding-top: 0; }
/* Safe area padding only in actual fullscreen (no Telegram header) */
.tg-fullscreen .tabs { padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }
.tg-fullscreen .filter-bar { padding-top: calc(6px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }
.tg-fullscreen .filter-bar.visible + .tabs-wrap .tabs { padding-top: 0; }
.filter-btn { flex: 1; padding: 6px; border: 1px solid var(--hint); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; font-size: 12px; }
.filter-btn.active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }

/* ── Cross-context scope chips (personal chat) ──────────────────────────── */
#crossContextFilter {
  display: none;
  padding: 6px 12px;
  overflow-x: auto;
  white-space: nowrap;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
  background: var(--secondary-bg);
  border-bottom: 1px solid rgba(128,128,128,0.15);
}
#crossContextFilter.visible { display: flex; }

.scope-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid var(--hint);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.scope-chip:hover { border-color: var(--btn); }
.scope-chip.active {
  background: var(--btn);
  color: var(--btn-text);
  border-color: var(--btn);
}

/* Group badge on task cards */
.group-badge {
  display: inline-block;
  background: var(--secondary-bg);
  color: var(--hint);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-inline-start: 6px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ── Collapsible stats sections ────────────────── */
.stats-section-wrap { margin: 12px 0; }
.stats-section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 16px; margin-bottom: 4px;
}
.stats-section-header span:first-child { font-size: 13px; font-weight: 600; color: var(--text); }
.stats-hide-btn {
  font-size: 12px; color: var(--hint); cursor: pointer;
  padding: 4px 8px; border-radius: 8px;
  transition: background .15s;
}
.stats-hide-btn:hover { background: var(--secondary-bg); }
.stats-collapsed-toggle {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; margin: 8px 0; cursor: pointer;
  border-radius: 12px; background: var(--secondary-bg);
}
.stats-collapsed-toggle span:first-child { font-size: 13px; color: var(--hint); }
.stats-toggle-hint { font-size: 12px; color: var(--btn); }

/* ── Profile groups section ────────────────────── */
.profile-groups-empty { text-align: center; padding: 40px 24px; }
.pge-icon { font-size: 48px; margin-bottom: 12px; }
.pge-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.pge-hint { font-size: 14px; color: var(--hint); line-height: 1.4; }
.profile-groups-section { margin: 16px 0 8px; }
.profile-groups-section h3 { font-size: 15px; font-weight: 700; margin: 0 0 10px; padding: 0 4px; }
.profile-groups-list { display: flex; flex-direction: column; gap: 8px; }
.profile-group-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--secondary-bg); cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.profile-group-card:active { transform: scale(0.98); }
.pg-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}
.pg-avatar-ph {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--btn); color: var(--btn-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.pg-info { flex: 1; min-width: 0; }
.pg-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--hint); margin-top: 2px; flex-wrap: wrap; }
.pg-roles { display: flex; gap: 4px; flex-wrap: wrap; }
.pg-role-tag {
  display: inline-block; padding: 1px 6px; border-radius: 6px;
  font-size: 11px; font-weight: 500;
  background: color-mix(in srgb, var(--btn) 15%, transparent);
  color: var(--btn);
}
.pg-tg-status {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
}
.pg-tg-status.owner {
  background: color-mix(in srgb, #f59e0b 18%, transparent);
  color: #d97706;
}
.pg-tg-status.admin {
  background: color-mix(in srgb, #3b82f6 18%, transparent);
  color: #2563eb;
}
.pg-tg-status.member {
  background: color-mix(in srgb, #6b7280 15%, transparent);
  color: var(--hint);
}
.pg-chevron { font-size: 18px; color: var(--hint); flex-shrink: 0; }

/* ── Team section ──────────────────────────────── */
.team-section { margin-top: 28px; }
.team-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2px; margin-bottom: 12px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.team-section-left { display: flex; align-items: center; gap: 8px; }
.team-section-title { font-size: 15px; font-weight: 600; color: var(--text); }
.team-section-count {
  font-size: 11px; font-weight: 600; background: var(--btn); color: var(--btn-text);
  border-radius: 10px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.team-section-chevron {
  font-size: 14px; color: var(--hint); transition: transform 0.25s ease;
}
.team-section-chevron.collapsed { transform: rotate(-90deg); }
.team-list { overflow: hidden; transition: max-height 0.3s ease, opacity 0.25s ease; }
.team-list.collapsed { max-height: 0 !important; opacity: 0; pointer-events: none; }
.team-actions-row {
  display: flex; gap: 8px; margin-top: 8px; margin-bottom: 4px;
  transition: max-height 0.3s ease, opacity 0.25s ease; overflow: hidden; max-height: 60px;
}
.team-actions-row.collapsed { max-height: 0; opacity: 0; pointer-events: none; }
.team-action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 8px; border-radius: 12px; border: 1.5px dashed var(--hint);
  background: transparent; color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: all 0.15s;
}
.team-action-btn:active { opacity: 0.6; }
.team-action-icon { font-size: 15px; }
.team-add-form { padding: 4px 0; }
.team-add-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.team-add-input-row input {
  flex: 1; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--hint);
  background: var(--secondary-bg); color: var(--text); font-size: 15px; outline: none;
}
.team-add-input-row input:focus { border-color: var(--btn); }
.team-add-submit-btn {
  padding: 10px 18px; border-radius: 12px; border: none;
  background: var(--btn); color: var(--btn-text); font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.team-add-submit-btn:disabled { opacity: 0.5; }
.team-add-error { color: #e74c3c; font-size: 13px; min-height: 18px; padding: 0 2px; }
.team-add-divider { height: 1px; background: var(--hint); opacity: 0.3; margin: 18px 0; }
.team-invite-section { text-align: center; }
.team-invite-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.team-invite-desc { font-size: 13px; color: var(--hint); margin-bottom: 14px; line-height: 1.4; }
.team-invite-link-row {
  display: flex; gap: 8px; align-items: center;
}
.team-invite-link-row input {
  flex: 1; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--hint);
  background: var(--secondary-bg); color: var(--text); font-size: 13px;
  outline: none; user-select: all; -webkit-user-select: all;
}
.team-invite-link-row input:focus { border-color: var(--btn); }
.team-invite-share-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none;
  background: var(--btn); color: var(--btn-text); font-size: 18px; font-weight: 700;
  cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.team-invite-share-btn:active { opacity: 0.7; }
.team-invite-loading { color: var(--hint); font-size: 14px; }

.team-member-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--secondary-bg); border-radius: 14px; padding: 12px 14px;
  margin-bottom: 8px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.team-member-card:active { background: var(--hint); opacity: 0.7; }

.team-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--btn), var(--hint));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; color: #fff; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.team-avatar img { width: 100%; height: 100%; object-fit: cover; }

.team-info { flex: 1; min-width: 0; }
.team-name-row { display: flex; align-items: baseline; gap: 6px; }
.team-name { font-size: 14px; font-weight: 600; color: var(--text); }
.team-username { font-size: 12px; color: var(--hint); }
.team-you-badge {
  font-size: 10px; font-weight: 600; background: var(--btn); color: var(--btn-text);
  border-radius: 6px; padding: 1px 5px; margin-inline-start: 2px;
}
.team-stats-row {
  display: flex; gap: 10px; margin-top: 3px; font-size: 11px; color: var(--hint);
}
.team-stats-row .stat-active { color: var(--btn); font-weight: 500; }
.team-stats-row .stat-done { color: #10b981; font-weight: 500; }

.team-roles-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.team-role-tag {
  font-size: 11px; font-weight: 500;
  border-radius: 10px; padding: 2px 9px; white-space: nowrap;
  border: 1px solid transparent;
}
.team-no-roles { font-size: 12px; color: var(--hint); margin-top: 3px; font-style: italic; }

/* Role tag colors (rotate) */
.team-role-tag.rc0 { background: rgba(124,58,237,0.15); color: #7c3aed; border-color: rgba(124,58,237,0.25); }
.team-role-tag.rc1 { background: rgba(59,130,246,0.15); color: #3b82f6; border-color: rgba(59,130,246,0.25); }
.team-role-tag.rc2 { background: rgba(16,185,129,0.15); color: #10b981; border-color: rgba(16,185,129,0.25); }
.team-role-tag.rc3 { background: rgba(245,158,11,0.15); color: #d97706; border-color: rgba(245,158,11,0.25); }
.team-role-tag.rc4 { background: rgba(239,68,68,0.15); color: #ef4444; border-color: rgba(239,68,68,0.25); }
.team-role-tag.rc5 { background: rgba(236,72,153,0.15); color: #ec4899; border-color: rgba(236,72,153,0.25); }

/* Team role editor — bottom sheet */
.team-role-sheet-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.team-role-sheet-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--btn), var(--hint));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; color: #fff; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.team-role-sheet-avatar img { width: 100%; height: 100%; object-fit: cover; }
.team-role-sheet-name { font-size: 16px; font-weight: 600; color: var(--text); }
.team-role-sheet-username { font-size: 13px; color: var(--hint); margin-top: 1px; }

.team-role-section-label {
  font-size: 12px; font-weight: 600; color: var(--hint);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px; margin-top: 4px;
}
.team-role-chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.team-role-chip {
  font-size: 14px; font-weight: 500;
  border-radius: 14px; padding: 7px 14px; display: flex; align-items: center; gap: 8px;
  border: 1px solid transparent;
}
.team-role-chip .remove-role {
  cursor: pointer; opacity: 0.5; font-size: 18px; line-height: 1;
  -webkit-tap-highlight-color: transparent;
  padding: 2px;
}
.team-role-chip .remove-role:active { opacity: 1; }

.team-role-presets-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.team-role-preset {
  font-size: 13px; color: var(--hint); background: var(--secondary-bg);
  border: 1.5px dashed rgba(128,128,128,0.3); border-radius: 12px;
  padding: 8px 14px; min-height: 38px;
  cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center;
}
.team-role-preset:active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }

.team-role-input-row { display: flex; gap: 8px; }
.team-role-input-row input {
  flex: 1; font-size: 16px; padding: 12px 14px; border: 1.5px solid var(--hint);
  border-radius: 12px; background: var(--bg); color: var(--text); outline: none;
  transition: border-color 0.15s;
}
.team-role-input-row input:focus { border-color: var(--btn); }
.team-role-input-row button {
  font-size: 14px; font-weight: 600; padding: 12px 20px; border: none; border-radius: 12px;
  background: var(--btn); color: var(--btn-text); cursor: pointer; white-space: nowrap;
  transition: opacity 0.15s;
  min-height: 48px;
}
.team-role-input-row button:active { opacity: 0.7; }

.team-remove-btn {
  width: 100%; margin-top: 20px; padding: 14px; border: none; border-radius: 12px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: rgba(239, 68, 68, 0.1); color: #ef4444;
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.team-remove-btn:active { opacity: 0.7; }

.team-empty {
  text-align: center; color: var(--hint); font-size: 13px; padding: 20px 0;
  font-style: italic;
}

/* ── Mobile kanban adaptation ──────────────────── */
@media (max-width: 600px) {
  .kanban { padding: 6px; gap: 6px; }
  .column { flex: 0 0 calc(100vw - 24px); overflow: hidden; }
  .column-body { padding: 0 6px 72px; }
  .card-inner { padding: 8px 10px 8px 14px; padding-inline: 14px 10px; }
  .card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
  }
  .card-done-btn { width: 24px; height: 24px; }
  .card-meta { font-size: 10px; gap: 4px; margin-top: 4px; padding-top: 4px; }
  .card-meta .tag { padding: 1px 4px; }
  .card-age-badge { font-size: 10px; padding: 1px 5px; }
  .card-notes { font-size: 11px; -webkit-line-clamp: 1; }
}

/* ── Create limit counter (near FAB) ─────────────── */
.create-limit-counter {
  position: fixed; bottom: 80px; inset-inline-end: 16px; z-index: 99;
  background: var(--secondary-bg); border-radius: 12px; padding: 4px 10px;
  font-size: 12px; font-weight: 600; color: var(--hint);
  display: none; align-items: center; gap: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.create-limit-counter.limit-warn { color: #e67e22; }
.create-limit-counter.limit-reached { color: #e74c3c; background: rgba(231,76,60,0.1); }

/* ── Limit banner (top of content when limit reached) */
.limit-banner {
  display: none; align-items: center; gap: 12px;
  background: rgba(231,76,60,0.08); border: 1px solid rgba(231,76,60,0.2);
  border-radius: 14px; padding: 12px 16px; margin: 8px 16px;
}
.limit-banner-text { flex: 1; }
.limit-banner-text strong { display: block; font-size: 14px; color: var(--text); }
.limit-banner-text span { font-size: 12px; color: var(--hint); }
.limit-banner-btn {
  background: var(--btn); color: var(--btn-text); border: none; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.limit-banner-btn:active { opacity: 0.7; }

/* ── Referral card ────────────────────────────────── */
.ref-card {
  background: var(--secondary-bg); border-radius: 16px; padding: 16px; margin-top: 12px;
}
.ref-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ref-card-icon { font-size: 28px; }
.ref-card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.ref-card-sub { font-size: 12px; color: var(--hint); margin-top: 2px; }
.ref-progress-section { margin-bottom: 14px; }
.ref-progress-text { font-size: 13px; color: var(--text); margin-bottom: 6px; font-weight: 600; }
.ref-progress-bar {
  height: 8px; border-radius: 4px; background: rgba(128,128,128,0.15); overflow: hidden;
}
.ref-progress-fill {
  height: 100%; border-radius: 4px; background: var(--btn);
  transition: width 0.3s ease;
}
.ref-progress-hint { font-size: 11px; color: var(--hint); margin-top: 4px; }
.ref-link-section { margin-bottom: 12px; }
.ref-link-label { font-size: 12px; color: var(--hint); margin-bottom: 6px; }
.ref-link-row { display: flex; gap: 8px; }
.ref-link-input {
  flex: 1; background: var(--bg); border: 1px solid rgba(128,128,128,0.2); border-radius: 10px;
  padding: 8px 12px; font-size: 12px; color: var(--text); min-width: 0;
}
.ref-copy-btn {
  background: var(--secondary-bg); border: 1px solid rgba(128,128,128,0.2); border-radius: 10px;
  padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--text); cursor: pointer;
}
.ref-copy-btn:active { opacity: 0.7; }
.ref-share-btn {
  width: 100%; background: var(--btn); color: var(--btn-text); border: none; border-radius: 12px;
  padding: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.ref-share-btn:active { opacity: 0.7; }

/* ── Routine assignee avatars ── */
.rtn-assignees { display:flex; gap:2px; margin-top:4px; flex-wrap:wrap; }
.rtn-assignee-ava { width:22px; height:22px; border-radius:50%; overflow:hidden; display:inline-flex; align-items:center; justify-content:center; background:var(--secondary-bg); font-size:11px; color:var(--hint); flex-shrink:0; }
.rtn-assignee-ava img { width:100%; height:100%; object-fit:cover; border-radius:50%; }

/* ── Desktop/laptop adaptation for stats/profile ── */
@media (min-width: 580px) {
  /* Comfortable reading width, centered */
  .stats-view {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px 20px 80px;
  }

  /* Groups — side by side */
  .profile-groups-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .profile-group-card { padding: 10px 12px; gap: 10px; }
  .pg-avatar, .pg-avatar-ph { width: 36px; height: 36px; font-size: 16px; }

  /* Insights — all 4 in one row */
  .insights-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
  .insight-card { flex: unset; min-width: unset; }

  /* Theme grid — 4 columns */
  .theme-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .theme-preview { height: 52px; }
  .custom-color-circle { width: 30px; height: 30px; }
}

/* ── Markdown rendered notes ─────────────────────── */
.md-rendered {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}
.md-rendered.hidden { display: none; }
textarea.hidden { display: none; }
.md-rendered a { color: var(--accent); text-decoration: underline; }
.md-rendered strong { font-weight: 600; }
.md-rendered em { font-style: italic; }
.md-rendered del { text-decoration: line-through; opacity: 0.6; }
.md-rendered .md-h1 { display: block; font-size: 17px; margin: 8px 0 4px; }
.md-rendered .md-h2 { display: block; font-size: 15px; margin: 6px 0 3px; }
.md-rendered .md-h3 { display: block; font-size: 14px; margin: 4px 0 2px; }
.md-rendered .md-list { padding-inline-start: 18px; margin: 4px 0; list-style: disc; }
.md-rendered .md-list li { margin-bottom: 2px; }
.md-rendered .md-check { list-style: none; margin-inline-start: -18px; }
.md-rendered .md-check.done { opacity: 0.6; text-decoration: line-through; }
.md-rendered .md-code {
  background: var(--secondary-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}
.md-rendered .md-pre {
  background: var(--secondary-bg);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
  margin: 6px 0;
}
.md-toggle {
  cursor: pointer;
  font-size: 12px;
  opacity: 0.6;
  margin-inline-start: 6px;
  vertical-align: middle;
}
.md-toggle:hover { opacity: 1; }

/* ── RTL (Arabic) ────────────────────────────────── */
[dir="rtl"] {
  direction: rtl;
}
/* Swipe actions flip to opposite side */
[dir="rtl"] .card-actions {
  inset-inline-end: auto;
  inset-inline-start: 0;
  flex-direction: row-reverse;
}
[dir="rtl"] .card.swiped .card-inner { transform: translateX(152px); }
[dir="rtl"] .card-inner.swipe-hint-anim {
  animation: swipeHintRtl 1.2s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes swipeHintRtl {
  0%   { transform: translateX(0); }
  30%  { transform: translateX(80px); }
  55%  { transform: translateX(80px); }
  100% { transform: translateX(0); }
}
/* Accent bar on cards flips to right edge */
[dir="rtl"] .card-inner::before {
  border-radius: 0 10px 10px 0;
}
[dir="rtl"] .project-card::before {
  border-radius: 0 14px 14px 0;
}
[dir="rtl"] .project-task-card::before {
  border-radius: 0 10px 10px 0;
}
/* Kanban scrolls from right in RTL */
[dir="rtl"] .kanban {
  flex-direction: row-reverse;
}
/* Tabs fade hint flips to left */
[dir="rtl"] .tabs-wrap::after {
  inset-inline-end: auto;
  inset-inline-start: 0;
  background: linear-gradient(to left, transparent, var(--secondary-bg));
}
/* Flip chevrons/arrows */
[dir="rtl"] .project-chevron,
[dir="rtl"] .pm-chevron,
[dir="rtl"] .pg-chevron,
[dir="rtl"] .pm-back-arrow {
  transform: scaleX(-1);
}
/* Toggle knobs: NOT mirrored in RTL — toggles are universal UI (right=ON everywhere) */

/* ── Reduced motion ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
