/* ==========================================================================
   pages.css — Layouts specific to individual pages
   Dashboard · Tasks · Subjects · Calendar · Progress · Notes · About
   ========================================================================== */

/* ==========================================================================
   Shared: stat cards & toolbars
   ========================================================================== */
/* Two-column layout that collapses to one column on narrow screens. */
.two-col { grid-template-columns: 1.3fr 1fr; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }



/* Toolbar (search + filters + sort + add) — Flexbox, wraps on small screens */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.toolbar .select { width: auto; min-width: 150px; }

/* ==========================================================================
  DASHBOARD
  ========================================================================== */

/* ---------- Hero -------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--gradient);
  color: #fff;
  box-shadow: var(--shadow-primary);
  margin-bottom: var(--space-6);
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -90px;
  top: -120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  right: 150px;
  bottom: -90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  pointer-events: none;
}

.hero h1 {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: clamp(1.8rem, 4vw, var(--fs-3xl));
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero p {
  position: relative;
  z-index: 1;
  max-width: 620px;
  color: rgba(255, 255, 255, 0.88);
  margin-top: var(--space-2);
}

.hero .hero__date {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  margin-bottom: var(--space-3);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: var(--fs-sm);
  font-weight: 600;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ---------- Dashboard stats -------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
}

.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 92px;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition);
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.18),
    transparent 55%
  );
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.stat-card:hover::after {
  opacity: 1;
}

.stat-card__icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
}

.stat-card__icon svg {
  width: var(--icon-md);
  height: var(--icon-md);
}

.stat-card__icon.green {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
}

.stat-card__icon.orange {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  color: var(--warning);
}

.stat-card__icon.blue {
  background: color-mix(in srgb, var(--info) 15%, transparent);
  color: var(--info);
}

.stat-card__value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-card__label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 5px;
}

/* ---------- Dashboard main layout -------------------------------------- */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.dash-col {
  display: grid;
  gap: var(--space-5);
}

/* ---------- Dashboard cards -------------------------------------------- */
.dash-col > .card {
  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.dash-col > .card:hover {
  box-shadow: var(--shadow-md);
}

/* ---------- Quote card ------------------------------------------------- */
.quote-card {
  position: relative;
  overflow: hidden;
  background: var(--gradient-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.quote-card::after {
  content: "“";
  position: absolute;
  right: 18px;
  bottom: -35px;
  font-family: Georgia, serif;
  font-size: 9rem;
  line-height: 1;
  color: var(--primary);
  opacity: 0.06;
  pointer-events: none;
}

.quote-card__mark {
  font-size: 3rem;
  line-height: 1;
  color: var(--primary);
  opacity: 0.35;
  font-family: Georgia, serif;
}

.quote-card blockquote {
  position: relative;
  z-index: 1;
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.55;
  color: var(--text);
  margin: var(--space-2) 0;
}

.quote-card cite {
  position: relative;
  z-index: 1;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-style: normal;
  font-weight: 600;
}

/* ---------- Dashboard lists -------------------------------------------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast);
}

.list-item:hover {
  background: var(--surface-2);
  border-color: var(--border);
  transform: translateX(2px);
}

.list-item__main {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.list-item__meta {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.list-item.done .list-item__title {
  text-decoration: line-through;
  color: var(--text-faint);
}

/* ---------- Priority labels -------------------------------------------- */
.priority-high {
  color: var(--danger);
  font-weight: 700;
}

.priority-medium {
  color: var(--warning);
  font-weight: 700;
}

.priority-low {
  color: var(--success);
  font-weight: 700;
}

/* ---------- Exam countdown -------------------------------------------- */
.countdown {
  min-width: 62px;
  padding: 8px 6px;
  text-align: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid transparent;
  transition:
    transform var(--transition-fast),
    border-color var(--transition-fast);
}

.list-item:hover .countdown {
  transform: scale(1.04);
  border-color: var(--border-strong);
}

.countdown b {
  display: block;
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.countdown small {
  display: block;
  margin-top: 3px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Responsive dashboard -------------------------------------- */
@media (max-width: 1050px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: var(--space-5);
    margin-bottom: var(--space-5);
  }

  .hero h1 {
    font-size: var(--fs-2xl);
  }

  .hero p {
    font-size: var(--fs-sm);
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .stat-card {
    min-height: 78px;
  }

  .dash-grid {
    gap: var(--space-4);
  }
}
/* ==========================================================================
   PROGRESS RINGS  (used on Dashboard progress card + Progress page)
   ========================================================================== */
.ring-wrap { display: grid; place-items: center; position: relative; }
.ring { transform: rotate(-90deg); }
.ring__track { fill: none; stroke: var(--surface-3); }
.ring__bar {
  fill: none;
  stroke: url(#ringGradient);
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-slow);
}
.ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}
.ring__label b { font-size: var(--fs-2xl); font-weight: 800; color: var(--text); line-height: 1; }
.ring__label small { font-size: var(--fs-xs); color: var(--text-muted); }

/* Linear progress bar (per-subject) */
.progress-row { margin-bottom: var(--space-4); }
.progress-row__top { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: var(--fs-sm); }
.progress-row__top b { color: var(--text); font-weight: 700; }
.bar { height: 10px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.bar__fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--gradient);
  width: 0;
  transition: width var(--transition-slow);
}

/* ==========================================================================
   TASKS
   ========================================================================== */
.task-tabs {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.task-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.task-tab:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.task-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.task-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-muted);
}
.task-tab.active .task-tab__count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}
.task-tab.urgent .task-tab__count {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}
.task-tab.active.urgent .task-tab__count {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
}

/* Suggested Next Task Card */
.suggested-card {
  position: relative;
  overflow: hidden;
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-5);
  animation: fadeInUp var(--transition) both;
}
.suggested-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}
.suggested-card__tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.suggested-card__reason {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}
.suggested-card__body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.suggested-card__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.suggested-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Summary Bar & Workload */
.task-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 0 0 var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.task-summary-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.task-workload-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-body);
}

