/* ─── Reset & Variables ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

button {
  cursor: pointer;
  font: inherit;
  background: none;
  border: none;
}

input,
select,
textarea {
  font: inherit;
}

:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #111317;
  --muted: #8a8f9c;
  --secondary: #f0f1f5;
  --secondary-hover: #e4e6ed;
  --primary: #5046e5;
  --primary-2: #7c6ff7;
  --gradient: linear-gradient(135deg, #5046e5 0%, #9061f9 100%);
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.07), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 10px;

  /* Category colors */
  --daily-dot: #7c6ff7;
  --daily-bg: #f0eeff;
  --daily-text: #4a3fbf;
  --daily-ring: rgba(124, 111, 247, 0.25);

  --routine-dot: #34c77b;
  --routine-bg: #e8faf1;
  --routine-text: #1a7a4a;
  --routine-ring: rgba(52, 199, 123, 0.25);

  --soon-dot: #f5a623;
  --soon-bg: #fff8ec;
  --soon-text: #a36100;
  --soon-ring: rgba(245, 166, 35, 0.25);

  --red: #e85d4a;
  --sidebar-w: 240px;
}

html {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Sidebar ───────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 30;
}

.sidebar-overlay.show {
  display: block;
}

.sidebar {
  position: fixed;
  inset-y: 0;
  left: 0;
  z-index: 40;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(.4, 0, .2, 1);
}

.sidebar.open {
  transform: translateX(0);
}

.desktop-only {
  display: none !important;
}

@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    transform: none !important;
    flex-shrink: 0;
    overflow-y: auto;
    transition: width 0.28s cubic-bezier(.4, 0, .2, 1);
  }

  .sidebar.collapsed {
    width: 80px;
  }
  
  .sidebar.collapsed .brand-name,
  .sidebar.collapsed .brand-sub,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-item span:not(.nav-dot) {
    display: none;
  }
  
  .sidebar.collapsed .sidebar-header {
    padding: 24px 10px 20px;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
  }
  
  .sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px;
  }
  
  .sidebar.collapsed .nav-item svg {
    margin: 0;
  }

  .sidebar.collapsed .nav-item::before {
    display: none;
  }

  .sidebar-overlay {
    display: none !important;
  }

  .mobile-only {
    display: none !important;
  }

  .desktop-only {
    display: grid !important;
  }
}

.sidebar-header {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  height: 36px;
  width: 36px;
  border-radius: 10px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(80, 70, 229, 0.3);
}

.brand-icon.logo-wrap {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

.brand-icon.logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.sidebar-nav {
  padding: 0 12px;
  flex: 1;
}
.nav-label {
  padding: 0 12px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.nav-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--muted);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
}

.nav-item:hover {
  background: var(--secondary);
  color: var(--text);
}

.nav-item.active {
  background: rgba(80, 70, 229, 0.06);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(80, 70, 229, 0.05);
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0.3);
  width: 4px;
  height: 60%;
  border-radius: 0 4px 4px 0;
  background: var(--gradient);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.active::before {
  transform: translateY(-50%) scaleY(1);
  opacity: 1;
}

.nav-dot {
  display: none;
}

