/* Thành phần dùng chung, theo mẫu 04 (dòng, khối, thẻ, dải 7 ngày, bảng tuần) và mẫu 02 cột X
   (tờ lịch, thanh chia đoạn). Cỡ chữ phóng theo Global Constraints: thân ≥ 16px, nhãn ≥ 12px.
   Màu dự án: đặt lớp .c-sN lên phần tử; .dot .sq.on .stages i.on .seg i.on đọc biến --c. */

/* Màu dự án */
.c-s2 { --c: var(--s2); background: var(--s2); }
.c-s3 { --c: var(--s3); background: var(--s3); }
.c-s4 { --c: var(--s4); background: var(--s4); }
.c-s5 { --c: var(--s5); background: var(--s5); }
.c-s6 { --c: var(--s6); background: var(--s6); }
.c-s7 { --c: var(--s7); background: var(--s7); }
.c-s8 { --c: var(--s8); background: var(--s8); }
.c-s9 { --c: var(--s9); background: var(--s9); }
.c-s10 { --c: var(--s10); background: var(--s10); }

/* Dòng việc: ô tick, tên, phần bên phải */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.t {
  font-size: var(--fs-body);
  line-height: 1.35;
  min-width: 0;
  overflow-wrap: anywhere;
}
.row .t { flex: 1 1 auto; cursor: pointer; }
.done { color: var(--text-3); text-decoration: line-through; }

.ck {
  position: relative;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ring);
  background: transparent;
}
.ck::before { content: ''; position: absolute; inset: -11px; } /* vùng chạm 44px */
.ck.on { background: var(--accent); border-color: var(--accent); }
.ck.on::after {
  content: '';
  position: absolute;
  left: 6.5px;
  top: 2.5px;
  width: 5px;
  height: 11px;
  border: solid var(--on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, var(--ring));
}

/* Nút viên bên phải dòng: "→ Tuần này", "→ Hôm nay" */
.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  font-size: var(--fs-sm);
  line-height: 1.3;
  padding: 5px 10px;
  border: 1px solid var(--pill-line);
  border-radius: 8px;
  color: var(--accent);
  background: transparent;
  white-space: nowrap;
}

/* Tiêu đề khối: "Hôm nay · 1 / 4" (không viết hoa bằng CSS để innerText giữ đúng chữ) */
.hd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 24px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--text);
  font-size: var(--fs-hd);
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-3);
}
.hd > * { min-width: 0; overflow-wrap: anywhere; }

/* Dòng gập: chữ bên trái, mũi tên › bên phải; mở ra khi có .open hoặc aria-expanded="true" */
.fold {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 12px 2px;
  font-size: var(--fs-md);
  color: var(--text-3);
  cursor: pointer;
}
.fold::after { content: '›'; flex: 0 0 auto; font-size: 20px; line-height: 1; transition: transform .15s; }
.fold.open::after, .fold[aria-expanded="true"]::after { transform: rotate(90deg); }

/* Nút chữ màu nhấn: "+ Thêm việc", "Xem cả 7 việc ›" */
.more {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-top: 10px;
  padding: 6px 0;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}

/* Nhãn trạng thái */
.chip {
  flex: 0 0 auto;
  display: inline-block;
  font-size: var(--fs-sm);
  line-height: 1.35;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--soft);
  color: var(--chip-text);
  white-space: nowrap;
}
.chip.warn { background: var(--chip-warn-bg); color: var(--chip-warn-text); }

