/* 婭菲後台：品牌暖色（橘黃白金）＋ 思源宋體標題、思源黑體內文。色票與 learn.html 相同。 */
:root{
  --bg:#FFFBF4; --white:#fff; --ink:#1A1614; --brown:#3D2817; --muted:#8B7355; --line:#E5DCC9;
  --line-soft:#F1E8D8; --gold:#F5B82E; --orange:#E87722; --deep:#C85A15; --gold-soft:#FDF1D8;
  --ok:#3F7D55; --ok-soft:#E4F2E8; --danger:#B8461F; --danger-soft:#FBE9E2;
  --radius:12px; --side:232px; --bar-h:56px; --ed-h:65px;
}
*{box-sizing:border-box}
html,body{margin:0}
body{font-family:"Noto Sans TC","PingFang TC",sans-serif;color:var(--ink);background:var(--bg);font-size:15px;line-height:1.65;-webkit-font-smoothing:antialiased}
h1,h2,h3,.serif{font-family:"Noto Serif TC",serif;color:var(--brown)}
a{color:var(--deep)}
.hidden{display:none!important}
.muted{color:var(--muted)}
button,input,select,textarea{font-family:inherit}
/* iPhone 輸入時不自動放大：輸入框一律 16px */
input,select,textarea{font-size:16px}

