:root {
  --wall: #f5ecdf; --card: #fffdf9; --ink: #2f251e; --espresso: #3a2a20; --muted: #756352;
  --line: rgba(58,42,32,.12); --caramel: #c2833a; --gold: #b8862b; --milk: #fffdf9;
  --red: #d9534f; --green: #3f9d6a;
  --serif: "Noto Serif TC", serif; --sans: "Noto Sans TC", -apple-system, "PingFang TC", sans-serif; --latin: "Cormorant Garamond", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--wall); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--caramel); }
.hidden { display: none !important; }

/* 頂欄 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px; background: rgba(245,236,223,.9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .logo { width: 30px; height: 30px; }
.top .brand { display: flex; align-items: baseline; gap: 7px; flex: 1; }
.top .brand .en { font-family: var(--latin); font-weight: 700; font-size: 21px; color: var(--espresso); }
.top .brand .zh { font-family: var(--serif); font-size: 12px; color: var(--muted); letter-spacing: .15em; }
.top a.home { text-decoration: none; font-size: 13px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--caramel); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 6px; border-radius: 8px; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 80px; }

/* 登入 */
.login { text-align: center; padding: 48px 20px; }
.login .face { width: 96px; height: 72px; margin: 0 auto 18px; }
.login h1 { font-family: var(--serif); font-size: 24px; margin: 0 0 8px; color: var(--espresso); }
.login p { color: var(--muted); margin: 0 auto 28px; max-width: 320px; line-height: 1.7; }
.login .gbtn { display: flex; justify-content: center; margin-bottom: 14px; min-height: 44px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 13px 18px; font-size: 15px; width: 100%; max-width: 320px; margin: 0 auto; display: block; }
.btn.espresso { background: var(--espresso); color: #fbefe0; border: 0; }
.login .note { font-size: 12px; color: var(--muted); margin-top: 18px; }

/* 統計卡 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-family: var(--latin); font-size: 30px; font-weight: 700; color: var(--espresso); line-height: 1; }
.stat b.grade { font-size: 32px; } .stat b.gold { color: var(--gold); }
.stat span { font-size: 12px; color: var(--muted); }
@media (max-width: 440px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* 修煉地圖 */
.path { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 18px; }
.path h3 { font-family: var(--serif); font-size: 16px; margin: 0 0 10px; color: var(--espresso); }
.path .items { display: flex; flex-wrap: wrap; gap: 8px; }
.path .p { font-size: 14px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.path .p.on { background: #f3e6d2; color: var(--espresso); border-color: rgba(194,131,58,.4); font-weight: 500; }
.path .p .n { color: var(--caramel); font-weight: 700; margin-left: 4px; }

/* 控制列 */
.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: rgba(58,42,32,.06); border-radius: 99px; padding: 4px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 99px; color: var(--muted); font-size: 14px; }
.seg button.on { background: #fff; color: var(--espresso); box-shadow: 0 2px 6px rgba(58,42,32,.1); font-weight: 500; }
.bar .spacer { flex: 1; }
.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { white-space: nowrap; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 13px; font-size: 13px; color: var(--muted); }
.chips button.on { background: var(--espresso); color: #fbefe0; border-color: var(--espresso); }

/* 格狀作品 */
.group-title { font-family: var(--serif); font-size: 15px; color: var(--espresso); margin: 16px 2px 10px; display: flex; align-items: baseline; gap: 8px; }
.group-title small { color: var(--muted); font-weight: 400; font-size: 12px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 440px) { .grid { grid-template-columns: repeat(2, 1fr); } }
.cup { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: #efe6d8; border: 1px solid var(--line); cursor: pointer; }
.cup img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cup .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cup .ph svg { width: 54%; height: 54%; opacity: .5; }
.cup .g { position: absolute; left: 7px; top: 7px; background: rgba(255,253,249,.92); color: var(--espresso); font-family: var(--latin); font-weight: 700; font-size: 20px; line-height: 1; padding: 3px 8px; border-radius: 9px; }
.cup .g.top { color: var(--gold); }
.cup .fav { position: absolute; right: 7px; top: 7px; color: #e7b64a; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.cup .pub { position: absolute; right: 6px; bottom: 6px; background: rgba(58,42,32,.7); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 99px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.more { display: block; margin: 18px auto 0; }

/* 詳細彈窗 */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(58,42,32,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet .inner { background: var(--wall); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 8px 18px calc(28px + env(safe-area-inset-bottom)); }
@media (min-width: 560px) { .sheet { align-items: center; } .sheet .inner { border-radius: 22px; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 99px; background: rgba(58,42,32,.2); margin: 8px auto 12px; }
.sheet .photo { width: 100%; border-radius: 16px; display: block; background: #efe6d8; aspect-ratio: 1; object-fit: cover; }
.sheet .ph-big { position: relative; width: 100%; aspect-ratio: 1; border-radius: 16px; background: #efe6d8; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sheet .ph-big .photo { position: absolute; inset: 0; }
.sheet .ph-big svg { width: 40%; opacity: .5; }
.dates { display: flex; gap: 24px; margin: 14px 2px 0; }
.dates div span { display: block; font-size: 11px; color: var(--muted); letter-spacing: .1em; }
.dates div b { font-size: 15px; font-weight: 600; color: var(--espresso); }
.cnote { margin: 10px 0 0; font-size: 13px; color: #8a5a2b; background: rgba(194,131,58,.1); border-radius: 10px; padding: 8px 11px; }
.verdict { display: flex; align-items: center; gap: 14px; margin: 16px 0 6px; }
.verdict .big { font-family: var(--latin); font-weight: 700; font-size: 52px; line-height: 1; color: var(--espresso); }
.verdict .big.top { color: var(--gold); }
.verdict .t b { font-family: var(--serif); font-size: 18px; } .verdict .t div { color: var(--muted); font-size: 13px; }
.roast2 { font-family: var(--serif); font-size: 16px; line-height: 1.7; color: var(--espresso); margin: 8px 0 0; }
.radar2 { display: block; width: 100%; max-width: 280px; margin: 8px auto; overflow: visible; }
.radar2 text { font-size: 11px; fill: var(--muted); font-family: var(--sans); }
.radar2 .v { fill: var(--espresso); font-weight: 700; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.acts button { border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 12px; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.acts button.danger { color: var(--red); }
.acts .full { grid-column: 1 / -1; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.picker button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 8px 14px; font-size: 14px; }
.picker button.on { background: var(--espresso); color: #fbefe0; border-color: var(--espresso); }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--espresso); color: #fbefe0; padding: 11px 20px; border-radius: 99px; font-size: 14px; z-index: 99; opacity: 0; transition: opacity .3s, transform .3s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* 語言切換、進步曲線、帳號（2026-10-20） */
.top .lang { border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 99px; }
.trend { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 8px; margin-bottom: 18px; }
.trend h3 { font-family: var(--serif); font-size: 16px; margin: 0 0 6px; color: var(--espresso); }
.trend svg { display: block; width: 100%; height: auto; overflow: visible; }
.acct { text-align: center; margin: 40px 0 0; }
.acct .linkish { background: none; border: 0; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
html[data-lang="en"] .top .brand .zh { letter-spacing: 0.04em; font-family: var(--sans); }
.top .brand, .top .brand span, .top a.home { white-space: nowrap; }
.top .brand .en { font-size: 19px; }
@media (max-width: 440px) { .top .brand .zh { display: none; } .top { gap: 8px; } }
/* Email 登入連結（2026-10-21） */
.login-email { max-width: 320px; margin: 0 auto; }
.email-login summary { list-style: none; cursor: pointer; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; display: inline-block; padding: 4px 2px; }
.email-login summary::-webkit-details-marker { display: none; }
.email-row { display: flex; gap: 8px; margin-top: 10px; }
.email-row .field { flex: 1; min-width: 0; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 12px; font-size: 15px; }
.email-row .secondary { border: 0; background: var(--espresso); color: #fbefe0; border-radius: 12px; padding: 0 14px; white-space: nowrap; font-size: 14px; }
.email-msg { font-size: 12px; color: var(--red); margin: 8px 0 0; text-align: left; line-height: 1.6; }
.email-msg.ok { color: var(--green); }

/* 臉書登入＋帳號密碼（2026-10-24） */
.fb-btn { display: flex; align-items: center; justify-content: center; gap: 8px; max-width: 280px; margin: 0 auto 12px; height: 42px; border-radius: 99px; background: #1877f2; color: #fff; text-decoration: none; font-size: 15px; font-weight: 500; }
.fb-btn svg { width: 20px; height: 20px; }
.pw-login { margin-top: 4px; }
.pw-login summary { list-style: none; cursor: pointer; font-size: 14px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; display: inline-flex; align-items: center; min-height: 44px; padding: 4px 2px; }
.pw-login summary::-webkit-details-marker { display: none; }
.pw-tabs { display: flex; gap: 4px; justify-content: center; margin: 8px 0 2px; }
.pw-tabs button { border: 0; background: transparent; color: var(--muted); font-size: 14px; min-height: 44px; padding: 6px 12px; border-radius: 99px; cursor: pointer; }
.pw-tabs button.on { background: #fff; color: var(--espresso); font-weight: 600; box-shadow: 0 1px 6px rgba(58, 42, 32, 0.08); }
.pw-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pw-form .field { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 12px; font-size: 16px; }
.pw-form .secondary { border: 0; background: var(--espresso); color: #fbefe0; border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.pw-hint { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 8px 0 0; text-align: left; }
.pw-change { text-align: center; margin-top: 40px; }
.wall-title { font-size: 24px; font-weight: 600; margin: 0 0 20px; }
.empty a { color: var(--espresso); }
.pw-change .pw-form { max-width: 360px; margin: 8px auto; }
.pw-setup .pw-google { display: flex; justify-content: center; margin-top: 12px; min-height: 44px; }
.pw-setup .pw-verified { font-size: 14px; color: var(--muted); }
.pw-form button:disabled { opacity: .5; cursor: wait; }
.pw-change + .acct { margin-top: 12px; }
.login-email .pw-hint, .login-email .email-msg { margin: 8px 0 0; max-width: none; }
