/* Reversible local preview of the current/next task hierarchy and alignment. */
.live-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 370px), 1fr));
}

.live-card {
  container-type: inline-size;
  min-height: 230px;
  padding: 18px 20px 15px;
  border-color: rgba(95, 123, 148, .36);
  background-image:
    radial-gradient(ellipse at 100% 0%, rgba(76, 178, 222, .095), transparent 48%),
    linear-gradient(138deg, rgba(20, 30, 41, .99), rgba(12, 18, 26, .99));
  box-shadow: 0 12px 30px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .025);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.live-card:hover {
  border-color: color-mix(in srgb, var(--live-accent), transparent 73%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .035);
}

.live-card::before {
  position: absolute;
  z-index: 0;
  inset: 0 auto auto 20px;
  width: 72px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, var(--live-accent), color-mix(in srgb, var(--live-accent), transparent 28%));
  box-shadow: 0 0 12px color-mix(in srgb, var(--live-accent), transparent 72%);
  opacity: .88;
  content: "";
  pointer-events: none;
}

.live-card::after { content: none; }
.live-current { --live-accent: #72c7ff; }
.live-current .live-pulse { animation: live-status-breathe 2.8s ease-in-out infinite; }
.live-next {
  --live-accent: #ffc65c;
  background-image:
    radial-gradient(ellipse at 100% 0%, rgba(255, 179, 73, .085), transparent 48%),
    linear-gradient(138deg, rgba(20, 30, 41, .99), rgba(12, 18, 26, .99));
}

.live-card-top,
.live-card-bottom,
.live-card-footer,
.live-start-time {
  display: flex;
  align-items: center;
}

.live-card-top {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(182, 204, 222, .09);
}

.live-state {
  color: #e1edf7;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .025em;
}

.live-current .live-state { color: #d9f1ff; }
.live-next .live-state { color: #f7e7c7; }
.live-pulse { width: 8px; height: 8px; flex: 0 0 auto; }

.live-start-time { flex: 0 0 auto; justify-content: flex-end; gap: 8px; }
.live-time-label { color: #8f9eac; font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.live-time {
  min-width: 78px;
  min-height: 39px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--live-accent), transparent 76%);
  border-radius: 8px;
  color: var(--live-accent);
  background: color-mix(in srgb, var(--live-accent), transparent 94%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
  font: 800 21px/1 ui-monospace, Consolas, monospace;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.live-task {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: max-content max-content minmax(0, 1fr);
  grid-template-areas: "title title title" "grade edit spacer";
  align-content: center;
  align-items: center;
  justify-content: start;
  gap: 9px 8px;
  min-height: 98px;
  margin-top: 8px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.live-task > .task-label {
  grid-area: title;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  color: #edf4fa;
  font-size: clamp(18px, 2.05vw, 23px);
  line-height: 1.32;
  letter-spacing: -.015em;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.live-task > .grade-chip {
  grid-area: grade;
  min-width: 50px;
  min-height: 32px;
  padding-inline: 10px;
  font-size: 12px;
}

.live-task > .rating-edit-button {
  grid-area: edit;
  min-width: 80px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 6px 10px;
  border-color: rgba(133, 167, 194, .3);
  border-radius: 7px;
  color: #cee4f3;
  background: rgba(102, 148, 180, .075);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.live-task > .rating-edit-button:hover {
  border-color: rgba(114, 199, 255, .58);
  color: #f0f9ff;
  background: rgba(76, 151, 194, .17);
  box-shadow: 0 0 0 3px rgba(114, 199, 255, .055);
}

.live-task > .rating-edit-button:active { transform: scale(.97); }
.live-task > .rating-edit-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.live-card .live-task .grade-chip { justify-self: start; }
.live-task.handoff-refresh .task-label { animation: task-handoff-in .34s ease-out both; }

.live-progress {
  position: relative;
  z-index: 1;
  height: 3px;
  overflow: hidden;
  margin: 0 0 8px;
  border-radius: 999px;
  background: rgba(126, 152, 174, .15);
}

.live-progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #399dcc, #78d7ff);
  box-shadow: 0 0 7px rgba(91, 193, 245, .48);
  transform-origin: left center;
  transition: transform .35s linear;
}

.live-progress[aria-valuenow="100"] > span { background: linear-gradient(90deg, #26b98c, #76e5be); }
.live-next .live-card-footer { border-top-color: rgba(255, 198, 92, .11); }

.live-card-footer {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-top: auto;
  padding-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, .075);
}

.live-card-bottom {
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  color: #9baab8;
  font-size: 11px;
}

.countdown {
  color: var(--live-accent);
  font: 750 15px/1.2 ui-monospace, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.live-card-actions { position: relative; z-index: 1; display: flex; justify-content: flex-end; flex: 0 0 auto; margin: 0; }
.live-card-actions button { min-width: 74px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; padding: 6px 10px; line-height: 1.2; text-align: center; transition: color .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.live-card-actions button:hover { border-color: rgba(114, 199, 255, .45); color: #eef8ff; background: rgba(114, 199, 255, .08); box-shadow: 0 0 0 3px rgba(114, 199, 255, .045); }
.live-card-actions button:active { transform: scale(.97); }
.live-card-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes task-handoff-in { from { opacity: .38; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@keyframes live-status-breathe { 0%, 100% { opacity: .88; box-shadow: 0 0 8px color-mix(in srgb, var(--live-accent), transparent 34%); } 50% { opacity: 1; box-shadow: 0 0 13px color-mix(in srgb, var(--live-accent), transparent 21%); } }

@media (max-width: 640px) {
  .live-card { min-height: 216px; padding: 15px; }
  .live-card::before { left: 15px; width: 58px; }
  .live-card-top { min-height: 44px; padding-bottom: 8px; }
  .live-state { font-size: 15px; }
  .live-start-time { gap: 6px; }
  .live-time-label { font-size: 9px; }
  .live-time { min-width: 70px; min-height: 36px; font-size: 19px; }
  .live-task { min-height: 96px; margin-top: 8px; gap: 8px 7px; }
  .live-task > .task-label { font-size: 18px; }
  .live-task > .rating-edit-button { min-height: 40px; }
  .live-card-footer { min-height: 40px; gap: 8px; padding-top: 8px; }
  .live-card-actions button { min-height: 40px; }
}

@media (max-width: 360px) {
  .live-card { padding-inline: 12px; }
  .live-card-top { gap: 7px; }
  .live-state { font-size: 14px; }
  .live-start-time { gap: 5px; }
  .live-time-label { font-size: 8px; }
  .live-time { min-width: 64px; min-height: 34px; padding-inline: 7px; font-size: 18px; }
  .live-task > .task-label { font-size: 17px; }
  .live-task > .grade-chip { min-width: 46px; padding-inline: 8px; }
  .live-task > .rating-edit-button { min-width: 76px; min-height: 40px; }
}

@media (max-height: 460px) and (min-width: 600px) {
  .live-card { min-height: 176px; padding: 10px 14px 9px; }
  .live-card::before { left: 14px; width: 48px; }
  .live-card-top { min-height: 37px; padding-bottom: 6px; }
  .live-state { font-size: 14px; }
  .live-time-label { font-size: 9px; }
  .live-time { min-width: 65px; min-height: 32px; font-size: 18px; }
  .live-task { min-height: 78px; margin-top: 6px; gap: 6px; }
  .live-task > .task-label { font-size: clamp(15px, 1.9vw, 19px); }
  .live-task > .grade-chip { min-height: 28px; }
  .live-task > .rating-edit-button { min-height: 34px; }
  .live-progress { margin-bottom: 5px; }
  .live-card-footer { min-height: 34px; padding-top: 6px; }
  .countdown { font-size: 13px; }
  .live-card-actions button { min-height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-card,
  .live-task > .rating-edit-button,
  .live-current .live-pulse,
  .live-card-actions button,
  .live-progress > span { transition: none !important; }
  .live-current .live-pulse { animation: none; }
  .live-task > .rating-edit-button:active,
  .live-card-actions button:active { transform: none; }
  .live-task.handoff-refresh .task-label { animation: none; }
}
