@media (max-width: 900px) {
  .priority-popover,
  .clock-choice-popover {
    right: auto;
    left: calc(100% + 8px);
  }
  html[dir="ltr"] .priority-popover,
  html[dir="ltr"] .clock-choice-popover {
    left: auto;
    right: calc(100% + 8px);
  }
  /* على الموبايل زري المظهر وعرض الأسبوع بيتنقلوا جوه قائمة «المزيد» فبيختفوا من شريط الهيدر */
  #themeBtn,
  #weekViewBtn {
    display: none;
  }
/* فروع بوب السهم في صف الإضافة على الموبايل: بتفتح كـ dropdown تحت البند نفسه
      بعرض البوب كله — مش fixed في نص الشاشة (كان بيغطي البوب الأساسي وبيكسر السكرول).
      المرساة على النهاية المنطقية فلوّمت مع العربية والإنجليزية من غير ما يخرج بره الشاشة */
   .add-arrow-sub,
   html[dir="ltr"] .add-arrow-sub {
     position: absolute;
     top: calc(100% + 4px);
     inset-inline: 0;
     transform: translateY(6px);
     width: 100%;
     max-width: 100%;
     max-height: 45vh;
     overflow-y: auto;
     -webkit-overflow-scrolling: touch;
     box-shadow: var(--shadow-lg, var(--shadow));
   }
  .add-arrow-sub.open,
  html[dir="ltr"] .add-arrow-sub.open {
    transform: translateY(0);
  }
  /* قايمة الفلتر بتفضل 140px (نفس الديسكتوب) — الـ max-height الكبيرة بتعدّي
     حدود الشاشة على الموبايل فالسكرول بيبان باطل، والسقف الصغير ده سكرول ثابت */
}

/* ===== عرض الأسبوع ===== */
.week-view {
  display: flex;
  flex-direction: column;
}
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.week-day-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 140px;
  min-width: 0;
}
.week-day-card.today {
  outline: 2px solid var(--pen);
  outline-offset: -2px;
}
.week-day-header {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 8px;
  font-family: inherit;
  color: var(--ink);
}
.week-day-header:hover {
  background: var(--paper);
}
.week-day-name {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 700;
}
.week-day-num {
  font-size: 1.05rem;
  font-weight: 800;
}
.week-day-card.today .week-day-num {
  color: var(--pen);
}
.week-day-sub {
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-align: center;
}
.week-day-tasks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.week-task-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 6px;
  min-width: 0;
}
.week-task-row:hover {
  background: var(--paper);
}
.week-task-row.done .week-task-name {
  text-decoration: line-through;
  color: var(--ink-soft);
}
.week-task-checkbox {
  flex-shrink: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--paper-line);
  border-radius: 5px;
  background: var(--card);
  position: relative;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}
.week-task-checkbox:hover {
  border-color: var(--pen);
}
.week-task-checkbox:active {
  transform: scale(0.9);
}
.week-task-checkbox:checked {
  background: var(--done);
  border-color: var(--done);
}
.week-task-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
/* في الوضع الداكن حدود الـ checkbox بتختفي (الـ paper-line غامقة على الكارت) — بنرفع وضوحها */
.dark-mode .week-task-checkbox {
  border-color: var(--ink-soft);
}

/* عرض الأسبوع ياخذ المساحة كاملة والمؤقت بيتخفي وقتهـا */
.main-layout.week-view-active .timer-col {
  display: none;
}

/* ===== السكرول الداخلي =====
   لما الشاشة الكاملة (إحصائيات / الجدول الزمني / عرض الأسبوع / إحصائيات المهمة الواحدة)
   تكون مفتوحة، السكرول بيبقى جوه المحتوى مش على مستوى الصفحة */
body.locked-view {
  overflow: hidden;
}
body.locked-view .wrap {
  height: calc(100vh - 20px);
}
body.locked-view .app-shell,
body.locked-view .app-main,
body.locked-view .main-layout,
body.locked-view .main-col {
  min-height: 0;
}
body.locked-view .main-layout {
  overflow: hidden;
}
body.locked-view .main-col {
  overflow-y: auto;
}
@media (max-width: 640px) {
  body.locked-view .wrap {
    height: 100vh;
    /* min-height:0 ضروري — base.css فيه min-height:calc(100vh-20px)
       وده مش متأثر بـ box-sizing (دايما content-box)، فالنتيجة كانت محتوى أدنى
       أطول من الشاشة (الـ padding بتاع التاببار بيتجمع فوقه).
       min-height:0 بيلغي القيمة دي وبيسيّب height:100vh مع border-box يتحكّم. */
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden;
  }
  body.locked-view .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
}
.week-task-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.week-day-more {
  font-size: 0.72rem;
  color: var(--ink-soft);
  padding: 2px 4px;
}
.week-day-empty {
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-align: center;
  padding: 8px 0;
}

