:root {
  --ink: #16130e; --ink2: #2a251c; --paper: #f7f3ea; --card: #fffdf8; --line: #e3dac8; --text: #1d1a14; --mute: #81786a;
  --gold: #e2a72e; --gold-d: #a8770c; --mine: #f4d98c; --mine-t: #1d1a14; --chatbg: #ece5d6; --danger: #c0412f; --ok: #2f9e5b;
  --sans: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --serif: "Songti TC", "Noto Serif TC", "PMingLiU", serif;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #1b1813; --card: #25211a; --line: #3a3429; --text: #efe8d8; --mute: #9c927f; --mine: #7d5a0c; --mine-t: #fff6de; --chatbg: #121009; --gold-d: #e2a72e; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.55 var(--sans); color: var(--text); background: var(--paper); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
a { color: var(--gold-d); }
h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input:not([type=checkbox]):not([type=file]), textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); outline: 0; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); }
textarea { resize: none; }

.btn { padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); } }
.btn.big { width: 100%; padding: 12px; margin-top: 6px; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.link { border: 0; background: none; padding: 6px 8px; color: var(--mute); font-weight: 500; }
.btn.danger, .btn.link.danger { color: var(--danger); }
.btn.row { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 15px 20px; background: none; font-weight: 500; }
.ib { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--mute); flex: none; }
.ib:hover { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--text); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--mute); margin-bottom: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rowf { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.hint { color: var(--mute); text-align: center; padding: 28px 20px; font-size: 14px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; background: color-mix(in srgb, var(--gold) 22%, transparent); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; font-style: normal; }
.badge.quiet { background: var(--mute); }

.av { border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; flex: none; position: relative; user-select: none; }
.av.grp { border-radius: 30%; }
.av img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.av.on::after { content: ""; position: absolute; right: 0; bottom: 0; width: 26%; height: 26%; min-width: 9px; min-height: 9px; border-radius: 50%; background: var(--ok); border: 2px solid var(--paper); }

/* auth */
#auth { height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); overflow: auto; }
#auth .brand { background: var(--ink); color: #f3ecdc; padding: clamp(32px, 7vw, 88px); display: flex; flex-direction: column; justify-content: center; }
#auth .brand img { border-radius: 18px; }
#auth h1 { font: 700 clamp(34px, 4.4vw, 56px)/1.15 var(--serif); margin: 26px 0 12px; letter-spacing: .04em; }
#auth .tag { font-size: clamp(17px, 1.6vw, 21px); color: var(--gold); line-height: 1.6; }
#auth ul { list-style: none; padding: 0; margin: 34px 0 0; display: grid; gap: 12px; color: #c9c0ad; }
#auth li { padding-left: 22px; position: relative; }
#auth li::before { content: ""; position: absolute; left: 0; top: .62em; width: 9px; height: 3px; background: var(--gold); }
#auth .free { margin-top: 40px; font-size: 13px; letter-spacing: .2em; color: #8d8473; }
#auth .formwrap { display: grid; place-items: center; padding: 32px 20px; }
.authform { width: min(380px, 100%); }
.authform h2 { font: 700 28px var(--serif); }
.authform .sub { color: var(--mute); margin: 6px 0 24px; }
.err { color: var(--danger); min-height: 1.5em; font-size: 14px; }
.switch { text-align: center; margin-top: 18px; color: var(--mute); }
.switch a { font-weight: 700; margin-left: 4px; }

/* layout */
#app { height: 100dvh; display: grid; grid-template-columns: 72px 340px minmax(0, 1fr); }
#app.wide { grid-template-columns: 72px minmax(0, 1fr); }
#app.wide #list { display: none; }
#rail { background: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0; }
#rail .logo { border-radius: 11px; margin-bottom: 14px; }
.tab { width: 60px; padding: 8px 0 6px; border-radius: 12px; color: #9a917e; display: grid; justify-items: center; gap: 1px; position: relative; }
.tab span { display: grid; }
.tab small { font-size: 11px; }
.tab.act { color: var(--gold); background: var(--ink2); }
.tab:hover { color: #f3ecdc; }
.tab .badge { position: absolute; top: 2px; right: 4px; }

#list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
#list > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 8px 18px; }
#list h2 { font: 700 22px var(--serif); letter-spacing: .05em; }
#list .search { margin: 0 14px 8px; width: auto; }
#listbody { overflow-y: auto; flex: 1; padding-bottom: 12px; }
.sec { padding: 14px 18px 6px; font-size: 12px; color: var(--mute); font-weight: 600; letter-spacing: .06em; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; text-align: left; }
button.item:hover, label.item:hover { background: color-mix(in srgb, var(--gold) 10%, transparent); }
.item.act { background: color-mix(in srgb, var(--gold) 22%, transparent); }
.mid { flex: 1; min-width: 0; display: grid; }
.mid strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mid strong i { font-style: normal; color: var(--mute); font-weight: 400; font-size: 13px; }
.mid em, .who em { font-style: normal; color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini { display: inline-block; vertical-align: -1px; margin-left: 4px; color: var(--mute); }
.side { display: grid; justify-items: end; gap: 4px; flex: none; }
.side time { font-size: 11px; color: var(--mute); }
.mecard { padding: 12px 16px; border-bottom: 1px solid var(--line); }

#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chatbg); position: relative; }
.empty { margin: auto; text-align: center; color: var(--mute); padding: 24px; max-width: 360px; }
.empty img { border-radius: 22px; opacity: .92; }
.empty h2 { font: 700 24px var(--serif); color: var(--text); margin: 16px 0 6px; letter-spacing: .08em; }

/* chat */
#chead { display: flex; align-items: center; gap: 4px; padding: 9px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
#chead .who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: left; }
#chead .who > span:last-child { display: grid; min-width: 0; }
.backbtn { display: none; }
#notice { display: flex; gap: 10px; padding: 8px 16px; background: color-mix(in srgb, var(--gold) 20%, var(--paper)); font-size: 13px; border-bottom: 1px solid var(--line); }
#notice span { white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#msgs { flex: 1; overflow-y: auto; padding: 16px clamp(12px, 3vw, 28px); display: flex; flex-direction: column; gap: 8px; }
.day, .sys { align-self: center; font-size: 12px; color: var(--mute); background: color-mix(in srgb, var(--text) 8%, transparent); padding: 3px 12px; border-radius: 99px; margin: 6px 0; text-align: center; }
.older { align-self: center; font-size: 13px; color: var(--gold-d); padding: 6px 12px; }
.msg { display: flex; gap: 8px; max-width: 100%; }
.msg.mine { flex-direction: row-reverse; }
.avb { align-self: flex-start; flex: none; }
.col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: min(74%, 560px); position: relative; }
.mine .col { align-items: flex-end; }
.nm { font-size: 12px; color: var(--mute); margin: 0 0 2px 4px; }
.line { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.mine .line { flex-direction: row-reverse; }
.meta { font-size: 11px; color: var(--mute); display: grid; flex: none; line-height: 1.3; }
.mine .meta { justify-items: end; }
.meta i { font-style: normal; color: var(--gold-d); }
.bubble { background: var(--card); padding: 8px 13px; border-radius: 4px 16px 16px 16px; white-space: pre-wrap; overflow-wrap: anywhere; cursor: pointer; min-width: 0; box-shadow: 0 1px 1px rgb(0 0 0 / .05); }
.mine .bubble { background: var(--mine); color: var(--mine-t); border-radius: 16px 4px 16px 16px; }
.mine .bubble a { color: inherit; }
.quote { border-left: 3px solid var(--gold-d); padding: 1px 0 1px 8px; margin-bottom: 6px; font-size: 13px; opacity: .8; display: grid; }
.quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media { cursor: pointer; }
.pic { display: block; max-width: min(280px, 100%); max-height: 320px; border-radius: 14px; cursor: zoom-in; }
.filecard { display: flex; align-items: center; gap: 10px; }
.filecard a { display: grid; text-decoration: none; color: inherit; min-width: 0; }
.filecard em { font-style: normal; font-size: 12px; opacity: .7; }
.stkmsg { width: 104px; cursor: pointer; color: var(--text); }
.stkmsg svg { display: block; width: 100%; }
.bcard { width: 240px; max-width: 100%; background: var(--ink); color: #f3ecdc; border-radius: 14px; overflow: hidden; cursor: pointer; border: 1px solid var(--ink2); }
.bcard .top { display: flex; gap: 12px; align-items: center; padding: 16px 14px; border-bottom: 2px solid var(--gold); }
.bcard .top > span:last-child { display: grid; min-width: 0; }
.bcard em { font-style: normal; font-size: 12px; color: #b9b09d; }
.bcard button { width: 100%; padding: 9px; color: var(--gold); font-weight: 600; font-size: 13px; }
.rxs { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.rxs button { padding: 1px 8px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 12px; }
.rxs button.on { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 22%, var(--card)); }
.pop { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 28px rgb(0 0 0 / .18); padding: 6px; margin-top: 4px; z-index: 3; }
.pop .rx { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 2px; }
.pop .rx button { font-size: 20px; width: 36px; height: 36px; border-radius: 8px; }
.pop .rx button:hover { background: color-mix(in srgb, var(--gold) 20%, transparent); }
.pop .ops { display: flex; }

#composer { background: var(--paper); border-top: 1px solid var(--line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.crow { display: flex; align-items: flex-end; gap: 2px; }
#input { flex: 1; min-width: 0; border-radius: 18px; padding: 8px 14px; max-height: 140px; margin: 0 4px; }
.sendbtn { background: var(--gold); color: var(--ink); border-radius: 50%; }
.sendbtn:hover { background: var(--gold); color: var(--ink); filter: brightness(1.08); }
#replybar { display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px 10px; border-left: 3px solid var(--gold); margin-bottom: 6px; }
#replybar > span { flex: 1; display: grid; min-width: 0; font-size: 13px; }
#replybar em { font-style: normal; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stk { padding: 6px 4px 10px; max-height: 250px; overflow-y: auto; }
.stkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.stkgrid button { padding: 6px; border-radius: 12px; color: var(--text); }
.stkgrid button:hover, .emo button:hover { background: color-mix(in srgb, var(--gold) 18%, transparent); }
.stkgrid svg { display: block; width: 100%; }
.emo { display: flex; flex-wrap: wrap; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.emo button { font-size: 22px; width: 40px; height: 40px; border-radius: 8px; }

/* pages */
.page { width: min(680px, 100%); margin: 0 auto; padding: 28px 18px 60px; overflow-y: auto; flex: 1; }
#main:has(.page) { overflow-y: auto; background: var(--paper); }
.page h2 { font: 700 28px var(--serif); letter-spacing: .06em; }
.page h3 { font: 700 18px var(--serif); margin: 28px 0 10px; }
.lead { color: var(--mute); margin: 4px 0 18px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.post { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.post header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post > p { white-space: pre-wrap; overflow-wrap: anywhere; }
.pimg { display: block; max-width: 100%; max-height: 420px; border-radius: 12px; margin-top: 10px; }
.compose textarea { border: 0; padding: 4px; background: none; margin-bottom: 8px; }
.compose select { width: auto; padding: 5px 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.chips button { padding: 5px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); white-space: nowrap; font-size: 14px; }
.chips button.on { background: var(--ink); color: var(--gold); border-color: var(--ink); }
.pacts { display: flex; gap: 16px; margin: 12px 0 2px; color: var(--mute); font-size: 14px; }
.pacts button { display: inline-flex; align-items: center; gap: 4px; }
.pacts button.on { color: var(--danger); }
.pacts span { display: grid; }
.cmts { list-style: none; padding: 10px 0 0; margin: 10px 0; border-top: 1px solid var(--line); display: grid; gap: 4px; font-size: 14px; }
.post .rowf { margin-top: 8px; }
.form .btn { margin-top: 4px; }
.avedit { display: grid; justify-items: center; gap: 4px; margin: 0 auto 14px; color: var(--mute); }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.page > .btn.danger { margin-top: 10px; }

/* modal */
#modal { position: fixed; inset: 0; background: rgb(10 8 4 / .55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.sheet { background: var(--paper); border-radius: 18px; width: min(420px, 100%); max-height: 86dvh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgb(0 0 0 / .35); }
.sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 10px 20px; border-bottom: 1px solid var(--line); }
.sheet h3 { font: 700 18px var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .body { padding: 16px 18px 18px; overflow-y: auto; }
.sheet .body .sec { padding-left: 0; }
.sheet .item { padding-left: 4px; padding-right: 4px; border-radius: 10px; }
.sheet.light { width: auto; max-width: 96vw; }
.full { display: block; max-width: 100%; max-height: 78dvh; }
.results { margin-top: 10px; min-height: 60px; }
.invite { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; }
.picker { max-height: 44dvh; overflow-y: auto; margin-bottom: 12px; }
.picker input { flex: none; width: 18px; height: 18px; accent-color: var(--gold-d); }
.profile { padding: 26px 22px 18px; text-align: center; display: grid; justify-items: center; gap: 6px; overflow-y: auto; }
.profile h4 { font: 700 22px var(--serif); margin-top: 8px; }
.profile .role, .profile .id { color: var(--mute); font-size: 14px; }
.profile .bio { white-space: pre-wrap; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.acts.minor { margin-top: 4px; }
.menu .btn.row:last-child { border-bottom: 0; }

/* call */
#call { position: fixed; inset: 0; background: #0d0b07; z-index: 30; color: #f3ecdc; display: grid; place-items: center; }
#rv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#rv.audio { opacity: 0; }
#lv { position: absolute; right: 16px; top: 16px; width: min(28vw, 180px); border-radius: 12px; border: 2px solid var(--gold); z-index: 2; }
.cinfo { position: relative; text-align: center; display: grid; justify-items: center; gap: 8px; z-index: 1; }
#call.live:has(#rv:not(.audio)) .cinfo { display: none; }
.cinfo h3 { font: 700 26px var(--serif); margin-top: 10px; }
.cinfo p { color: var(--gold); }
.cbtns { position: absolute; bottom: max(40px, env(safe-area-inset-bottom)); display: flex; gap: 40px; z-index: 2; }
.cbtns button { width: 66px; height: 66px; border-radius: 50%; color: #fff; display: grid; place-items: center; }
.cbtns .ok { background: var(--ok); }
.cbtns .no { background: var(--danger); }

/* admin & reports */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 2px; }
.tile small { color: var(--mute); font-size: 13px; }
.tile strong { font: 700 28px var(--serif); font-variant-numeric: tabular-nums; }
.tile.warn { border-color: var(--danger); }
.tile.warn strong { color: var(--danger); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; background: var(--card); }
.seg button { padding: 6px 18px; font-size: 14px; }
.seg button.on { background: var(--ink); color: var(--gold); }
.rep header strong { font-weight: 700; }
.rep time { font-size: 12px; color: var(--mute); }
.evidence { background: color-mix(in srgb, var(--danger) 7%, var(--paper)); border-left: 3px solid var(--danger); padding: 10px 12px; border-radius: 8px; }
.evidence p { white-space: pre-wrap; overflow-wrap: anywhere; }
.note { font-size: 13px; color: var(--mute); margin-top: 8px; }
.acts.left { justify-content: flex-start; margin-top: 12px; }
.flag { font-style: normal; color: var(--danger); font-size: 12px; font-weight: 600; }
.tagA { font-style: normal; color: var(--gold-d); font-size: 12px; font-weight: 600; }
.item.flat { padding: 4px 0; }
.ulist { padding: 6px; }
.urow { padding: 10px; flex-wrap: wrap; }
.uacts { display: flex; gap: 6px; }
.filterbar { margin-bottom: 12px; }
.filterbar select { width: auto; }
.radios { display: grid; margin: 4px 0 10px; }
.radios .check { margin: 0; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.radios input { accent-color: var(--gold-d); width: 17px; height: 17px; }
.grow-left { margin-left: auto; font-size: 13px; }
.sitenotice { display: flex; gap: 10px; align-items: flex-start; margin: 4px 12px 8px; padding: 10px 4px 10px 14px; border-radius: 12px; background: var(--ink); color: #f3ecdc; font-size: 13px; }
.page .sitenotice { margin: 0 0 14px; }
.sitenotice b { color: var(--gold); flex: none; }
.sitenotice span { flex: 1; white-space: pre-wrap; padding-top: 1px; }
.sitenotice .ib { width: 26px; height: 26px; color: #9a917e; }
.pop .ops { flex-wrap: wrap; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); background: var(--ink); color: #f3ecdc; padding: 9px 18px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: 90vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid var(--ink2); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* mobile */
@media (max-width: 760px) {
  #auth { grid-template-columns: 1fr; }
  #auth .brand { padding: 30px 24px; }
  #auth .brand ul, #auth .free { display: none; }
  #auth .brand img { width: 52px; height: 52px; }
  #auth h1 { margin: 14px 0 6px; }
  #auth .formwrap { place-items: start center; }
  #app, #app.wide { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  #rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
  #rail .logo { display: none; }
  #list { border-right: 0; }
  #app.pane-list #main, #app.pane-main #list { display: none; }
  #app.chatting #rail { display: none; }
  .backbtn { display: grid; }
  .col { max-width: 80%; }
  .two { grid-template-columns: 1fr; gap: 0; }
  .uacts { width: 100%; padding-left: 52px; }
  .tab { width: 54px; }
  #modal { place-items: end center; padding: 0; }
  .sheet { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