.nav-item.active .nav-dot {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  display: inline-block;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(80, 70, 229, 0.6);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(80, 70, 229, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(80, 70, 229, 0);
  }
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.sidebar-footer li {
  margin-bottom: 2px;
}

/* ─── Main ──────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 248, 250, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.topbar-title p {
  font-size: 12px;
  color: var(--muted);
}

.topbar-title p span {
  color: var(--text);
  font-weight: 500;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 280px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  background: var(--secondary);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, background .15s;
}

.search-wrap input:focus {
  background: var(--card);
  border-color: var(--primary);
}

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background .15s, color .15s;
}

.btn-icon:hover {
  background: var(--secondary);
  color: var(--text);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--gradient);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(80, 70, 229, 0.3);
  white-space: nowrap;
  transition: opacity .15s;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-ghost {
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
  transition: background .15s, color .15s;
}

.btn-ghost:hover {
  background: var(--secondary);
  color: var(--text);
}

.btn-ghost-sm {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  border: 1.5px solid var(--border);
  background: var(--card);
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.btn-ghost-sm:hover {
  background: var(--secondary);
  color: var(--text);
}

/* ─── Page & Cards ──────────────────────────────────────────────── */
.view {
  display: flex;
  flex-direction: column;
}

.view.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

/* ── Monthly Calendar ──────────────────────────────── */
.calendar-card {
  padding: 20px 24px;
}
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.calendar-header .section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}
.calendar-controls {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.calendar-controls .btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}
.calendar-controls .btn-icon:hover {
  background: var(--secondary);
  transform: translateY(-1px);
}
.monthly-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.cal-day-header {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.cal-cell:hover:not(.empty) {
  border-color: var(--border);
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.06);
  background: var(--card);
}
.cal-cell.selected {
  border-color: var(--primary);
  background: rgba(80, 70, 229, 0.05);
  color: var(--primary);
}
.cal-cell.today {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(80, 70, 229, 0.4);
  border: none;
}
.cal-cell.empty {
  background: transparent;
  cursor: default;
}
.cal-dots {
  display: flex;
  gap: 4px;
  position: absolute;
  bottom: 10px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.cal-cell.today .cal-dot {
  background: #ffffff !important;
  box-shadow: none;
  opacity: 0.9;
}
.cal-dot-soon { background: var(--soon-dot); }
.cal-dot-daily { background: var(--daily-dot); }
.cal-dot-routine { background: var(--routine-dot); }

.page-wrap {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px 48px;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ─── Week Header ───────────────────────────────────────────────── */
.week-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.label-xs {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-top: 2px;
}

.week-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.week-controls select {
  padding: 5px 8px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.week-controls select:focus {
  border-color: var(--primary);
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  border-radius: 12px;
  background: var(--secondary);
  color: var(--muted);
  transition: background .15s, color .15s, transform .1s;
  position: relative;
}

.day-btn:hover {
  background: var(--secondary-hover);
  color: var(--text);
}

.day-btn.active {
  background: var(--text);
  color: #fff;
}

.day-btn.today:not(.active) {
  box-shadow: 0 0 0 2px rgba(80, 70, 229, 0.4);
}

.day-btn.out-month {
  opacity: 0.35;
}

.day-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.day-num {
  font-size: 15px;
  font-weight: 600;
  margin-top: 1px;
}

/* ─── Timeline ──────────────────────────────────────────────────── */
.timeline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.timeline-scroll {
  overflow-x: auto;
}

.timeline-inner {
  min-width: 1600px;
  position: relative;
}

.timeline-labels {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  padding-top: 18px;
  position: relative;
}

.timeline-labels .tl-am,
.timeline-labels .tl-pm {
  position: absolute;
  top: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.timeline-labels .tl-am {
  left: 4px;
}

.tl-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.tl-dot-am {
  background: #f5a623;
}

.tl-dot-pm {
  background: #5046e5;
}

.timeline-hour {
  text-align: center;
  font-weight: 500;
}

.timeline-track {
  position: relative;
  height: 112px;
}

.timeline-cols {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
}

.timeline-col-line {
  border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.timeline-col-line:last-child {
  border-right: none;
}

.noon-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1.5px;
  background: var(--red);
  pointer-events: none;
  z-index: 1;
}

.noon-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--red);
  background: var(--card);
  padding: 0 5px;
  white-space: nowrap;
}

.task-chip {
  position: absolute;
  height: 80px;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 11.5px;
  cursor: pointer;
  text-align: left;
  z-index: 2;
  transition: transform .15s, box-shadow .15s;
  ring-width: 1.5px;
}

.task-chip:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.task-chip-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-chip-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-chip-sub {
  margin-top: 4px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-chip-time {
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.7;
}

.chip-daily {
  background: var(--daily-bg);
  color: var(--daily-text);
  box-shadow: 0 0 0 1.5px var(--daily-ring);
}

.chip-routine {
  background: var(--routine-bg);
  color: var(--routine-text);
  box-shadow: 0 0 0 1.5px var(--routine-ring);
}

.chip-soon {
  background: var(--soon-bg);
  color: var(--soon-text);
  box-shadow: 0 0 0 1.5px var(--soon-ring);
}

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

.dot-daily {
  background: var(--daily-dot);
}

.dot-routine {
  background: var(--routine-dot);
}

.dot-soon {
  background: var(--soon-dot);
}

/* ─── Badge ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--secondary);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

/* ─── Popover ───────────────────────────────────────────────────── */
.popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.popover-backdrop.hidden {
  display: none;
}

.popover {
  position: fixed;
  z-index: 55;
  width: 310px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.popover.hidden {
  display: none;
}

.popover-bar {
  height: 4px;
  width: 100%;
}

.popover-body {
  padding: 14px;
}

.popover-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popover-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 500;
}

.badge-daily {
  background: var(--daily-bg);
  color: var(--daily-text);
}

.badge-routine {
  background: var(--routine-bg);
  color: var(--routine-text);
}

.badge-soon {
  background: var(--soon-bg);
  color: var(--soon-text);
}

.popover-time {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.popover-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.popover-title {
  font-size: 13.5px;
  font-weight: 600;
}

.btn-delete {
  color: var(--muted);
  transition: color .15s;
  padding: 2px;
  border-radius: 5px;
}

.btn-delete:hover {
  color: var(--red);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.progress-bar {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: var(--secondary);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--text);
  border-radius: 99px;
  transition: width .3s;
}

.progress-label {
  font-size: 11px;
  color: var(--muted);
}

.subtask-list {
  margin-top: 10px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 7px;
  transition: background .12s;
}

.subtask-item:hover {
  background: var(--secondary);
}

.subtask-checkbox {
  flex-shrink: 0;
}

.subtask-checkbox input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.subtask-text {
  flex: 1;
  font-size: 13px;
}

.subtask-text.done {
  text-decoration: line-through;
  color: var(--muted);
}

.flag {
  flex-shrink: 0;
}

.flag svg {
  width: 13px;
  height: 13px;
}

.flag-high {
  color: var(--red);
}

.flag-medium {
  color: var(--soon-dot);
}

.flag-low {
  color: var(--muted);
}

.btn-rm-sub {
  opacity: 0;
  color: var(--muted);
  transition: opacity .15s, color .15s;
  padding: 2px;
  border-radius: 4px;
}

.subtask-item:hover .btn-rm-sub {
  opacity: 1;
}

.btn-rm-sub:hover {
  color: var(--red);
}

.empty-subs {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 4px 8px;
}

.add-sub-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.add-sub-form input {
  flex: 1;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1.5px solid transparent;
  background: var(--secondary);
  font-size: 12.5px;
  outline: none;
  transition: border-color .15s;
}

.add-sub-form input:focus {
  background: var(--card);
  border-color: var(--primary);
}

.btn-add-sub {
  padding: 6px 10px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--secondary);
  font-size: 12.5px;
  font-weight: 500;
  transition: background .15s;
}

.btn-add-sub:hover {
  background: var(--secondary-hover);
}

/* ─── Library ───────────────────────────────────────────────────── */
.library-card {
  padding: 20px 24px;
}

.library-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.library-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--secondary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.library-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.library-header p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.ml-auto {
  margin-left: auto;
}

.library-table-wrap {
  overflow-x: auto;
}

.library-table {
  width: 100%;
  min-width: 680px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.library-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.library-table th:first-child {
  width: 180px;
}

.library-table th span.dot {
  margin-right: 5px;
}

.library-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  vertical-align: top;
}

.library-table td:first-child {
  font-size: 12px;
}

.lib-week {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}

.lib-dash {
  color: var(--muted);
  opacity: 0.5;
  font-size: 13px;
}

.lib-tasks {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lib-chip {
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lib-chip-time {
  opacity: 0.7;
  font-size: 10.5px;
}

.lib-chip-done {
  opacity: 0.7;
  font-size: 10px;
  margin-top: 2px;
}

/* ─── Dialog ────────────────────────────────────────────────────── */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 60;
  backdrop-filter: blur(2px);
}

.dialog-backdrop.hidden {
  display: none;
}

.dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(460px, calc(100vw - 32px));
  height: fit-content;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 65;
  padding: 24px;
}

.dialog.hidden {
  display: none;
}

.dialog-header {
  margin-bottom: 20px;
}

.dialog-header h2 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.dialog-header p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field label {
  font-size: 12.5px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
}

.field textarea {
  resize: none;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

/* ─── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar-inner {
    padding: 12px 14px;
  }

  .page-wrap {
    padding: 16px 14px 40px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .search-wrap {
    min-width: 120px;
  }

  .week-controls {
    gap: 4px;
  }

  .week-controls select {
    font-size: 11px;
    padding: 4px 6px;
  }
}

/* ─── Archive ───────────────────────────────────────────────────── */
.archive-card {
  padding: 20px 24px;
}

.archive-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.archive-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--secondary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--muted);
}

.archive-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.archive-header p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.archive-table-wrap {
  overflow-x: auto;
}

.archive-table {
  width: 100%;
  min-width: 680px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.archive-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.archive-table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  vertical-align: middle;
}

.archive-task-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}

.archive-subtasks-summary {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.archive-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-restore {
  background: rgba(80, 70, 229, 0.08);
  color: var(--primary);
}

.btn-restore:hover {
  background: var(--primary);
  color: #fff;
}

.btn-delete-perm {
  background: rgba(232, 93, 74, 0.08);
  color: var(--red);
}

.btn-delete-perm:hover {
  background: var(--red);
  color: #fff;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 8px;
  background: rgba(232, 93, 74, 0.1);
  color: var(--red);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-danger:hover:not(:disabled) {
  background: var(--red);
  color: #fff;
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Downloads ─────────────────────────────────────────────────── */
.downloads-split-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 960px) {
  .downloads-split-layout {
    grid-template-columns: 1fr;
  }
}

.downloads-card {
  padding: 20px 24px;
}

.downloads-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.downloads-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--secondary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--muted);
}

.downloads-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.downloads-header p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.downloads-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dl-picker-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dl-picker-form.hidden {
  display: none;
}

.downloads-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.preview-card {
  padding: 24px;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.preview-header {
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.report-container {
  background: #eaecef;
  padding: 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

/* Simulated A4 printable sheet */
.report-paper {
  background: #ffffff;
  width: 100%;
  max-width: 800px;
  min-height: 842px;
  padding: 40px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  color: #1a1a1a;
  font-size: 13px;
  font-family: 'Inter', -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.report-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #5046e5;
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.report-doc-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.report-brand-logo {
  background: linear-gradient(135deg, #5046e5 0%, #9061f9 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.report-brand-name {
  font-size: 16px;
  font-weight: 700;
  color: #111317;
}

.report-brand-desc {
  font-size: 11px;
  color: #8a8f9c;
}

.report-doc-meta {
  text-align: right;
}

.report-meta-title {
  font-size: 14px;
  font-weight: 600;
  color: #111317;
}

.report-meta-date {
  font-size: 11px;
  color: #8a8f9c;
  margin-top: 2px;
}

.report-doc-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.report-doc-stats .stat-card {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.report-doc-stats .stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8a8f9c;
  font-weight: 600;
}

.report-doc-stats .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #111317;
  margin-top: 4px;
}

.report-doc-section {
  flex: 1;
  margin-bottom: 24px;
}

.report-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #5046e5;
  margin-bottom: 10px;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 6px;
}

.report-table-wrap {
  overflow-x: auto;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.report-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: #8a8f9c;
  border-bottom: 1px solid #dee2e6;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.report-table td {
  padding: 10px;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: top;
}

.report-task-title {
  font-weight: 600;
  color: #111317;
}

.report-task-desc {
  font-size: 11px;
  color: #8a8f9c;
  margin-top: 2px;
}

.report-subtasks-list {
  margin-top: 4px;
  padding-left: 12px;
  list-style: disc;
}

.report-subtasks-list li {
  font-size: 10.5px;
  color: #495057;
  margin-top: 1px;
}

.report-subtasks-list li.done {
  text-decoration: line-through;
  color: #adb5bd;
}

.report-doc-footer {
  border-top: 1px solid #e9ecef;
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #8a8f9c;
}

/* ─── PRINT LAYOUT ────────────────────────────────────────────── */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12px;
  }
  
  .sidebar,
  .topbar,
  .dialog,
  .dialog-backdrop,
  .popover,
  .popover-backdrop,
  .no-print,
  #sidebar-overlay {
    display: none !important;
  }
  
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  
  .page-wrap {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }
  
  .preview-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  
  .report-container {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible !important;
  }
  
  .report-paper {
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    min-height: auto !important;
  }
  }
}