/* Bulk Selection Toolbar */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1.5px solid var(--purple-200);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  animation: fadeInUp var(--transition-fast) both;
}
[data-theme="dark"] .bulk-bar {
  border-color: var(--purple-800);
}
.bulk-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.task-item__select {
  display: none;
  align-self: center;
  margin-right: 4px;
}
.selecting .task-item__select {
  display: block;
}
.task-item.selected {
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* Task Item & Meta */
.task-list { display: flex; flex-direction: column; gap: var(--space-3); }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  animation: fadeInUp var(--transition) both;
}
.task-item:hover { transform: translateX(3px); box-shadow: var(--shadow-md); }
.task-item.pri-high   { border-left-color: var(--danger); }
.task-item.pri-medium { border-left-color: var(--warning); }
.task-item.pri-low    { border-left-color: var(--success); }
.task-item.done { opacity: 0.65; }
.task-item.done .task-item__title { text-decoration: line-through; color: var(--text-muted); }
.task-item__body { flex: 1; min-width: 0; }
.task-item__title { font-weight: 700; color: var(--text); margin-bottom: 4px; }
.task-item__meta { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: var(--fs-xs); }
.task-item__notes {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.task-item__actions { display: flex; gap: 2px; align-items: center; }

/* Overdue & Urgent Accent */
.due-overdue { color: var(--danger); font-weight: 700; }
.due-soon    { color: var(--warning); font-weight: 700; }
.badge.badge-overdue {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  font-weight: 700;
}
.badge.badge-today {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  font-weight: 700;
}

/* ==========================================================================
   SUBJECTS
   ========================================================================== */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-5);
}
.subject-card {
  position: relative;
  overflow: hidden;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  animation: fadeInUp var(--transition) both;
}
.subject-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.subject-card.flash { animation: cardFlash 1.6s ease; }
@keyframes cardFlash {
  0%, 100% { box-shadow: var(--shadow-sm); }
  15%, 60% { box-shadow: 0 0 0 3px var(--primary), var(--shadow-lg); }
}
.subject-card__stripe { position: absolute; inset: 0 0 auto 0; height: 6px; }
.subject-card__icon {
  width: 48px; height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: var(--fs-xl);
  font-weight: 800;
  color: #fff;
  margin-bottom: var(--space-3);
  margin-top: var(--space-2);
}
.subject-card h3 { margin-bottom: var(--space-1); }
.subject-card__stats { display: flex; gap: var(--space-4); margin: var(--space-3) 0; }
.subject-card__stats div b { display: block; font-size: var(--fs-lg); color: var(--text); }
.subject-card__stats div small { font-size: var(--fs-xs); color: var(--text-muted); }
.subject-card__foot { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-3); }

/* ==========================================================================
   CALENDAR
   ========================================================================== */

