:root {
  color-scheme: light;
  --bg: #f3efe6;
  --surface: #fbf8f1;
  --surface-strong: #fffdf8;
  --ink: #1e211e;
  --muted: #76776f;
  --line: rgba(30, 33, 30, 0.13);
  --accent: #ef5b35;
  --accent-soft: #ffd8cb;
  --green: #78866b;
  --yellow: #efc768;
  --blue: #88a7b4;
  --purple: #9b8aa8;
  --shadow: 0 14px 38px rgba(48, 44, 36, 0.08);
  --radius: 28px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171916;
  --surface: #20231f;
  --surface-strong: #272a25;
  --ink: #f2f0e9;
  --muted: #a8aaa2;
  --line: rgba(255, 255, 255, 0.11);
  --accent-soft: #5a2e22;
  --shadow: 0 14px 38px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 2px; }

.app-shell { width: min(100%, 720px); min-height: 100vh; margin: 0 auto; padding: 20px 18px calc(112px + var(--safe-bottom)); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; padding: 8px 4px 24px; }
h1, h2, p { margin: 0; }
h1 { font-family: Georgia, "Songti SC", serif; font-size: clamp(2.4rem, 11vw, 4.2rem); line-height: .88; letter-spacing: -.06em; }
h2 { font-size: 1.35rem; letter-spacing: -.035em; }
.title-dot { color: var(--accent); }
.eyebrow { margin-bottom: 5px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.muted { color: var(--muted); }
.paper-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.icon-button, .text-button, .fab, .nav-item, .quick-card, .record-card, .settings-row, .emoji-picker button { border: 0; background: transparent; cursor: pointer; }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-size: 1.15rem; }
.text-button { padding: 8px 0; color: var(--accent); font-size: .82rem; font-weight: 800; }

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