/* ─── Mock Auth Overlay ────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-overlay.hidden {
  display: none !important;
}

.auth-card {
  background: var(--card);
  width: 100%;
  max-width: 400px;
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: fadeUpIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeUpIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: var(--gradient);
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 24px;
  box-shadow: 0 4px 16px rgba(80, 70, 229, 0.3);
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 32px;
  line-height: 1.5;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.btn-google:active {
  background: #f1f3f4;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gradient);
  color: white;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

. h o l i d a y - i c o n  
   p o s i t i o n :   a b s o l u t e ;   t o p :   2 p x ;   r i g h t :   2 p x ;   f o n t - s i z e :   8 p x ;    
 .cal-holiday-badge {
  margin-top: 4px;
  font-size: 8px;
  font-weight: 600;
  color: #fff;
  background: var(--gradient);
  border-radius: 12px;
  padding: 2.5px 6px;
  max-width: 85%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 4px rgba(80, 70, 229, 0.25);
  letter-spacing: 0.2px;
}
.cal-cell.today .cal-holiday-badge {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
  margin-top: 12px;
  background-color: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover {
  background-color: rgba(239, 68, 68, 0.15);
  transform: translateY(-1px);
}
.btn-logout svg {
  margin-right: 8px;
}
.nav-item.logout {
  color: #ef4444;
}
.nav-item.logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}
.nav-item.logout::before {
  background: #ef4444;
}


[data-theme="dark"] {
  --bg: #111317;
  --card: #1c1e24;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f7f8fa;
  --muted: #8a8f9c;
  --secondary: #2a2d36;
  --secondary-hover: #363a45;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  
  --daily-bg: rgba(124, 111, 247, 0.15);
  --daily-text: #b1a7fa;
  --routine-bg: rgba(52, 199, 123, 0.15);
  --routine-text: #6ee7b7;
  --soon-bg: rgba(245, 166, 35, 0.15);
  --soon-text: #fcd34d;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--secondary-hover);
  transition: .3s;
  border-radius: 24px;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--card);
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input:checked + .toggle-slider {
  background-color: var(--primary);
}
input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

[data-theme="dark"] .topbar {
  background: rgba(17, 19, 23, 0.85);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .day-btn.active {
  color: #111317;
}

[data-theme="dark"] .auth-card,
[data-theme="dark"] .dialog,
[data-theme="dark"] .popover {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

[dir="rtl"] {
  font-family: 'Tajawal', 'Cairo', 'Inter', sans-serif;
}
[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}
[dir="rtl"] .topbar-actions, [dir="rtl"] .nav-dot {
  margin-left: 0;
  margin-right: auto;
}
/* removed main-content RTL margin */
[dir="rtl"] .day-label, [dir="rtl"] .badge {
  letter-spacing: 0;
}
[dir="rtl"] .toggle-switch {
  transform: scaleX(-1);
}
[dir="rtl"] svg {
  transform: scaleX(-1);
}
[dir="rtl"] .nav-item svg, [dir="rtl"] .btn-primary svg {
  margin-right: 0;
  margin-left: 10px;
}
[dir="rtl"] .btn-logout svg {
  margin-right: 0;
  margin-left: 8px;
}


