:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #202124;
  --muted: #6d706f;
  --line: #d8d5cc;
  --accent: #2f7d68;
  --accent-dark: #1f5f4f;
  --gold: #b77a1b;
  --red: #b84a4a;
  --shadow: 0 18px 50px rgba(38, 41, 39, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fbfaf6;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.brand h1,
.panel h2,
.calendar-toolbar h2,
.dialog-card h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 30px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.today-pill {
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  background: #edf6f2;
  font-size: 13px;
  text-align: center;
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-title,
.calendar-toolbar,
.toolbar-actions,
.month-controls,
.task-actions,
.dialog-actions {
  display: flex;
  align-items: center;
}

.panel-title,
.calendar-toolbar {
  justify-content: space-between;
  gap: 14px;
}

.panel h2,
.dialog-card h2 {
  font-size: 18px;
}

.countdown-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.countdown-card {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.color-bar {
  width: 8px;
  height: 42px;
  border-radius: 999px;
}

.countdown-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.countdown-card span {
  color: var(--muted);
  font-size: 13px;
}

.countdown-days {
  min-width: 72px;
  color: var(--accent-dark);
  font-weight: 700;
  text-align: right;
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfbf8;
}

.form-panel {
  display: grid;
  gap: 12px;
}

.backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

.primary-button,
.ghost-button,
.icon-button,
.mini-button {
  border: 1px solid transparent;
  border-radius: 8px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.primary-button {
  padding: 10px 14px;
  color: #fff;
  background: var(--accent);
}

.ghost-button {
  padding: 8px 12px;
  border-color: var(--line);
  color: var(--ink);
  background: #fff;
}

.ghost-button.danger {
  color: var(--red);
}

.icon-button {
  width: 42px;
  height: 42px;
  border-color: var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 28px;
  line-height: 1;
}

.mini-button {
  padding: 5px 8px;
  border-color: var(--line);
  background: #fff;
  font-size: 12px;
}

.mini-button.complete {
  color: var(--accent-dark);
}

.mini-button.delay {
  color: var(--gold);
}

.mini-button.delete {
  color: var(--red);
}

button:hover {
  transform: translateY(-1px);
}

.calendar-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

.calendar-toolbar {
  min-height: 58px;
}

.month-controls,
.toolbar-actions,
.task-actions,
.dialog-actions {
  gap: 10px;
}

.week-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
}

.week-row {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.week-row span {
  padding: 10px;
}

.calendar-grid {
  flex: 1;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.day-cell {
  min-height: 132px;
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease, outline-color 120ms ease;
}

.day-cell.outside {
  background: #f2f0ea;
  color: #9a9b98;
}

.day-cell.off-day:not(.selected) {
  background: #fffaf0;
}

.day-cell.work-day:not(.selected) {
  background: #fff8f8;
}

.day-cell:hover {
  background: #fbfcf9;
  box-shadow: inset 0 0 0 1px rgba(47, 125, 104, 0.28);
}

.day-cell:focus-visible {
  outline: 3px solid rgba(47, 125, 104, 0.45);
  outline-offset: -3px;
}

.day-cell.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.day-cell.selected {
  background: #edf7f3;
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.day-cell.exam-day:not(.selected) {
  background: #fffaf0;
}

.day-number {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.day-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.day-badge.off {
  color: #8a5200;
  background: #ffe5b5;
}

.day-badge.work {
  color: #9b3131;
  background: #ffe0e0;
}

.day-badge.plain {
  display: none;
}

.lunar-text {
  min-height: 18px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.exam-list {
  display: grid;
  gap: 6px;
  margin-top: 9px;
}

.exam-chip {
  overflow-wrap: anywhere;
  padding: 6px 7px;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  color: #70490f;
  background: #fff3d7;
  font-size: 12px;
  font-weight: 700;
}

.task-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.task-card {
  display: grid;
  gap: 6px;
  padding: 7px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: #f8faf8;
}

.task-card.done {
  border-left-color: #9ea2a0;
  background: #f0f1ef;
}

.task-card.done .task-text {
  color: #898d8b;
  text-decoration: line-through;
}

.task-exam {
  color: var(--muted);
  font-size: 11px;
}

.task-text {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.task-actions {
  flex-wrap: wrap;
}

dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(31, 34, 32, 0.35);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  background: #fff;
}

.dialog-actions {
  justify-content: flex-end;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .week-row,
  .calendar-grid {
    grid-template-columns: repeat(7, minmax(92px, 1fr));
  }

  .calendar-section {
    overflow-x: auto;
  }

  .calendar-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  body {
    min-width: 0;
  }

  .app-shell {
    display: block;
  }

  .sidebar,
  .calendar-section {
    padding: 12px;
  }

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

  .brand h1 {
    font-size: 26px;
  }

  .today-pill {
    width: 100%;
    border-radius: 8px;
    text-align: left;
  }

  .panel {
    padding: 12px;
    box-shadow: none;
  }

  .calendar-section {
    overflow-x: visible;
  }

  .calendar-toolbar,
  .month-controls,
  .toolbar-actions {
    width: 100%;
  }

  .calendar-toolbar {
    gap: 10px;
  }

  .month-controls {
    justify-content: space-between;
  }

  .toolbar-actions {
    flex-wrap: wrap;
  }

  .toolbar-actions .ghost-button {
    flex: 1 1 130px;
  }

  .week-row,
  .calendar-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .week-row {
    margin-top: 10px;
    font-size: 11px;
  }

  .week-row span {
    padding: 8px 2px;
  }

  .calendar-grid {
    overflow: visible;
  }

  .day-cell {
    min-height: 104px;
    padding: 5px;
  }

  .day-number {
    font-size: 14px;
  }

  .day-badge {
    min-width: 18px;
    height: 18px;
    font-size: 10px;
  }

  .lunar-text,
  .exam-chip,
  .task-exam,
  .task-text,
  .mini-button {
    font-size: 10px;
  }

  .exam-chip,
  .task-card {
    padding: 5px;
  }

  .task-actions {
    gap: 4px;
  }

  .mini-button {
    padding: 4px 5px;
  }

  .backup-actions {
    grid-template-columns: 1fr;
  }
}
