/* ============ DayFlow 样式：移动优先 ============ */

:root {
  --bg: #f3f5fa;
  --bg-soft: #eef1f8;
  --card: #ffffff;
  --card-2: #f8f9fc;
  --text: #141824;
  --muted: #6b7385;
  --line: #e6e9f2;
  --accent: #5b5bd6;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(91, 91, 214, 0.09);
  --ok: #0ea472;
  --ok-soft: rgba(14, 164, 114, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --err: #e5484d;
  --err-soft: rgba(229, 72, 77, 0.1);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px -16px rgba(16, 24, 40, 0.18);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

[data-theme='dark'] {
  --bg: #0c0e13;
  --bg-soft: #10131a;
  --card: #161a22;
  --card-2: #1b2029;
  --text: #e7eaf2;
  --muted: #939cb0;
  --line: #242a36;
  --accent: #8b9cff;
  --accent-2: #b18cff;
  --accent-soft: rgba(139, 156, 255, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --err: #fb7185;
  --err-soft: rgba(251, 113, 133, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -18px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  font-feature-settings: 'tnum';
  overscroll-behavior-y: contain;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px 96px; }

/* ---------- 顶部 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-inner {
  max-width: 820px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.2px; }
.brand .dot {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px -4px var(--accent);
}
.topbar .date { margin-left: auto; color: var(--muted); font-size: 13px; }
.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- 今日概览 ---------- */
.hero {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 14px; margin: 16px 0 18px; padding: 18px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; inset: auto -40px -70px auto;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.ring { position: relative; width: 62px; height: 62px; flex: none; }
.ring svg { transform: rotate(-90deg); width: 62px; height: 62px; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: url(#grad); stroke-linecap: round; transition: stroke-dashoffset 0.5s cubic-bezier(0.3, 1, 0.4, 1); }
.ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 700; }

.hero-main { min-width: 0; }
.hero-title { display: flex; align-items: baseline; gap: 6px; }
.hero-title b { font-size: 26px; line-height: 1; letter-spacing: -0.5px; }
.hero-title span { color: var(--muted); }
.hero-sub { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.streak {
  text-align: center; padding: 6px 12px; border-radius: 13px;
  background: var(--warn-soft); color: var(--warn); flex: none;
}
.streak b { display: block; font-size: 19px; line-height: 1.1; }
.streak span { font-size: 10.5px; opacity: 0.9; }

/* ---------- 分组 ---------- */
.group { margin-bottom: 14px; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 8px; color: var(--muted); font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.3px;
}
.group-head .pill {
  margin-left: auto; font-weight: 600; font-size: 11.5px;
  padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--muted);
}
.group-head .pill.full { background: var(--ok-soft); color: var(--ok); }

.list {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}

.item {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: start; gap: 10px; padding: 13px 14px;
  border-top: 1px solid var(--line);
  transition: background 0.15s;
}
.item:first-child { border-top: 0; }
.item:active { background: var(--card-2); }

.check {
  width: 24px; height: 24px; margin-top: 1px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--muted) 45%, transparent);
  display: grid; place-items: center; flex: none;
  transition: all 0.18s ease; color: #fff;
}
.check svg { width: 13px; height: 13px; opacity: 0; transform: scale(0.5); transition: all 0.18s; }
.item.done .check { background: var(--ok); border-color: var(--ok); }
.item.done .check svg { opacity: 1; transform: scale(1); }

.body { min-width: 0; padding-top: 1px; }
.title { font-size: 15px; line-height: 1.42; word-break: break-word; }
.item.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

.note {
  margin-top: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.note.open { -webkit-line-clamp: unset; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge {
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 500;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.ghost { background: var(--bg-soft); color: var(--muted); }
.badge.time { background: transparent; color: var(--muted); padding-left: 0; }

.tools { display: flex; align-items: center; gap: 6px; padding-top: 1px; }
.tool {
  display: grid; place-items: center; gap: 2px;
  min-width: 34px; height: 34px; padding: 0 7px; border-radius: 10px;
  background: var(--bg-soft); color: var(--muted); font-size: 11px;
}
.tool:active { transform: scale(0.94); }
.tool.primary { background: var(--accent-soft); color: var(--accent); }
.tool svg { width: 15px; height: 15px; }
.tool .n { font-size: 10px; font-weight: 700; }

/* 已完成折叠区 */
.done-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 11px 14px; font-size: 12.5px; color: var(--muted);
  border-top: 1px solid var(--line); background: var(--card-2);
}
.done-toggle svg { width: 13px; height: 13px; transition: transform 0.2s; }
.done-toggle.open svg { transform: rotate(90deg); }

/* ---------- 热力图 ---------- */
.heat-card { margin-top: 6px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.heat-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.heat-head b { font-size: 13.5px; }
.heat-head span { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.heat-grid { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.heat-col { display: flex; flex-direction: column; gap: 4px; }
.cell { width: 14px; height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--muted) 24%, transparent); }
@media (min-width: 720px) { .cell { width: 16px; height: 16px; } }
.cell.void { background: color-mix(in srgb, var(--muted) 6%, transparent); }
.cell.l1 { background: color-mix(in srgb, var(--ok) 26%, transparent); }
.cell.l2 { background: color-mix(in srgb, var(--ok) 48%, transparent); }
.cell.l3 { background: color-mix(in srgb, var(--ok) 72%, transparent); }
.cell.l4 { background: var(--ok); }
.cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }

.foot { margin: 22px 4px 0; color: var(--muted); font-size: 11.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.foot a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--line); }

/* ---------- 悬浮按钮 ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + var(--safe-b)); z-index: 40;
  width: 54px; height: 54px; border-radius: 19px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 10px 26px -8px var(--accent), 0 2px 8px rgba(0, 0, 0, 0.12);
  display: grid; place-items: center;
}
.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(0.94); }
@media (min-width: 720px) { .fab { display: none; } }

/* ---------- 抽屉 / 弹窗 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(9, 12, 20, 0.45);
  backdrop-filter: blur(2px); animation: fade 0.18s ease;
}
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0;
  max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, 0.4);
  animation: up 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
  padding-bottom: var(--safe-b);
}
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); width: 620px; max-height: 84vh; border-radius: 22px; animation: pop 0.2s ease; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0.6; } }
@keyframes pop { from { transform: translate(-50%, 46%) scale(0.98); opacity: 0.6; } }

.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 16px; }
.sheet-head .spacer { flex: 1; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 16px 20px; -webkit-overflow-scrolling: touch; }
.sheet-foot { flex: 0 0 auto; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; white-space: nowrap;
  height: 38px; padding: 0 14px; border-radius: 11px; font-size: 14px; font-weight: 500;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
}
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.btn.danger { color: var(--err); background: var(--err-soft); border-color: transparent; }
.btn:active { transform: scale(0.97); }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }
.mgr-item .mini svg, .link-row .mini svg { width: 14px; height: 14px; }
button:disabled { opacity: 0.3; pointer-events: none; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; font-size: 16px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 11px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 64px; font-size: 15px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; height: 36px; border-radius: 10px; font-size: 13.5px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.seg button.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 32px; padding: 0 11px; border-radius: 9px; font-size: 12.5px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.chip.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); font-weight: 600; }

.link-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 6px; margin-bottom: 6px; }
.link-row .input { font-size: 15px; padding: 8px 10px; }
.link-row .mini { align-self: center; }
@media (max-width: 560px) {
  .link-row { grid-template-columns: 1fr auto; }
  .link-row [data-k="label"] { grid-row: 1; }
  .link-row .mini { grid-row: 1; }
  .link-row [data-k="url"] { grid-column: 1 / -1; grid-row: 2; }
}

.mgr-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px;
  padding: 11px 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 13px; margin-bottom: 8px;
}
.mgr-item .t { font-size: 14px; }
.mgr-item .m { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.mgr-item .row-btns { display: flex; gap: 4px; align-items: center; }
.mini { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-soft); color: var(--muted); }
.mini svg { width: 14px; height: 14px; }
button:disabled { opacity: 0.3; pointer-events: none; }

.section-title { font-size: 12px; color: var(--muted); font-weight: 600; margin: 16px 2px 8px; letter-spacing: 0.3px; }

/* ---------- 登录 ---------- */
.auth {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 24px; background: var(--bg);
  background-image: radial-gradient(60% 50% at 50% 0%, var(--accent-soft), transparent 70%);
}
.auth-card { width: 100%; max-width: 340px; text-align: center; }
.auth-card .logo {
  display: block; border-radius: 16px; margin: 0 auto 16px;
  box-shadow: 0 14px 34px -14px var(--accent);
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card p { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.auth-card .input { text-align: center; letter-spacing: 0.5px; }
.auth-card .btn { margin-top: 12px; height: 44px; }
.auth-err { color: var(--err); font-size: 12.5px; height: 18px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); z-index: 90;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  padding: 9px 16px; border-radius: 12px; font-size: 13px;
  background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--bg);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
  transition: all 0.22s cubic-bezier(0.2, 0.9, 0.3, 1); max-width: 86vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- 空态 / 加载 ---------- */
.skeleton { padding: 40px 0; text-align: center; color: var(--muted); font-size: 13px; }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }
