@font-face {
  font-family: "Genban Serif";
  src: url("/fonts/noto-serif-sc-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f3efe6;
  --paper: #f7f4ee;
  --ink: #1c1915;
  --muted: #5e584f;
  --faint: #5e584f;
  --line: #ddd6c8;
  --accent: #24382c;
  --accent-ink: #f6f1e8;
  --brick: #8d3b32;
  --brick-soft: #f3e6e2;
  --ochre: #7a5b28;
  --moss: #2f4a38;
  --moss-soft: #e7eee8;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 72px;
  --serif: "Genban Serif", "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --fast: 180ms;
  --drift: 42s;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #141311;
    --paper: #1b1a17;
    --ink: #f0ebe3;
    --muted: #b7b0a4;
    --faint: #8d867b;
    --line: #2e2b26;
    --accent: #e7dcc8;
    --accent-ink: #1c1915;
    --brick: #e0a197;
    --brick-soft: #2a211f;
    --ochre: #d4b483;
    --moss: #c9d7cc;
    --moss-soft: #222824;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; color: inherit; font-size: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: #e4d3bc; color: var(--ink); }

#atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.34;
}
.wash, .contours, .grain { position: absolute; inset: -20%; }
.wash {
  border-radius: 50%;
  transform: translate3d(0, 0, 0);
}
.wash.a {
  background: radial-gradient(circle at 40% 40%, rgba(36, 56, 44, 0.16), transparent 62%);
  animation: drift-a var(--drift) var(--ease) infinite alternate;
}
.wash.b {
  background: radial-gradient(circle at 60% 50%, rgba(176, 132, 78, 0.14), transparent 64%);
  animation: drift-b calc(var(--drift) * 1.25) var(--ease) infinite alternate;
}
.wash.c {
  background: radial-gradient(circle at 50% 60%, rgba(28, 25, 21, 0.06), transparent 60%);
  animation: drift-c calc(var(--drift) * 0.85) var(--ease) infinite alternate;
}
.contours { inset: 0; width: 100%; height: 100%; color: rgba(36, 56, 44, 0.2); opacity: 0; }
.contours path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-dasharray: 6 16;
  animation: flow calc(var(--drift) * 1.4) linear infinite;
}
.contours path:nth-child(2) { animation-duration: calc(var(--drift) * 1.8); }
.contours path:nth-child(3) { animation-duration: calc(var(--drift) * 1.1); opacity: 0.7; }
.grain {
  inset: 0;
  opacity: 0.22;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  background-size: 180px 180px;
  animation: grain calc(var(--drift) * 2) linear infinite;
  mix-blend-mode: multiply;
}
body.hero #atmosphere { opacity: 1; }
body.hero .contours { opacity: 1; }
body:not(.hero) .wash,
body:not(.hero) .contours path,
body:not(.hero) .grain { animation: none; }
@keyframes drift-a { to { transform: translate3d(6%, -4%, 0) scale(1.08); } }
@keyframes drift-b { to { transform: translate3d(-7%, 5%, 0) scale(1.12); } }
@keyframes drift-c { to { transform: translate3d(3%, 6%, 0) scale(0.94); } }
@keyframes flow { to { stroke-dashoffset: -480; } }
@keyframes grain { to { background-position: 180px 90px; } }
@media (prefers-color-scheme: dark) {
  .grain { mix-blend-mode: soft-light; opacity: 0.14; }
  .contours { color: rgba(231, 220, 200, 0.18); }
  .wash.a { background: radial-gradient(circle at 40% 40%, rgba(201, 215, 204, 0.1), transparent 62%); }
  .wash.b { background: radial-gradient(circle at 60% 50%, rgba(212, 180, 131, 0.1), transparent 64%); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
html.paused .wash, html.paused .contours path, html.paused .grain { animation-play-state: paused; }

#app {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.desk { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.pad { flex: 1; padding: var(--space-6) var(--space-5) 128px; }

h1, h2, .brand, .num, .bubble, .toast {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: 0.04em;
}
h1 { font-size: 2rem; line-height: 1.25; margin: 0 0 var(--space-3); }
.kicker {
  margin: 0 0 var(--space-3);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.22em;
}
.lede { margin: 0 0 var(--space-6); color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.6; }
.label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.18em;
  margin: 0 0 var(--space-3);
}
.section { margin-top: var(--space-7); }
.err { color: var(--brick); min-height: 1.4em; font-size: 13px; }

.card { background: transparent; }
.block, .task { padding: var(--space-4) 0; }
.block + .block, .task + .task { border-top: 1px solid var(--line); }
.row { display: flex; justify-content: space-between; gap: var(--space-3); align-items: baseline; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: var(--space-6) 0 var(--space-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat { padding: var(--space-4) 0; }
.stat + .stat { box-shadow: inset 1px 0 0 var(--line); padding-left: var(--space-4); }
.num { font-size: 2.25rem; line-height: 1; }
.bad { color: var(--brick); }
.now { color: var(--moss); }
.soon { color: var(--ochre); }

.chip, .pill {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  margin: 0 var(--space-2) var(--space-2) 0;
}
.pill.hot { color: var(--brick); border-color: color-mix(in srgb, var(--brick) 45%, var(--line)); }

.btn, .act, button.block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 2px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  letter-spacing: 0.06em;
  text-decoration: none;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn, .act { border-color: var(--line); background: transparent; }
.btn-primary, .act.ok {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn-text {
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}
.nudge-btn {
  color: var(--brick);
  border-color: color-mix(in srgb, var(--brick) 50%, var(--line));
}
.btn:hover, .act:hover, button.block:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tabs button { transition: color var(--fast) var(--ease); }
.btn-primary:hover, .act.ok:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn:active, .act:active { transform: translateY(1px); }
.btn:disabled, .act:disabled { opacity: 0.4; cursor: not-allowed; }
#logout { margin-top: var(--space-6); }

label { display: block; margin-top: var(--space-5); font-size: 13px; letter-spacing: 0.08em; color: var(--muted); }
.input, textarea, select {
  width: 100%;
  margin-top: var(--space-2);
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  line-height: 1.5;
}
textarea { min-height: 96px; resize: vertical; }
.input:focus, textarea:focus, select:focus { outline: none; border-bottom-color: var(--ink); }
input[type=file] {
  display: block;
  width: 100%;
  margin-top: var(--space-2);
  padding: 10px 0;
  font-size: 13px;
  color: var(--muted);
}
input[type=file]::file-selector-button {
  min-height: 44px;
  margin-right: 12px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 64px var(--space-5) var(--space-7);
}
.login h1 { font-size: 3rem; letter-spacing: 0.12em; margin-bottom: var(--space-3); }
.login label { margin-top: var(--space-4); }
.login form { margin-top: var(--space-2); }
.login .btn-primary { width: 100%; margin-top: var(--space-6); }

.tabs {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  display: flex;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.brand { display: none; }
.tabs button {
  flex: 1;
  min-height: 56px;
  border: 0;
  background: transparent;
  color: var(--faint);
  letter-spacing: 0.12em;
  font-size: 13px;
}
.tabs button.on { color: var(--ink); }
.tabs .idx { display: block; font-family: var(--serif); font-size: 10px; letter-spacing: 0.14em; opacity: 0.7; }
.nav-badge { margin-left: 6px; min-width: 1.2em; font-size: 11px; }
.nav-badge[hidden] { display: none; }
details { margin-top: var(--space-2); }
summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.veil {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(28, 25, 21, 0.28);
}
.remind {
  width: min(440px, 100%);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: var(--space-6) var(--space-5) var(--space-5);
}
.remind h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.7rem;
  letter-spacing: 0.04em;
  margin: 0 0 var(--space-4);
}
@media (min-width: 800px) {
  .veil { align-items: center; }
}
.payload {
  margin: var(--space-2) 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "SFMono-Regular", "Source Code Pro", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.bubble {
  margin: var(--space-5) 0 0;
  padding: 0 0 0 var(--space-4);
  border-left: 1px solid var(--line);
  background: transparent;
  border-radius: 0;
}
.bubble.mine { border-left-color: var(--accent); }
.bubble.nudge {
  border-left-color: var(--brick);
  background: linear-gradient(90deg, var(--brick-soft), transparent 70%);
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
  padding-right: var(--space-3);
}
.rise > * { animation: rise 640ms var(--ease) both; }
.rise > *:nth-child(2) { animation-delay: 50ms; }
.rise > *:nth-child(3) { animation-delay: 100ms; }
.rise > *:nth-child(4) { animation-delay: 150ms; }
.rise > *:nth-child(n+5) { animation-delay: 190ms; }
.card > .task, .card > .block { animation: rise 560ms var(--ease) both; }
.card > .task:nth-child(2), .card > .block:nth-child(2) { animation-delay: 40ms; }
.card > .task:nth-child(3), .card > .block:nth-child(3) { animation-delay: 80ms; }
.card > .task:nth-child(n+4), .card > .block:nth-child(n+4) { animation-delay: 120ms; }
.bubble.enter { animation: rise 520ms var(--ease) both; }
.bubble.nudge.enter { animation: rise 680ms var(--ease) both; }
.toast {
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.12em;
}

.empty { color: var(--muted); padding: var(--space-5) 0; }
.empty svg { display: block; width: 72px; height: 28px; margin-bottom: var(--space-3); color: var(--faint); }
.empty p { margin: 0; }

.skel span {
  display: block;
  height: 12px;
  margin: 18px 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 8%, transparent), transparent);
  background-size: 200% 100%;
  animation: sheen 1.4s var(--ease) infinite;
}
.skel span:nth-child(1) { width: 42%; height: 28px; }
.skel span:nth-child(2) { width: 78%; }
.skel span:nth-child(3) { width: 56%; }
@keyframes sheen { from { background-position: 100% 0; } to { background-position: -100% 0; } }

button.block {
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  padding: var(--space-4) 0;
  background: transparent;
  min-height: 72px;
  gap: 2px;
}
button.block b { display: block; font-family: var(--serif); font-weight: 400; font-size: 1.2rem; letter-spacing: 0.04em; }

#send { display: flex; gap: var(--space-3); align-items: flex-end; margin-top: var(--space-6); }
#send .input { flex: 1; }
#send .btn { flex: none; }

@media (min-width: 960px) {
  #app { width: min(1120px, calc(100% - 64px)); }
  .desk {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: start;
    justify-content: center;
    column-gap: 72px;
    min-height: 100vh;
    padding: var(--space-7) 0;
  }
  .pad { grid-column: 2; grid-row: 1; min-width: 0; padding: 0 0 var(--space-8); }
  .tabs {
    grid-column: 1;
    grid-row: 1;
    /* 手机导航靠 margin-top:auto 和 bottom:0 沉底。桌面行和正文一样高，不取消这两项，侧栏会被推到长页面底部。 */
    margin-top: 0;
    margin-bottom: 0;
    position: sticky;
    top: var(--space-7);
    bottom: auto;
    align-self: start;
    justify-self: start;
    flex-direction: column;
    align-items: flex-start;
    border: 0;
    background: transparent;
    backdrop-filter: none;
    height: fit-content;
  }
  .brand {
    display: block;
    margin: 0 0 var(--space-6);
    font-size: 1.6rem;
    letter-spacing: 0.18em;
  }
  .tabs button { flex: none; min-height: 44px; padding: 0; justify-content: flex-start; }
  .tabs .idx { display: inline; margin-right: 10px; }
  .login { max-width: 440px; margin: 0 auto; min-height: 100vh; padding-top: 36px; padding-bottom: 28px; }
  .login h1 { font-size: 2.75rem; margin-bottom: 8px; }
  .login label { margin-top: 12px; }
  .login .input { padding-top: 8px; padding-bottom: 8px; }
  .login .btn-primary { margin-top: 20px; }
}

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