:root {
  --planner-row-height: 24vh;
}

.workout-planner-overlay {
  z-index: 50;
}

.workout-planner-modal {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workout-planner-header {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0;
  margin-bottom: 4px;
  padding: 0 46px 12px 0;
}

.workout-planner-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.workout-planner-title {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: var(--font-size-base);
  color: var(--text-muted);
  min-height: var(--nav-control-height);
  display: flex;
  align-items: center;
}

.workout-planner-selected {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  text-align: center;
  font-weight: 700;
  font-size: 20px;
  color: var(--text-main);
  min-height: var(--nav-control-height);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workout-planner-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.workout-planner-header .picker-close-btn {
  position: absolute;
  top: 0;
  right: 0;
}

.planner-schedule-btn {
  padding-inline-start: 10px;
}

.workout-planner-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.planner-calendar {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  background: var(--surface);
  min-width: 900px;
}

.planner-calendar-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  border-bottom: 1px solid var(--border-subtle);
}

.planner-day-head {
  padding: 8px 10px;
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-left: 1px solid var(--border-subtle);
}

.planner-day-head:first-child {
  border-left: none;
}

.planner-calendar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.planner-week-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-height: var(--planner-row-height);
  height: auto;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border-subtle);
}

.planner-week-row:last-child {
  border-bottom: none;
}

.planner-day {
  position: relative;
  border-left: 1px solid var(--border-subtle);
  border-top: 1px solid transparent;
  display: flex;
  align-items: stretch;
  cursor: pointer;
  background: var(--surface);
  transition: var(--interactive-transition);
}

.planner-day:first-child {
  border-left: none;
}

.planner-day-content {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  box-sizing: border-box;
}

.planner-day-number {
  font-weight: 700;
  color: var(--text-main);
  font-size: 20px;
  line-height: 20px;
  padding: 12px 12px 4px 12px;
}

.planner-day.has-month-label {
  /* padding handled by content */
}

.planner-month-label {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 20px;
}

.planner-workout-card {
  width: 100%;
  margin: 0;
  border-radius: 0;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 11px 12px 11px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: opacity 0.14s ease, background-color 0.12s ease, filter 0.12s ease;
  opacity: 0.96;
}

.planner-workout-card:hover {
  opacity: 1;
  background: var(--hover-light);
  filter: brightness(0.98);
}

.planner-day.is-selected .planner-workout-card:hover {
  background: var(--planner-selected-hover-bg);
  border-left: 1px solid var(--cta-border);
  border-right: 1px solid var(--cta-border);
}

.planner-day.is-today:not(.is-selected) .planner-workout-card:hover {
  background: var(--planner-today-hover-bg);
  border-left: 1px solid var(--warning-border);
  border-right: 1px solid var(--warning-border);
}

.planner-workout-card:active {
  opacity: 1;
  background: var(--hover-medium);
  filter: brightness(0.95);
}

.planner-day.is-selected .planner-workout-card:active {
  background: var(--planner-selected-hover-bg);
  border-left: 1px solid var(--cta-border);
  border-right: 1px solid var(--cta-border);
}

.planner-day.is-today:not(.is-selected) .planner-workout-card:active {
  background: var(--planner-today-hover-bg);
  border-left: 1px solid var(--warning-border);
  border-right: 1px solid var(--warning-border);
}

.planner-scheduled-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
  height: 32px;
}

.planner-scheduled-tag {
  font-size: var(--font-size-base);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  line-height: 24px;
}

.planner-scheduled-tag-past {
  text-decoration: line-through;
}

.planner-scheduled-missing .planner-workout-name {
  color: var(--error);
}

.planner-scheduled-edit-btn {
  width: 32px;
  height: 32px;
}

.planner-workout-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.planner-workout-name {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--text-main);
}

.planner-workout-stats {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  row-gap: 0;
}

.planner-workout-stat-chip {
  display: inline-block;
  white-space: nowrap;
}

.planner-workout-chart {
  width: 100%;
  height: 36px;
}