@media (max-width: 900px) {
  .week-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .week-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* ===== الجدول الزمني — صف علوي موحد ===== */
.tb-date-nav {
  flex-wrap: nowrap;
  gap: 8px;
  padding: 15px;
}
.tb-month-label {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
}
.tb-nav-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--paper);
  border-radius: 12px;
  padding: 2px;
}
.tb-day-label {
  font-family: "Almarai", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--pen);
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.tb-day-label:hover {
  background: var(--paper-line);
}
.tb-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tb-range-dropdown {
  position: relative;
  flex-shrink: 0;
}
.tb-range-drop-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--card);
  border: 1.5px solid var(--ink-soft);
  border-radius: 10px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease;
}
.tb-range-drop-btn:hover {
  background: var(--paper);
}
.tb-drop-arrow {
  transition: transform 0.2s ease;
  font-size: 1rem !important;
}
.tb-range-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 110px;
  background: var(--popup);
  border: 1px solid var(--popup-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 4px;
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.96);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}
.tb-range-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.tb-range-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: start;
  transition: background 0.12s ease;
}
.tb-range-menu-item:hover {
  background: var(--paper);
}
.tb-range-menu-item.active {
  background: var(--pen);
  color: #fff;
}
.tb-today-btn {
  flex-shrink: 0;
  background: var(--pen);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tb-today-btn.current {
  background: var(--paper);
  color: var(--pen);
  border: 1px solid var(--pen);
}
.tb-today-btn:hover {
  opacity: 0.85;
}
.tb-unscheduled-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--ink-soft);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.tb-unscheduled-icon-btn:hover {
  background: var(--done-soft);
  border-color: var(--done);
  color: var(--done);
}
.tb-unscheduled-icon-btn .material-icons {
  font-size: 1.15rem;
}
.tb-unscheduled-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--done);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.tbw-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr)) 56px;
  margin-top: 16px;
  border: 1px solid var(--paper-line);
  border-radius: 12px;
  overflow-x: auto;
}
/* زرار «اليوم» العائم للموبايل بس — مخفي على الديسكتوب (بيظهر جوه الميديا كويري تحت) */
.tb-today-fab {
  display: none;
}
/* نسخة عمود واحد (عرض اليوم): نفس تصميم الأسبوع بالظبط بس من غير أسماء الأيام */
.tbw-grid.tbw-single {
  grid-template-columns: minmax(0, 1fr) 56px;
  margin-top: 0;
}
.tbw-grid.tbw-single .tbw-col {
  border-inline-end: none;
}
.tbw-grid.tbw-single .tbw-col-head {
  cursor: default;
}
.tbw-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
  border-inline-end: 1px solid var(--paper-line);
}
.tbw-col:nth-child(7) {
  border-inline-end: none;
}
.tbw-col.today {
  background: transparent;
}
/* تظليل نهاية الأسبوع (الجمعة والسبت) على رأس العمود */
.tbw-col.weekend .tbw-col-head {
  background: var(--paper);
}
.tbw-col-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 54px;
  padding: 0 4px;
  border: none;
  border-bottom: 1px solid var(--paper-line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}
.tbw-col-head.today {
  color: var(--pen);
}
.tbw-col-day {
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.tbw-col-head.today .tbw-col-day {
  color: var(--pen);
}
.tbw-col-num {
  font-size: 1.05rem;
  font-weight: 800;
}
.tbw-col-track {
  position: relative;
  cursor: pointer;
}
.tbw-hours {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-inline-start: 1px solid var(--paper-line);
}
.tbw-hours-head {
  height: 54px;
  border-bottom: 1px solid var(--paper-line);
}
.tbw-hours-track {
  position: relative;
}
.tbw-hour-label {
  position: absolute;
  right: 6px;
  font-size: 0.68rem;
  color: var(--ink-soft);
  white-space: nowrap;
  user-select: none;
}
.tbw-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--paper-line);
  pointer-events: none;
}
.timeline-block.tbw-block {
  cursor: pointer;
  /* نفس عرض اليوم: touch-action:none عشان سحب البلوك والريسايز باللمس يوصلوا
     للـ JS بدل ما المتصفح يخطف الإيماءة للسكرول — السكرول بيفضل شغال من
     الأماكن الفاضية في العمود وعمود الساعات والعناوين */
  touch-action: none;
}

