:root {
  --bg: #0e0b12; --bg2: #17121d; --card: #1d1626; --line: #2d2338;
  --txt: #f2edf7; --dim: #9a8fb0; --pink: #ff4d8d; --purple: #9b5cff;
  --grad: linear-gradient(135deg, #ff4d8d, #9b5cff);
}
* { box-sizing: border-box; margin: 0; }
body { background: var(--bg); color: var(--txt); font-family: "PingFang TC","Microsoft JhengHei",system-ui,sans-serif; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------- top nav ---------- */
.topnav { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(14,11,18,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 18px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.navsp { flex: 1; }
.tokbal { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; font-size: 14px; font-weight: 600; }
.tokbal .coin { color: #ffd166; }
.btn { border: 0; border-radius: 999px; padding: 7px 16px; font-size: 14px; font-weight: 600; color: #fff; background: var(--grad); }
.btn.ghost { background: var(--card); border: 1px solid var(--line); }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- filters + stories ---------- */
.filters { display: flex; gap: 8px; padding: 14px 16px 6px; overflow-x: auto; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--dim); border-radius: 999px;
  padding: 7px 16px; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--grad); color: #fff; border-color: transparent; font-weight: 600; }
.stories { display: flex; gap: 14px; padding: 12px 16px; overflow-x: auto; }
.story { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 64px; flex: none; }
.story img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; border: 2.5px solid var(--pink); padding: 2px; }
.story.live img { border-color: #ff3355; box-shadow: 0 0 10px #ff335580; }
.story span { font-size: 11px; color: var(--dim); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dot { font-size: 10px; color: #ff3355; font-weight: 700; }
.sec-title { padding: 14px 16px 8px; font-size: 15px; font-weight: 700; color: var(--dim); letter-spacing: 1px; }

/* ---------- masonry feed ---------- */
.feed { column-count: 2; column-gap: 10px; padding: 8px 16px 90px; }
@media (min-width: 720px) { .feed { column-count: 3; } }
@media (min-width: 1100px) { .feed { column-count: 4; } }
.card { break-inside: avoid; margin-bottom: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; }
.card .media { position: relative; }
.card img { width: 100%; display: block; }
.card img.locked { filter: blur(18px) brightness(.75); transform: scale(1.08); }
.lockovl { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.lockprice { background: rgba(0,0,0,.65); border: 1px solid #ffffff33; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; }
.badge { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.ai { background: #9b5cff; }
.badge.ppv { background: rgba(0,0,0,.65); border: 1px solid #ffffff33; }
.card .body { padding: 10px 12px 12px; }
.card .cap { font-size: 13px; line-height: 1.5; color: var(--txt); }
.card .who { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.card .who img { width: 24px; height: 24px; border-radius: 50%; }
.card .who b { font-size: 13px; }
.card .acts { display: flex; gap: 6px; margin-top: 10px; }
.card .acts .btn { flex: 1; text-align: center; font-size: 12px; padding: 6px 4px; }

/* ---------- ai explore ---------- */
.ai-row { display: flex; gap: 12px; padding: 8px 16px 90px; overflow-x: auto; }
.ai-card { flex: none; width: 200px; background: var(--card); border: 1px solid var(--purple); border-radius: 16px; padding: 16px; }
.ai-card img { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--purple); }
.ai-card h4 { margin: 10px 0 4px; }
.ai-card p { font-size: 12px; color: var(--dim); line-height: 1.5; min-height: 54px; }

/* ---------- login (中性頁) ---------- */
.loginwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f5f4f7; color: #222; }
.loginbox { width: 340px; background: #fff; border-radius: 16px; padding: 36px 30px; box-shadow: 0 8px 40px #0001; border: 1px solid #eee; }
.loginbox h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.loginbox .sub { color: #888; font-size: 13px; margin-bottom: 24px; }
.loginbox input { width: 100%; border: 1px solid #ddd; border-radius: 10px; padding: 12px 14px; font-size: 15px; margin-bottom: 12px; outline: none; }
.loginbox input:focus { border-color: #999; }
.loginbox .btn { width: 100%; background: #222; padding: 12px; }
.loginbox .err { color: #c0392b; font-size: 13px; margin-top: 10px; min-height: 18px; }
.loginbox .alt { margin-top: 18px; font-size: 13px; color: #888; text-align: center; }
.loginbox .alt a { color: #555; text-decoration: underline; cursor: pointer; }

/* ---------- chat ---------- */
.chatwrap { display: flex; flex-direction: column; height: 100vh; }
.chathead { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.chathead img { width: 42px; height: 42px; border-radius: 50%; }
.chathead .st { font-size: 12px; color: #5dd39e; }
.chathead .st.human { color: #ff3355; font-weight: 700; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.6; }
.msg.user { align-self: flex-end; background: var(--grad); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: none; color: var(--dim); font-size: 12px; }
.chatinput { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg2); }
.chatinput input { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 11px 18px; color: var(--txt); font-size: 15px; outline: none; }
.typing { color: var(--dim); font-size: 13px; font-style: italic; }
.costhint { font-size: 11px; color: var(--dim); text-align: center; padding: 4px; }

/* ---------- wallet ---------- */
.panel { max-width: 560px; margin: 0 auto; padding: 20px 16px 90px; }
.bigbal { background: var(--grad); border-radius: 20px; padding: 26px; text-align: center; }
.bigbal .n { font-size: 42px; font-weight: 800; }
.bigbal .l { opacity: .85; font-size: 13px; }
.rech { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.rech .btn { padding: 12px 0; }
.lrow { display: flex; justify-content: space-between; padding: 11px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.lrow .neg { color: #ff7d9c; } .lrow .pos { color: #5dd39e; }
.lrow small { color: var(--dim); }

/* ---------- creator page ---------- */
.chero { padding: 26px 16px; display: flex; gap: 16px; align-items: center; }
.chero img { width: 88px; height: 88px; border-radius: 50%; border: 3px solid var(--pink); }
.chero h2 { display: flex; gap: 8px; align-items: center; }
.chero p { color: var(--dim); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #222; border: 1px solid var(--line);
  padding: 10px 20px; border-radius: 999px; font-size: 14px; z-index: 99; }
