:root{
  --bg:#0b0b0d; --surface:#141418; --surface2:#1c1c22; --line:#2a2a33;
  --text:#ece6d8; --muted:#a09a8c; --gold:#d9b45b; --gold2:#f0d488;
  --jade:#7fb89b; --accent:#8b7fd4; --shadow:rgba(0,0,0,.5);
  --r:14px; --maxw:860px;
}
html[data-theme="light"]{
  --bg:#faf8f3; --surface:#fff; --surface2:#f2eee4; --line:#ddd7c8;
  --text:#2a251c; --muted:#6b6455; --gold:#9a7420; --gold2:#7a5c14;
  --jade:#2f7a55; --accent:#5b4fa8; --shadow:rgba(60,50,20,.12);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--text);
  font-family:"Noto Sans TC","PingFang TC","Microsoft JhengHei","Segoe UI",system-ui,sans-serif;
  line-height:1.7; -webkit-font-smoothing:antialiased; min-height:100vh;
}
#app{max-width:var(--maxw); margin:0 auto; padding:0 16px 40px}
.hidden{display:none !important}

.topbar{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:18px 0 14px; border-bottom:1px solid var(--line); flex-wrap:wrap}
.brand{display:flex; align-items:center; gap:12px}
.brand-mark{font-size:30px; color:var(--gold); line-height:1; width:34px; height:34px; display:inline-flex; flex:0 0 34px}
.brand-text{display:flex; flex-direction:column; line-height:1.2}
.brand-text strong{font-size:19px; font-weight:600; color:var(--gold2); letter-spacing:.5px}
.brand-text small{font-size:11px; color:var(--muted); letter-spacing:1px}
.top-actions{display:flex; align-items:center; gap:8px; flex-wrap:wrap}
select,button{font-family:inherit; font-size:13px}
#lang-select{background:var(--surface); color:var(--text); border:1px solid var(--line); border-radius:8px; padding:7px 8px}
.icon-btn{background:var(--surface); color:var(--gold); border:1px solid var(--line); border-radius:8px; width:34px; height:34px; cursor:pointer; font-size:16px}
.sync-box{display:flex; align-items:center; gap:6px}
.sync-status{color:var(--muted); font-size:16px; width:14px; text-align:center}
.sync-status.on{color:var(--jade)}
.login-btn{background:var(--gold); color:#1a1408; border:none; border-radius:8px; padding:7px 12px; font-weight:600; cursor:pointer}
.login-btn:hover{background:var(--gold2)}
.user-chip{display:flex; align-items:center; gap:7px; padding:2px 10px 2px 3px; border:1px solid var(--gold); border-radius:999px; background:var(--surface2); max-width:170px}
.user-avatar{width:28px; height:28px; border-radius:50%; object-fit:cover; border:2px solid var(--gold); background:var(--surface2); flex:0 0 28px}
.user-name{font-size:12px; color:var(--gold2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:110px}
html[data-theme="light"] .user-name{color:#7a5c14}

.tabs{display:flex; gap:4px; overflow-x:auto; padding:12px 0; border-bottom:1px solid var(--line); position:sticky; top:0; background:var(--bg); z-index:5}
.tab{background:transparent; color:var(--muted); border:none; padding:9px 14px; border-radius:8px; cursor:pointer; white-space:nowrap}
.tab.active{background:var(--surface2); color:var(--gold2); font-weight:600}

.main{padding:22px 0; min-height:50vh}
h1{font-size:24px; color:var(--gold2); margin:0 0 6px; font-weight:600}
h2{font-size:18px; color:var(--text); margin:26px 0 10px; font-weight:600}
h3{font-size:15px; color:var(--gold); margin:22px 0 8px; font-weight:600}
p{margin:10px 0; color:var(--text)}
.lead{color:var(--muted); font-size:14px; margin-bottom:20px}

.card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:20px; margin:14px 0}
.card.ref{border-color:#7a5c2a; background:linear-gradient(180deg,rgba(217,180,91,.06),transparent)}
.badge{display:inline-block; font-size:11px; padding:3px 9px; border-radius:20px; background:var(--surface2); color:var(--muted); border:1px solid var(--line); margin-left:8px}
.badge.ref{color:var(--gold); border-color:var(--gold)}

.grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:12px; margin:14px 0}
.tile{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:18px 14px; cursor:pointer; text-align:center; transition:border-color .15s,transform .15s}
.tile:hover{border-color:var(--gold); transform:translateY(-2px)}
.tile .ic{font-size:26px; color:var(--gold); display:block; margin-bottom:8px}
.tile .ttl{font-size:14px; color:var(--text); font-weight:600}
.tile .sub{font-size:11px; color:var(--muted); margin-top:4px}
.tile.ref .ic{color:var(--accent)}

.steps{counter-reset:st; list-style:none; padding:0; margin:12px 0}
.steps li{position:relative; padding:10px 0 10px 38px; border-bottom:1px dashed var(--line); color:var(--text)}
.steps li:before{counter-increment:st; content:counter(st); position:absolute; left:0; top:10px; width:24px; height:24px; border-radius:50%; background:var(--surface2); border:1px solid var(--gold); color:var(--gold); font-size:12px; display:flex; align-items:center; justify-content:center}
.bullets{padding-left:20px; color:var(--text)}
.bullets li{margin:6px 0}
.note{background:var(--surface2); border-left:3px solid var(--gold); padding:12px 16px; border-radius:0 8px 8px 0; margin:14px 0; font-size:14px; color:var(--muted)}
.notice{background:rgba(217,180,91,.1); border:1px solid var(--gold); border-radius:10px; padding:14px 16px; margin:14px 0; color:var(--gold2); font-size:14px}

.audio-row{display:flex; align-items:center; gap:12px; background:var(--surface2); border:1px solid var(--line); border-radius:10px; padding:12px; margin:10px 0; flex-wrap:wrap}
.audio-row .a-title{flex:1; min-width:160px; font-size:13px; color:var(--text)}
.audio-row audio{width:100%; height:36px; margin-top:6px}

.counter-panel{display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:12px; margin:16px 0}
.stat{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:18px; text-align:center}
.stat .num{font-size:30px; color:var(--gold2); font-weight:600; line-height:1.2}
.stat .lbl{font-size:12px; color:var(--muted); margin-top:4px}
.count-list{display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:10px; margin:14px 0}
.count-item{background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:12px; display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.count-item .nm{flex:1; font-size:12px; color:var(--text); min-width:80px}
.count-item .val{color:var(--gold2); font-weight:600; font-size:15px}
.mini-btn{background:var(--surface2); color:var(--gold); border:1px solid var(--line); border-radius:6px; width:30px; height:30px; cursor:pointer; font-size:15px}
.primary-btn{background:var(--gold); color:#1a1408; border:none; border-radius:8px; padding:10px 18px; font-weight:600; cursor:pointer; margin:6px 4px 6px 0}

textarea{width:100%; min-height:120px; background:var(--surface); color:var(--text); border:1px solid var(--line); border-radius:10px; padding:12px; font-family:inherit; font-size:14px; resize:vertical}
.note-entry{background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:14px; margin:10px 0}
.note-entry .meta{font-size:11px; color:var(--muted); display:flex; justify-content:space-between; align-items:center}
.note-entry .body{white-space:pre-wrap; margin-top:8px; color:var(--text)}

.modal{position:fixed; inset:0; z-index:50; display:flex; align-items:center; justify-content:center; padding:20px}
.modal-backdrop{position:absolute; inset:0; background:rgba(0,0,0,.7)}
.modal-card{position:relative; background:var(--surface); border:1px solid var(--gold); border-radius:16px; max-width:560px; width:100%; max-height:88vh; overflow-y:auto; padding:24px; box-shadow:0 20px 60px var(--shadow)}
.modal-close{position:absolute; top:12px; right:12px; background:var(--surface2); color:var(--muted); border:1px solid var(--line); border-radius:8px; width:32px; height:32px; cursor:pointer}
.sym-hero{display:flex; gap:20px; align-items:flex-start; flex-wrap:wrap}
.sym-hero img{width:180px; height:180px; object-fit:contain; background:#fff; border-radius:10px; padding:8px}
.sym-info{flex:1; min-width:200px}
.sym-name{font-size:24px; color:var(--gold2); font-weight:600; margin:0}
.sym-pron{color:var(--muted); font-size:13px; margin:4px 0 14px}

/* ---------- 文字播音 ---------- */
.spk-head{display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap}
.spk-head h2{margin-top:0}
.spk-head h2 .spk-btn{position:static; opacity:1; margin-left:4px}
.spk-top{display:flex; justify-content:flex-end; margin:4px 0 10px}
.read-btn{background:var(--surface2); color:var(--gold); border:1px solid var(--gold); border-radius:8px; padding:6px 12px; font-size:12px; cursor:pointer; white-space:nowrap; transition:background .15s,color .15s}
.read-btn:hover{background:var(--gold); color:#1a1408}
.read-btn.chapter{font-size:11px; padding:4px 10px}
.spk-item{position:relative}
.spk-btn{position:absolute; right:6px; top:6px; background:transparent; border:1px solid transparent; border-radius:6px; color:var(--gold); font-size:13px; line-height:1; padding:3px 5px; cursor:pointer; opacity:.45; transition:opacity .15s,background .15s}
.spk-item:hover .spk-btn,.spk-btn:focus{opacity:1}
.spk-btn:hover{background:var(--surface2); border-color:var(--line)}
.steps li.spk-item,.bullets li.spk-item{padding-right:40px}
.tts-active{background:rgba(217,180,91,.14); border-radius:8px; box-shadow:inset 3px 0 0 var(--gold)}
.spk-item.tts-active .spk-btn{opacity:1}
.tts-bar{position:fixed; left:50%; bottom:14px; transform:translateX(-50%); z-index:80; width:min(720px,calc(100% - 20px)); background:var(--surface); border:1px solid var(--gold); border-radius:14px; box-shadow:0 12px 40px var(--shadow); padding:10px 12px}
.tts-main{display:flex; align-items:center; gap:10px; flex-wrap:wrap}
.tts-btns{display:flex; gap:4px}
.tts-btn{background:var(--surface2); color:var(--gold); border:1px solid var(--line); border-radius:8px; min-width:34px; height:34px; cursor:pointer; font-size:14px}
.tts-btn:hover{border-color:var(--gold)}
.tts-play{background:var(--gold); color:#1a1408; font-weight:700; border-color:var(--gold)}
.tts-info{flex:1; min-width:130px}
.tts-now{font-size:12px; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.tts-meta{font-size:11px; color:var(--muted); margin-top:2px}
.tts-tools{display:flex; align-items:center; gap:6px}
.tts-tools select{background:var(--surface2); color:var(--text); border:1px solid var(--line); border-radius:6px; padding:5px}
.tts-voice{font-size:10px; color:var(--muted); max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.tts-x{min-width:26px; height:26px; font-size:12px}
.tts-dl{font-size:13px}
.brand-mark img{width:100%;height:100%;object-fit:cover;border-radius:50%;display:block}
.brand-hero{display:flex;justify-content:center;margin:6px 0 18px}
.brand-logo{width:min(100%,560px);height:auto;border-radius:14px;border:1px solid var(--line);box-shadow:0 8px 30px var(--shadow)}
.tts-dlprog{margin-top:8px; padding:6px 10px; border-radius:8px; background:var(--surface2); border:1px solid var(--line); color:var(--gold); font-size:11px; text-align:center}
.hidden{display:none!important}

.footer{border-top:1px solid var(--line); padding:20px 0; margin-top:30px; color:var(--muted); font-size:11px; text-align:center}
.footer p{margin:4px 0; color:var(--muted)}
@media(max-width:600px){.brand-text strong{font-size:16px}.topbar{padding:12px 0}h1{font-size:20px}.modal-card{padding:18px}.sym-hero img{width:140px;height:140px}.tts-voice{display:none}.tts-bar{bottom:6px;padding:8px}.tts-main{gap:6px}.tts-info{min-width:90px}}

/* 粵語冥想導引播放器 */
.med-guide{margin-top:14px;padding:14px;border:1px solid var(--gold);border-radius:12px;background:linear-gradient(180deg,rgba(217,180,91,.07),transparent)}
.med-guide-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:8px}
.med-badge{background:var(--gold);color:#1a1408;font-size:11px;font-weight:700;padding:2px 9px;border-radius:999px;white-space:nowrap}
.med-title{font-size:14px;color:var(--gold2);font-weight:600}
.med-status{font-size:12px;color:var(--muted);margin-bottom:10px}
.med-controls{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:10px}
.med-btn{background:var(--surface2);color:var(--gold);border:1px solid var(--line);border-radius:8px;padding:7px 12px;font-size:13px;cursor:pointer;transition:background .15s}
.med-btn:hover{background:var(--surface)}
.med-btn:disabled{opacity:.6;cursor:default}
.med-play{background:var(--gold);color:#1a1408;border-color:var(--gold);font-weight:600;min-width:90px}
.med-play:hover{background:var(--gold2)}
.med-dl{font-size:12px}
.med-text{font-size:13px;line-height:1.8;color:var(--text);background:var(--surface);border-radius:8px;padding:10px 12px;min-height:44px;max-height:120px;overflow:auto;margin-bottom:10px}
.med-progress{display:flex;align-items:center;gap:10px;margin-bottom:8px}
.med-bar{flex:1;height:5px;background:var(--surface2);border-radius:99px;overflow:hidden}
.med-fill{height:100%;background:linear-gradient(90deg,var(--gold),var(--gold2));width:0;transition:width .3s}
.med-count{font-size:11px;color:var(--muted);white-space:nowrap;min-width:48px;text-align:right}
.med-list{font-size:12px;color:var(--muted)}
.med-list summary{cursor:pointer;padding:4px 0}
.med-ol{margin:6px 0 0;padding-left:22px;max-height:180px;overflow:auto}
.med-li{padding:3px 4px;border-radius:6px;cursor:pointer;line-height:1.6}
.med-li:hover{background:var(--surface2)}
.med-li.active{background:var(--surface2);color:var(--gold2);font-weight:600}
