:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #e8f0ff;
  --text: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --surface: #ffffff;
  --high: #f05252;
  --medium: #e6a700;
  --low: #2ab673;
  --shadow: 0 18px 48px rgba(28, 43, 72, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.4)),
    linear-gradient(135deg, #e4f4ff 0%, #f4f7fb 48%, #f6efe7 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(960px, calc(100% - 28px));
  margin: 0 auto;
  padding: 36px 0;
}

.todo-panel {
  padding: 22px;
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.15;
}

.app-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.task-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  margin-bottom: 12px;
}

#taskInput {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
}

#taskInput:focus {
  border-color: var(--blue);
}

.controls-row,
.actions-row,
.stats-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.controls-row {
  justify-content: flex-end;
}

.priority-select {
  width: 176px;
}

.time-select {
  width: 184px;
}

.date-select {
  width: 210px;
}

.start-select {
  width: 190px;
}

.select-wrap {
  display: grid;
  grid-template-columns: auto minmax(68px, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  overflow: hidden;
}

.select-wrap span {
  height: 22px;
  font-size: 0.88rem;
  line-height: 22px;
}

select,
.time-select input,
.date-select input,
.start-select input {
  width: 100%;
  height: 36px;
  border: 0;
  color: var(--text);
  background: transparent;
  outline: none;
  caret-color: transparent;
}

select {
  cursor: pointer;
}

.time-select input,
.date-select input,
.start-select input {
  cursor: text;
}

select:focus,
select:active,
select option,
.time-select input:focus,
.time-select input:active,
.date-select input:focus,
.date-select input:active,
.start-select input:focus,
.start-select input:active {
  caret-color: transparent;
}

.primary-button,
.ghost-button,
.soft-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border: 0;
  border-radius: 14px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.primary-button {
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
}

.button-plus {
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.ghost-button,
.soft-button {
  padding: 0 14px;
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.danger-button {
  padding: 0 14px;
  color: #c53030;
  background: #ffe9e9;
}

.stats-bar {
  justify-content: space-between;
  margin: 10px 0 10px;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(231, 242, 255, 0.76);
  color: var(--muted);
}

.stats-bar {
  width: min(100%, 260px);
}

.stats-bar span {
  height: 24px;
  line-height: 24px;
}

.stats-bar strong {
  color: var(--blue-dark);
}

.actions-row {
  margin: -50px 0 10px 280px;
  min-height: 40px;
}

.task-list {
  display: grid;
  gap: 10px;
  margin: 0;
  max-height: 528px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 6px 0 0;
  list-style: none;
  scrollbar-gutter: stable;
}

.task-item {
  display: grid;
  position: relative;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--priority-color);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  overflow: hidden;
}

.task-item > * {
  position: relative;
  z-index: 1;
}

.task-item.dragging {
  opacity: 0.62;
}

.task-item.drag-over {
  border-color: var(--blue);
  background: #f2f8ff;
}

.task-item.conflict {
  border-color: #f6a3a3;
  background: #fff8f8;
}

.task-item.running {
  border-color: #65a9ff;
  border-left-color: #2388ff;
  background: #f4f9ff;
  animation: running-border-pulse 1.8s ease-in-out infinite;
}

.task-item.running::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(105deg, transparent 0%, rgba(76, 154, 255, 0.16) 42%, rgba(76, 154, 255, 0.28) 50%, rgba(76, 154, 255, 0.16) 58%, transparent 100%);
  transform: translateX(-115%);
  animation: running-sheen 2.4s ease-in-out infinite;
  pointer-events: none;
}

.task-item.paused {
  border-color: #d6c08a;
  background: #fffaf0;
}

.task-item.completed .task-text {
  color: #8b97a8;
  text-decoration: line-through;
}

.task-check {
  width: 20px;
  height: 20px;
  accent-color: var(--blue);
}

.task-main {
  display: grid;
  grid-template-columns: auto auto auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.task-pill,
.task-time,
.task-date,
.task-start,
.task-running,
.task-text {
  min-height: 30px;
  line-height: 30px;
  font-size: 0.98rem;
}

.task-pill,
.task-time,
.task-date,
.task-start,
.task-running {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.task-pill {
  color: #fff;
  background: var(--priority-color);
}

.task-time {
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.task-date {
  color: #187269;
  background: #e5f8f5;
}

.task-start {
  color: #5b4bb7;
  background: #efeaff;
}

.task-running {
  gap: 6px;
  color: #0f62b8;
  background: #dff0ff;
}

.running-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2388ff;
  animation: running-dot-pulse 1s ease-in-out infinite;
}

.task-item.paused .task-running {
  color: #7a5a10;
  background: #fff0c2;
}

@keyframes running-border-pulse {
  0%,
  100% {
    border-left-color: #2388ff;
    box-shadow: inset 5px 0 0 rgba(35, 136, 255, 0);
  }

  50% {
    border-left-color: #5fb1ff;
    box-shadow: inset 5px 0 0 rgba(35, 136, 255, 0.18);
  }
}

@keyframes running-sheen {
  0% {
    transform: translateX(-115%);
  }

  52%,
  100% {
    transform: translateX(115%);
  }
}

@keyframes running-dot-pulse {
  0%,
  100% {
    opacity: 0.42;
    transform: scale(0.86);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .task-item.running,
  .task-item.running::before,
  .running-dot {
    animation: none;
  }
}

.task-conflict {
  color: #c53030;
  background: #ffe9e9;
}

.sortable-chip {
  cursor: pointer;
  user-select: none;
}

.sortable-chip:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.task-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.task-conflict-note {
  grid-column: 1 / -1;
  color: #c53030;
  font-size: 0.88rem;
  line-height: 22px;
}

.task-edit-input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--blue);
  border-radius: 10px;
  outline: none;
}

.task-buttons {
  display: flex;
  gap: 8px;
}

.task-buttons button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.task-buttons .delete-task {
  color: #c53030;
  background: #ffe9e9;
}

.task-buttons .check-in-task {
  color: #1367bf;
  background: #dff0ff;
}

.task-buttons .check-in-task:disabled {
  color: #728097;
  background: #eef4fb;
}

.empty-state {
  display: none;
  padding: 28px 10px 8px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.empty-state.show {
  display: block;
}

.summary-dialog,
.calendar-dialog,
.settings-dialog,
.meeting-dialog,
.plans-dialog,
.projects-dialog,
.app-dialog {
  border: 0;
  border-radius: 20px;
  margin: auto;
  padding: 0;
  background: transparent;
}

.summary-dialog {
  width: min(560px, calc(100% - 28px));
}

.calendar-dialog {
  width: min(980px, calc(100% - 24px));
  height: min(86vh, 820px);
  overflow: hidden;
}

.meeting-dialog {
  width: min(980px, calc(100% - 24px));
  height: min(86vh, 820px);
  overflow: hidden;
}

.plans-dialog {
  width: min(980px, calc(100% - 24px));
  height: min(86vh, 820px);
  overflow: hidden;
}

.projects-dialog {
  width: min(980px, calc(100% - 24px));
  height: min(86vh, 820px);
  overflow: hidden;
}

.settings-dialog {
  width: min(560px, calc(100% - 24px));
}

.app-dialog {
  width: min(460px, calc(100% - 28px));
}

.summary-dialog::backdrop,
.calendar-dialog::backdrop,
.settings-dialog::backdrop,
.meeting-dialog::backdrop,
.plans-dialog::backdrop,
.projects-dialog::backdrop,
.app-dialog::backdrop {
  background: rgba(32, 48, 73, 0.28);
  backdrop-filter: blur(8px);
}

.summary-card,
.calendar-card,
.settings-card,
.meeting-card,
.plans-card,
.projects-card,
.app-dialog-card {
  padding: 22px;
  border-radius: 20px;
  background: #fff;
}

.calendar-card,
.meeting-card,
.plans-card,
.projects-card {
  display: flex;
  flex-direction: column;
  height: min(86vh, 820px);
  overflow: hidden;
}

.summary-card header,
.calendar-card header,
.settings-card header,
.meeting-card header,
.plans-card header,
.projects-card header,
.app-dialog-card header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.calendar-card header p,
.settings-card header p,
.meeting-card header p,
.plans-card header p,
.projects-card header p,
.settings-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.app-dialog-card {
  display: grid;
  gap: 14px;
}

.app-dialog-card header {
  margin-bottom: 0;
}

.app-dialog-card h2 {
  font-size: 1.1rem;
}

.app-dialog-card p {
  color: var(--text);
  line-height: 1.55;
  white-space: pre-line;
}

#appDialogInput {
  display: none;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

#appDialogInput:focus {
  border-color: var(--blue);
}

.app-dialog.with-input #appDialogInput {
  display: block;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  color: var(--muted);
  background: var(--blue-soft);
  font-size: 1.4rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-cell {
  padding: 14px;
  border-radius: 14px;
  background: #f5f9ff;
}

.summary-cell span {
  display: block;
  height: 22px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 22px;
}

.summary-cell strong {
  display: block;
  min-height: 30px;
  margin-top: 4px;
  color: var(--text);
  font-size: 1.06rem;
  line-height: 30px;
}

.calendar-stats {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.calendar-stat,
.day-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7fbff;
}

.calendar-stat {
  padding: 12px;
}

.calendar-stat span,
.day-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 22px;
}

.calendar-stat strong,
.day-card strong {
  display: block;
  color: var(--text);
  font-size: 1.06rem;
  line-height: 28px;
}

.calendar-scroller {
  flex: 0 0 auto;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 260px);
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
}

