:root {
  --bg: #f7f5fb; --card: #ffffff; --card-2: #f1eef8; --ink: #1d1a24; --ink-2: #5d5869; --ink-3: #8f899c;
  --line: #e7e3ef; --accent: #8a78c2; --accent-ink: #ffffff; --accent-soft: #ece7fa; --star: #f5b400;
  --good: #2f9e66; --warn: #d98b12; --bad: #d64545; --shadow: 0 6px 20px rgba(60, 40, 110, .08);
  --tab-h: 58px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16141b; --card: #201d27; --card-2: #2a2633; --ink: #f2eff7; --ink-2: #c4bed0; --ink-3: #8f899c;
    --line: #34303e; --accent: #a594dc; --accent-ink: #16141b; --accent-soft: #332d45; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-width: 100%; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* layout */
.splash { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 8px; }
.splash-icon { font-size: 56px; }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(var(--safe-t) + 10px) 16px 8px;
  display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: .5px; }
.page { padding: 0 16px calc(var(--tab-h) + var(--safe-b) + 24px); max-width: 720px; margin: 0 auto; }
.page.with-bar { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 92px); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: var(--safe-b); }
.tabbar a { height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  color: var(--ink-3); text-decoration: none; font-size: 11px; position: relative; }
.tabbar a .ico { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .65; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.tabbar a.on .ico { filter: none; opacity: 1; }
.dot { position: absolute; top: 7px; left: calc(50% + 8px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 17px; text-align: center; font-weight: 600; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: 20px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px; white-space: nowrap; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.line { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border: 1.5px solid var(--bad); }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 15px; }
.btn.block { width: 100%; height: 46px; border-radius: 23px; font-size: 16px; }
.btn:disabled { opacity: .45; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: var(--card); box-shadow: var(--shadow); }
.seg { display: inline-flex; background: var(--card-2); border-radius: 18px; padding: 3px; }
.seg button { height: 30px; padding: 0 14px; border-radius: 15px; font-size: 14px; color: var(--ink-2); position: relative; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.seg .dot { top: -4px; left: auto; right: -4px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line);
  font-size: 14px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.input, textarea.input, select.input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 10px 12px; font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 16px; }
.empty .big { font-size: 40px; margin-bottom: 6px; }
.stars { color: var(--star); letter-spacing: 1px; font-size: 13px; }
.stars .off { color: var(--line); }
.star-input button { font-size: 26px; color: var(--line); padding: 0 2px; }
.star-input button.on { color: var(--star); }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--card-2); color: var(--ink-2); }
.pill.new { background: #fde9e9; color: var(--bad); }
.pill.cooking { background: #fff2dc; color: var(--warn); }
.pill.done { background: #e2f5ea; color: var(--good); }
@media (prefers-color-scheme: dark) { .pill.new, .pill.cooking, .pill.done { background: var(--card-2); } }

/* menu */
.menu { display: grid; grid-template-columns: 92px 1fr; gap: 0; background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  min-height: 60vh; overflow: hidden; }
.rail { background: var(--card-2); padding: 6px 0; }
.rail button { display: block; width: 100%; padding: 14px 8px; font-size: 14px; color: var(--ink-2); text-align: center; position: relative; line-height: 1.35; }
.rail button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; }
.rail button[aria-pressed="true"]::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 2px; background: var(--accent); }
.rail .manage { font-size: 12px; color: var(--accent); }
.dishes { padding: 8px 10px; min-width: 0; }
.dishes h3 { font-size: 15px; margin: 6px 4px 8px; }
.dish { display: flex; gap: 10px; padding: 8px 4px; align-items: center; }
.thumb { width: 76px; height: 76px; border-radius: 14px; background: var(--accent-soft); flex: none; display: grid; place-items: center;
  font-size: 40px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.dish .info { flex: 1; min-width: 0; }
.dish .name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish .sub { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 20px; line-height: 28px;
  text-align: center; flex: none; font-weight: 600; position: relative; }
.add .n { position: absolute; top: -7px; right: -7px; background: var(--bad); color: #fff; font-size: 11px; min-width: 16px; height: 16px;
  line-height: 16px; border-radius: 8px; padding: 0 4px; }
.cartbar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + var(--safe-b) + 10px); z-index: 9; max-width: 696px; margin: 0 auto;
  background: var(--card); border-radius: 28px; box-shadow: 0 8px 30px rgba(40, 20, 90, .18); display: flex; align-items: center; gap: 8px; padding: 7px 7px 7px 16px; }