/* Summary & Deadlines Strip */
.cal-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.cal-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.cal-summary-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.cal-summary-card__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.cal-summary-card__icon svg { width: 20px; height: 20px; }
.cal-summary-card__title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}
.cal-summary-card__desc {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0;
}
.cal-summary-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.cal-metric {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
}
.cal-metric--wide {
  grid-column: 1 / -1;
}
.cal-metric__label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-metric__val {
  font-size: var(--fs-xl);
  color: var(--text);
  line-height: 1.2;
  margin-top: 2px;
}
.cal-metric__sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.cal-metric__busiest {
  font-size: var(--fs-sm);
  color: var(--primary);
  margin-top: 2px;
}

/* Upcoming Items List in Summary */
.cal-upcoming-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.cal-upcoming-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.cal-upcoming-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-upcoming-info {
  flex: 1;
  min-width: 0;
}
.cal-upcoming-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-upcoming-due {
  font-size: 0.72rem;
  margin-top: 1px;
}

/* Calendar Card & Controls */
.cal-card {
  padding: var(--space-5);
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}
.cal-head h2 {
  min-width: 180px;
  margin: 0;
}
.cal-jump-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: var(--fs-xs);
  color: var(--text);
  font-family: var(--font-sans);
  cursor: pointer;
  height: 32px;
  transition: var(--transition-fast);
}
.cal-jump-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

/* Weekday Headers */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.cal-weekdays span {
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Calendar Day Grid */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space-2);
}
.cal-cell {
  min-width: 0;
  min-height: 104px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  position: relative;
}
.cal-cell:hover {
  border-color: var(--purple-300);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.cal-cell:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

/* Cell Header (Day Number & Workload icon) */
.cal-cell__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 24px;
}
.cal-cell__num {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
  margin-left: auto;
}
.cal-cell__overload-indicator {
  font-size: 0.72rem;
  font-weight: 800;
}

/* Cell States: Today, Selected, Other-Month, Heavy */
.cal-cell--today {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-soft) 25%, var(--surface));
  box-shadow: 0 0 0 1px var(--primary);
}
.cal-cell--today .cal-cell__num {
  background: var(--primary);
  color: #fff;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: var(--fs-xs);
}

.cal-cell--selected {
  border: 2px solid var(--primary) !important;
  box-shadow: var(--shadow-md) !important;
}
.cal-cell--selected:not(.cal-cell--today) .cal-cell__num {
  color: var(--primary);
  font-weight: 800;
}

.cal-cell--other-month {
  background: var(--surface-2);
  opacity: 0.58;
}
.cal-cell--other-month .cal-cell__num {
  color: var(--text-faint);
}
.cal-cell--other-month:hover {
  opacity: 0.9;
}

.cal-cell--heavy {
  border-top: 3px solid var(--warning);
}
.cal-cell--has-overdue {
  border-left: 2px solid var(--danger);
}