.day-card {
  min-height: 148px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
}

.day-card.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.day-card .day-date {
  color: var(--blue-dark);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 30px;
}

.day-detail {
  flex: 1 1 0;
  min-height: 0;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.day-detail h3 {
  flex: 0 0 auto;
  margin: 0 0 10px;
  font-size: 1.08rem;
}

.day-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.day-detail table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}

.day-detail th,
.day-detail td {
  min-height: 34px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  line-height: 20px;
}

.day-detail th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  background: #f7fbff;
}

.day-detail td {
  font-size: 0.94rem;
  background: #fff;
}

.day-detail tr:last-child td {
  border-bottom: 0;
}

.day-task-name {
  min-width: 180px;
  word-break: break-word;
}

.detail-pill {
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.86rem;
  white-space: nowrap;
}

.detail-time {
  color: var(--blue-dark);
  white-space: nowrap;
}

.detail-start {
  color: #5b4bb7;
  white-space: nowrap;
}

.detail-done {
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.meeting-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.meeting-toolbar strong {
  min-width: 220px;
  text-align: center;
  color: var(--text);
}

.meeting-grid-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.meeting-grid {
  display: grid;
  grid-template-columns: 76px repeat(7, minmax(118px, 1fr));
  min-width: 940px;
}

.meeting-cell {
  min-height: 32px;
  padding: 5px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 20px;
}

.meeting-head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 42px;
  background: #f5f9ff;
  color: var(--text);
  font-weight: 700;
}

