/* AnnieWay · quiet, black-white-grey, mobile first */

:root {
  --ink: #1a1813;
  --ink-soft: #4a463e;
  --muted: #8c887f;
  --faint: #c2beb5;
  --line: #eae7e0;
  --track: #ecebe4;
  --chip: #f4f2ec;
  --surface: #ffffff;
  --page: #f5f4f1;
  --radius: 20px;
  --nav-h: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 18px calc(var(--nav-h) + 34px);
  min-height: 100dvh;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  letter-spacing: inherit;
}

h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 2px; }
.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }

.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------- nav ---------- */

#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
#nav .nav-inner { display: flex; width: 100%; max-width: 560px; }
#nav button {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 9px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--faint); font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
}
#nav button svg { display: block; }
#nav button.active { color: var(--ink); }

/* ---------- cards & buttons ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(20, 18, 12, 0.03);
}
.card.tappable { cursor: pointer; transition: border-color 0.15s ease; }
.card.tappable:hover { border-color: #d8d4cb; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; border-radius: 14px; padding: 14px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; letter-spacing: -0.01em;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #000; }
.btn.ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn.ghost:hover { border-color: #d8d4cb; color: var(--ink); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 11px; }
.btn.quiet { background: none; border: none; color: var(--muted); width: auto; padding: 6px 8px; font-size: 13px; }
.btn.quiet:hover { color: var(--ink); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ---------- home ---------- */

.home-top { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
.home-status { text-align: right; }
.home-date { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.home-local { font-size: 11px; color: var(--faint); display: flex; align-items: center; gap: 5px; justify-content: flex-end; margin-top: 2px; }
.home-local .ldot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }

.home-hero { margin: 6px 2px 18px; }
.home-hero .home-title { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 6px; }
.home-hero .home-zh { font-size: 13px; color: var(--muted); margin-top: 5px; }

.home-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }

.hcard { min-height: 108px; display: flex; flex-direction: column; justify-content: space-between; margin-bottom: 0; }
.hcard .hcard-title { font-size: 18px; font-weight: 650; margin-top: 8px; line-height: 1.25; }
.hcard .hcard-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.hcard .hcard-big { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.hcard.now-card { min-height: 140px; }

.home-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }

/* ---------- forms (plan) ---------- */