@media (max-width: 991px) {
  [dir="rtl"] .sidebar {
    transform: translateX(100%);
  }
  [dir="rtl"] .sidebar.open {
    transform: translateX(0);
  }
}

.sidebar-sublist { margin-left: 20px; display: flex; flex-direction: column; gap: 4px; list-style: none; padding: 0; }
.sidebar-sublist li button { padding: 6px 12px; font-size: 13px; text-align: left; width: 100%; background: transparent; border: none; color: var(--text-sec); cursor: pointer; border-radius: 6px; transition: background 0.2s, color 0.2s; display: flex; align-items: center; gap: 8px; }
.sidebar-sublist li button:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.sidebar-sublist li button.active { background: rgba(139, 92, 246, 0.15); color: var(--accent); font-weight: 500; }

/* Interactive Paper Cards */
.paper-cards-wrapper {
  margin: 20px auto 40px;
  max-width: 600px;
  height: 380px;
  position: relative;
  perspective: 1000px;
}

.paper-cards-container {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.paper-card {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 450px;
  height: 350px;
  border-radius: 8px;
  padding: 20px 30px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15), 0 10px 30px rgba(0,0,0,0.1);
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  cursor: pointer;
  overflow: hidden;
}

/* Paper Textures and Colors */
.card-today {
  background-color: #fdfdfd;
  z-index: 3;
  transform: translateX(-50%) translateY(0) scale(1);
}

