/* Calendar: month grid + week/day time grid. */

/* -------------------------------------------------- layout: grid + rail */
.cal-wrap { height: 100%; display: grid;
            grid-template-columns: minmax(0, 1fr) 248px; gap: var(--s3); }
.cal-main { min-width: 0; min-height: 0; }
.cal-rail { display: flex; flex-direction: column; gap: var(--s3);
            overflow-y: auto; }
@media (max-width: 1080px) { .cal-wrap { grid-template-columns: 1fr; }
                             .cal-rail { display: none; } }

.mini {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s3);
}
.mini-head { display: flex; align-items: center; gap: 4px; margin-bottom: var(--s2); }
.mini-title { flex: 1; font-weight: 700; font-size: var(--fs-md); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-n { text-align: center; font-size: var(--fs-xs); color: var(--text-3);
          font-weight: 600; padding: 2px 0; }
.mini-d {
  aspect-ratio: 1; border-radius: 6px; font-size: var(--fs-xs);
  font-weight: 600; color: var(--text-2); display: flex;
  align-items: center; justify-content: center;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.mini-d:hover { background: var(--raised); color: var(--text); }
.mini-d.pad { color: var(--text-3); opacity: 0.5; }
.mini-d.sel { outline: 1px solid var(--accent); }
.mini-d.today { background: var(--accent); color: #fff; }

.rail-cals {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s3);
}
.rail-head { display: flex; justify-content: space-between; font-weight: 700;
             font-size: var(--fs-md); margin-bottom: var(--s2); }
.rail-cal { display: flex; align-items: center; gap: 8px; padding: 6px 4px;
            font-size: var(--fs-sm); font-weight: 600; }
.rail-cal .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.rail-cal .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-cal .tag { color: var(--text-3); font-size: var(--fs-xs); }

/* ------------------------------------------------------------ month view */
.month {
  height: 100%; display: grid;
  grid-template-rows: auto 1fr; gap: var(--s2);
}
.month .dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s2);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 600;
  padding: 0 2px;
}
.month .dow span { padding-left: var(--s2); }
.month .cells {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr; gap: var(--s2); min-height: 0;
}
.cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s2);
  display: flex; flex-direction: column; gap: 3px;
  min-height: 0; overflow: hidden; cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.cell:hover { background: var(--raised); border-color: var(--border-strong); transform: translateY(-1px); }
.cell.weekend { background: var(--weekend); }
.cell.other { opacity: 0.45; }
.cell.today { border-color: var(--accent); background: var(--accent-dim); }
.cell.drop-target { border-color: var(--accent); border-style: dashed; }
.cell .num {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2);
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
}
.cell.today .num { background: var(--accent); color: #fff; border-radius: 50%; }

.chip {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 7px; border-radius: 5px;
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--chip-c, var(--text));
  background: color-mix(in srgb, var(--chip-c, var(--accent)) 13%, transparent);
  border-left: 3px solid var(--chip-c, var(--accent));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: none; cursor: grab;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.chip:hover { background: color-mix(in srgb, var(--chip-c, var(--accent)) 22%, transparent); }
.chip.dragging { opacity: 0.45; }
.chip .t { overflow: hidden; text-overflow: ellipsis; }
.chip.task { border-left-style: double; }
.more { font-size: var(--fs-xs); color: var(--text-3); padding-left: var(--s2); }

/* ------------------------------------------------------- week / day view */
.timegrid {
  height: 100%; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); position: relative;
}
.timegrid .head {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 52px repeat(var(--cols), 1fr);
  background: color-mix(in srgb, var(--surface) 88%, black);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.timegrid .head .day-h {
  padding: 9px 4px; text-align: center;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); cursor: pointer;
}
.timegrid .head .day-h .n { margin-left: 4px; }
.timegrid .head .day-h.today { color: var(--accent); }
.timegrid .head .day-h.today .n {
  background: var(--accent); color: #fff; border-radius: 50%;
  display: inline-flex; width: 20px; height: 20px;
  align-items: center; justify-content: center;
}
.timegrid .canvas {
  display: grid; grid-template-columns: 52px repeat(var(--cols), 1fr);
  position: relative; height: 1440px; /* 1 min = 1 px */
}
.timegrid .hour-label {
  grid-column: 1; position: relative; height: 60px;
  font-size: var(--fs-xs); color: var(--text-3); text-align: right;
  padding-right: 8px; transform: translateY(-6px);
}
.timegrid .col { border-left: 1px solid var(--border); position: relative; }
.timegrid .col.today { background: var(--accent-dim); }
.timegrid .col.weekend { background: var(--weekend); }
.timegrid .hline {
  position: absolute; left: 52px; right: 0; height: 1px;
  background: var(--border); pointer-events: none;
}
.timegrid .hline.half { background: color-mix(in srgb, var(--text) 4%, transparent); }
.timegrid .off-hours {
  position: absolute; left: 52px; right: 0;
  background: var(--off-hours); pointer-events: none;
}
.timegrid .now-dash {
  position: absolute; left: 52px; right: 0; z-index: 3; pointer-events: none;
  border-top: 1px dashed color-mix(in srgb, var(--text) 35%, transparent);
}
.timegrid .now-line {
  position: absolute; left: 0; right: 0; height: 2px;
  background: var(--danger); z-index: 4; pointer-events: none;
}
.timegrid .now-line::before {
  content: ""; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
}
.tg-block {
  position: absolute; left: 3px; right: 3px; z-index: 2;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--chip-c) 15%, var(--surface));
  border-left: 3px solid var(--chip-c);
  padding: 4px 8px; overflow: hidden;
  cursor: grab; touch-action: none; /* pointer drag owns the gesture */
  box-shadow: var(--shadow-1);
  transition: background var(--t-fast) var(--ease);
}
.tg-block:hover { background: color-mix(in srgb, var(--chip-c) 26%, var(--surface)); z-index: 3; }
.tg-block.fixed { cursor: default; }
.tg-block.dragging {
  opacity: 0.88; z-index: 12; cursor: grabbing;
  box-shadow: var(--shadow-2);
  transition: none; /* live tracking, no easing lag */
}
.tg-block .t { font-size: var(--fs-sm); font-weight: 700; color: var(--chip-c);
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-block .when { font-size: var(--fs-xs); color: var(--text-2); }

/* ----------------------------------------------------------- re-plan fx */
.shimmer { position: relative; overflow: hidden; }
.shimmer::after {
  content: ""; position: absolute; inset: 0; z-index: 30; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%,
              rgba(76, 141, 255, 0.13) 50%, transparent 60%);
  background-size: 220% 100%;
  animation: shimmer 1.1s var(--ease) infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -30% 0; } }