/* بوب إضافة مهمة مجدولة من عرض الأسبوع */
.addtl-input {
  width: 100%;
  box-sizing: border-box;
  margin: 12px 0 4px;
  padding: 11px 12px;
  border: 1px solid var(--paper-line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}
.addtl-input:focus {
  border-color: var(--pen);
}
.addtl-field {
  margin-top: 14px;
}
.addtl-field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.addtl-time-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--paper-line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.addtl-time-btn .material-icons {
  color: var(--pen);
  font-size: 18px;
}
.addtl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.addtl-duration-chip {
  padding: 7px 12px;
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.addtl-duration-chip:hover {
  border-color: var(--pen);
}
.addtl-duration-chip.active {
  background: var(--pen);
  border-color: var(--pen);
  color: #fff;
}
.addtl-priority {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.addtl-priority .priority-choice-btn {
  width: auto;
  padding: 7px 14px;
  border: 1px solid var(--paper-line);
  border-radius: 10px;
}
.addtl-priority .priority-choice-btn.selected {
  background: var(--pen-soft);
  border-color: var(--pen);
}
.addtl-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.addtl-actions .tl-task-btn {
  flex: 1;
  justify-content: center;
  width: auto;
}
.addtl-actions .tl-task-btn.primary {
  background: var(--pen);
  border-color: var(--pen);
  color: #fff;
}
.addtl-actions .tl-task-btn.primary .material-icons {
  color: #fff;
}


.timeblock-layout {
  position: relative;
  display: flex;
  gap: 22px;
  align-items: flex-start;
  margin-top: 16px;
}
.timeblock-layout .tbw-grid {
  margin-top: 0;
}
.timeblock-calendar-col {
  flex: 1 1 auto;
  min-width: 0;
}
.timeblock-side {
  position: absolute;
  top: 0;
  left: 0;
  width: 320px;
  max-height: 80%;
  overflow-y: auto;
  z-index: 30;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
}
.timeblock-side.open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
}
.timeblock-side.tb-open-anim {
  animation: tbSideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.timeblock-side.tb-closing {
  visibility: visible;
  opacity: 1;
  animation: tbSideOut 0.2s ease forwards;
}
@keyframes tbSideIn {
  from {
    opacity: 0;
    transform: translateX(-20px) translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
}
@keyframes tbSideOut {
  from {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(-20px) translateY(-8px) scale(0.95);
  }
}
.tb-side-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease;
}
.tb-side-close-btn:hover {
  background: var(--paper);
  color: var(--ink);
}
.tb-side-close-btn .material-icons {
  font-size: 1.1rem;
}
.tb-side-more-btn {
  display: block;
  width: 100%;
  padding: 8px 0;
  margin-top: 8px;
  background: none;
  border: none;
  border-top: 1px solid var(--paper-line);
  color: var(--pen);
  font-family: "Almarai";
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: center;
  transition: color 0.15s ease;
}
.tb-side-more-btn:hover {
  color: var(--ink);
}
.timeblock-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.timeblock-side-head .timeblock-side-title {
  margin-bottom: 0;
}
.timeblock-side-card {
  background: var(--paper-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 14px;
}
.timeblock-side-backdrop {
  display: none;
}
.timeblock-side-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.timeblock-side-hint {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 10px;
  line-height: 1.5;
}
.timeblock-unscheduled-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 10px;
}
.timeblock-side-item {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.timeblock-side-item.dragging {
  opacity: 0.35;
}
.timeblock-side-empty {
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
  padding: 10px 0;
}
.timeblock-side.drop-target .timeblock-unscheduled-list {
  outline: 2px dashed var(--pen);
  outline-offset: 4px;
  border-radius: 8px;
}

.timeline-container {
  position: relative;
  width: 100%;
  /* مساحة ثابتة بالبكسل (مش نسبة مؤيّة) عشان تفكّ كافيه لنص الساعه زي "14:00" حتى لما الشاشة تصغر، بدل ما تنكمش النص ويعمل overflow */
  padding-left: 44px;
  /* كارت زاي عرض الأسبوع: حدود + استدارة + خلفية موحّدة (مش محتاج padding علودي) */
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 12px;
}
/* مساعه عرض الساعات (بين التسميات والجدول) ممتد على طول الكرت */
.timeline-container::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 44px;
  border-left: 1px solid var(--paper-line);
  pointer-events: none;
}
.timeline-track {
  position: relative;
  width: 100%;
  user-select: none;
}
.timeline-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--paper-line);
}
.timeline-hour-label {
  position: absolute;
  top: -8px;
  right: calc(100% + 8px);
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: nowrap;
  padding-left: 4px;
}
.timeline-now-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px solid var(--missed);
  z-index: 5;
  pointer-events: none;
}
.timeline-now-dot {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--missed);
}
.timeline-block {
  position: absolute;
  background: color-mix(in srgb, var(--blk, var(--pen)) 14%, var(--card));
  border-inline-start: 3px solid var(--blk, var(--pen));
  border-radius: 8px;
  padding: 4px 8px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: box-shadow 0.15s ease;
}
.timeline-block.dragging,
.timeline-block.resizing {
  cursor: grabbing;
  box-shadow: var(--shadow);
  z-index: 20;
  opacity: 0.92;
}
.timeline-block.done {
  background: var(--done-soft);
  border-inline-start-color: var(--done);
  opacity: 0.65;
}
.timeline-block.done .timeline-block-name {
  text-decoration: line-through;
}
.timeline-block-time {
  font-size: 0.68rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.timeline-block.short {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.timeline-block.short .timeline-block-time {
  flex-shrink: 0;
}
.timeline-block.short .timeline-block-name {
  flex: 1 1 auto;
  min-width: 0;
}
.timeline-block-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timeline-block-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 9px;
  cursor: ns-resize;
  touch-action: none;
}
.timeline-block-resize-handle::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.15);
}
/* الشاشات اللمس: مقبض الريسايز بيكبر عشان الصباع يلقطه بسهولة */
@media (pointer: coarse) {
  .timeline-block-resize-handle {
    height: 20px;
  }
  .timeline-block-resize-handle::after {
    width: 44px;
    height: 5px;
    bottom: 7px;
  }
  /* السحبة العادية سكرول أصلي (pan-y) — السحب نفسه بالضغطة المطولة (JS).
     من غير كده البلوك بيخطف كل اللمسات واليوم المشغول مفيهوش حتة تسكرول منها */
  .timeline-block {
    touch-action: pan-y;
    user-select: none;
    -webkit-touch-callout: none;
  }
}
.timeline-drop-preview {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--pen);
  z-index: 15;
  pointer-events: none;
}
.timeline-drop-preview::before {
  content: attr(data-label);
  position: absolute;
  top: -9px;
  right: 4px;
  background: var(--pen);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
}

