:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  --bg: #eaf6ff;
  --panel: #ffffff;
  --panel-soft: #f5fbff;
  --primary: #1d8cf8;
  --primary-dark: #0967c5;
  --text: #16324f;
  --muted: #6b8297;
  --border: #d7e9f8;
  --done: #7a8ca0;
  --danger: #e34d59;
  --shadow: 0 18px 45px rgba(21, 99, 157, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(135deg, #dff4ff 0%, #f0e5ff 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 20px;
  display: flex;
  align-items: center;
}

.todo-panel {
  width: 100%;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 1;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.title-icon {
  width: 1.08em;
  height: 1.08em;
  border-radius: 50%;
  background: #eef8ff;
  display: inline-grid;
  place-items: center;
  font-size: 0.72em;
  box-shadow: 0 8px 18px rgba(29, 140, 248, 0.16);
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 10px;
  min-width: 210px;
}

.summary span {
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-soft);
  color: var(--muted);
  display: grid;
  align-content: center;
  text-align: center;
}

.summary strong {
  color: var(--primary-dark);
  font-size: 1.35rem;
  line-height: 1.1;
}

.todo-form {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 12px;
  margin-bottom: 18px;
}

.todo-form input,
.priority-select,
.edit-input,
.edit-priority {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.priority-select,
.edit-priority {
  cursor: pointer;
}

.todo-form input:focus,
.priority-select:focus,
.edit-input:focus,
.edit-priority:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(29, 140, 248, 0.13);
}

.todo-form button {
  min-height: 52px;
  padding: 0 24px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #20b8dc);
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(29, 140, 248, 0.25);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.todo-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(29, 140, 248, 0.32);
}

.todo-form button:active {
  transform: translateY(0);
}

.todo-actions {
  margin: -4px 0 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.clear-completed,
.clear-all {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(29, 140, 248, 0.24);
  border-radius: 14px;
  color: var(--primary-dark);
  background: #f2f8ff;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(21, 99, 157, 0.08);
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.clear-all {
  border-color: rgba(227, 77, 89, 0.24);
  color: var(--danger);
  background: #fff5f6;
}

.clear-completed:hover:not(:disabled),
.clear-all:hover:not(:disabled) {
  border-color: rgba(29, 140, 248, 0.48);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(21, 99, 157, 0.12);
}

.clear-all:hover:not(:disabled) {
  border-color: rgba(227, 77, 89, 0.5);
  color: #c93442;
}

.clear-completed:disabled,
.clear-all:disabled {
  color: #9dafbf;
  background: #f6f9fc;
  cursor: not-allowed;
  box-shadow: none;
}

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

.todo-item {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: 16px;
  background: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  box-shadow: 0 10px 22px rgba(22, 50, 79, 0.07);
}

.todo-item.priority-high {
  border-left-color: #ff6b6b;
}

.todo-item.priority-medium {
  border-left-color: #f4b740;
}

.todo-item.priority-low {
  border-left-color: #33b987;
}

.todo-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
}

.task-content {
  min-width: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

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

.priority-badge {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.priority-badge.priority-high {
  color: #b82332;
  background: #ffe7ea;
}

.priority-badge.priority-medium {
  color: #8a5b00;
  background: #fff2c9;
}

.priority-badge.priority-low {
  color: #167851;
  background: #ddf7ed;
}

.todo-item.completed .task-text {
  color: var(--done);
  text-decoration: line-through;
}

.item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn,
.save-btn,
.cancel-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  transition: background 160ms ease, transform 160ms ease;
}

.icon-btn:hover,
.save-btn:hover,
.cancel-btn:hover {
  transform: scale(1.04);
}

.edit-btn {
  color: var(--primary-dark);
  background: #eef8ff;
  font-size: 1.05rem;
}

.delete-btn {
  color: var(--danger);
  background: #fff0f2;
  font-size: 1.35rem;
}

.delete-btn:hover {
  background: #ffdce1;
}

.edit-btn:hover {
  background: #dff1ff;
}

.todo-item.editing {
  grid-template-columns: auto 1fr;
}

.edit-form {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 82px auto auto;
  gap: 8px;
  align-items: center;
}

.edit-input,
.edit-priority {
  min-height: 42px;
  border-radius: 12px;
}

.save-btn {
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.cancel-btn {
  color: var(--muted);
  background: #edf3f8;
  font-weight: 700;
}

.empty-state {
  margin: 18px 0 0;
  padding: 18px;
  border: 1px dashed #a9d7fb;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(245, 251, 255, 0.72);
  text-align: center;
}

.empty-state.hidden {
  display: none;
}

.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: 620px) {
  .app-shell {
    padding: 24px 14px;
    align-items: flex-start;
  }

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

  .app-header {
    display: grid;
  }

  .summary {
    width: 100%;
    min-width: 0;
  }

  .todo-form,
  .edit-form {
    grid-template-columns: 1fr;
  }

  .todo-form button {
    width: 100%;
  }

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

  .clear-completed,
  .clear-all {
    width: 100%;
  }

  .todo-item,
  .todo-item.editing {
    grid-template-columns: auto 1fr;
    align-items: flex-start;
  }

  .item-actions {
    grid-column: 2;
    justify-content: flex-end;
  }

  .edit-form {
    grid-column: 2;
  }
}

@media (max-width: 380px) {
  .todo-panel {
    padding: 18px;
  }

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