/* 按鈕：每個畫面只有一個橘金實心主按鈕 */
.btn{text-decoration:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:0 20px;border-radius:999px;border:1.5px solid var(--line);background:var(--white);color:var(--brown);font-size:15px;font-weight:500;cursor:pointer;transition:transform .15s,box-shadow .15s,border-color .15s,color .15s;white-space:nowrap}
.btn:hover{border-color:var(--orange);color:var(--deep)}
.btn:active{transform:translateY(1px)}
.btn:focus-visible,.icon-btn:focus-visible,a:focus-visible{outline:3px solid rgba(232,119,34,.35);outline-offset:2px}
.btn.primary{border:none;background:linear-gradient(135deg,var(--gold),var(--orange));color:#fff;box-shadow:0 6px 16px -8px rgba(232,119,34,.7)}
.btn.primary:hover{color:#fff;box-shadow:0 10px 22px -10px rgba(232,119,34,.8)}
.btn.secondary{background:var(--white)}
.btn.ghost{background:transparent;border-color:transparent;color:var(--muted)}
.btn.ghost:hover{color:var(--deep);border-color:transparent}
.btn.danger{color:var(--danger);border-color:#EBC9BC}
.btn.danger-solid{border:none;background:var(--danger);color:#fff}
.btn.small{min-height:36px;padding:0 14px;font-size:14px}
.btn.block{width:100%}
.btn:disabled{opacity:.55;cursor:not-allowed;transform:none}
.icon-btn{min-width:44px;min-height:44px;border:none;background:transparent;font-size:22px;color:var(--brown);cursor:pointer;border-radius:10px}
.spin{width:14px;height:14px;border:2px solid rgba(255,255,255,.5);border-top-color:#fff;border-radius:50%;display:inline-block;animation:sp .7s linear infinite}
.btn.secondary .spin,.btn .spin.dark{border-color:var(--gold-soft);border-top-color:var(--orange)}
@keyframes sp{to{transform:rotate(360deg)}}

/* 登入／載入 */
.gate{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:24px}
.spinner{width:34px;height:34px;border:3px solid var(--gold-soft);border-top-color:var(--orange);border-radius:50%;animation:sp .8s linear infinite}
.card{background:var(--white);border:1px solid var(--line-soft);border-radius:18px;box-shadow:0 10px 30px -18px rgba(120,70,20,.35);padding:28px}
.login{width:100%;max-width:380px;display:flex;flex-direction:column;gap:14px}
.login-brand{font-family:"Noto Serif TC",serif;font-size:28px;font-weight:700;text-align:center;background:linear-gradient(180deg,var(--gold),var(--deep));-webkit-background-clip:text;background-clip:text;color:transparent}
.login .muted{text-align:center;margin:-6px 0 6px}
.field{display:flex;flex-direction:column;gap:6px}
.field>span,.label{font-size:13px;color:var(--muted);letter-spacing:.04em}
.input,.field input,.field select,.field textarea{width:100%;min-height:44px;padding:10px 14px;border:1.5px solid var(--line);border-radius:10px;background:var(--bg);color:var(--ink);transition:border-color .15s,background .15s}
.field textarea{min-height:90px;resize:vertical;line-height:1.7}
.input:focus,.field input:focus,.field select:focus,.field textarea:focus{outline:none;border-color:var(--orange);background:var(--white)}
.form-err{min-height:1.2em;margin:0;color:var(--danger);font-size:14px}
.or{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:13px}
.or:before,.or:after{content:"";flex:1;height:1px;background:var(--line)}

/* 外殼 */
/* 左欄的白底畫在 .shell 上：內容比螢幕長時，白底與分隔線也一路到底（側欄本身固定在畫面上、太矮時可以捲） */
.shell{display:grid;grid-template-columns:var(--side) 1fr;min-height:100vh;background:linear-gradient(to right,var(--white) calc(var(--side) - 1px),var(--line-soft) calc(var(--side) - 1px) var(--side),transparent var(--side))}
.side{position:sticky;top:0;align-self:start;height:100vh;height:100dvh;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:8px;padding:22px 14px;background:var(--white);border-right:1px solid var(--line-soft)}
.side-brand{font-family:"Noto Serif TC",serif;font-size:22px;font-weight:700;color:var(--brown);padding:4px 12px 16px}
.side-brand span{color:var(--orange);margin-left:4px}
.side-nav{display:flex;flex-direction:column;gap:4px}
.side-nav a{display:flex;align-items:center;min-height:46px;padding:0 14px;border-radius:12px;color:var(--brown);text-decoration:none;font-weight:500}
.side-nav a:hover{background:var(--bg)}
.side-nav a.active{background:var(--gold-soft);color:var(--deep);box-shadow:inset 3px 0 0 var(--orange)}
.side-foot{margin-top:auto;display:flex;flex-direction:column;gap:6px;padding:12px;border-top:1px solid var(--line-soft)}
.who{font-size:12.5px;color:var(--muted);word-break:break-all}
.side-link{font-size:14px;text-decoration:none;min-height:36px;display:flex;align-items:center}
.side-foot .btn.ghost{justify-content:flex-start;padding:0}
.side-legacy{font-size:12.5px;color:var(--muted);text-decoration:none}
.side-legacy:hover{color:var(--deep);text-decoration:underline}
.view-fail{display:flex;flex-direction:column;align-items:center;gap:14px}
.main{min-width:0}
.view{padding:28px 32px 120px;max-width:1180px}
.mobile-bar{display:none}
.scrim{display:none}

/* 頁首（列表） */
.page-head{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-bottom:20px}
.page-head h1{margin:0;font-size:26px}
.page-head .spacer{flex:1}
.filters{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:14px}
.search{flex:1;min-width:200px;max-width:360px}
.seg{display:inline-flex;background:var(--white);border:1.5px solid var(--line);border-radius:999px;padding:3px}
.seg button{min-height:38px;padding:0 14px;border:none;background:transparent;border-radius:999px;color:var(--muted);cursor:pointer;font-size:14px}
.seg button.on{background:var(--brown);color:#fff}

/* 條列式列表 */
.list{background:var(--white);border:1px solid var(--line-soft);border-radius:var(--radius);overflow:hidden}
.row{display:grid;grid-template-columns:1fr 110px 110px 92px;gap:14px;align-items:center;min-height:60px;padding:12px 18px;border-top:1px solid var(--line-soft);color:inherit;text-decoration:none;cursor:pointer}
.row:first-child{border-top:none}
.row:hover{background:var(--bg)}
.row .t{font-family:"Noto Serif TC",serif;font-weight:500;color:var(--brown);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row .c,.row .d{font-size:13.5px;color:var(--muted)}
.row .acts{display:flex;justify-content:flex-end}
.row .meta-line{display:contents}
.list-head{background:var(--bg);font-size:12.5px;color:var(--muted);cursor:default;min-height:40px}
.list-head:hover{background:var(--bg)}
.list-head span:last-child{text-align:right}
.badge{display:inline-flex;align-items:center;justify-content:center;height:26px;padding:0 10px;border-radius:999px;font-size:12.5px;font-weight:500;white-space:nowrap}
.badge.published{background:var(--ok-soft);color:var(--ok)}
.badge.draft{background:var(--gold-soft);color:#9A6408}
.badge.trash{background:#EFE9E1;color:var(--muted)}
.empty{padding:48px 20px;text-align:center;color:var(--muted)}
.empty strong{display:block;font-family:"Noto Serif TC",serif;color:var(--brown);font-size:18px;margin-bottom:6px}
.skeleton span{display:block;height:14px;border-radius:7px;background:linear-gradient(90deg,#F3ECDF 25%,#FBF6EC 50%,#F3ECDF 75%);background-size:200% 100%;animation:sh 1.2s infinite}
.skeleton span:first-child{width:70%}
@keyframes sh{to{background-position:-200% 0}}

/* 編輯器 */
.ed-head{position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:10px;padding:12px 0;margin:-28px 0 16px;background:var(--bg);border-bottom:1px solid var(--line-soft)}
.ed-head .title{font-family:"Noto Serif TC",serif;font-size:18px;font-weight:700;color:var(--brown);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ed-head .spacer{flex:1}
.dirty-dot{width:8px;height:8px;border-radius:50%;background:var(--orange);display:none}
.dirty .dirty-dot{display:inline-block}
.menu{position:relative}
.menu-pop{position:absolute;right:0;top:calc(100% + 6px);min-width:200px;background:var(--white);border:1px solid var(--line);border-radius:12px;box-shadow:0 14px 30px -14px rgba(0,0,0,.25);padding:6px;z-index:20}
.menu-pop button{display:flex;width:100%;min-height:44px;align-items:center;padding:0 12px;border:none;background:none;border-radius:8px;cursor:pointer;font-size:15px;color:var(--brown);text-align:left}
.menu-pop button:hover{background:var(--bg)}
.menu-pop button.danger{color:var(--danger)}
.meta{display:grid;grid-template-columns:1fr 170px 170px;gap:14px;margin-bottom:14px}
.meta .full{grid-column:1/-1}
.slug-row{display:flex;align-items:center;gap:8px}
.slug-row .pfx{font-size:13px;color:var(--muted);white-space:nowrap}
.slug-row .input{min-width:0;flex:1}
.slug-hint{font-size:13px;color:#9A6408}
.tabs{display:none}
.panes{display:grid;grid-template-columns:1fr 1fr;gap:16px;min-height:560px}
.pane{display:flex;flex-direction:column;background:var(--white);border:1px solid var(--line-soft);border-radius:var(--radius);overflow:hidden;min-height:560px}
.toolbar{display:flex;flex-wrap:wrap;gap:6px;padding:8px 10px;border-bottom:1px solid var(--line-soft)}
.toolbar button{min-height:40px;min-width:44px;padding:0 12px;border:1px solid var(--line);background:var(--white);border-radius:9px;cursor:pointer;color:var(--brown);font-size:14px}
.toolbar button:hover{border-color:var(--orange);color:var(--deep)}
.editor-body{flex:1;border:none;resize:none;padding:18px 20px;line-height:1.9;font-family:"Noto Serif TC",serif;font-size:16px;background:var(--white);color:var(--ink);min-height:480px}
.editor-body:focus{outline:none}
.editor-body.drag{background:var(--gold-soft)}
.prev-head{padding:10px 14px;font-size:12.5px;color:var(--muted);border-bottom:1px solid var(--line-soft)}
.preview{flex:1;width:100%;border:none;min-height:480px;background:#fff}
.actions{display:flex;gap:10px;align-items:center}
.sec-card{border:1px solid var(--line-soft);border-radius:12px;padding:14px;background:var(--bg);display:flex;flex-direction:column;gap:10px}
.sec-card .sec-top{display:flex;align-items:center;gap:8px}
.sec-card .num{font-family:"Noto Serif TC",serif;color:var(--orange);font-weight:700;min-width:28px}
.check{display:inline-flex;align-items:center;gap:8px;min-height:44px;cursor:pointer}
.check input{width:20px;height:20px;accent-color:var(--orange)}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 14px;border:1.5px solid var(--line);border-radius:999px;background:var(--white);cursor:pointer;font-size:14px}
.chip input{accent-color:var(--orange)}
.chip.on{border-color:var(--orange);background:var(--gold-soft);color:var(--deep)}

/* 名詞百科 */
@media (min-width:861px){ .list.gl .row{grid-template-columns:1fr 200px 64px 92px} }
.list.gl .row .c{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.list.gl .row .c:empty{display:none}
.panes.gl{align-items:start}
.panes.gl .pane.edit{padding:14px 18px 20px;min-height:0}
/* 電腦版：左邊表單很長，右邊預覽黏在頁首下方，捲到哪都看得到 */
.panes.gl .pane.prev{position:sticky;top:84px;height:calc(100vh - 100px);min-height:480px}
.prev-state{color:var(--danger)}
.gl-mode{align-self:flex-start;font-size:14px;color:var(--muted)}
.gl-sec{display:flex;flex-direction:column;gap:12px;padding:18px 0;border-top:1px solid var(--line-soft)}
.gl-sec:first-child{border-top:none;padding-top:6px}
.gl-sec h3{margin:0;font-size:17px}
.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.hint{font-size:12px;color:#A8977F;letter-spacing:0;font-weight:400;font-family:"Noto Sans TC","PingFang TC",sans-serif}
.counter{font-size:12.5px;color:var(--muted)}
.counter.over{color:var(--danger)}
.sec-list{display:flex;flex-direction:column;gap:12px}
.sec-empty{padding:18px;border:1.5px dashed var(--line);border-radius:12px}
.sec-card.warm{background:#FDF3E3;border-color:#F1DDB8}
.sec-card .sec-top{gap:4px}
.sec-card .sec-top .spacer{flex:1}
.sec-card .check{font-size:14px;color:var(--muted)}
.sec-card .icon-btn{font-size:18px}
.sec-card .field input,.sec-card .field textarea{background:var(--white)}
.icon-btn:disabled{opacity:.28;cursor:default}
.icon-btn:not(:disabled):hover{background:var(--gold-soft)}
.chip.missing{border-color:#EBC9BC;background:var(--danger-soft);color:var(--danger)}
.gl-adv{display:flex;flex-direction:column;gap:8px}
.gl-adv p{margin:0;font-size:14px}
.raw-md{width:100%;min-height:65vh;padding:14px;border:1.5px solid var(--line);border-radius:10px;background:var(--bg);color:var(--ink);font-family:ui-monospace,Menlo,monospace;font-size:16px;line-height:1.7;resize:vertical}
.raw-md:focus{outline:none;border-color:var(--orange);background:var(--white)}

/* toast / 對話框 */
.toast{position:fixed;left:50%;width:max-content;bottom:calc(24px + env(safe-area-inset-bottom));transform:translate(-50%,20px);display:flex;align-items:center;gap:14px;max-width:min(92vw,560px);padding:12px 18px;border-radius:12px;background:var(--brown);color:#fff;font-size:15px;opacity:0;pointer-events:none;transition:.22s;z-index:100;box-shadow:0 12px 30px -12px rgba(0,0,0,.45)}
.toast.show{opacity:1;transform:translate(-50%,0);pointer-events:auto}
.toast.ok{background:var(--ok)}
.toast.err{background:var(--danger)}
.toast-action{min-height:36px;padding:0 12px;border:1.5px solid rgba(255,255,255,.7);border-radius:999px;background:transparent;color:#fff;cursor:pointer;font-weight:700}
.modal{position:fixed;inset:0;background:rgba(40,28,16,.45);display:flex;align-items:center;justify-content:center;padding:20px;z-index:90}
.modal .box{width:100%;max-width:480px;max-height:84vh;overflow:auto;background:var(--white);border-radius:16px;padding:22px;box-shadow:0 24px 60px -20px rgba(0,0,0,.5)}
.modal-msg{margin:0 0 18px;line-height:1.8;color:var(--brown)}
.modal .acts{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}
.rev-list{display:flex;flex-direction:column;gap:6px;margin:12px 0}
.rev{display:flex;align-items:center;gap:10px;min-height:48px;padding:6px 10px;border:1px solid var(--line-soft);border-radius:10px}
.rev .when{flex:1;font-size:14px}
.rev .badge{height:22px;font-size:12px;margin-left:4px}
.stu table{width:100%;border-collapse:collapse;font-size:14px}
.stu th,.stu td{padding:10px 8px;border-bottom:1px solid var(--line-soft);text-align:left}
.stu .tag{display:inline-block;padding:2px 10px;border-radius:999px;background:var(--gold-soft);color:var(--deep);font-size:12.5px;margin:2px}
.stu .prog-row{display:grid;grid-template-columns:200px 1fr 60px;gap:12px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line-soft)}
.stu .prog-cells{display:flex;flex-wrap:wrap;gap:6px}
.stu .prog-cell{width:34px;text-align:center}
.stu .bar{height:8px;background:#F1E8D8;border-radius:4px;overflow:hidden}
.stu .bar i{display:block;height:100%;background:linear-gradient(90deg,var(--gold),var(--orange))}
.stu .bar i.done{background:var(--ok)}
.stu .lb{font-size:11px;color:var(--muted)}
.stu .prog-who b{display:block;color:var(--brown)}
.stu .prog-who span{font-size:12.5px;color:var(--muted);word-break:break-all}
.stu .prog-total{text-align:right;font-weight:700;color:var(--deep)}
.stu .prog-head{font-size:12.5px;color:var(--muted);padding:0 0 6px;border-bottom:2px solid var(--line-soft)}
.stu .prog-head .prog-total{color:var(--muted);font-weight:400}
.stu .table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
.stack{display:flex;flex-direction:column;gap:18px}

/* 手機 */
@media (max-width:860px){
  .shell{display:block;background:none}
  /* 收起時完全隱藏（不露出陰影、Tab 鍵也不會跳進去）；打開才有陰影 */
  .side{position:fixed;left:0;top:0;bottom:0;width:78vw;max-width:300px;z-index:60;transform:translateX(-100%);visibility:hidden;transition:transform .25s,visibility 0s .25s}
  .menu-open .side{transform:none;visibility:visible;transition:transform .25s;box-shadow:10px 0 30px -10px rgba(0,0,0,.3)}
  .menu-open .scrim{display:block;position:fixed;inset:0;background:rgba(40,28,16,.35);z-index:50}
  .mobile-bar{position:sticky;top:0;z-index:40;display:flex;align-items:center;gap:6px;height:var(--bar-h);padding:0 8px;background:var(--white);border-bottom:1px solid var(--line-soft)}
  .mobile-title{font-family:"Noto Serif TC",serif;font-weight:700;color:var(--brown)}
  .view{padding:18px 16px calc(110px + env(safe-area-inset-bottom))}
  .page-head h1{font-size:22px}
  .search{max-width:none;min-width:0;flex-basis:100%}
  .row{grid-template-columns:1fr auto;grid-template-areas:"t s" "m m";row-gap:4px;padding:12px 14px}
  .row .t{grid-area:t;white-space:normal}
  .row .acts{grid-area:s}
  .row .c,.row .d{display:inline;font-size:12.5px}
  .row .meta-line{grid-area:m;display:flex;gap:10px}
  .list-head{display:none}
  .list-head+.row{border-top:none}
  /* 頁首固定高度：下面的「編輯／預覽」分頁剛好黏在它正下方 */
  .ed-head{top:var(--bar-h);height:var(--ed-h);margin:-18px -16px 12px;padding:10px 16px}
  .ed-head .actions{display:none}
  .meta{grid-template-columns:1fr 1fr}
  .meta .field:first-child{grid-column:1/-1}
  /* 分頁黏在頁首下方：往下捲到內文也按得到；後面墊一塊底色（方的，圓角處不露出捲過去的內容） */
  .tabs{display:flex;position:sticky;top:calc(var(--bar-h) + var(--ed-h));z-index:4;border-radius:999px;padding:4.5px;margin-bottom:10px}
  .tabs::before{content:"";position:absolute;inset:0 -16px -8px;background:var(--bg);z-index:-1}
  .tabs::after{content:"";position:absolute;inset:0;background:var(--white);border:1.5px solid var(--line);border-radius:999px;z-index:-1}
  .tabs button{flex:1;min-height:40px;border:none;background:transparent;border-radius:999px;color:var(--muted);font-size:15px}
  .tabs button.on{background:var(--brown);color:#fff}
  .toolbar{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch}
  .toolbar button{flex:none}
  .panes{display:block}
  .panes .pane{min-height:60vh}
  .panes[data-tab="edit"] .pane.prev,.panes[data-tab="prev"] .pane.edit{display:none}
  /* 存檔／發佈固定在畫面底部，捲到哪都按得到 */
  .bottom-bar{position:fixed;left:0;right:0;bottom:0;z-index:45;display:flex;gap:10px;padding:10px 16px calc(10px + env(safe-area-inset-bottom));background:rgba(255,251,244,.96);backdrop-filter:blur(6px);border-top:1px solid var(--line-soft)}
  .bottom-bar .btn{flex:1}
  .panes.gl .pane.prev{position:static;height:auto;min-height:70vh}
  .panes.gl .pane.edit{padding:12px 14px 18px}
  .two{grid-template-columns:1fr}
  .list.gl .row .c{white-space:normal}
  .stu .prog-row{grid-template-columns:1fr 50px}
  .stu .prog-cells{grid-column:1/-1;order:3}
  .stu .prog-head{display:none}
  .card{padding:20px 18px}
  /* 待開通名單：手機改成一筆一張小卡（不用左右滑） */
  .stu table,.stu tbody{display:block}
  .stu tr:first-child{display:none}
  .stu tr{display:grid;grid-template-columns:1fr auto;gap:2px 10px;padding:10px 0;border-bottom:1px solid var(--line-soft)}
  .stu td{display:block;padding:0;border:none}
  .stu td:nth-child(1){grid-column:1;word-break:break-all;font-weight:500;color:var(--brown)}
  .stu td:nth-child(2){grid-column:1}
  .stu td:nth-child(3){grid-column:1;font-size:12.5px;color:var(--muted)}
  .stu td:nth-child(4){grid-column:2;grid-row:1/4;align-self:center}
}
@media (min-width:861px){ .bottom-bar{display:none} }
/* 手機／觸控：所有可以按的東西至少 44px 高 */
@media (max-width:860px),(pointer:coarse){
  .btn.small,.side-link,.toast-action,.seg button,.tabs button,.toolbar button,.chip{min-height:44px}
}
