:root {
  --bg: #f4f5fb;
  --panel: #ffffff;
  --text: #131521;
  --muted: #6b7080;
  --line: #e6e8f0;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #e5484d;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(19, 21, 33, 0.04), 0 12px 32px rgba(19, 21, 33, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1017;
    --panel: #171a24;
    --text: #eceef6;
    --muted: #9aa0b4;
    --line: #262a37;
    --accent: #8b8bff;
    --accent-soft: #232447;
    --danger: #ff6b6f;
    --warn: #f0b464;
    --warn-soft: #3a2c18;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  padding: 32px 16px 48px;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 26px 20px;
}

.app-header {
  margin-bottom: 22px;
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 700;
}

.ghost-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 8px;
  padding: 4px 6px;
}

.ghost-link:hover {
  background: var(--accent-soft);
}

.subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------------------------- 输入框 --------------------------------- */

.composer {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}

@media (max-width: 560px) {
  .composer {
    grid-template-columns: 1fr auto;
  }
  .composer #input-due,
  .composer #input-priority {
    grid-row: 2;
  }
  .composer #input-title {
    grid-column: 1 / -1;
  }
}

.composer input[type="text"] {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 10px 8px;
  outline: none;
  min-width: 0;
}

.composer input[type="text"]::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.composer input[type="date"],
.composer select {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 9px;
  font-size: 13px;
  padding: 7px 8px;
  outline: none;
  cursor: pointer;
}

.composer button {
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.composer button:hover {
  opacity: 0.92;
}

.composer button:active {
  transform: scale(0.97);
}

/* ---------------------------------- 过滤器 --------------------------------- */

.filters {
  display: flex;
  gap: 6px;
  margin: 20px 0 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.filter {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  padding: 6px 12px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.filter:hover {
  background: var(--accent-soft);
}

.filter.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.count {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  opacity: 0.75;
}

/* ---------------------------------- 列表 ---------------------------------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}

.item:last-child {
  border-bottom: none;
}

.item[data-priority="2"] .title-text {
  font-weight: 600;
}

.check {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 7px;
  border: 1.5px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.check svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: transparent;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.check:hover {
  border-color: var(--accent);
}

.check.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check.checked svg {
  stroke: #fff;
}

.body {
  min-width: 0;
}

.title-line {
  display: block;
}

.title-text {
  font-size: 15.5px;
  word-break: break-word;
  cursor: text;
}

.title-edit {
  width: 100%;
  font-size: 15.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 4px 8px;
  outline: none;
}

.is-done .title-text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--muted);
  opacity: 0.75;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  line-height: 1.5;
}

.chip-high {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.chip-overdue {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: transparent;
}

.del {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.item:hover .del,
.item:focus-within .del {
  opacity: 1;
}

.del:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

@media (hover: none) {
  .del {
    opacity: 1;
  }
}

/* ---------------------------------- 空态 ---------------------------------- */

.empty {
  text-align: center;
  padding: 42px 16px 30px;
}

.empty-icon {
  font-size: 30px;
}

.empty-title {
  margin: 10px 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.empty-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------------------------- 页脚 --------------------------------- */

.app-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.dot {
  opacity: 0.4;
}

/* ---------------------------------- Toast -------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(19, 21, 33, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 50;
}

@media (prefers-color-scheme: dark) {
  .toast {
    background: rgba(236, 238, 246, 0.95);
    color: #171a24;
  }
}

/* ---------------------------------- 看板 --------------------------------- */

.dash {
  max-width: 880px;
  margin: 0 auto;
}

.dash-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

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

.kpi-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 14px;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 52px;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
}

.bar-label {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  background: var(--bg);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th,
td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11.5px;
}

td.ev {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}

.scroll {
  overflow-x: auto;
}

.dash-footer {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 8px 0 26px;
}