/* ===== عرض الشهر (زي Google Calendar): شبكة 7 أعمدة × أسابيع ===== */
.timeblock-layout-month {
  display: block;
}
/* الطول الكامل: بنمدّ سلسلة الحاويات لحد الشبكة عشان الصفوف توزع ارتفاع الشاشة
   كله فيما بينها بالتساوي (زي Google Calendar) — الكلاسات بتتحط وتتشال من timeBlocking.js */
.main-col.tb-stretch {
  display: flex;
  flex-direction: column;
}
.main-col.tb-stretch #content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* لما عمود المؤقت يبقى تحت عمود المهام (≤1236px): العمود الرئيسي هو اللي ياخد
   المساحة الفاضية بدل عمود المؤقت، عشان الشبكة توصل لطول الشاشة */
@media (max-width: 1236px) {
  .main-layout.tb-stretch .main-col {
    flex: 1 1 auto;
  }
  .main-layout.tb-stretch .timer-col {
    flex: 0 0 auto;
  }
}
/* على الموبايل (≤640px) سلسلة الطول بتقطع لأن app-shell بيبقى block —
   بنرجّعها لما عرض الشهر مفتوح عشان الشبكة تملى الشاشة بالظبط من غير أرقام ثابتة */
@media (max-width: 640px) {
  .app-shell.tb-stretch {
    display: flex;
    flex-direction: column;
  }
}
.tb-full-height {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tb-full-height .timeblock-layout-month {
  flex: 1;
  display: flex;
  min-height: 0;
}
.tb-full-height .tbm-grid-wrap {
  flex: 1;
  width: 100%;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tb-full-height .tbm-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto; /* الشاشات القصيرة: الشبكة تسكرول داخلي تحت رأس الأيام الثابت بدل ما الأسابيع تتقص */
  grid-auto-rows: minmax(min-content, 1fr); /* كل صف على قد محتواه (مهام ما تتقصش) — ولو المساحة أكتر بيتوزع بالتساوي زي Google Calendar */
}
/* عرض اليوم/الأسبوع: السكرول جوه عمود التقويم مش على مستوى الصفحة —
   الـ tb-stretch بيمدّ الحاويات لطول الشاشة، وهنا بنقفل سكرول الـ main-col
   الخارجي ونفتح سكرول داخلي في عمود التقويم نفسه.
   ملحوظة: الأسبقية لازم تكسب `body.locked-view .main-col` (عنصر + كلاسين)
   عشان تشتغل على كل الشاشات مش الموبايل بس */
body.locked-view .main-col.tb-stretch {
  overflow: hidden;
}
.tb-full-height .tb-date-nav {
  flex-shrink: 0;
}
.tb-full-height .timeblock-layout:not(.timeblock-layout-month) {
  flex: 1;
  display: flex;
  /* لازم stretch مش flex-start (القيمة الأصلية): مع flex-start العمود بياخد طول
     المحتوى كله (1472px) وبيتقص من غير أي سكرول، ومع stretch بيتحصر في ارتفاع
     الشاشة والسكرول الداخلي بيشتغل */
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}
.tb-full-height .timeblock-calendar-col {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* رأس الأعمدة بيثبت فوق أثناء السكرول الداخلي */
.tb-full-height .timeblock-calendar-col .tbw-col-head,
.tb-full-height .timeblock-calendar-col .tbw-hours-head {
  position: sticky;
  top: 0;
  z-index: 6;
}
/* ===== سكرول الصفحة الطبيعي لليوم/الأسبوع على الموبايل =====
   الكلاس body.tb-page-scroll بيترفع من timeBlocking.js على عرض اليوم/الأسبوع
   (في الموبايل بس — الـ media query هو اللي بيفعّل التحويل ده):
   كان الجدول بيستخدم سكرول داخلي متداخل على عمود التقويم جنب سكرول الشبكة
   الأفقي في الأسبوع — فبيبانوا شريطين متزاحمين بيشتغلوا ضد بعض على اللمس.
   هنا بينتقلا لسكرول الصفحة الواحد (الـ main-col) والشريط الأفقي للأسبوع
   بيشتغل باللمس من غير ما يبان.
   الشهر مستثنى عشان محافظ على سكروله الداخلي (سلوكه شغال كويس). */
@media (max-width: 900px) {
  body.tb-page-scroll .main-col.tb-stretch {
    overflow-y: auto;
  }
  body.tb-page-scroll .timeblock-view {
    flex: none;
    min-height: 0;
  }
  body.tb-page-scroll .timeblock-layout:not(.timeblock-layout-month) {
    flex: none;
    overflow: visible;
  }
  body.tb-page-scroll .timeblock-calendar-col {
    overflow: visible;
  }
  body.tb-page-scroll .timeblock-calendar-col .tbw-grid {
    scrollbar-width: none;
    /* overflow-x:auto بس في القاعدة الأساسية بيخلي overflow-y يتحسب auto
       تلقائيًا — فيبقى السحب العمودي يتلخبط مع سكرول الصفحة (التأثير اتخبّى
       لكنه موجود). هنا بنقفل المحور العمودي صراحةً ونخلي الأفقي يشتغل باللمس. */
    overflow-x: auto;
    overflow-y: hidden;
  }
  body.tb-page-scroll .timeblock-calendar-col .tbw-grid::-webkit-scrollbar {
    display: none;
    height: 0;
  }
}
.tbm-grid-wrap {
  margin-top: 0;
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: 12px;
  overflow: hidden;
}
.tbm-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--paper);
  border-bottom: 1px solid var(--paper-line);
}
.tbm-head-cell {
  padding: 8px 6px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink-soft);
}
.tbm-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(96px, 1fr);
}
.tbm-cell {
  border-top: 1px solid var(--paper-line);
  border-inline-start: 1px solid var(--paper-line);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}