.planner-workout-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.planner-footer {
  margin-top: 12px;
  font-size: var(--font-size-base);
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.planner-footer-left {
  text-align: left;
}

.planner-footer-right {
  text-align: right;
}

.planner-footer-right,
.planner-footer-left {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.planner-footer-sep {
  padding: 0 4px;
}
.planner-day:hover {
  background: var(--hover-light);
}

.planner-day.suppress-hover:hover:not(.is-selected):not(.is-today) {
  background: var(--surface);
  box-shadow: none;
}

.planner-day.suppress-hover:hover.is-selected {
  background: var(--planner-selected-hover-bg);
  box-shadow: inset 0 0 0 1px var(--cta-border);
}

.planner-day.suppress-hover:hover.is-today:not(.is-selected) {
  background: var(--planner-today-hover-bg);
  box-shadow: inset 0 0 0 1px var(--warning-border);
}

.planner-day.is-selected {
  background: var(--planner-selected-bg);
  box-shadow: inset 0 0 0 1px var(--cta-border);
}

.planner-day.is-selected:hover {
  background: var(--planner-selected-hover-bg);
  box-shadow: inset 0 0 0 1px var(--cta-border);
}

.planner-day.is-selected:hover:has(.planner-workout-card:hover) {
  background: var(--planner-selected-bg);
  box-shadow: inset 0 0 0 1px var(--cta-border);
}

.planner-day.is-today:not(.is-selected) {
  background: var(--planner-today-bg);
  box-shadow: inset 0 0 0 1px var(--warning-border);
}

.planner-day.is-today:not(.is-selected):hover {
  background: var(--planner-today-hover-bg);
  box-shadow: inset 0 0 0 1px var(--warning-border);
}

.planner-day.is-today:not(.is-selected):hover:has(.planner-workout-card:hover) {
  background: var(--planner-today-bg);
  box-shadow: inset 0 0 0 1px var(--warning-border);
}

.planner-day.month-top-boundary {
  border-top: 3px solid var(--border);
}

.planner-day.month-left-boundary {
  border-left: 3px solid var(--border);
}

.planner-day.month-bottom-boundary {
  border-bottom: 3px solid var(--border);
}

.planner-detail-view {
  display: none;
  flex: 1;
  min-height: 0;
  gap: 0;
  flex-direction: column;
}

.planner-detail-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
  flex: 0 0 50%;
  height: 50%;
}

.planner-detail-stats {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.planner-detail-date {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: var(--font-size-base);
  color: var(--text-muted);
  margin: 12px 0 6px 0;
}

.planner-detail-stats .wb-stats-row {
  width: 100%;
  margin: 0;
  gap: 12px;
}

.planner-detail-curve {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  min-height: 0;
}

.planner-power-curve {
  width: 100%;
  flex: 1 1 auto;
  height: calc(100% - 36px);
  min-height: 200px;
  max-height: 100%;
}

.planner-detail-chart-panel {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  flex: 0 0 50%;
  height: 50%;
  min-height: 0;
  position: relative;
}

.planner-detail-chart {
  width: 100%;
  height: 100%;
}

.planner-curve-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 6px 0;
}

.planner-curve-title {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: var(--font-size-base);
  color: var(--text-muted);
}

.planner-curve-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text-muted);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}

.planner-curve-help svg {
  width: 16px;
  height: 16px;
}

.planner-curve-help:hover {
  color: var(--text-main);
  background: var(--hover-medium);
}

.planner-detail-mode .planner-calendar,
.planner-detail-mode .planner-footer,
.planner-detail-mode .planner-schedule-btn {
  display: none !important;
}

.planner-detail-mode #plannerDetailView {
  display: flex !important;
}

.planner-detail-mode .workout-planner-title {
  text-transform: none;
}

.planner-detail-mode .workout-planner-body {
  overflow: hidden;
}

.planner-detail-mode #plannerBackBtn {
  display: inline-flex !important;
}

.planner-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@media (prefers-color-scheme: dark) {
  .planner-day:hover {
    background: var(--hover-medium);
  }
}

@media (max-width: 900px) {
  .workout-planner-modal {
    width: 96vw;
    height: 80vh;
  }

  .workout-planner-header {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .workout-planner-selected {
    justify-content: flex-start;
  }

  .workout-planner-actions {
    justify-content: flex-start;
  }
}
