/* Date-first private checklist. The four symbols are the whole planning model. */

:root {
  --plan-ink: #17231e;
  --plan-muted: #68756f;
  --plan-line: #dde6e1;
  --plan-soft: #f1f7f4;
  --plan-green: #0b6b4f;
  --plan-green-deep: #07543f;
  --plan-amber: #9a6500;
  --plan-amber-soft: #fff5d8;
  --plan-red: #ad4841;
  --plan-red-soft: #fff0ef;
}

.calendar-head-actions,
.home-personal-plan-actions,
.personal-plan-day > header,
.personal-plan-error {
  display: flex;
  align-items: center;
}

.calendar-head-actions,
.home-personal-plan-actions {
  gap: 8px;
}

.calendar-head-actions > button {
  min-width: 0;
}

/* Home shows today's first undecided item and one add action. */
.home-personal-plan {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--plan-line);
  border-radius: 8px;
  background: #fff;
}

.home-personal-plan-main {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  min-width: 0;
  min-height: 80px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--plan-ink);
  padding: 13px 16px;
  text-align: left;
}

.home-personal-plan-main:hover,
.home-personal-plan-main:focus-visible {
  background: var(--plan-soft);
}

.home-personal-plan-main:focus-visible,
.personal-plan-status button:focus-visible,
.personal-plan-quick-add :is(input, button):focus-visible,
.personal-plan-menu summary:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--plan-green) 72%, white);
  outline-offset: 2px;
}

.home-personal-plan-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #cfe0d7;
  border-radius: 8px;
  background: var(--plan-soft);
  color: var(--plan-green);
}

.home-personal-plan-icon .icon {
  width: 19px;
  height: 19px;
}

.home-personal-plan-main > span:nth-child(2),
.home-personal-plan-main :where(small, strong, em) {
  display: block;
  min-width: 0;
}

