:root {
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --text: #1C2333;
  --text-sub: #6B7488;
  --text-weak: #9AA2B4;
  --line: #ECEFF5;
  --brand: #4F7DF3;
  --brand-soft: #EAF0FE;
  --danger: #F2544B;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(28, 35, 51, .06);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 246, 250, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.header-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .3px;
}

.header-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-weak);
}

.icon-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text-sub);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s ease, color .15s ease;
}
.icon-btn:active { transform: scale(.92); color: var(--brand); }
.icon-btn.is-loading svg { animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Page ---------- */
.page { padding: 14px 16px 0; max-width: 680px; margin: 0 auto; }

.banner {
  margin: 2px 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #FFF1F0;
  color: #B4291F;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.banner button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #B4291F;
  font-weight: 600;
  font-size: 13px;
  padding: 2px 4px;
  cursor: pointer;
}

/* ---------- Cards ---------- */
.card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 14px 0;
  margin-bottom: 12px;
  overflow: hidden;
  animation: pop .22s ease both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.card-bar {
  align-self: stretch;
  flex: none;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--brand);
  margin-right: 10px;
}
.card.is-past .card-bar { background: #C9CEDB; }
.card.is-today .card-bar { background: #FF8A3D; }

.card-main { flex: 1; min-width: 0; }

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 6px;
  word-break: break-word;
}
.card.is-past .card-title { color: var(--text-weak); text-decoration: line-through; }

.meta {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 3px;
}
.meta svg { flex: none; margin-top: 2px; color: var(--text-weak); }
.meta span { word-break: break-word; }
.meta.time.is-today { color: #E8731B; font-weight: 600; }

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}
.tag.today { background: #FFF0E4; color: #E8731B; }

.del-btn {
  flex: none;
  align-self: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #F6F7FB;
  color: var(--text-weak);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.del-btn:active { background: #FDECEB; color: var(--danger); }
.del-btn[disabled] { opacity: .5; }
.del-btn svg { animation: none; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 72px 20px; color: var(--text-weak); }
.empty-icon {
  width: 84px; height: 84px; margin: 0 auto 16px;
  border-radius: 24px; background: #EBEFF7; color: #AEB7C9;
  display: flex; align-items: center; justify-content: center;
}
.empty-title { margin: 0 0 6px; font-size: 16px; color: var(--text-sub); font-weight: 600; }
.empty-desc { margin: 0; font-size: 13px; line-height: 1.7; }

/* ---------- Skeleton ---------- */
.sk-card {
  height: 92px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #EFF1F7 25%, #F7F8FC 37%, #EFF1F7 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  margin-bottom: 12px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 54px; height: 54px;
  border: 0; border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(79, 125, 243, .38);
  cursor: pointer;
  transition: transform .15s ease;
}
.fab:active { transform: scale(.93); }

/* ---------- Sheet ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20, 26, 40, .38);
  animation: fade .18s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  animation: up .24s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  font-size: 16px; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.sheet-head .icon-btn { box-shadow: none; background: transparent; }

.sheet-body { padding: 14px 16px 18px; }

.field { display: block; margin-bottom: 12px; }
.field-label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.field-label i { color: var(--danger); font-style: normal; }

.field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #F6F7FB;
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.field input:focus { border-color: var(--brand); background: #fff; }

.btn-primary {
  width: 100%;
  height: 46px;
  margin-top: 6px;
  border: 0; border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 16px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s ease;
}
.btn-primary:active { opacity: .85; }
.btn-primary[disabled] { opacity: .6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(28, 35, 51, .9);
  color: #fff;
  font-size: 13px;
  animation: fade .18s ease both;
}

/* ---------- Desktop ---------- */
@media (min-width: 700px) {
  body { padding-bottom: 40px; }
  .fab { right: calc(50% - 340px + 18px); }
  .sheet { left: 50%; transform: translateX(-50%); width: 680px; }
  @keyframes up {
    from { transform: translate(-50%, 100%); }
    to   { transform: translate(-50%, 0); }
  }
}
