.task-schedule-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6) 0;
}

.task-schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}

.task-schedule-header__left {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.task-schedule-title {
  margin: 0;
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.task-schedule-plan-meta {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.task-schedule-header__right {
  text-align: right;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.task-schedule-week-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: var(--color-gray-50);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
}

.task-schedule-minimap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-2);
  background: var(--color-gray-50);
  border-radius: var(--radius-lg);
}

.timeline-minimap__week {
  flex: 0 0 auto;
  min-width: 4rem;
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-xs);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  position: relative;
}

.timeline-minimap__week::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--color-primary);
  opacity: clamp(0.15, calc(var(--task-count, 0) / 6), 1);
  border-bottom-left-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

.timeline-minimap__week.is-active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(58, 151, 212, 0.3);
}

.timeline-minimap__week:hover {
  background: var(--color-gray-100);
}

.timeline-minimap__week--density-low {
  background: var(--color-success-light);
  border-color: var(--color-success);
  color: var(--color-success-dark, var(--text-primary));
}

.timeline-minimap__week--density-medium {
  background: var(--color-warning-light);
  border-color: var(--color-warning);
  color: var(--color-warning-dark, var(--text-primary));
}

.timeline-minimap__week--density-high {
  background: var(--color-error-light);
  border-color: var(--color-error);
  color: var(--color-error-dark, var(--text-primary));
}

.timeline-minimap__label {
  flex: 0 0 auto;
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-tertiary, var(--text-secondary));
  padding: var(--space-1) var(--space-2);
  margin-right: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.task-schedule-week-label {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-lg);
  color: var(--text-primary);
}

.task-schedule-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.task-schedule-field {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.task-schedule-field__header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  align-items: center;
  row-gap: var(--space-1);
}

.task-schedule-field__name {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.task-schedule-field__subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.task-schedule-field__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.task-schedule-field__add {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-primary);
  background: rgba(58, 151, 212, 0.08);
  color: var(--color-primary-dark);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.task-schedule-field__add:hover {
  background: rgba(58, 151, 212, 0.16);
  border-color: var(--color-primary-dark);
}

.timeline-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-0);
  overflow-x: auto;
}

.timeline-day-header-row,
.timeline-day-cells {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  column-gap: var(--space-1);
  row-gap: var(--space-0);
}

.timeline-day-label {
  background: var(--color-gray-100);
  color: var(--text-secondary);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  text-align: center;
}

.timeline-day-label--today {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: var(--font-weight-semibold);
}

.timeline-day-cell {
  min-height: 24px;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: var(--space-0);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: var(--space-0);
  border: none;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.timeline-day-cell--empty {
  color: var(--text-secondary);
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: var(--font-size-sm);
}

.timeline-day-cell--drag-over {
  border-color: var(--color-primary);
  background: rgba(58, 151, 212, 0.12);
  box-shadow: 0 0 0 2px rgba(58, 151, 212, 0.18);
}

.timeline-day-cell--pending {
  position: relative;
  opacity: 0.6;
}

.timeline-day-cell--pending::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px dashed var(--color-primary);
  animation: timeline-pending-pulse 1s ease-in-out infinite alternate;
}

.timeline-task {
  display: block;
  background: #fff;
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--color-primary);
  border: 1px solid var(--color-gray-300);
  padding: calc(var(--space-1) * 1.5625) calc(var(--space-2) * 1.5625);
  font-size: calc(var(--font-size-sm) * 1.5625);
  line-height: 1.3;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  text-align: left;
  cursor: grab;
  width: 100%;
  min-height: 32px;
  box-sizing: border-box;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.timeline-task + .timeline-task {
  margin-top: calc(var(--space-1) * 1.5625);
}

.timeline-task--fertilizer {
  border-left-color: var(--color-success);
}

.timeline-task:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
  border-color: var(--color-primary);
  background: #fff;
}

.timeline-task--dragging {
  opacity: 0.6;
  transform: scale(0.98);
  box-shadow: var(--shadow-lg);
  cursor: grabbing;
}

.timeline-task__name {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  display: block;
}

