:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #161e29;
  --line: #222d3a;
  --text: #e7edf5;
  --muted: #8b9aad;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --ok: #35d39a;
  --danger: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image: radial-gradient(900px 500px at 15% -10%, rgba(79, 140, 255, 0.16), transparent 60%);
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* ---------- 登录 ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.login-card h1 { font-size: 20px; text-align: center; }
.login-card .muted { text-align: center; margin: -6px 0 6px; font-size: 13px; }
.brand { font-size: 40px; text-align: center; line-height: 1; }

/* ---------- 布局 ---------- */
.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

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

.top h1 { font-size: 22px; }
.goal { margin: 6px 0 0; font-size: 13px; line-height: 1.6; max-width: 52ch; }
.top-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- 进度 ---------- */
.progress-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.progress-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 8px; }
.pct { color: var(--accent); font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: #1c2531; border-radius: 99px; overflow: hidden; }
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #4f8cff, #35d39a);
  border-radius: 99px;
  transition: width 0.35s ease;
}

/* ---------- 工具条 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

/* ---------- 按钮 ---------- */
.btn {
  font: inherit;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: #2e3d50; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #6399ff; }
.btn.ghost { background: transparent; }
.btn.icon { padding: 6px 9px; font-size: 13px; color: var(--muted); background: transparent; border-color: transparent; }
.btn.icon:hover { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.btn.danger:hover { color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- 列表 ---------- */
.plan-list { display: flex; flex-direction: column; gap: 18px; }

.day-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin: 4px 2px 8px;
  letter-spacing: 0.02em;
}
.day-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day-label .weekday { color: #5f6f83; }

.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.item:hover { border-color: #2c3a4d; }
.item.done { background: rgba(53, 211, 154, 0.05); border-color: rgba(53, 211, 154, 0.22); }

.check {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 6px;
  border: 1.5px solid #33445a;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 12px;
  padding: 0;
  transition: all 0.15s ease;
}
.item.done .check { background: var(--ok); border-color: var(--ok); color: #06251a; }
.check:hover { border-color: var(--ok); }

.item-body { min-width: 0; }
.item-title { font-size: 14px; line-height: 1.5; word-break: break-word; }
.item.done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(139, 154, 173, 0.6); }
.item-detail { margin: 5px 0 0; font-size: 12.5px; line-height: 1.65; color: var(--muted); word-break: break-word; white-space: pre-wrap; }
.item-actions { display: flex; gap: 2px; opacity: 0.35; transition: opacity 0.15s ease; }
.item:hover .item-actions, .item:focus-within .item-actions { opacity: 1; }

.empty { text-align: center; padding: 48px 0; }

/* ---------- 输入 ---------- */
input, textarea {
  font: inherit;
  font-size: 14px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0e141c;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
input[type="date"] { color-scheme: dark; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

/* ---------- 弹窗 ---------- */
.dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  padding: 22px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dialog::backdrop { background: rgba(4, 7, 11, 0.7); backdrop-filter: blur(3px); }
.dialog form { display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { font-size: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.dialog .small { margin: -6px 0 0; line-height: 1.6; }
#json-text {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  min-height: 280px;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}
#json-text[readonly] { color: #c8d4e4; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1d2836;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  max-width: calc(100vw - 40px);
}
.toast.error { border-color: rgba(255, 107, 107, 0.45); color: #ffc9c9; }

.error { color: var(--danger); font-size: 12.5px; margin: 0; min-height: 16px; text-align: center; }
.foot { text-align: center; margin-top: 40px; }

@media (max-width: 560px) {
  .app { padding: 20px 14px 48px; }
  .top { flex-direction: column; gap: 10px; }
  .top-actions { width: 100%; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .spacer { display: none; }
  #updated-at { width: 100%; }
}