.home-personal-plan-main small {
  color: var(--plan-green-deep);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.home-personal-plan-main strong {
  margin-top: 3px;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-personal-plan-main em {
  margin-top: 2px;
  overflow: hidden;
  color: var(--plan-muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-personal-plan-main > .icon {
  width: 17px;
  color: #84918a;
}

.home-personal-plan-actions {
  align-self: stretch;
  border-left: 1px solid var(--plan-line);
  padding: 12px;
}

.home-personal-plan-actions > button {
  min-height: 40px;
  border-radius: 8px;
  white-space: nowrap;
}

.home-personal-plan.is-loading {
  grid-template-columns: 42px minmax(0, 1fr);
  min-height: 80px;
  align-content: center;
  gap: 12px;
  padding: 13px 16px;
}

.home-personal-plan.is-loading i,
.home-personal-plan.is-loading span,
.personal-plan-loading i {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, #edf1ef 20%, #f7f9f8 50%, #edf1ef 80%);
  background-size: 220% 100%;
  animation: personal-plan-loading 1.2s linear infinite;
}

.home-personal-plan.is-loading i {
  width: 40px;
  height: 40px;
}

.home-personal-plan.is-loading span {
  width: min(100%, 320px);
  height: 28px;
}

/* The selected date is a flat, fast checklist rather than a scheduling form. */
.personal-plan-day {
  min-width: 0;
  border-bottom: 1px solid var(--plan-line);
  background: #fbfdfc;
  padding: 16px 20px 14px;
}

.personal-plan-day > header {
  min-width: 0;
  justify-content: space-between;
  gap: 14px;
}

.personal-plan-day > header > div {
  min-width: 0;
}

.personal-plan-day .workspace-kicker {
  color: var(--plan-green);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.personal-plan-day h3 {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 2px 0 0;
  color: var(--plan-ink);
  font-size: 18px;
  font-weight: 720;
  line-height: 1.35;
}

.personal-plan-day h3 small,
.personal-plan-summary {
  color: var(--plan-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.personal-plan-summary {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.personal-plan-quick-add {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  gap: 8px;
  margin-top: 12px;
}

.personal-plan-quick-add > label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.personal-plan-quick-add input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid #cfdad4;
  border-radius: 8px;
  background: #fff;
  color: var(--plan-ink);
  padding: 0 13px;
}

.personal-plan-quick-add input::placeholder {
  color: #8a9690;
}

.personal-plan-quick-add input:focus {
  border-color: var(--plan-green);
  outline: 0;
}

.personal-plan-quick-add button {
  min-width: 76px;
  min-height: 44px;
  border-radius: 8px;
}

.personal-plan-quick-add.is-busy {
  opacity: .58;
}

.personal-plan-list {
  min-width: 0;
  margin-top: 8px;
}

.personal-plan-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 36px;
  min-width: 0;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e5ece8;
  padding: 11px 0;
}

.personal-plan-row:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.personal-plan-row.is-busy {
  opacity: .58;
  pointer-events: none;
}

.personal-plan-copy,
.personal-plan-copy strong {
  display: block;
  min-width: 0;
}

.personal-plan-copy strong {
  overflow-wrap: anywhere;
  color: var(--plan-ink);
  font-size: 14px;
  font-weight: 670;
  line-height: 1.45;
}

.personal-plan-row.status-done .personal-plan-copy strong,
.personal-plan-row.status-skipped .personal-plan-copy strong {
  color: #89938e;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.personal-plan-row.status-partial .personal-plan-copy strong {
  color: #6f571f;
}

.personal-plan-status {
  display: grid;
  grid-template-columns: repeat(4, 36px);
  gap: 5px;
}

.personal-plan-status button {
  display: grid;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  border: 1px solid #cbd6d0;
  border-radius: 8px;
  background: #fff;
  color: #6f7b75;
  padding: 0;
  font-size: 18px;
  font-weight: 750;
  line-height: 1;
}

.personal-plan-status button:hover {
  border-color: #9fb0a7;
  background: #f7faf8;
}

.personal-plan-status .status-pending.is-selected {
  border-color: #708078;
  background: #eef2f0;
  color: var(--plan-ink);
}

.personal-plan-status .status-done.is-selected {
  border-color: var(--plan-green);
  background: var(--plan-green);
  color: #fff;
}

.personal-plan-status .status-partial.is-selected {
  border-color: #d7a32f;
  background: var(--plan-amber-soft);
  color: var(--plan-amber);
}

.personal-plan-status .status-skipped.is-selected {
  border-color: #d8756e;
  background: var(--plan-red-soft);
  color: var(--plan-red);
}

.personal-plan-menu {
  position: relative;
  justify-self: end;
}

.personal-plan-menu summary {
  display: grid;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  border-radius: 8px;
  cursor: pointer;
  list-style: none;
}

.personal-plan-menu summary::-webkit-details-marker {
  display: none;
}

.personal-plan-menu > div {
  position: absolute;
  z-index: 18;
  top: calc(100% + 5px);
  right: 0;
  display: grid;
  width: 148px;
  overflow: hidden;
  border: 1px solid var(--plan-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgb(28 51 41 / 14%);
  padding: 4px;
}

.personal-plan-menu > div > button {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--plan-ink);
  padding: 8px 10px;
  text-align: left;
}

.personal-plan-menu > div > button:hover,
.personal-plan-menu > div > button:focus-visible {
  background: var(--plan-soft);
}

.personal-plan-menu > div > button .icon {
  width: 16px;
  height: 16px;
  color: var(--plan-green);
}

.personal-plan-menu > div > button.danger-text {
  color: #b43c3c;
}

.personal-plan-empty {
  margin: 12px 0 2px;
  color: var(--plan-muted);
  font-size: 12px;
  line-height: 1.5;
}

.personal-plan-loading {
  display: grid;
  gap: 8px;
  padding: 16px 0 2px;
}

.personal-plan-loading i {
  height: 18px;
}

.personal-plan-loading i:last-child {
  width: 72%;
}

.personal-plan-error {
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: #8b5818;
  font-size: 12px;
}

.personal-plan-error > span {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.personal-plan-error .icon {
  width: 16px;
  flex: 0 0 auto;
}

.school-calendar-marks .plan,
.school-calendar-legend .plan {
  background: var(--plan-green-deep);
}

.school-calendar-marks .plan.status-done {
  background: #9ca9a3;
}

.school-calendar-marks .plan.status-partial {
  background: #d49a1d;
}

.school-calendar-marks .plan.status-skipped {
  background: #ca6d67;
}

.school-calendar-day .personal-plan-preview {
  color: var(--plan-green-deep);
}

.school-calendar-day .personal-plan-preview.status-done,
.school-calendar-day .personal-plan-preview.status-skipped {
  color: #8c9691;
  text-decoration: line-through;
}

.school-calendar-day .personal-plan-preview.status-partial {
  color: var(--plan-amber);
}

/* The fallback dialog contains one field only; day selection stays in the calendar. */
.personal-plan-dialog {
  width: min(460px, 100%);
}

.personal-plan-dialog .ui-dialog-form {
  grid-template-columns: minmax(0, 1fr);
}

.personal-plan-dialog .dialog-field-wide,
.personal-plan-dialog .ui-dialog-actions {
  grid-column: 1;
}

.personal-plan-dialog .dialog-field > span {
  color: var(--plan-ink);
  font-size: 12px;
  font-weight: 650;
}

.personal-plan-dialog .ui-dialog-actions .primary {
  border-color: var(--plan-green);
  background: var(--plan-green);
}

.personal-plan-dialog .ui-dialog-actions .primary:hover,
.personal-plan-dialog .ui-dialog-actions .primary:focus-visible {
  border-color: var(--plan-green-deep);
  background: var(--plan-green-deep);
}

@keyframes personal-plan-loading {
  to { background-position: -220% 0; }
}

@media (max-width: 700px) {
  .calendar-head-actions {
    width: 100%;
  }

  .calendar-head-actions > button {
    flex: 1 1 0;
    width: auto;
  }

  .home-personal-plan {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-personal-plan-main {
    min-height: 74px;
    padding: 11px 13px;
  }

  .home-personal-plan-actions {
    display: block;
    border-top: 1px solid var(--plan-line);
    border-left: 0;
    padding: 8px;
  }

  .home-personal-plan-actions > button {
    width: 100%;
  }

  .personal-plan-day {
    padding: 14px;
  }

  .personal-plan-day > header {
    align-items: flex-end;
  }

  .personal-plan-row {
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 8px 10px;
    padding: 12px 0;
  }

  .personal-plan-copy {
    grid-column: 1;
    grid-row: 1;
  }

  .personal-plan-status {
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(4, 40px);
    gap: 6px;
  }

  .personal-plan-status button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .personal-plan-menu {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .personal-plan-menu > div {
    position: fixed;
    z-index: 390;
    right: 12px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    top: auto;
    width: min(220px, calc(100vw - 24px));
    padding: 6px;
  }

  .personal-plan-menu > div > button {
    min-height: 44px;
  }
}

@media (max-width: 370px) {
  .personal-plan-summary {
    display: none;
  }

  .personal-plan-status {
    width: 100%;
    grid-template-columns: repeat(4, minmax(38px, 1fr));
  }

  .personal-plan-status button {
    width: 100%;
    min-width: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-personal-plan.is-loading i,
  .home-personal-plan.is-loading span,
  .personal-plan-loading i {
    animation: none;
  }
}
