:root {
  --paper: #f7f5ef;
  --ink: #1f2933;
  --muted: #69737d;
  --line: #ded9cf;
  --major-line: #d2cdc4;
  --accent: #2f6f66;
  --accent-strong: #24574f;
  --cell: #fffdf8;
  --cell-active: #edf7f4;
  --weekend-cell: #f3f0e8;
  --weekend-active: #e8f0ec;
  --past-cell: #ebe8df;
  --past-weekend-cell: #e5e0d5;
  --today: #4d9bb8;
  --rest: #6f9c78;
  --easy: #6f9c78;
  --medium: #c49342;
  --hard: #b95c52;
  --start: #8f6ec8;
  --rest-bg: #edf6ee;
  --easy-bg: #edf6ee;
  --medium-bg: #fff2d9;
  --hard-bg: #f8e5df;
  --start-bg: #eee7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #e9ece7;
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-weight: 400;
}

button,
input,
textarea,
.intensity-option {
  font: inherit;
}

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
  padding: 24px;
  background: var(--paper);
  border: 1px solid rgba(86, 93, 99, 0.14);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(31, 41, 51, 0.08);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0;
}

#rangeLabel {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.controls input {
  height: 36px;
  border: 1px solid rgba(86, 93, 99, 0.18);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.controls input[type="number"] {
  width: 76px;
}

button {
  height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 400;
  box-shadow: 0 6px 16px rgba(47, 111, 102, 0.18);
}

button:hover {
  background: var(--accent-strong);
}

.login-button {
  align-self: end;
  height: auto;
  border-radius: 0;
  border-bottom: 1px dashed currentColor;
  margin-bottom: 10px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  line-height: 1.2;
}

.login-button:hover {
  color: var(--ink);
  background: transparent;
}

.auth-name {
  align-self: end;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(86, 93, 99, 0.12);
  border-radius: 8px;
  background: rgba(222, 217, 207, 0.72);
}

.weekday {
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: rgba(229, 224, 213, 0.72);
  font-weight: 400;
}

.weekday.weekend {
  background: rgba(220, 215, 204, 0.82);
  color: #5f656b;
}

.grid {
  display: contents;
}

.day {
  position: relative;
  min-height: 132px;
  --intensity-color: transparent;
  border: 1px solid rgba(86, 93, 99, 0.18);
  border-radius: 6px;
  overflow: hidden;
  background: var(--cell);
}

.day.weekend {
  background: var(--weekend-cell);
}

.day::before {
  content: none;
}

.day-filled {
  background: var(--cell);
}

.day-filled.weekend {
  background: var(--weekend-cell);
}

.day.past,
.day-filled.past {
  background: var(--past-cell);
}

.day.past.weekend,
.day-filled.past.weekend {
  background: var(--past-weekend-cell);
}

.day.past .date,
.day.past .plan,
.day.past .intensity-option {
  opacity: 0.58;
}

.day.past:focus-within .date,
.day.past:focus-within .plan,
.day.past:focus-within .intensity-option {
  opacity: 1;
}

.day.today {
  z-index: 1;
  box-shadow: 0 0 8px -3px #002b758a;
  border-color: transparent;
}

.day.today .date,
.day.today .plan,
.day.today .intensity-option {
  opacity: 1;
}

.day-intensity-0 {
  --intensity-color: var(--rest);
}

.day-intensity-1 {
  --intensity-color: var(--easy);
  background: var(--easy-bg);
}

.day-intensity-2 {
  --intensity-color: var(--medium);
  background: var(--medium-bg);
}

.day-intensity-3 {
  --intensity-color: var(--hard);
  background: var(--hard-bg);
}

.day-intensity-S {
  --intensity-color: var(--start);
  background: var(--start-bg);
}

.day.past.day-intensity-0,
.day-filled.past.day-intensity-0 {
  background: var(--past-cell);
}

.day.past.day-intensity-1,
.day-filled.past.day-intensity-1 {
  background: #e2eadf;
}

