:root {
  color-scheme: light;
  --bg: #eef6fa;
  --surface: #ffffff;
  --surface-soft: #f6fbfd;
  --text: #17323d;
  --muted: #617884;
  --border: #d7e7ef;
  --border-strong: #b9d6e3;
  --primary: #2f7fd1;
  --primary-soft: #e7f2ff;
  --secondary: #17a086;
  --secondary-soft: #e4f8f3;
  --accent: #ef7d34;
  --accent-soft: #fff0e5;
  --danger: #d64545;
  --focus: rgba(47, 127, 209, 0.28);
  --shadow: 0 10px 24px rgba(23, 50, 61, 0.08);
  --input-bg: #ffffff;
  --mark: #d8e8f1;
  --completed-bg: #f4fbf8;
  --completed-border: #bfe8dc;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10202a;
  --surface: #17303d;
  --surface-soft: #1b3746;
  --text: #eaf4f8;
  --muted: #a8c0cc;
  --border: #2c4958;
  --border-strong: #3d6275;
  --primary: #74b7ff;
  --primary-soft: #17364d;
  --secondary: #43d9b6;
  --secondary-soft: #163b37;
  --accent: #ffa970;
  --accent-soft: #3d2a1d;
  --danger: #ff8f8f;
  --focus: rgba(116, 183, 255, 0.3);
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  --input-bg: #10242f;
  --mark: #2b4959;
  --completed-bg: #16312f;
  --completed-border: #2f6b5d;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
}

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

.app-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 32px auto;
  display: grid;
  gap: 18px;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.site-header > div {
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 6px 0 4px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.3;
}

.current-date {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-button,
.primary-button,
.text-button,
.filter-button,
.delete-button,
input,
select,
button {
  font: inherit;
}

.icon-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.stat-card strong {
  font-size: 28px;
  line-height: 1.1;
}

.stat-card:nth-child(1) strong { color: var(--primary); }
.stat-card:nth-child(2) strong { color: var(--secondary); }
.stat-card:nth-child(3) strong { color: var(--accent); }
.stat-card:nth-child(4) strong { color: var(--text); }

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

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading > div {
  min-width: 0;
}

.section-mark {
  color: var(--mark);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.task-form {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(110px, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.task-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
}

input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.primary-button {
  min-width: 120px;
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:hover,
.icon-button:hover,
.filter-button:hover,
.delete-button:hover,
.text-button:hover {
  filter: brightness(1.04);
}

:is(button, input, select, a):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.form-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 700;
}

.form-message.is-error {
  color: var(--danger);
}

.task-heading {
  margin-bottom: 14px;
}

.text-button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.filter-button.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.task-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.task-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "check main actions";
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.task-checkbox {
  grid-area: check;
  width: 20px;
  height: 20px;
  accent-color: var(--secondary);
  cursor: pointer;
}

.task-main {
  grid-area: main;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.task-title {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.task-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 8px;
}

.delete-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.delete-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.task-item.is-completed {
  background: var(--completed-bg);
  border-color: var(--completed-border);
}

.task-item.is-completed .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge-high {
  border-color: #f4c9a8;
  background: var(--accent-soft);
  color: #b45516;
}

.badge-medium {
  border-color: #bfdcff;
  background: var(--primary-soft);
  color: #215f9e;
}

.badge-low {
  border-color: #b9e7d8;
  background: var(--secondary-soft);
  color: #146c59;
}

html[data-theme="dark"] .badge-high { color: #ffc49a; }
html[data-theme="dark"] .badge-medium { color: #a9d4ff; }
html[data-theme="dark"] .badge-low { color: #85e8ce; }

.empty-state {
  margin: 18px 0 0;
  padding: 26px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .primary-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100%, calc(100% - 20px));
    margin: 16px auto;
    gap: 14px;
  }

  .site-header,
  .panel {
    padding: 18px;
  }

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

  .icon-button {
    justify-self: start;
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 20px;
  }

  .section-heading,
  .task-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .task-item {
    grid-template-areas:
      "check"
      "main"
      "actions";
    align-items: start;
  }

  .task-actions {
    justify-content: space-between;
    width: 100%;
  }

  .delete-button {
    width: 100%;
  }

  .section-mark {
    display: none;
  }
}