.tbm-body .tbm-cell:nth-child(7n + 1) {
  border-inline-start: none;
}
/* تظليل نهاية الأسبوع (الجمعة والسبت) — قبل other-month و today عشان يتفوقوا عليه */
.tbm-cell.weekend {
  background: var(--paper);
}
.tbm-cell.other-month {
  background: var(--paper);
  opacity: 0.55;
}
.tbm-cell.today {
  background: var(--pen-soft);
}
.tbm-day-num {
  align-self: flex-start;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tbm-day-num:hover {
  background: var(--popup);
}
.tbm-cell.today .tbm-day-num {
  background: var(--pen);
  color: #fff;
}
.tbm-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}
.tbm-event {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  padding: 2px 6px;
  border: none;
  border-inline-start: 3px solid var(--blk, var(--pen));
  border-radius: 6px;
  background: color-mix(in srgb, var(--blk, var(--pen)) 10%, var(--card));
  color: var(--ink);
  font-family: inherit;
  font-size: 0.68rem;
  line-height: 1.5;
  text-align: start;
  cursor: pointer;
  white-space: nowrap;
}
.tbm-event:hover {
  background: color-mix(in srgb, var(--blk, var(--pen)) 18%, var(--card));
}
.tbm-event-time {
  flex-shrink: 0;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.62rem;
}
.tbm-event-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.tbm-event.done {
  opacity: 0.55;
}
.tbm-event.done .tbm-event-name {
  text-decoration: line-through;
}
.tbm-event-more {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--pen);
  padding-inline-start: 4px;
  border: none;
  background: transparent;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tbm-event-more:hover {
  text-decoration: underline;
}
.tbm-cell.drop-hover {
  background: var(--pen-soft);
  box-shadow: inset 0 0 0 2px var(--pen);
}
/* بوب "+N المزيد": قائمة كل مهام اليوم */
.tbm-more-pop {
  position: fixed;
  z-index: 300;
  min-width: 200px;
  max-width: 280px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--popup);
  border: 1px solid var(--popup-border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow-hover);
}
.tbm-more-head {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink-soft);
  padding: 6px 8px;
}
.tbm-more-empty {
  font-size: 0.72rem;
  color: var(--ink-soft);
  padding: 4px 8px 8px;
}
.tbm-more-item {
  display: flex;
  align-items: baseline;
  gap: 5px;
  width: 100%;
  padding: 4px 8px;
  border: none;
  border-inline-start: 3px solid var(--blk, var(--pen));
  border-radius: 6px;
  background: color-mix(in srgb, var(--blk, var(--pen)) 10%, var(--card));
  color: var(--ink);
  font-family: inherit;
  font-size: 0.7rem;
  text-align: start;
  cursor: pointer;
  margin-bottom: 2px;
}
.tbm-more-item:hover {
  background: color-mix(in srgb, var(--blk, var(--pen)) 18%, var(--card));
}
.tbm-more-item .tbm-event-time {
  flex-shrink: 0;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.62rem;
}
.tbm-more-item .tbm-event-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tbm-more-item.done {
  opacity: 0.55;
}
.tbm-more-item.done .tbm-event-name {
  text-decoration: line-through;
}