/* Cell Indicators & Badges */
.cal-cell__content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
}
.cal-chip {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-chip--exam {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.cal-chip__icon { flex-shrink: 0; }
.cal-chip__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cal-task-summary {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 0.68rem;
  color: var(--text-body);
  max-width: 100%;
}
.cal-task-summary--done {
  opacity: 0.75;
}
.cal-dots-group {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.cal-task-count {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.65rem;
}
.cal-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}
.cal-tag {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1.2;
}
.cal-tag--high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.cal-tag--overdue {
  background: rgba(239, 68, 68, 0.18);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.cal-tag--heavy {
  background: rgba(245, 158, 11, 0.18);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.cal-tag--done {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

/* Legend */
.cal-legend {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  align-items: center;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.cal-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cal-legend-pill {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.cal-legend-pill--overdue { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.cal-legend-pill--heavy { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.cal-legend-pill--done { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.cal-legend-ring {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}
.cal-legend-selected {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 2px solid var(--primary);
  display: inline-block;
}

/* Day Detail Modal */
.cal-modal {
  max-width: 560px;
}
.cal-modal-subtitle {
  font-size: var(--fs-xs);
  margin-top: 2px;
}
.cal-workload-banner {
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
  flex-wrap: wrap;
  gap: var(--space-2);
}
.cal-workload-banner--light {
  background: var(--surface-2);
}
.cal-workload-banner--moderate {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
}
.cal-workload-banner--heavy {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
}
.cal-workload-banner--done {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
}
.cal-workload-banner__tag {
  display: block;
  font-weight: 700;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-workload-banner--heavy .cal-workload-banner__tag { color: var(--warning); }
.cal-workload-banner--done .cal-workload-banner__tag { color: var(--success); }
.cal-workload-banner__desc {
  font-size: var(--fs-sm);
  color: var(--text);
  font-weight: 500;
}
.cal-workload-banner__counts {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.cal-modal-task-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: var(--transition-fast);
}
.cal-modal-task-item.is-overdue {
  border-left: 3px solid var(--danger);
}
.cal-modal-task-item:hover {
  border-color: var(--border-strong);
}
.cal-task-item__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.badge-xs {
  font-size: 0.65rem;
  padding: 2px 6px;
}

/* ==========================================================================
   NOTES & KNOWLEDGE MANAGEMENT
   ========================================================================== */
.notes-toolbar-wrap .toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.notes-filter-pills {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.notes-filter-pills .btn {
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  padding: 4px 12px;
  border: none;
  color: var(--text-muted);
  transition: all var(--transition);
}

.notes-filter-pills .btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}

.note-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  animation: fadeInUp var(--transition) both;
  min-height: 190px;
  cursor: pointer;
  outline: none;
}

.note-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-focus, var(--primary));
}

.note-card:focus-visible {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
  border-color: var(--primary);
}

.note-card--pinned {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.04) 0%, var(--surface) 35%);
}

.note-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.note-card__title-wrap {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
}

.note-pin-indicator {
  font-size: var(--fs-sm);
  line-height: 1.2;
  flex-shrink: 0;
}

.note-card h3 {
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  margin: 0;
  overflow-wrap: anywhere;
}

.note-card__subject-wrap {
  margin-bottom: var(--space-2);
  align-self: flex-start;
}

.note-subject-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.note-subject-pill:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--text-faint);
}

.note-card__content {
  color: var(--text-body);
  font-size: var(--fs-sm);
  line-height: 1.55;
  flex: 1;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.note-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-4);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

/* Search Term Highlight */
.search-highlight {
  background: rgba(245, 158, 11, 0.28);
  color: inherit;
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: 600;
}

/* Note Detail Modal */
.note-detail-modal {
  max-width: 680px;
}

.note-detail-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
}

.note-detail-head-left {
  flex: 1;
  min-width: 0;
}

.note-detail-title {
  font-size: var(--fs-2xl);
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-primary);
  margin: 0;
  overflow-wrap: anywhere;
}

.note-detail-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.note-detail-content {
  color: var(--text-primary);
  font-size: var(--fs-base);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: var(--space-2);
}

/* ==========================================================================
   ABOUT & FEATURE SHOWCASE
   ========================================================================== */
.about-hero { text-align: center; padding: var(--space-6) 0; }
.about-hero .brand__mark { width: 72px; height: 72px; margin: 0 auto var(--space-4); border-radius: 20px; }
.about-hero .brand__mark svg { width: 40px; height: 40px; }
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-5);
}
.feature-card { text-align: center; }
.feature-card .stat-card__icon { margin: 0 auto var(--space-3); }
.tech-list { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.tech-list .badge { font-size: var(--fs-sm); padding: 6px 14px; }

/* ==========================================================================
   TIMER & STUDY SESSIONS PAGE
   ========================================================================== */
.timer-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.timer-overview-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.timer-stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.timer-stat-col {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: left;
}

.timer-stat-val {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.timer-stat-lbl {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

/* Progress bar for daily goal */
.timer-goal-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.timer-progress-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

.timer-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #a855f7);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.timer-progress-fill.is-complete {
  background: linear-gradient(90deg, #10b981, #059669);
}

.timer-weekly-subject {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

/* Session preview banner */
.timer-preview-banner {
  width: 100%;
  max-width: 440px;
  margin: var(--space-3) auto 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-align: center;
}

.timer-preview-banner b,
.timer-preview-banner i {
  color: var(--text);
}

/* Paused badge */
.timer-paused-badge {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  font-weight: 800;
  margin-bottom: var(--space-1);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* Focus context banner (shows the linked task/subject on the timer) */
.timer-context {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  max-width: 440px;
  margin: var(--space-3) auto 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid rgba(124, 58, 237, 0.2);
  color: var(--text);
  font-size: var(--fs-xs);
  line-height: 1.4;
  text-align: left;
}

.timer-context[hidden] { display: none; }
.timer-context b { color: var(--text); font-weight: 700; }
.timer-context .dot { width: 10px; height: 10px; flex-shrink: 0; }
.timer-context__icon { flex-shrink: 0; font-size: var(--fs-sm); }
.timer-context__badge {
  background: var(--surface);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  font-weight: 600;
  display: inline-block;
}

/* Session Completion Modal stats */
.session-modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: var(--space-3);
  text-align: center;
}

.session-modal-stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.session-modal-stat-card b {
  display: block;
  font-size: var(--fs-lg);
  color: var(--text);
  margin-top: 2px;
}

@media (max-width: 560px) {
  .timer-controls { flex-wrap: wrap; gap: var(--space-2); }
}

/* ==========================================================================
   SETTINGS PAGE
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  max-width: 800px;
  margin: 0 auto;
}

/* ==========================================================================
   TASK & SUBJECT CARD EXTENSIONS
   ========================================================================== */
.task-item.is-overdue {
  border-left-color: var(--danger) !important;
  background: color-mix(in srgb, var(--danger) 4%, var(--surface));
}
.task-item.is-today {
  border-left-color: var(--warning) !important;
}

.subject-badge-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  background: var(--surface-2);
  color: var(--text-muted);
}

.subject-card__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

#overallTiles.stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ==========================================================================
   PROGRESS & ANALYTICS PAGE (PHASE 5)
   ========================================================================== */
.analytics-range-bar {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.range-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
}

.range-btn:hover {
  color: var(--text);
  background: var(--surface-3);
}

.range-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.analytics-metric-card {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: var(--radius-md);
  min-height: 120px;
}

.analytics-metric-card .metric-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.analytics-metric-card .metric-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.analytics-metric-card .metric-value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}

.analytics-metric-card .metric-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Study Time Trend Chart */
.analytics-chart-wrap {
  width: 100%;
}

.trend-chart-container {
  width: 100%;
  overflow-x: auto;
  padding-bottom: var(--space-2);
}

.trend-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  min-height: 220px;
  padding: var(--space-4) var(--space-2) var(--space-2);
  justify-content: space-between;
}

.chart-col {
  flex: 1;
  min-width: 28px;
  max-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  outline: none;
  border-radius: var(--radius-sm);
  padding: 4px 2px;
  transition: background var(--transition);
}

.chart-col:hover,
.chart-col:focus-visible {
  background: var(--surface-2);
}

.chart-val {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  height: 16px;
  white-space: nowrap;
}

.chart-col:hover .chart-val,
.chart-col:focus-visible .chart-val {
  color: var(--primary);
}

.chart-bar-track {
  width: 14px;
  height: 140px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

.chart-bar-fill {
  width: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #a855f7, var(--primary));
  transition: height 0.4s ease;
}

.chart-col.is-today .chart-bar-fill {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
}

.chart-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.chart-col.is-today .chart-lbl {
  color: var(--primary);
  font-weight: 800;
}

/* Day-of-Week Distribution mini-bars */
.dow-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  min-height: 140px;
  align-items: flex-end;
}

.dow-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dow-val {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.dow-track {
  width: 12px;
  height: 90px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  border: 1px solid var(--border);
}

.dow-fill {
  width: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #f59e0b, #d97706);
  transition: height 0.4s ease;
}

.dow-col.is-peak .dow-fill {
  background: linear-gradient(180deg, var(--primary), #a855f7);
}

.dow-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.dow-col.is-peak .dow-label {
  color: var(--text);
  font-weight: 700;
}

.pattern-highlight-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

/* Subject Study Distribution */
.subject-dist-row {
  margin-bottom: var(--space-3);
}

.subject-dist-name {
  color: var(--text);
  font-size: var(--fs-sm);
  text-decoration: none;
}

.subject-dist-name:hover {
  text-decoration: underline;
}

/* Multi-segmented completion bar */
.segmented-progress-track {
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  display: flex;
  overflow: hidden;
  gap: 2px;
}

.segmented-fill {
  height: 100%;
  transition: width 0.4s ease;
}

.bg-success { background: var(--success); }
.bg-primary { background: var(--primary); }
.bg-danger  { background: var(--danger); }

/* Productivity Insights */
.insight-card-item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: var(--space-3);
}

.insight-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}

.insight-title {
  font-size: var(--fs-sm);
  color: var(--text);
  margin-bottom: 2px;
}

.insight-desc {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

.insight-desc b {
  color: var(--text);
}

/* ==========================================================================
   HABIT TRACKER STYLES (Phase 9)
   ========================================================================== */

/* Summary Metrics */
.habit-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.habit-summary-card {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
}

.habit-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.habit-summary-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.habit-summary-value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.habit-summary-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.habit-progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.habit-progress-bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--primary), #a855f7);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Habit Cards Grid */
.habit-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-4);
}