/* Dải 7 ngày: mỗi ô "T7" + <b>14</b> + vạch <em class="f|h"> */
.strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-top: 12px;
}
.strip > * {
  display: block;
  width: 100%;
  padding: 7px 0 8px;
  border-radius: 10px;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text-3);
  cursor: pointer;
}
.strip b { display: block; margin-top: 1px; font-family: var(--mono); font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.strip em { display: block; width: 16px; height: 3px; margin: 5px auto 0; border-radius: 2px; background: var(--soft); }
.strip em.f { background: var(--s4); }
.strip em.h { background: var(--s3); }
.strip .sel { box-shadow: inset 0 0 0 1.5px var(--text); }
.strip .now { background: var(--accent); color: #F3C9C5; }
.strip .now b { color: var(--on-accent); }

/* Thẻ dự án */
.card {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}
.name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.card .name { flex: 1 1 auto; font-size: var(--fs-name); line-height: 1.3; }

/* Thanh giai đoạn: mỗi giai đoạn một <i>, đã qua và hiện tại có .on (+ .c-sN) */
.stages { display: flex; flex: 0 1 auto; gap: 4px; min-width: 0; }
.stages i { flex: 0 1 20px; min-width: 6px; height: 6px; border-radius: 3px; background: var(--soft); }
.stages i.on { background: var(--c, var(--text)); }

/* Bảng tuần: hàng đầu là <th>; cột đầu tên dòng, bảy cột ngày có .sq, cột cuối tổng */
.week-table { width: 100%; margin-top: 8px; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.week-table th { padding: 4px 0; font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); text-align: center; }
.week-table td { padding: 8px 0; border-top: 1px solid var(--line); text-align: center; }
.week-table tr > :first-child { width: 32%; padding-right: 8px; text-align: left; overflow-wrap: anywhere; }
.week-table tr > :last-child { width: 2.6em; text-align: right; }
.week-table td:last-child { font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-3); }
.sq { display: inline-block; width: 16px; height: 16px; border-radius: 4px; background: var(--soft); vertical-align: middle; }
.sq.on { background: var(--c, var(--text)); }

/* Tờ lịch tháng: .h tên thứ, .d ô ngày (.l1 .l2 .l3 mức đậm, .fu chưa tới, .x ô trống, .now hôm nay) */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 18px; }
.cal .h { padding-bottom: 2px; font-size: var(--fs-xs); color: var(--text-3); text-align: center; }
.cal .d {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 9px;
  background: var(--soft);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text);
  cursor: pointer;
}
.cal .l1 { background: var(--cal-1); }
.cal .l2 { background: var(--cal-2); }
.cal .l3 { background: var(--cal-3); color: var(--on-accent); }
.cal .fu { background: transparent; color: var(--cal-future); }
.cal .x { background: transparent; cursor: default; }
.cal .now { outline: 2px solid var(--text); outline-offset: 1px; }

/* Thanh chia đoạn: mỗi việc một <i>, việc xong có .on */
.seg { display: flex; gap: 4px; margin-top: 8px; }
.seg i { flex: 1 1 0; min-width: 0; height: 8px; border-radius: 4px; background: var(--soft); }
.seg i.on { background: var(--c, var(--accent)); }

/* Bảng trượt từ dưới (openSheet). .menu: danh sách lệnh trong bảng. */
.sheet-bg {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(30, 24, 23, .35);
}
.sheet {
  width: 100%;
  max-width: var(--w-max);
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 16px rgba(30, 24, 23, .12);
  animation: sheet-in .18s ease-out;
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: .6; } }
.menu > button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-body);
  text-align: left;
}
.menu > button:last-child { border-bottom: 0; }
.menu > .danger { color: var(--accent); }

/* Thông báo ngắn, tự tắt sau 5 giây; nút hành động bên phải */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(var(--w-max) - 32px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--tip-bg);
  color: var(--tip-text);
  font-size: var(--fs-md);
  box-shadow: 0 4px 14px rgba(30, 24, 23, .2);
}
.toast > span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast > button { flex: 0 0 auto; font-weight: 600; color: var(--cal-1); }

/* Dòng khi khối không có gì */
.empty { padding: 14px 0; font-size: var(--fs-body); color: var(--text-3); border-bottom: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .fold::after { transition: none; }
}

/* add sheet (shared by Tuần and Tháng) */
.add-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.add-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 40px;
  padding: 7px 13px;
  border: 1px solid var(--pill-line);
  border-radius: 99px;
  font-size: var(--fs-md);
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-align: left;
}
.add-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.add-chips.need .add-chip { border-color: var(--accent); animation: add-nudge .3s; }
@keyframes add-nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@media (prefers-reduced-motion: reduce) { .add-chips.need .add-chip { animation: none; } }
