:root {
  --bg: #f5f5f6;
  --bg-grad: radial-gradient(1100px 480px at 100% -12%, #ecebf0 0%, rgba(236,235,240,0) 58%), var(--bg);
  --panel: #ffffff;
  --panel-2: #fafafb;
  --border: #eaeaec;
  --border-strong: #d9d9de;
  --text: #1b1c20;
  --muted: #83848c;
  --muted-2: #a8a9b1;
  --accent: #6f6e9e;
  --accent-2: #807ba3;
  --accent-soft: #eeedf3;
  --done: #aeb2bb;
  --overdue: #e5484d;
  --overdue-soft: #feecec;
  --duetoday: #c2830f;
  --duetoday-soft: #fbf2dd;
  --weekend: #fafafc;
  --shadow-sm: 0 1px 2px rgba(18,20,28,.04);
  --shadow: 0 1px 2px rgba(18,20,28,.04), 0 8px 24px rgba(18,20,28,.06);
  --shadow-lg: 0 16px 48px rgba(18,20,28,.18);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --font-display: "Sora", var(--font);
  font-synthesis: none;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f13; --bg-grad: radial-gradient(1100px 480px at 100% -12%, #1c1b3a 0%, rgba(28,27,58,0) 55%), var(--bg);
    --panel: #16181d; --panel-2: #1b1d24; --border: #26272e; --border-strong: #34363f;
    --text: #ecedf0; --muted: #8a8e98; --muted-2: #62656e; --accent: #8f8db8; --accent-2: #9f9bc0;
    --accent-soft: #24243a; --weekend: #131419; --overdue-soft: #341f20; --duetoday-soft: #322713;
    --done: #6b6e78;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4); --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-grad); background-attachment: fixed; color: var(--text);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01"; letter-spacing: -0.006em;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

/* ---------- top bar ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px; background: color-mix(in srgb, var(--panel) 80%, transparent);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: -.02em; margin-right: 2px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.topbar .brand::before {
  content: ""; width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: var(--shadow-sm);
}
.topbar .brand span { color: var(--accent); }
.spacer { flex: 1; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 11px; padding: 3px; }
.seg button {
  border: none; background: transparent; color: var(--muted);
  padding: 6px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; transition: .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }
.icon-btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; font-size: 16px; display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary {
  border: none; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 650;
  padding: 9px 15px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-sm); transition: .15s; white-space: nowrap;
}
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:active { transform: translateY(0); }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 18%, transparent); }
.sync-dot.cloud { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.sync-dot.local { background: #eab308; box-shadow: 0 0 0 3px rgba(234,179,8,.18); }
#langBtn { font-size: 12px; font-weight: 800; letter-spacing: .02em; }

/* ---------- filter bar ---------- */
.filterbar {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px 6px; max-width: 1280px; margin: 0 auto;
}
.search {
  flex: 0 0 auto; width: 210px; padding: 8px 13px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 13px; background: var(--panel); color: var(--text); transition: .15s; box-shadow: var(--shadow-sm);
}
.search::placeholder { color: var(--muted-2); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cat-chips { display: flex; gap: 7px; flex-wrap: wrap; overflow-x: auto; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--border); background: var(--panel); border-radius: 20px;
  font-size: 12.5px; font-weight: 650; color: var(--muted); white-space: nowrap; transition: .15s; box-shadow: var(--shadow-sm);
}
.cat-chip:hover { color: var(--text); transform: translateY(-1px); }
.cat-chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.cat-chip.active { color: var(--text); border-color: currentColor; background: color-mix(in srgb, currentColor 8%, var(--panel)); }
.cat-chip[data-cat="all"].active { color: var(--accent); }

/* ---------- nav row ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 0 18px 130px; }
.navrow { display: flex; align-items: center; gap: 8px; padding: 8px 18px 12px; max-width: 1280px; margin: 0 auto; }
.navrow .range { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.navrow .today-link { color: var(--accent); font-weight: 650; background: none; border: none; padding: 6px 10px; border-radius: 8px; transition: .15s; }
.navrow .today-link:hover { background: var(--accent-soft); }

/* ---------- grid view ---------- */
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.day {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  min-height: 140px; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-sm); transition: box-shadow .15s;
}
.day:hover { box-shadow: var(--shadow); }
.day.weekend { background: var(--panel-2); }
.day.is-today { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent), var(--shadow); }
.day-head {
  display: flex; align-items: center; gap: 7px; padding: 9px 11px 8px;
  border-bottom: 1px solid var(--border);
}
.day-head .dow { font-size: 11px; color: var(--muted); font-weight: 750; text-transform: uppercase; letter-spacing: .03em; }
.day-head .dnum { font-size: 14px; font-weight: 700; margin-left: auto; font-variant-numeric: tabular-nums; }
.day.is-today .day-head { background: var(--accent-soft); border-bottom-color: color-mix(in srgb, var(--accent) 20%, var(--border)); }
.day.is-today .day-head .dow { color: var(--accent); }
.day.is-today .day-head .dnum {
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; margin-left: auto;
}
.day-tasks { flex: 1; padding: 6px 7px; display: flex; flex-direction: column; gap: 3px; }
.day-add { border: none; background: transparent; color: var(--muted-2); text-align: left; padding: 6px 8px; font-size: 12px; border-radius: 8px; transition: .12s; font-weight: 600; }
.day-add:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- task chip ---------- */
.task {
  display: flex; align-items: flex-start; gap: 8px; padding: 6px 22px 6px 13px;
  border-radius: 9px; font-size: 13px; position: relative; transition: background .12s;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
.task:hover { background: var(--bg); }
.task .cat-bar { position: absolute; left: 5px; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; opacity: .9; }
.task .check {
  flex: none; width: 17px; height: 17px; margin-top: 1px; border: 2px solid var(--muted-2);
  border-radius: 6px; display: grid; place-items: center; background: var(--panel);
  cursor: pointer; transition: .15s;
}
.task .check:hover { border-color: var(--accent); transform: scale(1.08); }
.task.done .check { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: var(--accent); color: #fff; }
.task .check svg { width: 11px; height: 11px; opacity: 0; transform: scale(.5); transition: .15s; }
.task.done .check svg { opacity: 1; transform: scale(1); }
.task .task-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.task .txt { overflow-wrap: anywhere; cursor: text; transition: .15s; }
.task.done .txt { color: var(--done); text-decoration: line-through; }
.task .due-pill { font-size: 10.5px; font-weight: 750; padding: 1.5px 8px; border-radius: 20px; white-space: nowrap; align-self: flex-start; letter-spacing: .01em; }
.task.overdue:not(.done) { background: var(--overdue-soft); }
.task.overdue:not(.done) .due-pill { background: var(--overdue); color: #fff; }
.task.duetoday:not(.done) { background: var(--duetoday-soft); }
.task.duetoday:not(.done) .due-pill { background: var(--duetoday); color: #fff; }
.task .due-pill.future { background: var(--accent-soft); color: var(--accent); }
.task .del { position: absolute; top: 4px; right: 4px; border: none; background: transparent; color: var(--muted-2); opacity: 0; font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 6px; transition: .12s; }
.task:hover .del { opacity: 1; }
.task .del:hover { color: var(--overdue); background: var(--overdue-soft); }

/* ---------- list view ---------- */
.list-section { margin-bottom: 22px; }
.list-section h3 { font-size: 13.5px; margin: 0 0 10px; display: flex; align-items: center; gap: 9px; font-weight: 750; }
.list-section h3 .count { color: var(--muted); font-weight: 650; }
.list-section .bar { width: 4px; height: 17px; border-radius: 3px; background: var(--accent); }
.list-section.overdue .bar { background: var(--overdue); }
.list-section.today .bar { background: var(--duetoday); }
.list-section.done .bar { background: var(--done); }
.list-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.list-row { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--border); transition: background .12s; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg); }
.list-row .cat-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.list-row .txt { flex: 1; cursor: text; }
.list-row.done .txt { color: var(--done); text-decoration: line-through; }
.list-row .meta { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-row .due-pill { font-size: 11px; font-weight: 750; padding: 2.5px 10px; border-radius: 20px; white-space: nowrap; }
.list-row.overdue .due-pill { background: var(--overdue); color: #fff; }
.list-row.today .due-pill { background: var(--duetoday); color: #fff; }
.list-row .due-pill.future { background: var(--accent-soft); color: var(--accent); }
.list-row .del { border: none; background: transparent; color: var(--muted-2); font-size: 16px; padding: 2px 5px; border-radius: 6px; transition: .12s; }
.list-row .del:hover { color: var(--overdue); background: var(--overdue-soft); }
.empty { color: var(--muted); text-align: center; padding: 60px 0; font-size: 14px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,18,30,.45); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s ease; backdrop-filter: blur(2px); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--panel); border-radius: 18px; width: 100%; max-width: 430px; box-shadow: var(--shadow-lg); padding: 22px; max-height: 90vh; overflow: auto; animation: rise .2s cubic-bezier(.2,.8,.2,1); border: 1px solid var(--border); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal h2 { font-family: var(--font-display); margin: 0 0 16px; font-size: 18px; letter-spacing: -.01em; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; background: var(--bg); color: var(--text); transition: .15s;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--panel); }
.field textarea { resize: vertical; min-height: 62px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.btn-ghost { border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 9px 15px; border-radius: 10px; font-weight: 650; transition: .15s; }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--bg); }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }
.hint a { color: var(--accent); }
.banner { background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 60%, var(--panel))); color: var(--accent); font-size: 12.5px; font-weight: 650; padding: 9px 16px; text-align: center; cursor: pointer; transition: .15s; }
.banner:hover { filter: brightness(.98); }

/* ---------- fab ---------- */
.fab { position: fixed; right: 20px; bottom: 24px; z-index: 25; width: 56px; height: 56px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 28px; box-shadow: var(--shadow-lg); transition: .15s; display: none; }
.fab:hover { transform: translateY(-2px) scale(1.04); }
.fab:active { transform: scale(.97); }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .topbar { gap: 7px; padding: 10px 13px; flex-wrap: wrap; }
  .topbar .brand { font-size: 15px; }
  .seg button { padding: 6px 11px; }
  .filterbar { padding: 9px 13px 4px; flex-wrap: nowrap; }
  .search { width: 130px; flex: 1 1 auto; }
  .cat-chips { flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  main { padding: 0 12px 130px; }
  .grid { grid-template-columns: 1fr; gap: 8px; }
  .day { min-height: auto; }
  .day.weekend { background: var(--panel); }
  .navrow { padding: 8px 13px 10px; }
  .fab { display: grid; place-items: center; }
}