.habit-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-4);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
}

.habit-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.habit-card.is-today-done {
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
}

.habit-card__top {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

.habit-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.habit-card__info {
  flex: 1;
  min-width: 0;
}

.habit-card__title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.3;
}

.habit-card__desc {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: var(--space-2);
}

.habit-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge-streak {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-weight: 700;
}

[data-theme="dark"] .badge-streak {
  color: #fbbf24;
}

.badge-subject {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-xs);
  padding: 2px 8px;
}

.badge-subject:hover {
  background: var(--surface-3);
}

/* Habit Check-Off Button */
.habit-card__check-wrap {
  flex-shrink: 0;
}

.habit-check-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  transition: all var(--transition-fast);
}

.habit-check-btn svg {
  width: 16px;
  height: 16px;
}

.habit-check-btn.btn-ghost {
  border: 1.5px solid var(--border-strong);
  color: var(--text);
}

.habit-check-btn.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.habit-check-btn.btn-success {
  background: var(--success);
  border: 1.5px solid var(--success);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.habit-check-btn.btn-success:hover {
  background: color-mix(in srgb, var(--success) 88%, #000);
}

.habit-rest-badge {
  font-size: var(--fs-xs);
  padding: 6px 10px;
}

/* 7-Day Current Week Strip */
.habit-card__week-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.habit-week-title {
  margin-bottom: var(--space-2);
}

.habit-week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.week-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 2px;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

.week-col.is-today {
  background: var(--surface-3);
  outline: 1.5px solid var(--primary);
}

.week-day-lbl {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}

.week-col.is-today .week-day-lbl {
  color: var(--primary);
  font-weight: 800;
}

.week-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.week-dot--done {
  background: var(--success);
  color: #fff;
  box-shadow: 0 1px 4px rgba(16, 185, 129, 0.3);
}

.week-dot--pending {
  background: transparent;
  border: 2px dashed var(--primary);
  color: var(--primary);
}

.week-dot--missed {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
  font-size: 0.85rem;
}

.week-dot--future {
  background: var(--surface-3);
  color: var(--text-faint);
}

.week-dot--off {
  background: transparent;
  color: var(--text-faint);
  opacity: 0.5;
}

.week-day-num {
  font-size: 0.62rem;
  color: var(--text-muted);
}

/* Habit Card Actions */
.habit-card__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}

/* 30-Day Consistency History Table */
.habit-history-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.history-matrix-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-xs);
  min-width: 720px;
}

