:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #fffdf9;
  --ink: #29272c;
  --muted: #8b878b;
  --line: rgba(64, 58, 65, 0.09);
  --purple: #8174bd;
  --purple-deep: #65599f;
  --purple-soft: #ebe7f5;
  --rose: #c98994;
  --shadow: 0 16px 45px rgba(76, 65, 80, 0.09);
  --nav-height: 78px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1a1d;
  --surface: rgba(39, 37, 42, 0.82);
  --surface-solid: #29272d;
  --ink: #f3eff2;
  --muted: #a9a4aa;
  --line: rgba(255, 255, 255, 0.08);
  --purple-soft: #373247;
  --shadow: 0 16px 45px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 6%, rgba(201, 158, 166, 0.17), transparent 25rem),
    radial-gradient(circle at 5% 34%, rgba(138, 127, 194, 0.13), transparent 23rem),
    var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }

.app-shell { width: min(100%, 720px); min-height: 100vh; margin: 0 auto; position: relative; padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 18px); }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) 22px 0; }
.brand { display: flex; align-items: center; gap: 9px; background: transparent; font-family: "Songti SC", "STSong", serif; font-weight: 700; font-size: 20px; }
.brand-mark { display: block; width: 31px; height: 31px; background: url("./icons/logo-mark.svg") center / contain no-repeat; filter: drop-shadow(0 5px 8px rgba(121, 104, 177, .17)); }
.brand-mark span { display: none; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.48); border: 1px solid var(--line); }
.icon-button svg, .search-head svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.avatar-button { width: 39px; height: 39px; border-radius: 50%; background: linear-gradient(145deg, #ded8ef, #ebcfd2); color: #5d5479; font-size: 13px; font-weight: 700; border: 3px solid rgba(255,255,255,.75); }

main { padding: 4px 22px 0; }
.view { display: none; animation: rise .32s ease both; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.hero { min-height: 150px; display: flex; align-items: center; justify-content: space-between; padding: 10px 4px 16px; }
.eyebrow, .section-kicker { margin: 0 0 7px; color: var(--purple); font-size: 12px; font-weight: 700; letter-spacing: .16em; }
.hero h1, .page-title h1 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(32px, 8vw, 42px); line-height: 1.2; letter-spacing: -.04em; }
.hero-subtitle, .page-title > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 15px; }
.mood-orbit { position: relative; width: 118px; height: 118px; flex: 0 0 118px; }
.orbit { position: absolute; border-radius: 50%; }
.orbit-one { inset: 8px; background: linear-gradient(140deg, rgba(129,116,189,.25), rgba(201,137,148,.12)); animation: breathe 5s ease-in-out infinite; }
.orbit-two { inset: 29px 15px 16px 31px; background: linear-gradient(145deg, rgba(232,181,130,.5), rgba(203,146,160,.42)); filter: blur(.2px); animation: breathe 5s 1s ease-in-out infinite reverse; }
.orbit-core { position: absolute; inset: 0; display: grid; place-items: center; color: white; font-size: 24px; text-shadow: 0 3px 10px rgba(104,81,115,.25); }
@keyframes breathe { 50% { transform: scale(1.07) rotate(5deg); border-radius: 43% 57% 60% 40%; } }

.quick-capture { width: 100%; display: flex; align-items: center; gap: 14px; padding: 18px; text-align: left; background: linear-gradient(115deg, rgba(255,255,255,.82), rgba(246,237,242,.78)); border: 1px solid rgba(255,255,255,.78); border-radius: 22px; box-shadow: var(--shadow); }
.capture-plus { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 44px; border-radius: 15px; color: white; background: linear-gradient(145deg, var(--purple), var(--rose)); font-size: 27px; font-weight: 300; box-shadow: 0 8px 18px rgba(128,104,169,.22); }
.capture-copy { display: flex; flex-direction: column; flex: 1; }
.capture-copy strong { font-size: 16px; }
.capture-copy small { color: var(--muted); margin-top: 3px; }
.capture-arrow { color: var(--purple); font-size: 22px; }

.mood-section, .recent-section, .selected-day { margin-top: 31px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 16px; }
.section-heading.compact { align-items: center; }
.section-heading h2 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: 19px; }
.section-kicker { color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.count-badge { padding: 5px 9px; color: var(--purple-deep); background: var(--purple-soft); border-radius: 20px; font-size: 11px; }
.text-button { padding: 5px; color: var(--purple); background: transparent; font-size: 13px; font-weight: 600; }
.text-button.muted { color: var(--muted); }

.mood-strip { min-height: 94px; display: flex; align-items: flex-end; gap: 6px; padding: 13px 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); scrollbar-width: none; }
.mood-strip::-webkit-scrollbar, .filter-row::-webkit-scrollbar { display: none; }
.mood-point { min-width: 42px; flex: 1; text-align: center; }
.mood-point .dot { display: block; width: 26px; height: 26px; margin: 0 auto 8px; border-radius: 50% 50% 45% 55%; box-shadow: inset 0 1px rgba(255,255,255,.45); }
.mood-point:nth-child(2n) .dot { transform: translateY(-8px); }
.mood-point:nth-child(3n) .dot { transform: translateY(-2px) scale(.8); }
.mood-point time { color: var(--muted); font-size: 9px; }
.empty-mood { width: 100%; align-self: center; text-align: center; color: var(--muted); font-size: 13px; }