.timeline-task__stage {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.timeline-task--status-completed {
  background: var(--color-success-light);
  border-left-color: var(--color-success);
  color: var(--color-success-dark, var(--text-primary));
}

.timeline-task--status-delayed {
  background: var(--color-error-light);
  border-left-color: var(--color-error);
  color: var(--color-error-dark, var(--text-primary));
}

.timeline-task--status-cancelled {
  background: var(--color-gray-100);
  border-left-color: var(--color-gray-400);
  color: var(--text-secondary);
}

.timeline-task--priority-high {
  border-left-color: var(--color-warning-dark);
}

.timeline-task--priority-medium {
  border-left-color: var(--color-warning);
}

.timeline-task--priority-low {
  border-left-color: var(--color-warning-light);
}

.timeline-unscheduled {
  background: var(--color-gray-50);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}

.timeline-unscheduled__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.timeline-unscheduled__list {
  margin: 0;
  padding-left: var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  color: var(--text-primary);
}

.timeline-unscheduled__item {
  list-style: disc;
}

.timeline-unscheduled__button {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  cursor: pointer;
}

.timeline-unscheduled__button:hover {
  text-decoration: underline;
}

.timeline-drag-error {
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-error-light);
  color: var(--color-error-dark);
  font-size: var(--font-size-sm);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.timeline-drag-error.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes timeline-pending-pulse {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 1;
  }
}

.task-schedule-loading,
.task-schedule-error,
.task-schedule-empty {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--color-gray-50);
  color: var(--text-secondary);
  text-align: center;
  font-size: var(--font-size-base);
}

.task-schedule-error {
  background: var(--color-error-light);
  color: var(--color-error-dark);
}

.task-schedule-detail {
  margin: 0;
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: 100%;
  overflow-y: auto;
}

.task-schedule-detail.hidden {
  display: none;
}

.task-schedule-detail__title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.task-schedule-detail__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.task-schedule-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: var(--space-1);
}

.task-schedule-detail__form {
  border-top: 1px solid var(--color-gray-200);
  padding-top: var(--space-3);
}

.timeline-action-btn {
  border: 1px solid var(--color-primary);
  background: rgba(58, 151, 212, 0.1);
  color: var(--color-primary-dark);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.timeline-action-btn:hover {
  background: rgba(58, 151, 212, 0.2);
}

.timeline-action-btn--danger {
  border-color: var(--color-error);
  background: rgba(211, 47, 47, 0.1);
  color: var(--color-error);
}

.timeline-action-btn--danger:hover {
  background: rgba(211, 47, 47, 0.2);
}

.timeline-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.timeline-form__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.timeline-form__field input,
.timeline-form__field select,
.timeline-form__field textarea {
  width: 100%;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-gray-300);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.timeline-form__field textarea {
  resize: vertical;
}

.timeline-date-input {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.timeline-date-input input[type="date"] {
  min-width: 160px;
}

.timeline-date-btn {
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-gray-50);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.timeline-date-btn:hover {
  background: var(--color-gray-100);
  border-color: var(--color-primary);
}

.timeline-date-btn:active {
  background: var(--color-primary-light);
}

.timeline-form__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.timeline-form__message {
  font-size: var(--font-size-xs);
  min-height: 1em;
}

.timeline-form__message--success {
  color: var(--color-success);
}

.timeline-form__message--error {
  color: var(--color-error);
}

.timeline-form__hint {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin: 0;
}

.timeline-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.timeline-chip {
  border: 1px solid var(--color-gray-300);
  border-radius: 999px;
  padding: var(--space-1) var(--space-3);
  background: var(--bg-card);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.timeline-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.timeline-chip.is-active {
  border-color: var(--color-primary);
  background: rgba(58, 151, 212, 0.15);
  color: var(--color-primary-dark);
}

body.timeline-modal-open {
  overflow: hidden;
}

.timeline-modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
}

.timeline-modal.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.timeline-modal__dialog {
  position: relative;
  background: transparent;
  padding: var(--space-3);
  width: min(640px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.timeline-modal__dialog:focus {
  outline: none;
}

.timeline-modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: var(--font-size-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.timeline-modal__close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .timeline-modal.is-open {
    align-items: flex-end;
  }

  .timeline-modal__dialog {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    padding: 0;
  }

  .task-schedule-detail {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0));
  }

  .timeline-modal__close {
    top: var(--space-3);
    right: var(--space-3);
  }
}

.detail-row {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-gray-50);
}

.detail-row--empty {
  font-style: italic;
}

@media (max-width: 1024px) {
  .timeline-day-header-row,
  .timeline-day-cells {
    grid-template-columns: repeat(7, minmax(96px, 1fr));
  }
}

@media (max-width: 768px) {
  .task-schedule-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .task-schedule-header__right {
    text-align: left;
  }

  .timeline-day-header-row,
  .timeline-day-cells {
    grid-template-columns: repeat(7, minmax(80px, 1fr));
  }

  .task-schedule-field__header {
    grid-template-columns: 1fr;
  }

  .task-schedule-field__actions {
    justify-content: flex-start;
  }
}