.cartbar .cart { font-size: 24px; position: relative; }
.cartbar .cart .n { position: absolute; top: -6px; right: -10px; background: var(--bad); color: #fff; font-size: 11px; min-width: 18px; height: 18px;
  line-height: 18px; border-radius: 9px; text-align: center; padding: 0 4px; }
.linkish { color: var(--accent); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.order .items { margin: 8px 0; display: grid; gap: 4px; }
.order .line { display: flex; gap: 8px; font-size: 15px; }
.order .choices { color: var(--ink-3); font-size: 13px; }

/* lists */
.item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--accent); flex: none; margin-top: 1px; display: grid; place-items: center;
  color: var(--accent-ink); font-size: 14px; }
.check.on { background: var(--accent); }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; word-break: break-word; }
.item.done .title { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.item .note { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
.veil { filter: blur(7px); user-select: none; }
.lockcard { text-align: center; padding: 26px 16px; }

/* diary */
.month { font-size: 13px; color: var(--ink-3); margin: 18px 4px 8px; font-weight: 600; }
.entry .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.entry .mood { font-size: 26px; }
.entry .text { white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.photos img, .photos .ph { aspect-ratio: 1; object-fit: cover; border-radius: 10px; width: 100%; background: var(--card-2); }
.photos .ph { position: relative; }
.photos .ph button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; }
.photos .addph { aspect-ratio: 1; border-radius: 10px; border: 1.5px dashed var(--line); display: grid; place-items: center; font-size: 26px; color: var(--ink-3); }

/* notes */
.notes { columns: 2; column-gap: 10px; }
.note-card { break-inside: avoid; border-radius: 14px; padding: 12px; margin-bottom: 10px; white-space: pre-wrap; word-break: break-word;
  font-size: 15px; color: #2a2530; box-shadow: var(--shadow); position: relative; min-height: 64px; }
.note-card .meta { font-size: 11px; color: rgba(40,30,50,.55); margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.note-card.done .txt { text-decoration: line-through; opacity: .55; }
.c-yellow { background: #fff4bf; } .c-pink { background: #ffdbe6; } .c-blue { background: #d9ebff; }
.c-green { background: #daf3df; } .c-purple { background: #e7defa; } .c-white { background: #ffffff; }
.colors { display: flex; gap: 10px; }
.colors button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; }
.colors button[aria-pressed="true"] { border-color: var(--accent); }

/* messages */
.chat { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.bubble-row { display: flex; gap: 8px; align-items: flex-end; }
.bubble-row.mine { flex-direction: row-reverse; }
.bubble { max-width: 76%; padding: 9px 13px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); white-space: pre-wrap; word-break: break-word; }
.mine .bubble { background: var(--accent); color: var(--accent-ink); }
.bubble img { border-radius: 12px; max-height: 260px; }
.stamp { text-align: center; font-size: 12px; color: var(--ink-3); margin: 8px 0 2px; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 9; background: var(--bg);
  padding: 8px 12px; display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-height: 40px; max-height: 120px; border-radius: 20px; padding: 8px 14px; resize: none; }

/* sheets */
.backdrop { position: fixed; inset: 0; background: rgba(20, 10, 40, .38); z-index: 30; animation: fade .15s ease; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; background: var(--bg); border-radius: 20px 20px 0 0;
  max-height: 88vh; overflow-y: auto; padding: 18px 16px calc(var(--safe-b) + 18px); animation: rise .2s ease; max-width: 720px; margin: 0 auto; }
.sheet h2 { font-size: 19px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.sheet h2 .x { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; background: var(--card-2); color: var(--ink-2); font-size: 16px; }
.sheet .group-title { font-size: 14px; font-weight: 600; margin: 12px 0 8px; }
.sheet .chips { flex-wrap: wrap; overflow: visible; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
#toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 16px); transform: translateX(-50%); z-index: 50; background: rgba(30, 24, 40, .9);
  color: #fff; padding: 9px 16px; border-radius: 18px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 86vw; text-align: center; }
#toast.on { opacity: 1; }
.big-pick { text-align: center; padding: 10px 0 18px; }
.big-pick .emoji { font-size: 72px; }
.big-pick .name { font-size: 24px; font-weight: 700; margin-top: 6px; }
.spec-row { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 10px; background: var(--card); }
.login { min-height: 100vh; display: grid; place-content: center; padding: 24px; gap: 4px; width: 100%; max-width: 380px; margin: 0 auto; }
.login .logo { font-size: 60px; text-align: center; }
.login h1 { text-align: center; margin: 0 0 18px; font-size: 24px; }
.qty { display: inline-flex; align-items: center; gap: 10px; }
.qty button { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.settings .card .row { padding: 6px 0; }