.moment-list { display: grid; gap: 11px; }
.moment-card { position: relative; display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: start; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 5px 18px rgba(79,67,79,.035); }
.mood-blob { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 44% 56% 50% 50%; font-size: 17px; }
.moment-body p { margin: 0; font-size: 14px; line-height: 1.68; white-space: pre-wrap; overflow-wrap: anywhere; }
.moment-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.moment-meta .tag { padding: 3px 7px; border-radius: 10px; background: var(--purple-soft); color: var(--purple-deep); }
.more-button { width: 27px; height: 27px; background: transparent; color: var(--muted); border-radius: 50%; }
.more-button:hover { background: var(--line); }
.empty-state { padding: 32px 16px; text-align: center; border: 1px dashed rgba(123,113,126,.17); border-radius: 20px; color: var(--muted); }
.empty-state span { display: block; margin-bottom: 8px; font-size: 29px; color: var(--purple); }
.empty-state p { margin: 0; font-size: 13px; }

.page-title { padding: 28px 3px 24px; }
.page-title.calendar-title { display: flex; align-items: end; justify-content: space-between; }
.filter-row { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 20px; padding-bottom: 3px; scrollbar-width: none; }
.filter-chip { flex: 0 0 auto; padding: 8px 13px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.filter-chip.active { color: white; background: var(--ink); }
.timeline-list { display: grid; gap: 24px; }
.day-group h2 { position: sticky; top: 0; z-index: 2; display: inline-block; margin: 0 0 11px; padding: 5px 9px; background: var(--bg); border-radius: 8px; font-size: 12px; color: var(--muted); }
.day-group .moment-list { padding-left: 10px; border-left: 1px solid var(--line); }

.month-nav { display: flex; gap: 6px; }
.calendar-card { padding: 19px 16px 15px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.calendar-card h2 { margin: 0 0 19px; text-align: center; font-family: "Songti SC", "STSong", serif; font-size: 17px; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.weekdays { margin-bottom: 8px; color: var(--muted); font-size: 10px; }
.calendar-day { position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 13px; background: transparent; font-size: 12px; }
.calendar-day.muted { opacity: .22; }
.calendar-day.today { color: var(--purple); font-weight: 700; box-shadow: inset 0 0 0 1px var(--purple); }
.calendar-day.selected { color: white; background: var(--ink); }
.calendar-day.has-entry::after { content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--rose); }
.calendar-day.selected::after { background: white; }

.insight-card { min-height: 145px; padding: 22px; border-radius: 24px; color: #fff; background: linear-gradient(135deg, #8174b7, #aa7d9e); box-shadow: 0 15px 32px rgba(104,83,138,.2); overflow: hidden; position: relative; }
.insight-card::after { content: "✦"; position: absolute; right: 20px; top: 7px; font-size: 90px; color: rgba(255,255,255,.1); }
.insight-card p { position: relative; z-index: 1; margin: 0; opacity: .78; font-size: 12px; }
.insight-card strong { position: relative; z-index: 1; display: block; margin: 6px 0 13px; font-family: "Songti SC", "STSong", serif; font-size: 28px; }
.insight-stats { position: relative; z-index: 1; display: flex; gap: 25px; }
.insight-stats span { font-size: 11px; opacity: .76; }
.insight-stats b { display: block; margin-top: 2px; font-size: 17px; opacity: 1; }
.settings-card { margin-top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); }
.setting-item { width: 100%; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; background: transparent; border-bottom: 1px solid var(--line); cursor: pointer; }
.setting-item:last-child { border-bottom: 0; }
.setting-item span:nth-child(2) { display: flex; flex-direction: column; }
.setting-item strong { font-size: 14px; }
.setting-item small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.setting-item b { color: var(--muted); font-size: 20px; font-weight: 400; }
.setting-icon { width: 37px; height: 37px; display: grid !important; place-items: center; border-radius: 12px; font-size: 17px; }
.setting-icon.lavender { background: #e9e4f4; color: #7264aa; }
.setting-icon.peach { background: #f7e5dc; color: #b1765d; }
.setting-icon.sage { background: #e3eee7; color: #658272; }
.setting-icon.sky { background: #e0edf2; color: #557e8d; }
.privacy-note { margin: 18px 0; color: var(--muted); text-align: center; font-size: 10px; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 720px); height: calc(var(--nav-height) + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); align-items: start; padding: 9px 12px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(18px); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; background: transparent; color: var(--muted); font-size: 10px; }
.nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: var(--purple); }
.nav-compose { justify-self: center; transform: translateY(-23px); width: 55px; height: 55px; border-radius: 50%; color: white; background: linear-gradient(145deg, var(--purple), var(--rose)); border: 5px solid var(--bg); font-size: 29px; font-weight: 300; box-shadow: 0 10px 24px rgba(103,83,145,.25); }

dialog { color: var(--ink); }
dialog::backdrop { background: rgba(35,31,38,.3); backdrop-filter: blur(4px); }
.composer { width: min(100% - 20px, 700px); max-height: calc(100vh - 20px); margin: auto auto 0; padding: 0; border: 0; border-radius: 28px 28px 0 0; background: var(--surface-solid); box-shadow: 0 -15px 50px rgba(31,25,36,.18); }
.composer[open] { animation: sheetUp .32s ease both; }
@keyframes sheetUp { from { transform: translateY(30%); opacity: 0; } }
.composer form { padding: 8px 20px calc(25px + env(safe-area-inset-bottom)); }
.sheet-handle { width: 36px; height: 4px; margin: 0 auto 7px; border-radius: 4px; background: var(--line); }
.composer-head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.composer-head > span { color: var(--muted); font-size: 11px; }
.save-button { padding: 8px 15px; border-radius: 18px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; }
.composer textarea { width: 100%; min-height: 145px; resize: none; padding: 18px 3px; border: 0; border-bottom: 1px solid var(--line); outline: 0; background: transparent; font-family: "Songti SC", "STSong", serif; font-size: 19px; line-height: 1.8; }
.composer textarea::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }
.composer-block { padding-top: 17px; }
.composer-block > p { margin: 0 0 12px; font-size: 12px; font-weight: 700; }
.composer-block > p span { color: var(--muted); font-weight: 400; }
.mood-picker, .tag-picker { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.mood-choice { flex: 0 0 54px; padding: 8px 4px; border: 1px solid transparent; border-radius: 15px; background: transparent; text-align: center; }
.mood-choice span { display: block; width: 34px; height: 34px; margin: 0 auto 4px; display: grid; place-items: center; border-radius: 50%; font-size: 17px; }
.mood-choice small { color: var(--muted); font-size: 10px; }
.mood-choice.active { background: var(--purple-soft); border-color: rgba(128,112,185,.13); }
.tag-choice { flex: 0 0 auto; padding: 8px 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 16px; background: transparent; font-size: 11px; }
.tag-choice.active { color: var(--purple-deep); background: var(--purple-soft); border-color: transparent; }
.composer-foot { display: flex; justify-content: space-between; padding-top: 18px; color: var(--muted); font-size: 9px; }

.search-dialog { width: min(100%, 720px); height: 100%; max-height: none; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 20px 30px; border: 0; background: var(--bg); }
.search-dialog[open] { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.search-head { display: flex; align-items: center; gap: 10px; }
.search-head input { flex: 1; padding: 11px 12px; border: 1px solid var(--line); border-radius: 15px; outline: 0; background: var(--surface-solid); }
.search-results { display: grid; gap: 10px; margin-top: 24px; }
.search-hint { color: var(--muted); text-align: center; padding-top: 70px; font-size: 13px; }

.lock-dialog { width: min(calc(100% - 36px), 390px); padding: 0; border: 0; border-radius: 28px; background: var(--surface-solid); box-shadow: 0 28px 80px rgba(27,22,32,.28); }
.lock-dialog::backdrop { background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(20px); }
.lock-dialog form { display: flex; flex-direction: column; align-items: center; padding: 35px 28px 30px; text-align: center; }
.lock-mark { width: 60px; height: 60px; display: grid; place-items: center; margin-bottom: 22px; border-radius: 21px; color: white; background: linear-gradient(145deg, var(--purple), var(--rose)); box-shadow: 0 12px 27px rgba(112,88,154,.24); font-size: 25px; }
.lock-dialog h2 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: 25px; }
.lock-dialog form > p:not(.eyebrow) { margin: 9px 0 20px; color: var(--muted); font-size: 12px; }
.lock-dialog input { width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: var(--bg); text-align: center; letter-spacing: .24em; outline: 0; }
.unlock-button { width: 100%; margin-top: 12px; padding: 12px; border-radius: 15px; color: white; background: var(--ink); font-size: 13px; font-weight: 700; }
.lock-dialog small { min-height: 18px; margin-top: 9px; color: var(--rose); font-size: 10px; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(var(--nav-height) + 22px); transform: translate(-50%, 15px); padding: 9px 15px; border-radius: 19px; color: white; background: rgba(38,34,41,.9); opacity: 0; pointer-events: none; transition: .25s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 721px) {
  body { padding: 22px 0; }
  .app-shell { min-height: calc(100vh - 44px); border: 1px solid rgba(255,255,255,.8); border-radius: 32px; background: rgba(246,243,237,.35); box-shadow: 0 24px 80px rgba(61,52,62,.12); overflow: hidden; }
  .bottom-nav { bottom: 22px; border-radius: 0 0 32px 32px; }
  .composer { margin-bottom: 22px; border-radius: 28px; }
}

@media (max-width: 390px) {
  main { padding-inline: 16px; }
  .topbar { padding-inline: 16px; }
  .mood-orbit { width: 96px; height: 96px; flex-basis: 96px; }
  .hero h1 { font-size: 31px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