.field-name { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.field-name .opt { font-weight: 600; letter-spacing: 0.04em; color: var(--faint); }

input[type='text'], input[type='time'], input[type='number'], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: var(--surface);
  outline: none;
  font-size: 16px; /* ≥16px 防 iOS Safari 聚焦时自动放大 */
  caret-color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238c887f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
input:focus, textarea:focus, select:focus { border-color: var(--ink-soft); }
::selection { background: var(--faint); }
textarea { resize: vertical; min-height: 64px; }
input::placeholder, textarea::placeholder { color: var(--faint); }

.seg { display: flex; background: var(--chip); border-radius: 13px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: none; background: none; border-radius: 10px; padding: 9px 6px;
  font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 18, 12, 0.08); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row .narrow { flex: 0 0 92px; }
.row .icon-btn { flex: 0 0 auto; }

.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.icon-btn:hover { color: var(--ink); border-color: #d8d4cb; }

.todo-list, .fixed-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }

.hint { font-size: 12px; color: var(--faint); margin-top: 6px; }

/* ---------- today ---------- */

.today-head { display: flex; align-items: baseline; justify-content: space-between; }

.now-panel { text-align: center; padding: 22px 16px 18px; }
.now-panel .eyebrow { margin-bottom: 6px; }
.now-panel .now-title { font-size: 21px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.now-panel .now-zh { font-size: 13px; color: var(--muted); margin-top: 3px; }
.now-panel .now-meta { font-size: 13px; color: var(--muted); margin-top: 7px; font-variant-numeric: tabular-nums; }

.next-strip { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.next-strip .eyebrow { flex-shrink: 0; }
.next-strip .next-title { font-weight: 600; font-size: 14.5px; }
.next-strip .next-time { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.block { padding: 14px 16px; }
.block .b-top { display: flex; align-items: baseline; gap: 8px; }
.block .b-time { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.block .b-cat {
  margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); background: var(--chip); border-radius: 6px; padding: 3px 7px; white-space: nowrap;
}
.block .b-title { font-size: 16.5px; font-weight: 650; margin-top: 6px; line-height: 1.25; }
.block .b-zh { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.block .b-desc { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.block .b-details { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.block .b-line { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; }
.block .b-line .k { flex-shrink: 0; font-weight: 700; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); padding-top: 2px; width: 72px; }
.block .b-actions { display: flex; gap: 6px; margin-top: 12px; }
.block .b-actions button {
  flex: 1; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 10px; padding: 8px 4px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.block .b-actions button:hover { border-color: #d8d4cb; color: var(--ink); }
.block .b-status { margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: space-between; }
.block .b-status .undo { border: none; background: none; color: var(--faint); font-size: 12px; cursor: pointer; padding: 2px 4px; }
.block .b-status .undo:hover { color: var(--ink); }

.block.is-current { border-color: var(--ink); box-shadow: 0 2px 10px rgba(20, 18, 12, 0.06); }
.block.done { opacity: 0.55; }
.block.done .b-title { text-decoration: line-through; text-decoration-thickness: 1px; }
.block.dim { opacity: 0.62; }

.leftover { background: var(--chip); border: none; }
.leftover .lo-item { font-size: 13.5px; color: var(--ink-soft); padding: 3px 0; }

.gentle-note {
  background: var(--chip); border-radius: 14px; padding: 12px 14px;
  font-size: 13px; color: var(--ink-soft); margin-bottom: 12px;
}

/* ---------- wheels ---------- */

.wheel-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.wheel-card { text-align: center; padding: 18px 16px 16px; margin-bottom: 0; }
.wheel-card h3 { margin: 2px 0 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.wheel-card .wheel-zh { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

.wheel-stage { position: relative; width: min(280px, 78vw); margin: 6px auto 4px; }
.wheel-stage svg.wheel-svg { width: 100%; height: auto; display: block; transition: transform 4.2s cubic-bezier(0.12, 0.72, 0.06, 1); }
.wheel-pointer {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 14px solid var(--ink); z-index: 2;
}

.wheel-result { margin-top: 10px; min-height: 52px; }
.wheel-result .wr-num { font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.wheel-result .wr-zh { font-size: 17px; font-weight: 650; margin-top: 3px; }
.wheel-result .wr-en { font-size: 13.5px; color: var(--ink-soft); margin-top: 1px; }
.wheel-result .wr-empty { font-size: 13px; color: var(--faint); padding-top: 16px; }

.wheel-add { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 12px; text-align: left; }
.wheel-add .row { margin-bottom: 8px; }
.wheel-add label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 4px; }

.wheel-legend { margin-top: 12px; text-align: left; columns: 2; column-gap: 14px; }
.wheel-legend .wl-item { font-size: 11.5px; color: var(--muted); padding: 2px 0; break-inside: avoid; }
.wheel-legend .wl-item b { color: var(--ink-soft); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- money ---------- */

.money-big { text-align: center; padding: 22px 16px; }
.money-big .m-num { font-size: 40px; font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.money-big .m-num .cur { font-size: 20px; font-weight: 600; color: var(--muted); margin-right: 3px; }
.money-big .m-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.money-input-card { padding: 14px; }
.money-input-row { display: flex; gap: 8px; }
.money-input-row input { flex: 1; }
.money-input-row .btn { width: auto; padding: 11px 18px; border-radius: 12px; flex-shrink: 0; }

.cat-bars { display: flex; flex-direction: column; gap: 8px; }
.cat-bar .cb-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 3px; }
.cat-bar .cb-name { color: var(--ink-soft); font-weight: 600; }
.cat-bar .cb-amt { color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-bar .cb-track { height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; }
.cat-bar .cb-fill { height: 100%; background: var(--ink-soft); border-radius: 3px; }

.m-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.ms { display: flex; flex-direction: column; gap: 3px; text-align: center; }
.ms.tappable { cursor: pointer; border-radius: 10px; }
.ms.tappable:hover .ms-v { color: var(--ink); }
.ms-k { font-size: 9.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.ms-v { font-size: 14.5px; font-weight: 650; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ms-edit { grid-column: span 2; }

.family-code {
  text-align: center; font-size: 30px; font-weight: 700; letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums; margin: 10px 0 8px; cursor: pointer;
  border: 1.5px dashed var(--faint); border-radius: 16px; padding: 14px 10px;
}
.family-code:hover { border-color: var(--ink-soft); }

.m-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 4px; }
.m-nav .icon-btn { width: 30px; height: 30px; border-radius: 9px; font-size: 15px; }
.m-nav .icon-btn:disabled { opacity: 0.3; cursor: default; }
.m-nav .eyebrow { min-width: 96px; text-align: center; }

.donut-row { display: flex; align-items: center; gap: 18px; }
.donut { flex: 0 0 132px; width: 132px; height: 132px; }
.donut-row .cat-bars { flex: 1; min-width: 0; }
.cb-dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
@media (max-width: 430px) {
  .donut-row { flex-direction: column; }
  .donut-row .cat-bars { width: 100%; }
}

.day-bars { display: flex; align-items: flex-end; gap: 2px; height: 60px; }
.db-col { flex: 1; display: flex; align-items: flex-end; }
.db-bar { width: 100%; background: var(--ink-soft); border-radius: 2px 2px 0 0; }
.db-bar.zero { background: var(--track); }
.db-bar.today { background: var(--ink); }
.db-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); margin-top: 5px; font-variant-numeric: tabular-nums; }

.trend-bars { display: flex; gap: 10px; align-items: flex-end; height: 92px; }
.tr-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
.tr-amt { font-size: 9.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-bar { width: 100%; max-width: 36px; background: var(--track); border-radius: 5px 5px 0 0; }
.tr-bar.cur { background: var(--ink-soft); }
.tr-lab { font-size: 10px; color: var(--faint); }

.txn-edit .chips .chip { padding: 6px 11px; font-size: 12px; }

.txn-day { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin: 16px 2px 6px; }
.txn { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 8px; }
.txn .t-item { font-weight: 600; font-size: 14.5px; }
.txn .t-cat { font-size: 11px; color: var(--muted); margin-top: 1px; }
.txn .t-amt { margin-left: auto; font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txn .t-amt.in { color: var(--muted); }
.txn .t-del { border: none; background: none; color: var(--faint); cursor: pointer; font-size: 15px; padding: 4px 2px 4px 8px; }
.txn .t-del:hover { color: var(--ink); }

/* ---------- review ---------- */

.review-q { margin-bottom: 12px; }
.review-q .q-en { font-size: 14.5px; font-weight: 650; }
.review-q .q-zh { font-size: 12px; color: var(--muted); margin: 1px 0 8px; }

.done-note { text-align: center; padding: 46px 20px; color: var(--ink-soft); font-size: 16px; line-height: 1.7; }
.done-note .big { font-size: 36px; margin-bottom: 10px; }

/* ---------- history ---------- */

.hist-line { display: flex; gap: 8px; font-size: 13px; color: var(--ink-soft); margin-top: 5px; }
.hist-line .hk { flex-shrink: 0; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); width: 62px; padding-top: 2px; }
.hist-date { font-size: 15px; font-weight: 700; }
.hist-tag { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); background: var(--chip); border-radius: 6px; padding: 2px 7px; vertical-align: 2px; margin-left: 4px; }

/* ---------- sync ---------- */

.sync-status { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.sync-status .ldot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); }
.sync-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.sync-facts b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- toast ---------- */

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease; z-index: 30; white-space: nowrap;
  max-width: 88vw; overflow: hidden; text-overflow: ellipsis;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.center { text-align: center; }
.mt { margin-top: 14px; }

/* ---------- desktop / wide ---------- */

@media (min-width: 860px) {
  :root { --nav-h: 58px; }
  body { font-size: 15.5px; }

  #app { max-width: 1020px; padding: 26px 32px 60px; }

  #nav {
    top: 0; bottom: auto; border-top: none; border-bottom: 1px solid var(--line);
    padding-bottom: 0;
  }
  #nav .nav-inner { max-width: 1020px; padding: 0 20px; justify-content: flex-end; gap: 4px; }
  #nav button { flex: 0 0 auto; flex-direction: row; gap: 7px; padding: 18px 14px; font-size: 13px; }
  #nav button svg { width: 16px; height: 16px; }
  #app { padding-top: calc(var(--nav-h) + 30px); }

  .home-hero { margin: 18px 2px 26px; }
  .home-hero .home-title { font-size: 44px; }
  .home-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .hcard { min-height: 128px; padding: 20px; }
  .hcard.now-card { grid-column: span 2; grid-row: span 2; min-height: 0; }
  .hcard.now-card .hcard-title { font-size: 26px; }
  .home-actions { flex-direction: row; max-width: 560px; }

  .wheel-grid { grid-template-columns: 1fr 1fr; align-items: start; }

  .plan-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
  .plan-cols .span2 { grid-column: span 2; }

  /* 列表型页面在宽屏上保持舒服的阅读宽度；Today 打开转盘时才用全宽并排 */
  #app[data-route='today'][data-wheels='0'],
  #app[data-route='money'],
  #app[data-route='review'],
  #app[data-route='history'],
  #app[data-route='sync'] { max-width: 680px; }

  #toast { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .wheel-stage svg.wheel-svg { transition: none; }
  .btn, .chip, .seg button { transition: none; }
}