@media (max-width: 900px) {
  .timeblock-layout {
    position: relative;
    flex-direction: column;
    align-items: stretch;
  }
  .timeblock-side-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    /* فوق التاببار (120) وتحت الشيت — الشيت المفتوح يغطي التاببار */
    z-index: 125;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }
  .timeblock-side-backdrop.open {
    opacity: 1;
    visibility: visible;
  }
  .timeblock-side {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    /* فوق الشريط السفلي (z120) — كانت بتطلع من تحته والسكرول جواها بيخبط فيه */
    z-index: 130;
    transform: translateY(100%);
    visibility: hidden;
    opacity: 0;
  }
  .timeblock-side.open {
    transform: translateY(0);
    visibility: visible;
    opacity: 1;
  }
  .timeblock-side.tb-open-anim {
    animation: tbSideInMobile 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
  .timeblock-side.tb-closing {
    visibility: visible;
    opacity: 1;
    animation: tbSideOutMobile 0.2s ease forwards;
  }
  @keyframes tbSideInMobile {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  @keyframes tbSideOutMobile {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(100%); opacity: 0; }
  }
  .timeblock-side .timeblock-side-head {
    margin-bottom: 8px;
  }
  .timeblock-side .timeblock-side-hint {
    display: none;
  }  .timeblock-side .timeblock-unscheduled-list {
    max-height: 800px;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .timeblock-side .timeblock-unscheduled-list.tb-side-collapsed {
    max-height: 190px;
  }
  .timeblock-calendar-col {
    width: 100%;
  }
  .timeblock-unscheduled-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .timeblock-side-item {
    flex: 0 0 auto;
  }
  .tb-date-nav {
    flex-wrap: nowrap;
  }
  .tb-nav-group {
    gap: 4px;
    padding: 2px;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
  }
  .nav-btn {
    padding: 4px;
    flex-shrink: 0;
  }
  .tb-day-label {
    font-size: 0.82rem;
    padding: 4px 4px;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tb-actions-group {
    flex-shrink: 1;
    min-width: 0;
  }
  .tb-today-btn {
    display: none;
  }
  /* زر «اليوم» العائم على الموبايل — بيظهر لما تكون بتتصفح يوم غير النهاردة */
  .tb-today-fab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    position: fixed;
    bottom: calc(96px + env(safe-area-inset-bottom));
    inset-inline-start: 18px;
    z-index: 60;
    background: var(--pen);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 26px -8px color-mix(in srgb, var(--pen) 55%, transparent);
    animation: tb-fab-in 0.3s ease both;
  }
  .tb-today-fab .material-icons { font-size: 18px; }
  .tb-today-fab:active { transform: scale(0.94); }
  @keyframes tb-fab-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
  }
  /* عرض الشهر على الموبايل: خلايا أضغط — الطول الكامل بيتم عن طريق
     إعادة سلسلة flex في stats.css (app-shell.tb-stretch) مش بارتفاع ثابت */
  .tbm-grid-wrap {
    border-radius: 10px;
  }
  .tbm-head-cell {
    padding: 5px 2px;
    font-size: 0.62rem;
  }
  .tbm-body {
    grid-auto-rows: minmax(56px, 1fr);
  }
  .tbm-cell {
    padding: 2px;
    gap: 1px;
  }
  .tbm-day-num {
    width: 20px;
    height: 20px;
    font-size: 0.68rem;
  }
  .tbm-event {
    padding: 1px 4px;
    font-size: 0.6rem;
    border-inline-start-width: 2px;
  }
  .tbm-event-time {
    display: none;
  }
}