.hero-card { min-height: 202px; padding: 26px; display: flex; justify-content: space-between; overflow: hidden; position: relative; }
.hero-number { display: flex; align-items: baseline; gap: 6px; margin: 10px 0 8px; }
.hero-number strong { font-family: Georgia, serif; font-size: 4rem; line-height: .9; }
.hero-number span { color: var(--muted); font-weight: 700; }
.hero-copy { width: 18ch; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.cup-orbit { position: relative; width: 132px; flex: 0 0 132px; }
.hero-emoji { position: absolute; inset: 50% auto auto 50%; z-index: 2; transform: translate(-50%, -50%) rotate(-8deg); font-size: 4.6rem; filter: drop-shadow(0 9px 10px rgba(0,0,0,.09)); }
.orbit { position: absolute; border: 1px solid var(--line); border-radius: 50%; }
.orbit-a { width: 118px; height: 118px; inset: 12px 0 0 7px; }
.orbit-b { width: 82px; height: 82px; inset: 30px 0 0 25px; background: var(--accent-soft); border: 0; }

.section-block { padding-top: 30px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 4px 14px; }
.compact-heading { margin: 0 0 18px; }
.tiny-pill { padding: 7px 10px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .7rem; font-weight: 750; border: 1px solid var(--line); white-space: nowrap; }

.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; overflow-x: auto; scrollbar-width: none; }
.quick-card { min-width: 0; padding: 14px 8px 12px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); text-align: center; transition: transform .16s ease, background .16s ease; }
.quick-card:active { transform: scale(.96); }
.quick-card .sticker { display: grid; width: 52px; height: 52px; margin: 0 auto 9px; place-items: center; border-radius: 18px; background: var(--accent-soft); font-size: 2rem; transform: rotate(-3deg); }
.quick-card:nth-child(2n) .sticker { background: color-mix(in srgb, var(--yellow) 35%, var(--surface)); transform: rotate(3deg); }
.quick-card:nth-child(3n) .sticker { background: color-mix(in srgb, var(--blue) 35%, var(--surface)); }
.quick-card strong { display: block; overflow: hidden; font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.quick-card small { color: var(--muted); font-size: .61rem; }
.quick-empty { grid-column: 1 / -1; padding: 22px; border: 1px dashed var(--line); border-radius: 22px; color: var(--muted); text-align: center; font-size: .8rem; }

.record-list { display: grid; gap: 10px; }
.record-card { width: 100%; padding: 14px; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); text-align: left; }
.record-sticker { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 18px; background: var(--accent-soft); font-size: 1.8rem; }
.record-main { min-width: 0; }
.record-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.record-main p { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.record-side { text-align: right; }
.record-side time { display: block; font-size: .76rem; font-weight: 800; }
.record-side small { color: var(--muted); font-size: .66rem; }
.empty-state { padding: 34px 18px; border: 1px dashed var(--line); border-radius: 24px; color: var(--muted); text-align: center; }
.empty-state span { display: block; margin-bottom: 8px; font-size: 2rem; }

.calendar-card { padding: 20px 14px 16px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 18px; }
.calendar-title-wrap { text-align: center; }
.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-row { padding: 0 4px 8px; color: var(--muted); font-size: .62rem; text-align: center; }
.calendar-day { position: relative; min-height: 70px; padding: 6px 3px; border: 0; border-radius: 18px; background: transparent; color: var(--ink); cursor: pointer; }
.calendar-day:hover { background: color-mix(in srgb, var(--surface-strong) 65%, transparent); }
.calendar-day.outside { opacity: .26; }
.calendar-day.selected { background: var(--ink); color: var(--bg); }
.calendar-day.today .day-number { color: var(--accent); }
.calendar-day.selected .day-number { color: inherit; }
.day-number { font-size: .69rem; font-weight: 800; }
.day-stickers { min-height: 37px; margin-top: 4px; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; line-height: 1; }
.day-stickers span { margin: -2px; font-size: 1.05rem; filter: drop-shadow(0 2px 2px rgba(0,0,0,.08)); }
.day-more { display: block; color: var(--muted); font-size: .5rem !important; margin-top: 4px !important; }
.calendar-day.selected .day-more { color: inherit; opacity: .7; }
.selected-day-block { padding-bottom: 14px; }

.stats-heading { margin-top: 4px; }
.select-compact { padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: .72rem; font-weight: 750; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric-card { min-height: 132px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-card span { color: var(--muted); font-size: .76rem; }
.metric-card strong { font-family: Georgia, serif; font-size: 2.15rem; font-weight: 500; }
.metric-card small { color: var(--muted); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; }
.chart-card { margin-top: 12px; padding: 20px; }
.bar-chart { height: 178px; display: flex; align-items: end; gap: 5px; overflow: hidden; }
.bar-column { min-width: 8px; flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 5px; }
.bar { width: min(100%, 18px); min-height: 3px; border-radius: 999px; background: var(--accent); transition: height .35s ease; }
.bar-column:nth-child(4n + 2) .bar { background: var(--green); }
.bar-column:nth-child(4n + 3) .bar { background: var(--yellow); }
.bar-column:nth-child(4n) .bar { background: var(--blue); }
.bar-label { color: var(--muted); font-size: .5rem; }
.category-chart-wrap { display: grid; grid-template-columns: 142px 1fr; align-items: center; gap: 24px; }
.donut { width: 142px; height: 142px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--line) 0 100%); position: relative; }
.donut::after { content: ""; position: absolute; width: 88px; height: 88px; border-radius: 50%; background: var(--surface); }
.donut span { z-index: 2; font-family: Georgia, serif; font-size: 1.8rem; }
.legend { margin-top: 12px; display: grid; gap: 8px; }
.legend-row { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 7px; font-size: .7rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.legend-row span:last-child { color: var(--muted); }

.settings-card { padding: 26px; }
.settings-copy { margin: 12px 0 22px; font-size: .86rem; line-height: 1.65; }
.settings-list { margin-top: 12px; overflow: hidden; }
.settings-row { width: 100%; min-height: 58px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); text-align: left; }
.settings-row:last-child { border-bottom: 0; }
.settings-row b { color: var(--muted); font-size: .76rem; }
.static-row { cursor: default; }
.footer-note { padding: 24px 20px; color: var(--muted); font-size: .68rem; line-height: 1.5; text-align: center; }

.primary-button, .danger-button { min-height: 48px; padding: 0 18px; border: 0; border-radius: 16px; cursor: pointer; font-weight: 850; }
.primary-button { background: var(--ink); color: var(--bg); }
.danger-button { background: color-mix(in srgb, #e84b4b 13%, var(--surface)); color: #d74444; }
.full-button { width: 100%; }

.fab { position: fixed; z-index: 20; left: 50%; bottom: calc(74px + var(--safe-bottom)); width: 62px; height: 62px; transform: translateX(-50%); border: 6px solid var(--bg); border-radius: 50%; background: var(--accent); color: white; box-shadow: 0 12px 28px rgba(239, 91, 53, .3); font-size: 2rem; }
.fab span { display: block; transform: translateY(-2px); }
.bottom-nav { position: fixed; z-index: 19; left: 50%; bottom: 0; width: min(100%, 720px); height: calc(82px + var(--safe-bottom)); padding: 9px 18px var(--safe-bottom); transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(18px); }
.bottom-nav::before { content: ""; grid-column: 3; grid-row: 1; }
.nav-item { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); }
.nav-item:nth-child(n+3) { grid-column: auto; }
.nav-item[data-target="today"] { grid-column: 1; }
.nav-item[data-target="calendar"] { grid-column: 2; }
.nav-item[data-target="stats"] { grid-column: 4; }
.nav-item[data-target="settings"] { grid-column: 5; }
.nav-item span { font-size: 1rem; }
.nav-item small { font-size: .58rem; }
.nav-item.active { color: var(--ink); font-weight: 850; }

.sheet, .login-dialog { width: 100%; max-width: none; height: 100%; margin: 0; padding: 0; border: 0; background: transparent; }
.sheet::backdrop, .login-dialog::backdrop { background: rgba(18, 19, 17, .48); backdrop-filter: blur(4px); }
.sheet-panel { position: absolute; left: 50%; bottom: 0; width: min(100%, 720px); max-height: 92vh; padding: 10px 18px calc(20px + var(--safe-bottom)); transform: translateX(-50%); overflow-y: auto; border-radius: 32px 32px 0 0; background: var(--surface-strong); color: var(--ink); box-shadow: 0 -24px 70px rgba(0,0,0,.18); }
.sheet-handle { width: 40px; height: 5px; margin: 2px auto 16px; border-radius: 999px; background: var(--line); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.emoji-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; margin-bottom: 18px; }
.emoji-picker button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 1.45rem; }
.emoji-picker button.selected { background: var(--accent-soft); border-color: var(--accent); transform: rotate(-4deg); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { min-width: 0; display: grid; gap: 7px; }
.full-field { margin-bottom: 12px; }
.field span { color: var(--muted); font-size: .7rem; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); }
.field textarea { resize: vertical; }
.sheet-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }
.sheet-actions .primary-button { flex: 1; }
.login-dialog { display: none; place-items: center; padding: 18px; }
.login-dialog[open] { display: grid; }
.login-card { width: min(100%, 390px); padding: 28px; text-align: center; }
.login-mark { display: block; margin-bottom: 14px; font-size: 3.5rem; }
.login-card .muted { margin: 9px 0 20px; font-size: .82rem; }
.login-card .field { text-align: left; }
.form-error { min-height: 18px; margin: 4px 0 8px; color: #d74444; font-size: .74rem; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(98px + var(--safe-bottom)); max-width: calc(100% - 36px); padding: 11px 16px; transform: translate(-50%, 20px); border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: .76rem; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .app-shell { padding-inline: 14px; }
  .hero-card { min-height: 186px; padding: 22px; }
  .cup-orbit { width: 108px; flex-basis: 108px; }
  .orbit-a { width: 104px; height: 104px; }
  .orbit-b { width: 72px; height: 72px; inset: 28px 0 0 21px; }
  .hero-emoji { font-size: 4rem; }
  .quick-grid { grid-template-columns: repeat(4, 86px); margin-right: -14px; padding-right: 14px; }
  .calendar-day { min-height: 62px; }
  .category-chart-wrap { grid-template-columns: 116px 1fr; gap: 18px; }
  .donut { width: 116px; height: 116px; }
  .donut::after { width: 72px; height: 72px; }
  .emoji-picker { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 721px) {
  .app-shell { padding-top: 32px; }
  .bottom-nav { border-inline: 1px solid var(--line); border-radius: 24px 24px 0 0; }
}

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