/* ===== 基础与变量 ===== */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1a2233;
  --ink-soft: #5b6573;
  --ink-faint: #9aa3b2;
  --line: #eceef2;
  --line-soft: #f2f3f6;
  --accent: #3b6cf6;
  --accent-soft: #eaf0ff;
  --accent-ink: #2a5ae0;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --amber: #d97706;
  --amber-soft: #fdf2e2;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 10px 30px rgba(15,23,42,.04);
  --shadow-hover: 0 2px 6px rgba(15,23,42,.06), 0 18px 40px rgba(15,23,42,.07);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font-family: inherit; }

/* ===== 顶部栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 24px;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar__left { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand__logo { font-size: 20px; line-height: 1; color: var(--accent); }
.brand__name { font-size: 16px; font-weight: 600; letter-spacing: .02em; }

/* 同步状态指示点 */
.sync-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-left: 4px; vertical-align: middle;
  background: #c5cbd6; transition: background .3s, box-shadow .3s;
}
.sync--syncing { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); animation: pulse 1s infinite; }
.sync--ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.sync--error { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.sync--offline { background: var(--ink-faint); }
.sync--idle { background: #c5cbd6; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.topbar__date { font-size: 13px; color: var(--ink-faint); }
.topbar__right { display: flex; gap: 8px; align-items: center; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn--ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: #2f5fe0; }
.btn--sm { padding: 6px 12px; font-size: 12px; }
.iconbtn {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent;
  color: var(--ink-soft); font-size: 18px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--line-soft); color: var(--ink); }
.select {
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
  padding: 8px 10px; font-size: 13px; cursor: pointer;
}
.select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ===== Hero 问候 + 时钟 + 概览 ===== */
.hero {
  max-width: 1200px; margin: 0 auto;
  padding: 30px 24px 18px;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
}
.hero__left { min-width: 0; }
.hero__hello { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -.02em; }
.hero__sub { margin: 6px 0 10px; color: var(--ink-soft); font-size: 14px; }
.hero__clock {
  text-align: right; flex: 0 0 auto;
  padding: 10px 18px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #6a8bff 100%);
  color: #fff; box-shadow: 0 8px 24px rgba(59,108,246,.28);
}
.clock__time { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.clock__date { font-size: 12px; opacity: .9; margin-top: 2px; }

/* 概览胶囊 */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft); cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  text-decoration: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip b { font-weight: 600; color: var(--ink); }
.chip--accent { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-ink); }
.chip--accent b { color: var(--accent-ink); }

/* ===== 网格（桌面 12 栏 bento） ===== */
.grid {
  max-width: 1200px; margin: 0 auto;
  padding: 6px 24px 40px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}
.card--full { grid-column: span 12; }
.card--4 { grid-column: span 4; }
.card--8 { grid-column: span 8; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 16px 18px 10px;
}
.card__title { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card__icon { color: var(--accent); font-size: 15px; }
.card__meta { font-size: 12px; color: var(--ink-faint); }
.card__body { padding: 4px 18px 18px; }

/* ===== 快速输入 ===== */
.quick-add, .event-add {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap;
}
.quick-add__input {
  flex: 1; min-width: 120px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.quick-add__input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.event-add .select { flex: 0 0 auto; }

/* ===== 列表通用 ===== */
.plan-list, .todo-list, .flash-list, .reminder-list, .event-list, .note-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.plan-item, .todo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px;
  background: var(--line-soft); transition: background .15s;
}
.plan-item:hover, .todo-item:hover { background: #eef0f4; }
.check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.8px solid var(--ink-faint); cursor: pointer; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: transparent; transition: all .15s; font-size: 12px;
}
.check:hover { border-color: var(--accent); }
.plan-item.done .check, .todo-item.done .check, .reminder-item.done .check {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.plan-item.done .item-text, .todo-item.done .item-text { text-decoration: line-through; color: var(--ink-faint); }
.item-text { flex: 1; min-width: 0; font-size: 14px; word-break: break-word; }
.item-del {
  border: none; background: transparent; color: var(--ink-faint);
  cursor: pointer; opacity: 0; transition: opacity .15s, color .15s;
  font-size: 14px; padding: 2px 4px; line-height: 1;
}
.plan-item:hover .item-del, .todo-item:hover .item-del,
.flash-item:hover .item-del, .reminder-item:hover .item-del,
.event-item:hover .item-del, .note-item:hover .item-del { opacity: 1; }
.item-del:hover { color: var(--red); }

/* 优先级 */
.prio { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; flex: 0 0 auto; }
.prio-0 { background: var(--line-soft); color: var(--ink-faint); }
.prio-1 { background: var(--amber-soft); color: var(--amber); }
.prio-2 { background: var(--red-soft); color: var(--red); }

/* 灵感速记 */
.flash-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--line-soft); transition: background .15s;
}
.flash-item:hover { background: #eef0f4; }
.flash-text { flex: 1; min-width: 0; font-size: 14px; word-break: break-word; }
.flash-time { font-size: 11px; color: var(--ink-faint); flex: 0 0 auto; padding-top: 1px; }

/* 提醒 / 事件 */
.reminder-item, .event-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  background: var(--line-soft); transition: background .15s;
}
.reminder-item:hover, .event-item:hover { background: #eef0f4; }
.reminder-item.done .reminder-text { text-decoration: line-through; color: var(--ink-faint); }
.reminder-text, .event-text { flex: 1; min-width: 0; font-size: 14px; word-break: break-word; }
.reminder-when, .event-when { font-size: 12px; color: var(--ink-soft); flex: 0 0 auto; }
.reminder-when.due { color: var(--red); font-weight: 600; }

/* ===== 日历 ===== */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav__label { font-size: 13px; font-weight: 600; min-width: 92px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 14px; }
.cal-grid .dow { text-align: center; font-size: 11px; color: var(--ink-faint); padding: 6px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--ink); cursor: pointer; position: relative;
  transition: background .12s; border: 1px solid transparent;
}
.cal-cell:hover { background: var(--line-soft); }
.cal-cell.muted { color: var(--ink-faint); background: transparent; }
.cal-cell.today { background: var(--accent); color: #fff; font-weight: 600; }
.cal-cell.has-evt::after {
  content: ""; position: absolute; bottom: 4px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.cal-cell.today.has-evt::after { background: #fff; }

/* ===== 笔记 ===== */
.notes-wrap { display: grid; grid-template-columns: 1fr; gap: 0; }
.note-list { max-height: 320px; overflow-y: auto; }
.note-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--line-soft); cursor: pointer;
  transition: background .15s; border: 1px solid transparent;
}
.note-item:hover { background: #eef0f4; }
.note-item.active { background: var(--accent-soft); border-color: var(--accent-soft); }
.note-item__main { min-width: 0; flex: 1; }
.note-item__title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item__title.empty { color: var(--ink-faint); }
.note-item__date { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.note-editor { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.note-editor__title {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; font-weight: 600;
}
.note-editor__title:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note-editor__content {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 14px; line-height: 1.6;
  min-height: 140px; resize: vertical; font-family: var(--font);
}
.note-editor__content:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note-editor__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note-editor__saved { font-size: 12px; color: var(--green); }

/* 空状态 */
.empty { text-align: center; color: var(--ink-faint); font-size: 13px; padding: 18px 8px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1a2233; color: #fff;
  padding: 10px 18px; border-radius: 24px;
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 90;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 电脑端悬浮速记小窗 ===== */
.floaty {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  width: 300px; border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(15,23,42,.16);
  overflow: hidden; user-select: none;
  display: flex; flex-direction: column;
}
.floaty__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: move;
  background: linear-gradient(135deg, var(--accent) 0%, #6a8bff 100%);
  color: #fff;
}
.floaty__title { font-size: 13px; font-weight: 600; }
.floaty__acts { display: flex; gap: 6px; }
.floaty__btn {
  width: 22px; height: 22px; border-radius: 6px;
  border: none; background: rgba(255,255,255,.2); color: #fff;
  cursor: pointer; font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.floaty__btn:hover { background: rgba(255,255,255,.32); }
.floaty__body { padding: 12px 14px 14px; }
.floaty__glance {
  display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.floaty__glance .chip { font-size: 11px; padding: 4px 10px; }
.floaty__form { display: flex; }
.floaty__input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font-size: 13px; background: #fff; color: var(--ink);
}
.floaty__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.floaty.dragging { opacity: .92; }
/* 悬浮按钮 */
.fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  width: 52px; height: 52px; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0%, #6a8bff 100%);
  color: #fff; font-size: 20px;
  box-shadow: 0 10px 28px rgba(59,108,246,.4);
  transition: transform .12s;
}
.fab:hover { transform: scale(1.06); }

/* ===== 移动端底部导航 ===== */
.tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.tabbar__item {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--ink-faint); font-size: 11px; padding: 4px 0;
  border-radius: 8px; transition: color .15s;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar__ic { font-size: 16px; line-height: 1; }
.tabbar__item.active { color: var(--accent); }

/* ===== 同步状态指示点 ===== */
.sync-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 4px; vertical-align: middle; background: #c5cbd6; transition: background .3s, box-shadow .3s; }
.sync--syncing { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); animation: pulse 1s infinite; }
.sync--ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.sync--error { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.sync--offline { background: var(--ink-faint); }
.sync--idle { background: #c5cbd6; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ===== 绑定设备弹窗 ===== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__mask { position: absolute; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); }
.modal__box {
  position: relative; z-index: 1;
  background: var(--card); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(15,23,42,.3);
  padding: 24px; max-width: 360px; width: 100%;
  text-align: center;
}
.modal__close {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 8px;
  border: none; background: var(--line-soft); color: var(--ink-soft);
  cursor: pointer; font-size: 14px;
}
.modal__close:hover { background: var(--line); }
.modal__title { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.modal__sub { margin: 0 0 18px; font-size: 13px; color: var(--ink-soft); }
.bind-qr {
  display: inline-block; padding: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 16px;
}
.bind-qr img, .bind-qr canvas { display: block; }
.bind-code {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  margin-bottom: 12px; flex-wrap: wrap;
}
.bind-code__label { font-size: 12px; color: var(--ink-faint); }
.bind-code code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px; background: var(--accent-soft); color: var(--accent-ink);
  padding: 4px 10px; border-radius: 6px; letter-spacing: .5px;
}
.modal__tip { font-size: 12px; color: var(--ink-faint); margin: 0; word-break: break-all; }
.modal__tip code { font-size: 11px; color: var(--ink-soft); }

@media (max-width: 760px) {
  .modal__box { padding: 20px 16px; }
  .bind-qr { padding: 8px; }
}
.install-card {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  z-index: 85;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(15,23,42,.18);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  max-width: 92vw;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.install-card.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.install-card__main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.install-card__icon { width: 44px; height: 44px; border-radius: 10px; flex: 0 0 auto; }
.install-card__title { font-size: 14px; font-weight: 600; }
.install-card__sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.install-card__acts { display: flex; gap: 6px; flex: 0 0 auto; }

/* 移动端全屏适配（PWA standalone） */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
  .topbar { top: env(safe-area-inset-top); }
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .card--full, .card--8 { grid-column: span 2; }
  .card--4 { grid-column: span 1; }
}
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; padding: 8px 14px 88px; gap: 14px; }
  .card--full, .card--8, .card--4 { grid-column: auto; }
  .hero { padding: 20px 14px 12px; gap: 14px; }
  .hero__hello { font-size: 24px; }
  .hero__clock { padding: 8px 14px; }
  .clock__time { font-size: 22px; }
  .topbar { padding: 12px 14px; }
  .topbar__date { display: none; }
  .btn--ghost span { display: none; }
  .tabbar { display: flex; }
  .floaty, .fab { display: none !important; }
  .note-list { max-height: 240px; }
}
@media (min-width: 761px) {
  .fab[hidden] { display: none; }
}
