:root {
  --bg: #f7f2ea;
  --card: #fffdf9;
  --ink: #2b1d18;
  --muted: #8a7b72;
  --line: #e8ddd0;
  --wine: #5b1a2a;
  --wine-2: #7d2a3e;
  --gold: #b08a3e;
  --in: #2f7a4a;
  --out: #b0412e;
  --shadow: 0 1px 2px rgba(60, 30, 20, .06), 0 4px 14px rgba(60, 30, 20, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17110f; --card: #221916; --ink: #f1e7dd; --muted: #a8968a; --line: #3a2c27;
    --wine: #c8687c; --wine-2: #e08a9c; --gold: #d6b26a; --in: #6fc28d; --out: #ec8a76;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #17110f; --card: #221916; --ink: #f1e7dd; --muted: #a8968a; --line: #3a2c27;
  --wine: #c8687c; --wine-2: #e08a9c; --gold: #d6b26a; --in: #6fc28d; --out: #ec8a76;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .serif { font-family: "Noto Serif TC", Georgia, serif; }
a { color: var(--wine); }
.hidden { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 20px; color: var(--wine); }
main { max-width: 760px; margin: 0 auto; padding: 14px 16px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; text-align: center; padding: 8px 0 6px; font-size: 12px; color: var(--muted); text-decoration: none; }
.tabs a span { display: block; font-size: 20px; line-height: 1.2; }
.tabs a.on { color: var(--wine); font-weight: 600; }

button, .btn {
  font: inherit; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--wine); color: #fff; font-weight: 600;
}
button.ghost { background: transparent; color: var(--wine); padding: 6px 8px; }
button.line { background: transparent; color: var(--wine); border: 1px solid var(--wine); }
button.in { background: var(--in); }
button.out { background: var(--out); }
button.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; }

