:root {
  --ink: #17213a;
  --ink-soft: #566079;
  --paper: #f5f7fb;
  --surface: #ffffff;
  --navy: #1d2b4f;
  --blue: #4266d5;
  --blue-pale: #dfe7ff;
  --mint: #9cdbc8;
  --line: #dce2ef;
  --danger: #be4354;
  --shadow: 0 20px 55px rgba(27, 41, 75, .14);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { background: #dfe4ef; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "SF Pro Text", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, .file-row { -webkit-tap-highlight-color: transparent; }

.app-shell {
  position: relative;
  width: min(100%, 540px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px calc(112px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 90% -5%, rgba(156, 219, 200, .32), transparent 28%),
    var(--paper);
}

.topbar, .section-heading, .sheet-title-row, .progress-block, .date-strip, .form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar { margin-bottom: 20px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: #aab4c9; box-shadow: 0 0 0 4px rgba(170,180,201,.18); }
.sync-dot.online { background: #4ba88b; box-shadow: 0 0 0 4px rgba(75,168,139,.17); }
.sync-dot.syncing { background: #d69a3c; box-shadow: 0 0 0 4px rgba(214,154,60,.18); animation: pulse 1s infinite alternate; }
.sync-dot.offline { background: #be4354; box-shadow: 0 0 0 4px rgba(190,67,84,.15); }
@keyframes pulse { to { opacity: .45; } }
.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(29px, 8vw, 38px);
  font-weight: 700;
  letter-spacing: -.04em;
}
h2 { margin-bottom: 0; font-size: 24px; letter-spacing: -.03em; }

.icon-button, .date-arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.72);
}
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.icon-button.small { width: 38px; height: 38px; font-size: 25px; line-height: 1; }

.view { display: none; animation: appear .22s ease both; }
.view.active { display: block; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } }

.date-strip { margin: 0 0 18px; }
.date-arrow { width: 40px; height: 40px; border: 0; background: transparent; font-size: 20px; }
.today-chip, .filter {
  border: 0;
  border-radius: 999px;
  background: var(--blue-pale);
  color: #27499f;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 700;
}

.progress-block {
  min-height: 118px;
  margin-bottom: 25px;
  padding: 21px 20px;
  border-radius: var(--radius);
  color: white;
  background: var(--navy);
  box-shadow: var(--shadow);
}
.progress-copy { display: grid; gap: 8px; padding-right: 18px; }
.progress-copy strong { font-size: 18px; letter-spacing: -.02em; }
.progress-copy span { color: #bfc9df; font-size: 13px; line-height: 1.5; }
.progress-ring {
  --progress: 0deg;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 67px;
  height: 67px;
  border-radius: 50%;
  background: conic-gradient(var(--mint) var(--progress), rgba(255,255,255,.13) 0);
  position: relative;
}
.progress-ring::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--navy); }
.progress-ring span { z-index: 1; font-family: ui-monospace, monospace; font-size: 13px; font-weight: 700; }

.timeline { position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 12px;
  left: 51px;
  width: 1px;
  background: var(--line);
}
.timeline-item { display: grid; grid-template-columns: 39px 1fr; gap: 25px; position: relative; padding-bottom: 14px; }
.timeline-time { padding-top: 18px; color: var(--ink-soft); font-family: ui-monospace, monospace; font-size: 12px; text-align: right; }
.timeline-dot { position: absolute; top: 21px; left: 47px; width: 9px; height: 9px; border: 2px solid var(--paper); border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 2px var(--blue-pale); }
.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
  width: 100%;
  padding: 17px 15px;
  border: 1px solid rgba(220,226,239,.88);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 7px 22px rgba(29,43,79,.06);
}
.task-card.done { opacity: .58; }
.task-card.done .task-title { text-decoration: line-through; }
.check-button {
  width: 23px;
  height: 23px;
  margin-top: 1px;
  padding: 0;
  border: 1.5px solid #aab4c9;
  border-radius: 8px;
  background: white;
}
.task-card.done .check-button { border-color: var(--blue); background: var(--blue); }
.task-card.done .check-button::after { content: "✓"; display: block; color: white; font-size: 14px; }
.task-title { display: block; margin-bottom: 4px; font-size: 15px; line-height: 1.45; }
.task-note, .task-meta { display: block; color: var(--ink-soft); font-size: 12px; line-height: 1.45; }
.edit-button { border: 0; background: transparent; padding: 2px 4px; color: #78839a; font-size: 18px; }

.empty-state { padding: 38px 20px; text-align: center; }
.empty-mark { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 18px; border: 1px dashed #93a4cb; border-radius: 18px; color: var(--blue); font-size: 25px; transform: rotate(3deg); }
.empty-state h2 { margin-bottom: 8px; font-family: "Songti SC", serif; font-size: 22px; }
.empty-state p, .section-note { color: var(--ink-soft); font-size: 14px; line-height: 1.65; }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 700; }
.hidden { display: none !important; }

.section-heading { margin: 11px 0 22px; }
.count-badge { padding: 6px 10px; border-radius: 9px; color: var(--ink-soft); background: #e8ecf4; font: 12px ui-monospace, monospace; }
.filter-row { display: flex; gap: 8px; margin-bottom: 17px; }
.filter { color: var(--ink-soft); background: #e9edf5; }
.filter.active { color: white; background: var(--navy); }
.flat-list, .history-list { display: grid; gap: 10px; }
.flat-item, .history-item { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.flat-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.flat-item .check-button { margin-top: 0; }
.flat-item-main strong { display: block; margin-bottom: 5px; font-size: 15px; }
.flat-item-main span, .history-item span { color: var(--ink-soft); font-size: 12px; }
.history-day { margin: 18px 0 4px; color: var(--blue); font: 700 11px ui-monospace, monospace; letter-spacing: .1em; }
.history-item { display: flex; align-items: center; justify-content: space-between; }
.history-item strong { font-size: 14px; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, 540px);
  margin: 0 auto;
  padding: 10px 25px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(220,226,239,.9);
  background: rgba(250,251,254,.92);
  backdrop-filter: blur(18px);
}
.nav-item { display: grid; justify-items: center; gap: 4px; border: 0; background: transparent; color: #7b859b; font-size: 11px; }
.nav-item svg { width: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.nav-item.active { color: var(--navy); font-weight: 700; }
.fab {
  position: fixed;
  z-index: 30;
  right: max(calc((100vw - 500px) / 2), 20px);
  bottom: calc(77px + env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 57px;
  height: 57px;
  padding: 0;
  border: 0;
  border-radius: 19px;
  color: white;
  background: var(--blue);
  box-shadow: 0 13px 25px rgba(66,102,213,.35);
}
.fab svg { width: 27px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }

.sheet { width: min(calc(100% - 20px), 520px); max-height: 90dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 27px 27px 0 0; color: var(--ink); background: white; box-shadow: var(--shadow); }
.sheet::backdrop { background: rgba(13,20,38,.44); backdrop-filter: blur(2px); }
.sheet form, .sheet-body { padding: 9px 21px calc(25px + env(safe-area-inset-bottom)); }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 15px; border-radius: 4px; background: #d7dce7; }
.sheet-title-row { margin-bottom: 22px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field > span { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 11px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 13px; outline: none; background: #f8f9fc; padding: 13px 12px; color: var(--ink); }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-pale); }
.form-actions { gap: 10px; margin-top: 8px; }
.primary-button, .danger-button { min-height: 49px; padding: 0 20px; border: 0; border-radius: 14px; font-weight: 700; }
.primary-button { flex: 1; color: white; background: var(--navy); }
.danger-button { color: var(--danger); background: #fbecef; }
.settings-group { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 70px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; cursor: pointer; }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong, .setting-row small { display: block; }
.setting-row strong { margin-bottom: 4px; font-size: 14px; }
.setting-row small { color: var(--ink-soft); font-size: 11px; }
.file-row { position: relative; }
.file-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.privacy-note { margin: 17px 4px 0; color: var(--ink-soft); font-size: 12px; line-height: 1.65; }
.toast { position: fixed; z-index: 80; right: 20px; bottom: calc(98px + env(safe-area-inset-bottom)); left: 20px; width: fit-content; max-width: calc(100% - 40px); margin: auto; padding: 11px 15px; border-radius: 12px; color: white; background: #10182a; font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.login-card { width: min(calc(100% - 38px), 410px); padding: 0; border: 0; border-radius: 25px; color: var(--ink); background: white; box-shadow: var(--shadow); }
.login-card::backdrop { background: rgba(13,20,38,.7); backdrop-filter: blur(8px); }
.login-card form { padding: 28px; }
.login-card h2 { margin-bottom: 9px; font-family: "Songti SC", serif; font-size: 27px; }
.login-card p:not(.eyebrow):not(.login-error) { margin-bottom: 23px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.login-card .primary-button { width: 100%; }
.login-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 20px; border-radius: 16px; color: white; background: var(--navy); font-size: 22px; }
.login-error { margin: -6px 0 13px; color: var(--danger); font-size: 12px; }

button:focus-visible, .file-row:focus-within { outline: 3px solid rgba(66,102,213,.4); outline-offset: 2px; }
@media (min-width: 700px) { .app-shell { min-height: calc(100dvh - 28px); margin-top: 14px; border-radius: 28px; box-shadow: 0 25px 80px rgba(29,43,79,.18); } .bottom-nav { bottom: 14px; border-radius: 0 0 28px 28px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