.day.past.day-intensity-2,
.day-filled.past.day-intensity-2 {
  background: #eee4ce;
}

.day.past.day-intensity-3,
.day-filled.past.day-intensity-3 {
  background: #ead7d1;
}

.day.past.day-intensity-S,
.day-filled.past.day-intensity-S {
  background: #ded6ea;
}

.day.weekend.day-intensity-0,
.day-filled.weekend.day-intensity-0 {
  background: var(--weekend-cell);
}

.day.weekend.day-intensity-1,
.day-filled.weekend.day-intensity-1 {
  background: var(--easy-bg);
}

.day.weekend.day-intensity-2,
.day-filled.weekend.day-intensity-2 {
  background: var(--medium-bg);
}

.day.weekend.day-intensity-3,
.day-filled.weekend.day-intensity-3 {
  background: var(--hard-bg);
}

.day.weekend.day-intensity-S,
.day-filled.weekend.day-intensity-S {
  background: var(--start-bg);
}

.day.past.weekend.day-intensity-0,
.day-filled.past.weekend.day-intensity-0 {
  background: var(--past-weekend-cell);
}

.day.past.weekend.day-intensity-1,
.day-filled.past.weekend.day-intensity-1 {
  background: #e2eadf;
}

.day.past.weekend.day-intensity-2,
.day-filled.past.weekend.day-intensity-2 {
  background: #eee4ce;
}

.day.past.weekend.day-intensity-3,
.day-filled.past.weekend.day-intensity-3 {
  background: #ead7d1;
}

.day.past.weekend.day-intensity-S,
.day-filled.past.weekend.day-intensity-S {
  background: #ded6ea;
}

.date {
  position: absolute;
  top: 8px;
  left: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
}

.day.weekend .date,
.day.holiday .date {
  color: #e55e44;
}

.day.today .date {
  top: 6px;
  left: 8px;
  border-radius: 4px;
  padding: 2px 4px;
  background: #f0f0f0;
  box-shadow: 0 0 0 1px #ece9e9;
}

.intensity {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 2px;
}

.day:focus-within .intensity {
  display: flex;
}

.intensity-option {
  width: 14px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(86, 93, 99, 0.18);
  border-radius: 4px;
  padding: 0;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  font-size: 9px;
  font-weight: 400;
  line-height: 1;
  box-shadow: none;
}

.intensity-option:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
}

.intensity-option[aria-pressed="true"] {
  color: #fff;
  border-color: var(--intensity-color);
  background: var(--intensity-color);
}

.plan {
  width: 100%;
  height: 100%;
  min-height: 132px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 32px 10px 12px;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
}

.plan:focus {
  background: rgba(255, 255, 255, 0.18);
}

.plan::placeholder {
  color: #aaa49a;
}

.save-status {
  margin: 10px 0 0;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.language-footer {
  width: min(1180px, calc(100vw - 32px));
  display: flex;
  gap: 6px;
  margin: 14px auto 28px;
  color: var(--muted);
  font-size: 13px;
}

.language-option {
  height: auto;
  border-radius: 0;
  border-bottom: 1px dashed currentColor;
  padding: 0;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  line-height: 1.2;
}

.language-option:hover {
  color: var(--ink);
  background: transparent;
}

.language-option.active,
.language-option:disabled {
  border-bottom-color: transparent;
  color: var(--ink);
  cursor: default;
}

@media (max-width: 760px) {
  .app {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 14px;
    border: 0;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar {
    overflow: auto;
    grid-template-columns: repeat(7, minmax(136px, 1fr));
  }

  .day,
  .plan {
    min-height: 124px;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  body {
    background: #fff;
  }

  .app {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }

  .controls,
  .save-status {
    display: none;
  }

  .topbar {
    margin-bottom: 8mm;
  }

  .day {
    min-height: 31mm;
    break-inside: avoid;
  }

  .plan {
    min-height: 31mm;
  }
}