input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px; color: var(--ink);
  border: 1px solid var(--line); background: var(--card);
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--wine); font-family: "Noto Serif TC", serif; }
.stat small { color: var(--muted); font-size: 12px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.chip {
  flex: none; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 13px; font-weight: 500;
}
.chip.on { background: var(--wine); color: #fff; border-color: var(--wine); }

.list { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.wine { display: flex; gap: 12px; padding: 10px; cursor: pointer; align-items: center; }
.wine .ph { width: 60px; height: 80px; flex: none; border-radius: 8px; background: var(--line) center/cover; display: grid; place-items: center; font-size: 26px; }
.wine .info { flex: 1; min-width: 0; }
.wine .nm { font-weight: 700; font-family: "Noto Serif TC", serif; line-height: 1.3; }
.wine .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wine .qty { text-align: center; min-width: 48px; }
.wine .qty b { display: block; font-size: 24px; color: var(--wine); line-height: 1.1; }
.wine .qty small { font-size: 11px; color: var(--muted); }
.wine.empty { opacity: .55; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--ink); margin-right: 4px; font-weight: 500; }
.badge.紅酒 { background: #7d2a3e; color: #fff; }
.badge.白酒 { background: #e9d98f; color: #4a3b0c; }
.badge.氣泡酒 { background: #cfe3ea; color: #1e4552; }
.badge.粉紅酒 { background: #f3c4cc; color: #6a1f2d; }
.badge.pending { background: var(--gold); color: #fff; }

.hero { display: flex; gap: 14px; padding: 14px; }
.hero .ph { width: 110px; height: 150px; flex: none; border-radius: 10px; background: var(--line) center/cover; display: grid; place-items: center; font-size: 44px; }
.hero h2 { margin: 2px 0 4px; font-size: 20px; line-height: 1.3; }
.hero .en { color: var(--muted); font-size: 13px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 12px 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.sec { padding: 12px 14px; margin-top: 10px; }
.sec h3 { margin: 0 0 6px; font-size: 16px; color: var(--wine); }
.sec p { margin: 0; white-space: pre-wrap; font-size: 15px; }
.stockbar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-top: 10px; }
.stockbar .n { font-size: 34px; font-weight: 700; color: var(--wine); font-family: "Noto Serif TC", serif; }
.tx { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: center; }
.tx:first-child { border-top: 0; }
.tx .act { font-weight: 700; min-width: 56px; }
.tx .act.in { color: var(--in); }
.tx .act.out { color: var(--out); }
.tx .memo { flex: 1; color: var(--muted); min-width: 0; }
.month { margin: 16px 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 10px; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(20, 10, 8, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 6px; color: var(--wine); }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.actions > * { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 99px; z-index: 30; font-size: 14px; max-width: 90vw;
}
.auth { max-width: 380px; margin: 30px auto; padding: 22px; }
.auth h2 { text-align: center; color: var(--wine); margin: 0 0 4px; }
.auth .lead { text-align: center; color: var(--muted); margin: 0 0 12px; font-size: 14px; }
table.admin { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin th, table.admin td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.scroll-x { overflow-x: auto; }

/* 2026-09-27 獲利功能 */
.warn { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 4px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; margin-top: 12px; }
label.check input { width: auto; }
.cellar-sel { margin-bottom: 10px; font-weight: 600; color: var(--wine); }
.stat b.sm { font-size: 16px; line-height: 1.6; }
.notice { padding: 10px 14px; margin-bottom: 10px; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.notice button { margin-left: auto; }
.notice.low { border-color: var(--out); color: var(--out); }
.chip-label { flex: none; font-size: 12px; color: var(--muted); align-self: center; }
.badge.d-ready { background: #d8ecd9; color: #1f5a31; }
.badge.d-ending { background: #fbe1b8; color: #7a4a05; }
.badge.d-past { background: #f4cfc8; color: #7c2415; }
.ai-wait { display: flex; align-items: center; gap: 12px; }
.spinner { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--wine); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ev-ph { height: 150px; border-radius: 10px; background: var(--line) center/cover; margin-bottom: 10px; }
a.btn { display: inline-block; text-align: center; text-decoration: none; }
.plan ul { margin: 6px 0 4px; padding-left: 20px; font-size: 14px; }
.plan .price { font-size: 18px; font-weight: 700; color: var(--wine); margin: 2px 0 4px; }
.plan .price small { font-size: 12px; color: var(--muted); font-weight: 400; }
.plan.cur { border-color: var(--wine); }
.tabs a { font-size: 11px; }

/* 2026-09-28 瓶數、品飲筆記、多語言 */
.tabs a i { font-style: normal; }
.seg { display: flex; gap: 0; margin: 4px 0 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { flex: 1; background: transparent; color: var(--ink); border-radius: 0; font-weight: 500; padding: 8px 4px; font-size: 14px; }
.seg button.on { background: var(--wine); color: #fff; font-weight: 700; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px 0 4px; }
.stepper button { width: 48px; height: 48px; font-size: 22px; padding: 0; border-radius: 50%; }
.stepper input { width: 90px; text-align: center; font-size: 26px; font-weight: 700; }
.rate { display: flex; align-items: center; gap: 2px; }
.rate button { background: transparent; color: var(--gold); font-size: 30px; padding: 0 4px; }
.note { border-top: 1px solid var(--line); padding: 8px 0; }
.note:first-of-type { border-top: 0; }
.note-h { display: flex; gap: 10px; align-items: center; }
.note-h .hint { flex: 1; margin: 0; }
.note p { margin: 4px 0 0; font-size: 15px; white-space: pre-wrap; }
.stars { color: var(--gold); font-weight: 700; }
.lang-sel { width: auto; padding: 6px 10px; font-size: 14px; }
i[data-t] { font-style: normal; }
.rate button { color: var(--line); }
.rate button.full { color: var(--gold); }
.rate button.half { background: linear-gradient(90deg, var(--gold) 50%, var(--line) 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* 未登入時首頁下方的介紹（原始 HTML 就有，給搜尋引擎與 AI 爬蟲讀） */
.landing { max-width: 640px; margin: 8px auto 24px; color: var(--ink); }
.landing h2 { font-size: 1.1rem; margin: 22px 0 6px; }
.landing ul { padding-left: 1.2em; }
.landing li { margin: 4px 0; }
.landing .hint { color: var(--muted); font-size: .9rem; }