/* ============================================================
   القوائم الذكية (Pro)
   ============================================================ */
.smart-view {
  max-width: 760px;
  margin: 0 auto;
  padding: 4px 0 20px;
}
.view-page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.view-page-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
  flex: 1;
}
.view-head-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.5px solid var(--paper-line);
  background: var(--card);
  color: var(--ink);
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 11px;
  cursor: pointer;
}
.view-head-action-btn .material-icons {
  font-size: 16px;
  color: var(--pen);
}
.smart-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.smart-tabs::-webkit-scrollbar {
  display: none;
}
.smart-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  border: 1.5px solid var(--paper-line);
  background: var(--card);
  color: var(--ink);
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 11px;
  cursor: pointer;
}
.smart-tab .material-icons {
  font-size: 16px;
  color: var(--ink-soft);
}
.smart-tab.active {
  border-color: var(--pen);
  color: var(--pen);
  background: var(--pen-soft);
}
.smart-tab.active .material-icons {
  color: var(--pen);
}
.smart-tab-count {
  font-size: 0.68rem;
  font-weight: 800;
  background: var(--paper-line);
  color: var(--ink-soft);
  border-radius: 20px;
  padding: 1px 7px;
}
.smart-tab.active .smart-tab-count {
  color: var(--card);
  background: var(--pen);
}
.smart-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.smart-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: 13px;
  padding: 10px 12px;
}
.smart-task-row.done {
  opacity: 0.55;
}
.smart-task-row.done .smart-task-name {
  text-decoration: line-through;
}
.smart-done-btn {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
}
.smart-done-btn .material-icons {
  font-size: 22px;
}
.smart-done-btn.checked {
  color: var(--done);
}
.smart-task-icon {
  font-size: 19px;
}
.smart-task-body {
  flex: 1;
  min-width: 0;
}
.smart-task-name {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.smart-task-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}
.smart-task-date {
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.smart-task-time {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.smart-task-time .material-icons {
  font-size: 13px;
}
.smart-to-day-btn {
  border: none;
  background: transparent;
  color: var(--pen);
  cursor: pointer;
  display: inline-flex;
  padding: 4px;
  border-radius: 50%;
}
.smart-to-day-btn:hover {
  background: var(--pen-soft);
}
.smart-to-day-btn .material-icons {
  font-size: 20px;
}