.card-next {
  background-color: #f4f1ea;
  z-index: 2;
  transform: translateX(-50%) translateY(-15px) scale(0.95);
}

.card-later {
  background-color: #e6dfcc;
  z-index: 1;
  transform: translateX(-50%) translateY(-30px) scale(0.9);
}

/* Ruled Lines Background */
.paper-lines {
  position: relative;
  margin-top: 10px;
  height: calc(100% - 50px);
  background-image: repeating-linear-gradient(transparent, transparent 31px, rgba(0,0,0,0.1) 31px, rgba(0,0,0,0.1) 32px);
  background-position: 0 5px;
  padding-top: 4px;
}

/* Handwritten Typography */
.handwritten-title {
  font-family: 'Patrick Hand', cursive;
  font-size: 28px;
  color: #333;
  margin: 0;
  padding: 0;
  border-bottom: 2px solid rgba(0,0,0,0.1);
  padding-bottom: 5px;
}

.handwritten-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.handwritten-list li {
  font-family: 'Patrick Hand', cursive;
  font-size: 22px;
  color: #334;
  height: 32px;
  line-height: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.handwritten-list li.completed {
  text-decoration: line-through;
  opacity: 0.6;
}

.handwritten-input {
  font-family: 'Patrick Hand', cursive;
  font-size: 22px;
  color: #334;
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  height: 32px;
  line-height: 32px;
}

.handwritten-input::placeholder {
  color: rgba(0,0,0,0.3);
}

.paper-form {
  margin: 0;
  padding: 0;
}

/* Dark Mode Overrides for Paper (we keep them light for paper realism, but slightly dimmer text) */
[data-theme="dark"] .handwritten-title, 
[data-theme="dark"] .handwritten-list li, 
[data-theme="dark"] .handwritten-input {
  color: #1a1a24;
}

.paper-checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #555;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}

.paper-checkbox:checked::after {
  content: "✔";
  position: absolute;
  top: -6px;
  left: 2px;
  font-size: 18px;
  color: #d32f2f;
  font-family: 'Patrick Hand', cursive;
}
