:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --ink: #182234;
  --muted: #748097;
  --faint: #a6afbf;
  --line: #e6eaf2;
  --accent: #5a68e8;
  --accent-2: #4654cf;
  --mint: #36bba6;
  --mint-soft: #e9f8f4;
  --coral: #ee6d77;
  --coral-soft: #fff0f1;
  --amber: #eea331;
  --amber-soft: #fff7e8;
  --navy: #111b2e;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  background:
    radial-gradient(circle at 100% 0%, rgba(97, 111, 235, .08), transparent 34%),
    var(--bg);
  padding-bottom: calc(82px + var(--safe-bottom));
}
.app-header {
  height: 76px;
  padding: max(12px, env(safe-area-inset-top)) 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: linear-gradient(130deg, #10192b, #1c2b47 62%, #213557);
  border-radius: 0 0 24px 24px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6a76f2, #39c3ad);
  font-size: 17px; font-weight: 800;
  box-shadow: 0 7px 22px rgba(40, 55, 92, .35);
}
.brand strong { display: block; font-size: 17px; letter-spacing: .4px; }
.brand span { display: block; margin-top: 2px; font-size: 8px; letter-spacing: 1.5px; color: #8491aa; }
.connection {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 20px;
  background: rgba(255, 255, 255, .07);
  color: #aebbd0; font-size: 10px;
}
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #e6a43d; }
.connection.online i { background: #4fd2bb; box-shadow: 0 0 0 4px rgba(79, 210, 187, .1); }
.connection.offline i { background: #f07179; }

main { padding: 22px 18px 16px; }
.screen { display: none; animation: enter .22s ease-out; }
.screen.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

h1, h2, h3, p { margin: 0; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .4px; }
.page-title { margin-top: 5px; font-size: 24px; line-height: 1.25; letter-spacing: -.5px; }
.page-subtitle { margin-top: 7px; color: var(--muted); font-size: 11.5px; line-height: 1.65; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 24px 1px 10px; }
.section-title h2 { font-size: 15px; }
.section-title span { color: var(--faint); font-size: 10.5px; }

.hero {
  position: relative; overflow: hidden;
  margin-top: 20px; padding: 21px 20px;
  color: #fff; border-radius: 21px;
  background: linear-gradient(130deg, #23395f, #4d61d6 72%, #6074e7);
  box-shadow: 0 14px 30px rgba(53, 70, 128, .17);
}
.hero:after {
  content: ""; position: absolute; width: 170px; height: 170px;
  right: -65px; top: -70px; border-radius: 50%;
  border: 24px solid rgba(255, 255, 255, .055);
}
.hero-label {
  display: inline-block; padding: 4px 9px; border-radius: 7px;
  background: rgba(255, 255, 255, .14); font-size: 9.5px; font-weight: 700;
}
.hero-row { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 15px; }
.hero-count { font-size: 32px; font-weight: 800; letter-spacing: -1px; }
.hero-count small { margin-left: 5px; font-size: 10.5px; font-weight: 400; color: #d5dbff; }
.hero-note { margin-top: 6px; color: #d7dcff; font-size: 10.5px; line-height: 1.55; }
.progress-ring {
  flex: 0 0 70px; width: 70px; height: 70px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(#61d9c2 calc(var(--progress, 0) * 1%), #354566 0);
  position: relative;
}
.progress-ring:before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #354676; }
.progress-ring b { position: relative; font-size: 14px; }
.progress-track { height: 6px; border-radius: 6px; margin-top: 16px; background: rgba(255,255,255,.14); overflow: hidden; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5ed5be, #a2eddE); transition: width .36s ease; }

.quick-card {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 25px rgba(37, 50, 76, .04);
}
.quick-card input {
  flex: 1; min-width: 0; height: 38px; border: 0; outline: 0; background: transparent;
  padding: 0 8px; color: var(--ink); font-size: 12.5px;
}
.quick-card input::placeholder { color: var(--faint); }
.primary, .soft, .ghost {
  border: 0; border-radius: 10px; min-height: 38px; padding: 0 15px;
  cursor: pointer; font-weight: 700; font-size: 12px;
}
.primary { color: #fff; background: var(--accent); box-shadow: 0 5px 14px rgba(90, 104, 232, .19); }
.primary:active { background: var(--accent-2); transform: translateY(1px); }
.soft { color: var(--accent-2); background: #eef0ff; }
.ghost { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.full { width: 100%; }
.danger { color: var(--coral); background: var(--coral-soft); }

.task-card {
  display: grid; grid-template-columns: 37px minmax(0, 1fr) auto; align-items: center;
  gap: 7px; padding: 13px 12px; margin-bottom: 9px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.task-card.completed { background: #fafbfd; }
.check {
  width: 25px; height: 25px; border-radius: 8px; border: 1.5px solid #cbd3e1;
  background: transparent; color: transparent; display: grid; place-items: center;
  font-size: 13px; font-weight: 900; cursor: pointer;
}
.check.on { color: #fff; background: var(--mint); border-color: var(--mint); }
.task-main { min-width: 0; cursor: pointer; }
.task-title { font-size: 12.8px; font-weight: 700; line-height: 1.48; word-break: break-word; }
.completed .task-title { color: var(--muted); text-decoration: line-through; }
.task-meta { margin-top: 7px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; color: var(--faint); font-size: 9px; }
.pill { display: inline-flex; align-items: center; border-radius: 7px; padding: 3px 7px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.pill.high { color: #ef6e66; background: #fff0ee; }
.pill.normal { color: #6471df; background: #eef0ff; }
.pill.low { color: #7b8da6; background: #f0f3f7; }
.pill.done { color: var(--mint); background: var(--mint-soft); }
.task-note-btn {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 9px; min-width: 42px; height: 31px; padding: 0 8px;
  font-size: 9.5px; font-weight: 600; cursor: pointer;
}

.empty {
  padding: 29px 18px; text-align: center;
  border: 1px solid var(--line); border-radius: 15px; background: #fff;
}
.empty .icon {
  width: 44px; height: 44px; margin: 0 auto 11px; border-radius: 14px;
  display: grid; place-items: center; background: #eef0ff; color: var(--accent); font-size: 20px;
}
.empty h3 { font-size: 13px; }
.empty p { margin-top: 6px; color: var(--muted); font-size: 10.5px; line-height: 1.6; }
.empty button { margin-top: 13px; }

.search-box {
  display: flex; align-items: center; gap: 8px; height: 42px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 0 13px;
}
.search-box span { color: var(--faint); font-size: 18px; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 12px; color: var(--ink); }
.segmented {
  display: flex; padding: 3px; margin-top: 10px; border-radius: 10px; background: #e9edf4;
}
.segmented button {
  flex: 1; border: 0; border-radius: 8px; padding: 8px 5px;
  background: transparent; color: var(--muted); font-size: 10.5px; cursor: pointer;
}
.segmented button.active { color: var(--ink); background: #fff; font-weight: 700; box-shadow: 0 2px 7px rgba(34, 44, 65, .08); }
.date-group { margin: 17px 1px 8px; display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.metric {
  padding: 14px; border-radius: 14px; background: #fff; border: 1px solid var(--line);
}
.metric label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 9.5px; }
.metric label i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.metric b { display: block; margin: 8px 0 2px; font-size: 23px; letter-spacing: -.5px; }
.metric small { color: var(--faint); font-size: 8.5px; }
.chart-card { margin-top: 13px; padding: 16px 14px 12px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.chart-head h3 { font-size: 13px; }
.chart-head span { color: var(--faint); font-size: 8.5px; }
.bars { height: 170px; display: flex; align-items: flex-end; gap: 5px; padding-top: 9px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; }
.bar-stack { position: relative; width: min(24px, 76%); height: 132px; display: flex; align-items: flex-end; justify-content: center; }
.bar-total { position: absolute; bottom: 0; width: 100%; min-height: 0; border-radius: 5px 5px 2px 2px; background: #edf0f6; }
.bar-done { position: absolute; bottom: 0; width: 58%; border-radius: 5px 5px 2px 2px; background: linear-gradient(#6875ef, #46c4ae); z-index: 1; }
.bar-label { height: 18px; color: var(--faint); font-size: 8px; white-space: nowrap; }
.bar-col.current .bar-label { color: var(--accent); font-weight: 700; }
.period-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding: 4px; border-radius: 11px; border: 1px solid var(--line); background: #fff; }
.period-nav button { width: 36px; height: 31px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.period-nav b { font-size: 12px; }
.note-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 13px; }
.note-breakdown div { padding: 12px 9px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.note-breakdown i { display: block; width: 7px; height: 22px; margin-bottom: 8px; border-radius: 5px; background: var(--mint); }
.note-breakdown b { display: block; font-size: 18px; }
.note-breakdown small { color: var(--muted); font-size: 8.5px; }

.settings-card { padding: 4px 15px; background: #fff; border: 1px solid var(--line); border-radius: 15px; margin-bottom: 13px; }
.setting-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { display: block; font-size: 12px; }
.setting-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.switch { width: 44px; height: 25px; position: relative; flex: 0 0 44px; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: #d7dce6; transition: .2s; }
.switch span:after { content: ""; position: absolute; width: 19px; height: 19px; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.14); transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span:after { transform: translateX(19px); }
.sync-panel { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.sync-panel h3 { font-size: 13px; }
.sync-panel p { margin-top: 5px; color: var(--muted); font-size: 9.5px; line-height: 1.65; }
.sync-state { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: var(--muted); font-size: 10px; }
.sync-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.sync-state.online i { background: var(--mint); }
.sync-meta { margin-top: 12px; padding: 10px; border-radius: 9px; background: #f7f8fb; color: var(--faint); font-size: 9px; line-height: 1.65; word-break: break-word; }
.sync-panel .soft { margin-top: 12px; }

.tabbar {
  position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 720px; height: calc(68px + var(--safe-bottom));
  padding: 7px 18px calc(7px + var(--safe-bottom));
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, .95);
  border-top: 1px solid rgba(224, 229, 239, .9);
  backdrop-filter: blur(14px);
}
.tab {
  border: 0; background: transparent; color: #98a2b4;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer;
}
.tab b {
  width: 27px; height: 25px; border-radius: 8px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}
.tab span { font-size: 9px; }
.tab.active { color: var(--accent); }
.tab.active b { background: #eef0ff; }

.modal-layer, .sheet-layer, .hourly-layer {
  position: fixed; inset: 0; z-index: 100; display: none;
}
.modal-layer.open, .sheet-layer.open, .hourly-layer.open { display: block; }
.modal-layer { place-items: center; padding: 22px; background: rgba(8, 17, 32, .62); backdrop-filter: blur(5px); }
.modal-layer.open { display: grid; }
.dialog { width: 100%; max-width: 380px; padding: 28px 23px 22px; border-radius: 21px; background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.dialog-glyph { width: 50px; height: 50px; display: grid; place-items: center; margin-bottom: 17px; border-radius: 16px; background: linear-gradient(135deg, #5b68e8, #38c1ac); color: #fff; font-size: 21px; font-weight: 800; }
.dialog h2 { font-size: 20px; }
.dialog p { margin: 9px 0 17px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.dialog input, .field input, .field textarea {
  width: 100%; border: 1px solid var(--line); outline: 0; border-radius: 10px;
  background: #f8f9fc; color: var(--ink); padding: 11px 12px; font-size: 12px;
}
.dialog input:focus, .field input:focus, .field textarea:focus { border-color: #aeb6f7; background: #fff; }
.dialog .primary { margin-top: 10px; }
.dialog small { display: block; text-align: center; margin-top: 12px; color: var(--faint); font-size: 9px; }

.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 17, 32, .55); backdrop-filter: blur(4px); }
.sheet {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 720px; max-height: 91vh; overflow-y: auto;
  padding: 22px 19px calc(24px + var(--safe-bottom));
  border-radius: 24px 24px 0 0; background: var(--bg);
  animation: sheetUp .25s ease-out;
}
@keyframes sheetUp { from { transform: translate(-50%, 35px); opacity: .5; } }
.sheet-handle { width: 38px; height: 4px; margin: -10px auto 18px; border-radius: 3px; background: #ced4df; }
.sheet-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-title-row h2 { font-size: 20px; line-height: 1.35; }
.round-close {
  flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--muted); font-size: 22px; cursor: pointer;
}
.sheet-subtitle { margin-top: 8px; color: var(--muted); font-size: 10px; }
.field { margin-top: 15px; }
.field label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 9.5px; font-weight: 700; }
.field textarea { min-height: 93px; resize: vertical; line-height: 1.65; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-row { display: flex; gap: 5px; }
.choice-row button {
  flex: 1; min-height: 36px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--muted); font-size: 10px; cursor: pointer;
}
.choice-row button.active { color: var(--accent); border-color: #cbd0fb; background: #eef0ff; font-weight: 700; }
.sheet-actions { display: flex; gap: 8px; margin-top: 19px; }
.sheet-actions button { flex: 1; }
.note-list { margin-top: 21px; }
.note-card { padding: 13px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.note-head { display: flex; align-items: center; justify-content: space-between; }
.note-head button { border: 0; background: transparent; color: var(--faint); font-size: 16px; cursor: pointer; }
.note-content { margin-top: 8px; color: var(--ink); font-size: 11px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.note-time { margin-top: 6px; color: var(--faint); font-size: 8.5px; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 12px; }
.detail-actions { display: flex; gap: 7px; margin-top: 17px; }
.detail-actions button { flex: 1; min-height: 36px; font-size: 10px; }

.hourly-layer {
  z-index: 120; overflow-y: auto; padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
  background: rgba(5, 11, 22, .73); backdrop-filter: blur(9px);
}
.hourly-panel {
  min-height: calc(100vh - 28px); padding: 23px 18px 18px; display: flex; flex-direction: column;
  border: 1px solid #34445f; border-radius: 23px;
  color: #fff; background: linear-gradient(140deg, #101a2c, #1b2a46 56%, #17243c);
  box-shadow: 0 24px 80px rgba(0,0,0,.38);
}
.hourly-top { display: flex; justify-content: space-between; gap: 12px; }
.hourly-top small { color: #9cb0cf; font-size: 10px; }
.hourly-top h2 { margin-top: 11px; font-size: 27px; letter-spacing: -.5px; }
.hourly-top p { margin-top: 7px; color: #8fa2be; font-size: 10.5px; line-height: 1.6; }
.hourly-top .round-close { color: #d4deee; border-color: #3a4d6a; background: #22334e; }
.hourly-summary { margin-top: 19px; padding: 15px; border: 1px solid #344862; border-radius: 14px; background: rgba(255,255,255,.065); }
.hourly-summary b { display: block; font-size: 28px; }
.hourly-summary span { color: #8fa2be; font-size: 9.5px; }
.hourly-section { margin-top: 19px; color: #aebdd4; font-size: 11px; font-weight: 700; }
.hourly-task { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 8px; align-items: center; margin-top: 8px; padding: 13px; border: 1px solid #30435f; border-radius: 12px; background: rgba(255,255,255,.055); }
.hourly-task .check { border-color: #62738c; }
.hourly-task h3 { font-size: 12px; }
.hourly-task small { display: block; margin-top: 5px; color: #7f91ad; font-size: 9px; }
.hourly-footer { margin-top: auto; padding-top: 22px; color: #798ba7; font-size: 9px; }
.hourly-footer button { width: 100%; margin-top: 12px; background: #5770e8; }

.offline-banner {
  display: none; position: fixed; z-index: 90; left: 50%; top: 10px; transform: translateX(-50%);
  width: calc(100% - 28px); max-width: 600px; padding: 9px 12px;
  border-radius: 10px; background: #fff3df; color: #9a681d; text-align: center;
  box-shadow: 0 8px 25px rgba(80,60,20,.16); font-size: 9.5px;
}
.offline-banner.show { display: block; }
.toast {
  position: fixed; z-index: 150; left: 50%; bottom: calc(86px + var(--safe-bottom));
  transform: translate(-50%, 8px); max-width: calc(100% - 36px);
  padding: 10px 15px; border-radius: 10px; background: #1e293c; color: #fff;
  opacity: 0; pointer-events: none; transition: .2s; font-size: 10px;
  box-shadow: 0 10px 30px rgba(10, 20, 35, .2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  .app-header { border-radius: 0 0 27px 27px; }
  main { padding: 27px 28px; }
  .task-card { padding-left: 15px; padding-right: 15px; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