.meeting-time {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fbfdff;
  color: var(--muted);
}

.meeting-corner {
  left: 0;
  z-index: 3;
}

.meeting-busy {
  background: rgba(35, 136, 255, 0.18);
  color: var(--blue-dark);
}

.meeting-busy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--blue-dark);
  font-size: 0.82rem;
  line-height: 18px;
}

.plan-form {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.project-form {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
}

.plan-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.88rem;
}

.project-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.88rem;
}

.plan-form input,
.plan-form select,
.project-form input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.plan-form .primary-button {
  align-self: end;
}

.weekday-fieldset {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.weekday-fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.weekday-fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.plans-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  margin-top: 14px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.projects-list {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  margin-top: 14px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.plan-card,
.project-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7fbff;
}

.plan-card header,
.project-card header {
  margin: 0;
}

.plan-card h3,
.project-card h3 {
  margin: 0;
  font-size: 1rem;
}

.plan-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.plan-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7f2ff;
}

.plan-progress span {
  display: block;
  height: 100%;
  width: var(--progress);
  background: var(--blue);
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.project-module {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.project-module header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-module h4 {
  margin: 0;
  font-size: 0.95rem;
}

.subtask-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.subtask-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--text);
}

.subtask-list button:disabled {
  cursor: default;
  color: var(--muted);
  background: #eef3f8;
}

.subtask-list li.done span {
  color: var(--muted);
  text-decoration: line-through;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 18px, 960px);
    padding: 14px 0;
  }

  .todo-panel {
    padding: 18px;
    border-radius: 18px;
  }

  .app-header,
  .controls-row,
  .actions-row {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-bar {
    width: 100%;
  }

  .actions-row {
    margin: 0 0 10px;
  }

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

  .priority-select,
  .time-select,
  .date-select,
  .start-select {
    width: 100%;
  }

  .header-actions {
    justify-content: stretch;
  }

  .primary-button,
  .ghost-button,
  .soft-button,
  .danger-button {
    width: 100%;
  }

  .select-wrap {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .task-item {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .task-buttons {
    grid-column: 2;
    width: 100%;
  }

  .task-buttons button {
    flex: 1;
  }

  .task-main {
    grid-template-columns: auto auto auto auto minmax(120px, 1fr);
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .calendar-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plan-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day-table-wrap {
    overflow-x: auto;
  }

  .day-detail table {
    min-width: 620px;
  }
}

@media (max-width: 460px) {
  .task-main {
    grid-template-columns: 1fr 1fr;
  }

  .task-text,
  .task-edit-input {
    grid-column: 1 / -1;
  }

  .calendar-stats {
    grid-template-columns: 1fr;
  }

  .plan-form {
    grid-template-columns: 1fr;
  }
}