.history-table th,
.history-table td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.history-th-habit,
.history-td-habit {
  text-align: left !important;
  padding-left: var(--space-3) !important;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.04);
}

.history-habit-icon {
  margin-right: 6px;
  font-size: 1rem;
}

.history-habit-name {
  font-weight: 600;
  color: var(--text);
}

.history-th-day {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}

.history-th-day.is-today {
  color: var(--primary);
  font-weight: 800;
  background: var(--primary-soft);
}

.history-td-cell {
  vertical-align: middle;
}

.matrix-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
}

.matrix-box.inline-box {
  width: 12px;
  height: 12px;
  margin-right: 4px;
}

.matrix-cell--done {
  background: var(--success);
}

.matrix-cell--pending {
  background: transparent;
  border: 1.5px dashed var(--primary);
}

.matrix-cell--missed {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.matrix-cell--off {
  background: var(--surface-3);
  opacity: 0.4;
}

.history-legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  align-items: center;
}

/* Modal form controls */
.habit-emoji-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emoji-preset-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.emoji-preset-btn:hover {
  transform: scale(1.1);
  background: var(--surface-3);
  border-color: var(--primary);
}

.emoji-preset-btn.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  outline: 2px solid var(--primary);
}

.habit-weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.day-chip {
  position: relative;
  cursor: pointer;
}

.day-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.day-chip span {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.day-chip:hover span {
  background: var(--surface-3);
  color: var(--text);
}

.day-chip input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.day-chip input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Dashboard Habit Widget */
.dash-habit-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.dash-habit-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.dash-habit-item:hover {
  background: var(--surface-3);
}

.dash-habit-item.is-done {
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
}

.dash-habit-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.dash-habit-main {
  flex: 1;
  min-width: 0;
}

.dash-habit-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-habit-item.is-done .dash-habit-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.dash-habit-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Focus Pulse for URL target */
@keyframes habitHighlightPulse {
  0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}

.highlight-pulse {
  animation: habitHighlightPulse 1.2s ease infinite;
}
