/* ============================================================================
   CatcherBiz 後台共用設計系統  ·  assets/admin.css
   ----------------------------------------------------------------------------
   本檔案是後台介面的「唯一真相」。以往每一頁都各自抄一份 <style>，
   結果各頁顏色、圓角、字級全都不同（同一個按鈕有 12.5px / 14px / 14.5px
   三個版本，圓角有 999px / 9px / 8px 三個版本）。現時全部集中在此。

   ⚠️ 本檔案只負責「後台介面」。
      IG 版式（slide）的外觀由 assets/carousel.css 負責，兩者不可混用。
      shot.php 截圖輸出用的是 carousel.css，改錯會污染已發佈的圖。

   目錄
     1. TOKENS       設計變數（顏色 / 間距 / 圓角 / 動態）
     2. RESET + BASE 重設、字體、焦點環、icon
     3. LAYOUT       .wrap / .top / .spacer / .grid / .full / .row / .formbar
     4. COMPONENTS   .card / 按鈕 / 表單 / .msg / .note / .pill / 表格 / code…
     5. LOGIN        登入頁（置中卡片，不用 .wrap）
     6. RESPONSIVE   窄螢幕
     7. MOTION       prefers-reduced-motion
   ========================================================================== */


/* ==========================================================================
   1. TOKENS
   --------------------------------------------------------------------------
   顏色以 index.php 那套「已做過無障礙修正」的值為準：
     --gold-ink   #96650F   白底 5.04:1（原本 #D99B2B 只有 1.9，不可用作文字色）
     --ink-muted  #5A6870   所有底色上都 ≥ 4.59:1（原本 #7A8890 只有 2.9）

   ⚠️ 為何叫 --gold-ink / --ink-muted，而非沿用 carousel.css 的
      --primary-deep / --muted？
      因為 carousel.css 也有這兩個名稱，但值不同：
          --primary-deep   carousel #C4841A   vs   後台 #96650F
          --muted          carousel #6E7E86   vs   後台 #5A6870
      CSS 自訂 property 是會繼承的。index.php（縮圖）、editor.php
      （右邊預覽）、palette-check.php（版式牆）都會在後台版面中渲染真正的
      IG slide；若後台在 :root 覆蓋這兩個名稱，slide 便會用後台的值繪製，
      與 shot.php／render.php 輸出的圖不一致（.lead、.tag、.kicker、
      h2.big .hl 全部使用它們）。
      carousel.js 的 applyBrand() 只在租戶確實選定品牌色時才寫 inline
      值到 html；未選定時是 removeProperty()，即退回 stylesheet ——
      所以「不宣告」是唯一穩妥的做法。改名之後兩套色永遠不會相撞。
   ========================================================================== */
:root{
  /* ---- 品牌色 ---- */
  --primary:#D99B2B;          /* 金：填色、強調底，不可用作小字 */
  --gold-ink:#96650F;         /* 金（文字安全版）5.04:1 on #fff。⚠️ 不可改名為
                                 --primary-deep：會與 carousel.css 相撞，見上方說明。 */
  --dark:#1C5470;             /* 主要深藍綠：標題、主要按鈕 */
  --dark-hover:#17455D;
  --bg:#F1EADB;               /* 後台頁底（暖奶油） */
  --bg-alt:#EDE7DA;           /* 稍深頁底：登入頁、配色檢查台 */
  --card:#fff;
  --border:#E7DFCC;
  --border-strong:#D9CDB0;    /* hover 時的邊框 */
  --ink:#243B44;              /* 正文 */
  --ink-on-primary:#3A2606;   /* 金底上的文字 5.96:1 */
  --ink-muted:#5A6870;        /* 次要文字。⚠️ 同上，不可改名為 --muted。 */
  --ring:#1C5470;             /* 鍵盤焦點環 */

  /* ---- 中性表面 ---- */
  --field:#FCFAF4;            /* 輸入框底 */
  --surface:#F4EEE0;          /* code、次要按鈕、表頭 */
  --surface-hover:#E9E0CB;
  --zebra:#FCFAF4;            /* 表格間條 */

  /* ---- 狀態色（原本散落在 14 個檔案內的固定 hex）---- */
  --ok-bg:#EDF6F0;   --ok-border:#B7DCC5;   --ok-ink:#1F5C39;   /* 6.9:1 */
  --bad-bg:#FBECEA;  --bad-border:#E8B4AE;  --bad-ink:#8F1D17;  /* 7.5:1 */
  --note-bg:#FDF6E6; --note-border:#EAD9AE; --note-ink:#7A5B12; /* 6.0:1 */
  --info-bg:#E4EDF2;                                            /* 藍標籤底 */
  --gold-bg:#FDF3DD;                                            /* 金標籤底 */
  --neutral-bg:#EEEDE8;                                         /* 灰標籤底 */
  --success:#1F7340;          /* ✅ 內文字 5.86:1 on #fff */
  --danger:#B3261E;           /* ❌ 內文字 6.53:1 on #fff */

  /* ---- 深色代碼區 ---- */
  --code-bg:#1D2B31;
  --code-ink:#E8E3D6;

  /* ---- 間距階梯（以往是 11/12/14/16/18/20/22px 雜亂跳動）---- */
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:24px; --s6:32px;

  /* ---- 圓角 ---- */
  --r-sm:7px;                 /* 標籤、小按鈕 */
  --r-md:9px;                 /* 按鈕、輸入框 */
  --r-lg:14px;                /* 卡片 */
  --r-pill:999px;             /* pill 標籤 */

  /* ---- 動態 ---- */
  --dur:180ms;
  --ease:cubic-bezier(.22,.61,.36,1);
  --shadow:0 6px 16px rgba(28,84,112,.05);
  --shadow-lift:0 10px 24px rgba(28,84,112,.11);
  --focus-ring:0 0 0 3px rgba(28,84,112,.13);

  /* ---- 字體 ---- */
  --font-sans:'Noto Sans TC',system-ui,-apple-system,'Segoe UI',sans-serif;
  --font-serif:'Noto Serif TC',Georgia,serif;
  --font-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}


/* ==========================================================================
   2. RESET + BASE
   ========================================================================== */
*{margin:0;padding:0;box-sizing:border-box;-webkit-font-smoothing:antialiased;}

body{
  background:var(--bg);
  color:var(--ink);
  font-family:var(--font-sans);
  font-size:14px;
  line-height:1.6;
  padding:var(--s6) 18px 80px;
}

/* 統一鍵盤焦點環：一次覆蓋所有可聚焦元素。
   用 :where() 令特異度為 0，個別元件想自訂焦點環一樣可以覆蓋。 */
:where(a,button,input,select,textarea,summary,[tabindex]):focus-visible{
  outline:2px solid var(--ring);
  outline-offset:2px;
  border-radius:var(--r-sm);
}

a{color:var(--dark);}
a:hover{color:var(--gold-ink);}

h1{font-family:var(--font-serif);font-size:23px;color:var(--dark);font-weight:900;line-height:1.35;}
h2{font-size:15px;color:var(--dark);font-weight:900;line-height:1.5;}
h3{font-size:13px;color:var(--dark);font-weight:900;line-height:1.5;}

/* icon sprite（見 inc/layout.php 的 cb_icon_sprite()） */
svg.i{
  width:1em;height:1em;flex-shrink:0;
  stroke:currentColor;fill:none;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round;vertical-align:-.125em;
}
h1 svg.i{width:22px;height:22px;color:var(--gold-ink);}

/* 只供螢幕閱讀器讀取 */
.sr-only{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;
}


/* ==========================================================================
   3. LAYOUT
   ========================================================================== */
.wrap{max-width:940px;margin:0 auto;}
.wrap.narrow{max-width:720px;}
.wrap.wide{max-width:1000px;}

/* 頁首行：標題在左，帳號列在右 */
.top{
  display:flex;align-items:center;gap:var(--s3);flex-wrap:wrap;
  margin-top:var(--s2);
}
.spacer{flex:1;}

/* 返回連結。可點區 44px 高；左右 padding 令「收起」這類短標籤一併夠闊。
   頁首那條向上借 body 的留白，下方留一點空隙，避免點擊區壓住標題。 */
.back{
  display:inline-flex;align-items:center;gap:var(--s1);
  min-height:44px;padding:0 12px;
  font-size:13px;font-weight:700;line-height:1.2;color:var(--ink-muted);text-decoration:none;
  border-radius:var(--r-sm);
  transition:color var(--dur) var(--ease);
}
.back:hover{color:var(--dark);}
.wrap > .back{margin-top:-8px;}
.wrap > .back + .top{margin-top:4px;}

/* 副標 / 說明段 */
.sub{color:var(--ink-muted);font-size:13px;margin-top:6px;line-height:1.8;}
.sub b{color:var(--ink);}

/* 兩欄表單格 */
.grid{display:grid;grid-template-columns:1fr 1fr;gap:var(--s1) var(--s4);}
.full{grid-column:1/-1;}

/* 一行掣／控制項 */
.row{display:flex;gap:var(--s2);flex-wrap:wrap;align-items:center;margin-top:var(--s4);}

/* 貼底工具列（brand.php、dedupe.php 的「儲存」列）
   ⚠️ 刻意叫 .formbar 而非 .bar：editor.php / seo-editor.php 已有一個
      意義完全不同的 .bar（貼頂工具列），而且它們的 JS 用
      document.querySelector('.bar') 取用它。兩者同名必定相撞，
      所以以改名解決，不依賴載入次序。 */
.formbar{
  position:sticky;bottom:0;z-index:5;
  background:var(--bg);
  padding:var(--s4) 0 var(--s1);
  margin-top:var(--s2);
  border-top:1px solid var(--border);
  display:flex;align-items:center;gap:var(--s3);flex-wrap:wrap;
}
/* 貼底儲存是主動作。桌面 .btn／:where(button) 只有 40px，brand「儲存品牌設定」量到約 41px。
   ≤620 的 .btn,button 已是 44px，這裡桌面一併對齊，不改 .btn.sm。 */
.formbar > button,
.formbar > .btn{min-height:44px;}


/* ==========================================================================
   4. COMPONENTS
   ========================================================================== */

/* ---- 卡片 ---------------------------------------------------------------- */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--r-lg);
  padding:var(--s5);
  margin-top:var(--s4);
  box-shadow:var(--shadow);
  transition:border-color var(--dur) var(--ease),box-shadow var(--dur) var(--ease);
}
.card:focus-within{border-color:var(--border-strong);}
/* 卡片內第一個元素不應再疊加上邊距（.msg / table 本身有 margin-top） */
.card > :first-child{margin-top:0;}


/* ---- 分頁掣 .tabs --------------------------------------------------------
   本來只在 assets/admin-list.css（index.php 專用）。brand.php 亦需要分頁，
   所以搬上來作共用元件；admin-list.css 不再重複定義。
   用法：
     <div class="tabs" role="tablist">
       <button type="button" role="tab" aria-selected="true" data-tab="x">…</button>
     </div>
   ⚠️ 在 <form> 內必須寫 type="button"，否則一按便會 submit 整張表單。
   ⚠️ min-height:0 是為了退出 admin.css 的 :where(button)（見 .btn-unset 註解）。 */
.tabs{display:flex;gap:6px;background:#EDE5D3;padding:var(--s1);border-radius:10px;
      width:max-content;margin-bottom:18px;}
.tabs button{border:none;background:transparent;padding:8px 18px;border-radius:var(--r-sm);
      font-size:13px;font-weight:700;color:var(--ink-muted);cursor:pointer;font-family:inherit;
      display:inline-flex;align-items:center;gap:6px;min-height:0;box-shadow:none;transform:none;
      transition:background var(--dur) var(--ease),color var(--dur) var(--ease);}
.tabs button:hover{color:var(--dark);box-shadow:none;}
.tabs button[aria-selected="true"]{background:var(--card);color:var(--dark);box-shadow:0 2px 6px rgba(0,0,0,.06);}


/* ---- 按鈕 ----------------------------------------------------------------
   一個尺寸走天涯：13.5px / 700 / --r-md / min-height 40px。
   以前 brand 用 14px+999px、users 用 12.5px+999px、index 用 13px+9px。
   統一採用 index.php 那套幾何（圓角 9px），因為它與輸入框、卡片的圓角一致。

   ⚠️ 裸 `button` 包了一層 :where()，特異度變 0。
      很多頁面都有複合元件（分頁按鈕 .tabs button、分段按鈕 .seg button、
      頁碼按鈕 .pager button、月曆箭嘴 .calhead button…），它們自有一整套樣式，
      不應視為主要按鈕。特異度 0 令「任何帶 class 的選擇器」都必定勝出，
      無須依賴檔案載入次序。
      但「未宣告的 property」仍然會漏下去（例如 min-height:40px），
      所以複合元件仍須在自己的 css 檔用 .btn-unset 退出 —— 見下方。 */
.btn,
:where(button){
  display:inline-flex;align-items:center;justify-content:center;gap:7px;
  font-family:inherit;font-size:13.5px;font-weight:700;line-height:1.4;
  padding:10px 18px;min-height:40px;
  border:1px solid transparent;border-radius:var(--r-md);
  background:var(--dark);color:#fff;
  text-decoration:none;cursor:pointer;
  transition:background var(--dur) var(--ease),
             transform var(--dur) var(--ease),
             box-shadow var(--dur) var(--ease),
             color var(--dur) var(--ease);
}
.btn:hover,
:where(button:hover:not(:disabled)){background:var(--dark-hover);color:#fff;transform:translateY(-1px);box-shadow:var(--shadow-lift);}
.btn:active,
:where(button:active:not(:disabled)){transform:translateY(0);box-shadow:none;}
button:disabled,.btn:disabled,.btn[aria-disabled="true"]{opacity:.5;cursor:default;transform:none;box-shadow:none;}

/* 次要：淺米底 */
.btn.ghost,button.ghost,.btn.g2{background:var(--surface);color:var(--dark);border-color:transparent;}
.btn.ghost:hover,button.ghost:hover:not(:disabled){background:var(--surface-hover);color:var(--dark);}

/* 強調：金底（唯一以 --primary 作底的按鈕） */
.btn.g,button.g{background:var(--primary);color:var(--ink-on-primary);}
.btn.g:hover,button.g:hover:not(:disabled){background:#C98C1E;color:var(--ink-on-primary);}

/* 危險／停用類動作 */
.btn.warn,button.warn{background:var(--bad-bg);color:var(--bad-ink);border-color:var(--bad-border);}
.btn.warn:hover,button.warn:hover:not(:disabled){background:#F7DFDB;color:var(--bad-ink);}

.btn.del,button.del{background:var(--danger);color:#fff;}
.btn.del:hover,button.del:hover:not(:disabled){background:var(--bad-ink);color:#fff;}

/* 小按鈕（表格內） */
.btn.sm,button.sm{font-size:12.5px;padding:7px 13px;min-height:34px;}

/* ---- 按鈕基本樣式「退出區」-------------------------------------------------
   複合元件（分頁、分段、頁碼、月曆箭嘴、icon 按鈕…）自有一整套樣式，
   不應視為主要按鈕。上面 :where(button) 特異度 0，所以它們自己的
   `.tabs button {…}` 規則必定勝出；但「它們未宣告的 property」仍然會漏
   （最典型是 min-height:40px 撐壞一個 38×38 的方形按鈕）。

   兩個用法：
     1. 加 class：<div class="tabs btn-unset"> 或 <button class="btn-unset">
     2. 不想改 markup／JS 的話，在該頁的 css 檔照抄同一批 property，
        用實際的選擇器寫一次（見 admin-list.css 頂部）。

   刻意逐個 property 寫，不用 `all:unset` —— `all` 會連 `*` 那句
   box-sizing:border-box 一併 revert，整個版面立即散掉。 */
.btn-unset,
.btn-unset button{
  min-height:0;padding:0;border:0;border-radius:0;
  background:none;color:inherit;
  font-size:inherit;font-weight:inherit;line-height:inherit;
  gap:0;box-shadow:none;transform:none;text-decoration:none;
  font-family:inherit;cursor:pointer;
}
.btn-unset:hover,.btn-unset:active,
.btn-unset button:hover,.btn-unset button:active{
  background:none;color:inherit;transform:none;box-shadow:none;
}


/* ---- SLIDE 預覽保護區 ⚠️ ---------------------------------------------------
   index.php（卡片縮圖）、editor.php（右邊預覽）、palette-check.php（版式牆）
   都會在後台版面中渲染真正的 IG slide，使用的是 assets/carousel.css。
   那個畫面就是 shot.php 截圖輸出的內容，不可被後台 UI 樣式污染。

   carousel.css 不會逐個 property 寫齊（它沒理由要防範一個當時未存在的
   admin.css），所以 admin.css 上方的裸元素規則（h1/h2/h3/table/th/td/
   button/a/ul…）會漏入 slide。此處在 .slide 範圍內全部還原。

   在 admin.css 加入新的裸元素規則之前，先想想 slide 內會否有該 tag；
   會的話就要在此補上一句。 */
.slide a,.slide a:hover{color:inherit;text-decoration:inherit;}
.slide h1,.slide h2,.slide h3{
  font-family:inherit;font-size:inherit;color:inherit;
  font-weight:inherit;line-height:inherit;
}
.slide table{border-collapse:inherit;width:auto;font-size:inherit;margin-top:0;display:table;}
.slide th,.slide td{
  border:0;padding:0;text-align:inherit;vertical-align:inherit;
  line-height:inherit;white-space:inherit;
}
.slide thead th{background:none;color:inherit;font-weight:inherit;font-size:inherit;letter-spacing:inherit;}
.slide tbody tr:hover{background:none;}
.slide code,.slide pre{
  background:none;color:inherit;padding:0;border-radius:0;
  font-family:inherit;font-size:inherit;word-break:inherit;overflow-x:visible;
}
.slide label{display:inherit;font-size:inherit;font-weight:inherit;color:inherit;margin:0;line-height:inherit;}
.slide button{
  min-height:0;padding:0;border:0;border-radius:0;background:none;color:inherit;
  font:inherit;box-shadow:none;transform:none;text-decoration:none;
}

/* carousel.css 的預覽外殼按鈕（editor.php 右邊的上／下一頁箭嘴）。
   它是 34px 圓形按鈕，若套用 admin.css 的 min-height:40px + padding:10px 18px 便會變形。 */
.ig-nav{min-height:0;padding:0;gap:0;font-weight:400;box-shadow:none;text-decoration:none;}
.ig-nav:hover{transform:translateY(-50%);box-shadow:none;}


/* ---- Toast（浮動提示）-----------------------------------------------------
   assets/admin.js 的 toast() 依賴這個。版面須有：
     <div class="toast" id="toast" role="status" aria-live="polite"></div>
   本來 index / editor / seo-editor 各自抄了一份，三份還略有不同
   （editor 那份沒有 .err、沒有 max-width）。此處採用最完整的一份。 */
.toast{
  position:fixed;bottom:18px;left:50%;z-index:99;
  transform:translateX(-50%) translateY(8px);
  background:var(--dark);color:#fff;
  padding:10px 18px;border-radius:var(--r-pill);
  font-size:13px;font-weight:700;
  opacity:0;pointer-events:none;
  display:flex;align-items:center;gap:var(--s2);
  max-width:calc(100vw - 36px);
  box-shadow:0 10px 26px rgba(28,84,112,.26);
  transition:opacity var(--dur) var(--ease),transform var(--dur) var(--ease);
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0);}
.toast.err{background:var(--danger);}


/* ---- Dialog（模態視窗）----------------------------------------------------
   本來 index 有一套（dialog/.dlg/.field/.dlgbtns）、editor 有一套平行的
   （.mdlg/.mrow/.mbtns）、seo-editor 更直接寫死在 style="" 內。此處統一為一份。 */
dialog{
  border:none;border-radius:var(--r-lg);padding:0;margin:auto;
  width:100%;max-width:min(420px,calc(100vw - 32px));
  box-shadow:0 24px 60px rgba(28,84,112,.28);
  color:var(--ink);background:var(--card);
}
dialog::backdrop{background:rgba(28,84,112,.42);backdrop-filter:blur(2px);}
.dlg{padding:var(--s5);}
.dlg h2{font-family:var(--font-serif);font-size:18px;color:var(--dark);margin-bottom:var(--s1);}
.dlg p{font-size:12.5px;color:var(--ink-muted);margin-bottom:var(--s4);line-height:1.7;}
.field{display:flex;flex-direction:column;gap:5px;margin-bottom:var(--s3);}
/* ⚠️ display:flex 會蓋過 [hidden] 的 UA display:none，所以 hidden 屬性完全無效。
   曾出事：WordPress 推送對話框選了「立即發佈」之後，「排程時間」那格仍然顯示，
   令人以為仍可排程。須用同等特異度的選擇器補回。 */
.field[hidden]{display:none;}
.row[hidden]{display:none;}   /* 同上：brand.php 的 #aiPick 用 .row + hidden */
.field label{font-size:12px;font-weight:700;color:var(--ink);margin:0;}
.field input,.field select{width:100%;}
.field .hint{font-size:11px;margin-top:0;}
.field .hint.bad{color:var(--danger);}
.dlgbtns{display:flex;gap:var(--s2);justify-content:flex-end;margin-top:var(--s5);flex-wrap:wrap;}


/* ---- 表單 ---------------------------------------------------------------- */
label{
  display:block;
  font-size:12px;font-weight:800;color:var(--dark);
  margin:var(--s3) 0 var(--s1);
  line-height:1.5;
}
/* ⚠️ <label> 有兩種完全不同的用法，上面那條 margin 只適用其中一種：
     ① 欄位標題 —— <label for=x>標題</label><input id=x>　　要 12px 上邊距，正確。
     ② 排版容器 —— <label class=sortbox><select>…</select></label>
        它是一個控件外殼，並非標題。繼承 margin-top:12px 之後，
        在 flex 行中便會**整個下沉 12px**，而且因為 stretch 要扣除
        上下 margin，它還會**矮 16px** —— 即與旁邊的搜尋框高度對不上。
        （2026-08-09 用戶拍照回報此問題。）

   分辨方法：容器式的 label **內部包住控件**，標題式的不會（控件是兄弟節點）。
   所以用 :has() 一次過解決，無須逐個修補。 */
label:has(> input),
label:has(> select),
label:has(> textarea){ margin:0; }

input,select,textarea{
  font-family:inherit;
  font-size:13.5px;
  color:var(--ink);
  background:var(--field);
  border:1px solid var(--border);
  border-radius:var(--r-md);
  padding:10px 12px;
  transition:border-color var(--dur) var(--ease),
             background var(--dur) var(--ease),
             box-shadow var(--dur) var(--ease);
}
/* 用「排除法」而非「逐個 type 點名」。
   點名寫法有一個很容易中招的漏洞：`input[type=text]` 是屬性選擇器，
   **未寫 type 的 <input> 完全不會命中**（HTML 會當作 text，但 CSS 不會）。
   結果那些欄位退回瀏覽器預設寬度（size=20，只有百多 px），
   與旁邊有寫 type 的欄位大小不一 —— 登入頁、新輪播標題、品牌設定、
   API key 名稱共六個欄位都因此出錯。順帶 type=time／file 亦一直遺漏。
   checkbox／radio 於下方以 width:auto 覆蓋。 */
input:not([type=checkbox]):not([type=radio]),
select,textarea{width:100%;}

/* 剔格／圓點：不要讓上方的輸入框樣式（邊框、圓角、內距、底色）令其走樣 */
input[type=checkbox],input[type=radio]{
  width:auto;min-height:0;padding:0;
  appearance:auto;-webkit-appearance:auto;
  background:none;border:0;border-radius:0;box-shadow:none;
  accent-color:var(--dark);cursor:pointer;
}
input[type=checkbox]:focus,input[type=radio]:focus{box-shadow:none;}

input:hover:not(:disabled),select:hover:not(:disabled),textarea:hover:not(:disabled){
  border-color:var(--border-strong);
}
input:focus,select:focus,textarea:focus{
  outline:none;background:var(--card);
  border-color:var(--dark);box-shadow:var(--focus-ring);
}
/* 鍵盤使用者仍會得到實心焦點環（上面 :focus 沒有 outline） */
input:focus-visible,select:focus-visible,textarea:focus-visible{
  outline:2px solid var(--ring);outline-offset:1px;
}
input::placeholder,textarea::placeholder{color:#9AA5AB;}

textarea{min-height:74px;resize:vertical;line-height:1.7;}
select{cursor:pointer;}

.hint{font-size:11.5px;color:var(--ink-muted);margin-top:var(--s1);line-height:1.7;}

/* ---- 色彩選擇器 + hex 欄位（brand.php 的四隻品牌色）--------------------------
   ⚠️ 必須排在上方 `input:not([type=checkbox]):not([type=radio])` 之後：
      兩條規則特異度相同（0,2,1），純粹靠源碼次序分勝負。若排在前面
      <input type=color> 會套到 width:100%，變成橫跨整欄的灰色色塊。 */
.colorrow{display:flex;gap:var(--s2);align-items:center;}
.colorrow input[type=color]{
  width:42px;min-width:42px;height:38px;min-height:38px;padding:3px;
  border:1px solid var(--border);border-radius:var(--r-md);
  background:var(--field);cursor:pointer;flex:none;
}
.colorrow input[type=text]{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;text-transform:uppercase;}


/* ---- 訊息條 -------------------------------------------------------------- */
.msg{
  margin-top:var(--s4);
  font-size:13px;line-height:1.8;
  border:1px solid transparent;border-radius:10px;
  padding:11px 14px;
  white-space:pre-wrap;              /* 部分頁面由 JS 填入多行文字 */
}
.msg.ok  {background:var(--ok-bg); border-color:var(--ok-border); color:var(--ok-ink);}
.msg.bad {background:var(--bad-bg);border-color:var(--bad-border);color:var(--bad-ink);}

/* 提示塊（黃底） */
.note{
  margin-top:var(--s3);
  font-size:12.5px;line-height:1.85;
  background:var(--note-bg);border:1px solid var(--note-border);color:var(--note-ink);
  border-radius:10px;padding:12px 14px;
}
.note b{color:#5F460B;}


/* ---- Pill 標籤 ----------------------------------------------------------- */
.pill{
  display:inline-block;
  font-size:11px;font-weight:800;line-height:1.6;
  border-radius:var(--r-pill);
  padding:3px 10px;
  background:var(--neutral-bg);color:var(--ink-muted);
  white-space:nowrap;
}
/* 藍：身分 / 現用中 */
.pill.owner,.pill.on{background:var(--info-bg);color:var(--dark);}
/* 金：權限升級 / 排程 */
.pill.admin,.pill.rw,.pill.future{background:var(--gold-bg);color:var(--gold-ink);}
/* 灰：預設狀態 */
.pill.editor,.pill.draft,.pill.none{background:var(--neutral-bg);color:var(--ink-muted);}
/* 綠：完成 */
.pill.publish{background:var(--ok-bg);color:var(--ok-ink);}
/* 紅：問題 */
.pill.dup,.pill.bad{background:var(--bad-bg);color:var(--bad-ink);}

/* 已停用的行／卡 */
.off{opacity:.5;}


/* ---- 表格 ----------------------------------------------------------------
   兩種：預設「只有底線」（用戶、租戶、API Key…），
        .boxed「全框 + 間條」（check.php、import.php 的檔案清單）。 */
table{border-collapse:collapse;width:100%;font-size:13.5px;margin-top:var(--s3);}
th,td{
  border-bottom:1px solid var(--border);
  padding:11px 8px;text-align:left;vertical-align:middle;line-height:1.6;
}
thead th{
  color:var(--dark);font-weight:800;font-size:12px;letter-spacing:1px;
  border-bottom-width:1px;
}
tbody tr{transition:background var(--dur) var(--ease);}
tbody tr:hover{background:var(--field);}

table.boxed{font-size:13px;}
table.boxed th,table.boxed td{border:1px solid var(--border);padding:8px 10px;vertical-align:top;}
table.boxed thead th{background:var(--surface);}
table.boxed tbody tr:nth-child(even){background:var(--zebra);}
table.boxed tbody tr:hover{background:var(--surface);}


/* ---- code / pre ---------------------------------------------------------- */
code{
  background:var(--surface);
  padding:1px 6px;border-radius:5px;
  font-family:var(--font-mono);font-size:12px;
  word-break:break-all;
}
pre{
  background:var(--code-bg);color:var(--code-ink);
  border-radius:10px;padding:14px 16px;margin-top:var(--s3);
  font-family:var(--font-mono);font-size:12px;line-height:1.75;
  overflow-x:auto;
}
pre code{background:none;padding:0;color:inherit;font-size:inherit;}

/* 發佈日期：瀏覽器原生 date 控制項跟系統語系，英文環境會顯示 mm/dd/yyyy。
   JS 套上 .datehit 後，原生文字收成透明，畫面上改顯示「2026年10月27日」；
   點整列（至少 44px）仍會打開原本的日期選擇器。未填顯示「—」。 */
.datehit{position:relative;min-height:44px;width:100%;}
.datehit input[type=date]{
  min-height:44px;width:100%;font-size:16px;color:transparent;caret-color:transparent;
  position:relative;z-index:1;
}
.datehit input[type=date]::-webkit-datetime-edit,
.datehit input[type=date]::-webkit-datetime-edit-fields-wrapper,
.datehit input[type=date]::-webkit-datetime-edit-text,
.datehit input[type=date]::-webkit-datetime-edit-month-field,
.datehit input[type=date]::-webkit-datetime-edit-day-field,
.datehit input[type=date]::-webkit-datetime-edit-year-field{color:transparent;}
.dateface{
  position:absolute;left:10px;right:34px;top:0;bottom:0;z-index:2;
  display:flex;align-items:center;pointer-events:none;
  font-size:14px;font-weight:700;color:var(--ink);
}


/* ---- details / summary --------------------------------------------------- */
details summary{
  cursor:pointer;
  font-weight:800;font-size:12.5px;color:var(--dark);
  border-radius:var(--r-sm);
  transition:color var(--dur) var(--ease);
}
details summary:hover{color:var(--gold-ink);}
details[open] > summary{margin-bottom:var(--s2);}


/* ---- 編號步驟（apikeys.php 的五步設定）------------------------------------ */
.step{
  display:flex;gap:var(--s4);align-items:flex-start;
  padding:var(--s4) 0;
  border-bottom:1px solid var(--border);
}
.step:last-of-type{border-bottom:0;padding-bottom:var(--s1);}
.step .n{
  flex:none;width:26px;height:26px;border-radius:50%;
  background:var(--dark);color:#fff;
  font-weight:900;font-size:13px;
  display:flex;align-items:center;justify-content:center;margin-top:1px;
}
.step b{font-size:14px;color:var(--dark);}
.step pre{margin-top:var(--s2);font-size:11.5px;}


/* ---- 有序／無序清單 ------------------------------------------------------- */
.card ol,.card ul{margin:var(--s2) 0 0 20px;font-size:13.5px;line-height:1.95;}
.card ol li,.card ul li{margin-top:var(--s1);}


/* ==========================================================================
   5. LOGIN — 置中卡片，不用 .wrap
   ========================================================================== */
body.login{
  background:var(--bg-alt);
  min-height:100vh;
  display:flex;align-items:center;justify-content:center;
  padding:var(--s5) 18px;
}
body.login .box{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:16px;
  padding:34px 32px 30px;
  width:100%;max-width:400px;
  box-shadow:0 18px 44px rgba(28,84,112,.12);
}
body.login .logo{
  width:44px;height:44px;border-radius:12px;
  background:var(--dark);color:#fff;
  display:flex;align-items:center;justify-content:center;
}
body.login h1{font-size:21px;margin-top:var(--s4);}
body.login label{font-size:12.5px;margin:var(--s4) 0 5px;}
body.login input{font-size:14px;padding:11px 13px;}
body.login button{width:100%;margin-top:22px;font-size:14.5px;padding:12px;}
body.login .msg{margin-top:var(--s4);}
body.login .remember{display:flex;align-items:center;gap:8px;margin-top:var(--s4);cursor:pointer;}
body.login .remember input{width:auto;padding:0;margin:0;accent-color:var(--dark);}
body.login .foot{
  text-align:center;font-size:11px;color:var(--ink-muted);
  margin-top:22px;letter-spacing:1.5px;
}


/* ==========================================================================
   6. RESPONSIVE
   ========================================================================== */
@media (max-width:620px){
  body{padding:var(--s5) var(--s3) 72px;}
  h1{font-size:20px;}
  .grid{grid-template-columns:1fr;}

  /* 表格橫向捲動，不要撐爆版面。display:block 令 table 自身具 overflow。
     一般表格（第一欄為長文字）照樣自動換行，捲軸只在確實不夠位時出現；
     .boxed 是資料密集的檢查表，寧願橫捲也勝過每格只擠兩個字。 */
  table{display:block;overflow-x:auto;-webkit-overflow-scrolling:touch;}
  table.boxed th,table.boxed td{white-space:nowrap;}

  /* 觸控熱區最少 44px */
  .btn,button{min-height:44px;}
  .btn.sm,button.sm{min-height:40px;}
  input,select,textarea{min-height:44px;}
  input[type=checkbox],input[type=radio]{min-height:0;}

  .formbar{padding:var(--s3) 0 var(--s1);}
  .formbar .btn,.formbar button{flex:1 1 auto;}
}

code.iga-url{
  display:inline-block;max-width:100%;box-sizing:border-box;
  overflow-wrap:anywhere;word-break:break-all;vertical-align:baseline;
}
table.ig-rules td.acts form{display:inline;}
.field.iga-check{flex-direction:row;align-items:center;gap:8px;}
.field.iga-check label{margin:0;cursor:pointer;}

@media (max-width:420px){
  .card{padding:var(--s4);}

  /* 規則表在約 390px 不必橫向捲到最右才按得到操作。 */
  table.ig-rules.boxed{
    display:table;width:100%;max-width:100%;overflow:visible;table-layout:fixed;
  }
  table.ig-rules.boxed th,
  table.ig-rules.boxed td{
    white-space:normal;word-break:break-word;overflow-wrap:anywhere;
  }
  table.ig-rules.boxed th:nth-child(1),
  table.ig-rules.boxed td:nth-child(1){width:12%;}
  table.ig-rules.boxed th:nth-child(2),
  table.ig-rules.boxed td:nth-child(2){width:26%;}
  table.ig-rules.boxed th:nth-child(3),
  table.ig-rules.boxed td:nth-child(3){width:26%;}
  table.ig-rules.boxed th:nth-child(4),
  table.ig-rules.boxed td:nth-child(4){width:12%;}
  table.ig-rules.boxed th:nth-child(5),
  table.ig-rules.boxed td:nth-child(5){width:24%;}
  table.ig-rules.boxed td.acts form{display:block;margin:0 0 6px;}
  table.ig-rules.boxed td.acts form:last-child{margin-bottom:0;}
  table.ig-rules.boxed td.acts .btn,
  table.ig-rules.boxed td.acts button{
    display:flex;width:100%;box-sizing:border-box;
    padding-left:6px;padding-right:6px;margin:0 0 6px;
  }
  table.ig-rules.boxed td.acts form button{margin-bottom:0;}
}


/* ==========================================================================
   7. MOTION
   ========================================================================== */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.01ms!important;
    animation-iteration-count:1!important;
    transition-duration:.01ms!important;
    scroll-behavior:auto!important;
  }
  .btn:hover,button:hover{transform:none;}
}


/* ==========================================================================
   8. MOBILE — 全站手機操作（Thumb Reach）
   --------------------------------------------------------------------------
   §6 處理了版面收窄；此處補「用手指操作」本身：
     · 輸入欄 ≥16px，iOS 聚焦時才不會把整版放大
     · 帳號列可換行、連結變成 44px 熱區（原本 nowrap，375px 必定橫向溢出）
     · 所有 dialog 貼底成 sheet，按鈕落在拇指區
     · 觸控裝置沒有 hover：取消升起效果，免得點完卡住「浮起」狀態
     · 貼底工具列避開 iPhone home bar
   ========================================================================== */
@media (max-width:620px){
  input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]),
  select,textarea{font-size:16px;}

  /* 帳號列（lib-auth.php cb_userbar_html）：自成一行、可換行 */
  .top .cb-ub{flex:1 0 100%;flex-wrap:wrap;white-space:normal;gap:6px 4px;}
  .top .cb-ub .sep{display:none;}
  .top .cb-ub .who{flex:1 0 auto;}
  /* 租戶／用戶／API 係桌面管理工作，手機只留「設定」「登出」 */
  .top .cb-ub a[href="tenants"],.top .cb-ub a[href="users"],.top .cb-ub a[href="apikeys"]{display:none;}
  .top .cb-ub a{flex:0 1 auto;justify-content:center;min-height:44px;display:inline-flex;align-items:center;padding:0 12px;
                background:var(--surface);border-radius:var(--r-md);}

  /* dialog → 貼底 sheet */
  dialog{max-width:none;width:100%;margin:auto auto 0;border-radius:16px 16px 0 0;
         max-height:calc(100dvh - 24px);overflow-y:auto;}
  .dlg{padding:18px var(--s4) calc(18px + env(safe-area-inset-bottom));}
  .dlgbtns .btn,.dlgbtns button{flex:1 1 0;min-height:46px;}

  .formbar{padding-bottom:calc(var(--s1) + env(safe-area-inset-bottom));}
  body{padding-bottom:calc(72px + env(safe-area-inset-bottom));}
}
@media (hover:none){
  .btn:hover,:where(button:hover:not(:disabled)){transform:none;box-shadow:none;}
  .card:hover,.tcard:hover,.acard:hover{transform:none;}
}

/* ---- ✨ AI 生成頁（ai-gen.php + assets/admin-ai.js）。全站 CSS 因為它是獨立頁面，不屬列表頁 ---- */
#aiKind{display:flex;gap:6px;margin-bottom:var(--s3);}
#aiKind button{font-size:12px;font-weight:800;padding:5px 12px;border-radius:var(--r-pill);
     border:1px solid var(--line,#E7DFCC);background:#F7F3EA;color:var(--ink);cursor:pointer;}
#aiKind button[aria-pressed=true]{background:var(--dark);color:#fff;border-color:var(--dark);}
.ailog{display:flex;flex-direction:column;gap:10px;height:calc(100vh - 330px);min-height:240px;
     overflow-y:auto;padding:12px;background:#F7F3EA;border-radius:var(--r-lg);}
.aimsg{max-width:88%;padding:9px 13px;border-radius:14px;font-size:13.5px;line-height:1.75;
     white-space:pre-wrap;word-break:break-word;}
.aimsg.u{align-self:flex-end;background:var(--dark);color:#fff;border-bottom-right-radius:4px;}
.aimsg.a{align-self:flex-start;background:#fff;color:var(--ink);border:1px solid var(--line,#E7DFCC);border-bottom-left-radius:4px;}
.aimsg.wait{color:var(--ink-muted);}
.aimsg.sys{align-self:center;max-width:100%;background:transparent;color:var(--ink-muted);font-size:12px;padding:0 6px;}
.aimsg.card{align-self:stretch;max-width:100%;background:var(--ok-bg,#EAF4EC);border:1px solid var(--ok-border,#BFD9C4);color:var(--ok-ink,#1F5A2E);}
.aicardbtns{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:8px;}
.aicardbtns .hint{margin:0;}
.aiinput{display:flex;gap:8px;align-items:flex-end;margin-top:var(--s3);}
.aiinput textarea{flex:1;min-height:44px;max-height:160px;resize:vertical;font-size:13.5px;line-height:1.6;}
.aiinput button{white-space:nowrap;}

/* 窄螢幕（≤560px）故意收起日曆分頁 #tabCal。
   七欄月曆加拖放在約 375–560px 排不下，也難按，所以只留清單分頁。
   這不是故障：寬度大於 560px（桌面、以及一般平板橫向）日曆分頁仍然顯示。
   不要在更寬的斷點把 #tabCal 設成 display:none。 */
@media (max-width:560px){
  #stats,.top .sub,.top .toolbtn[href="cron-log"],.top .archtoggle,#tabCal{display:none;}
  .top .tabs{flex:1 0 100%;margin-bottom:0;}
  .top #aiBtn{flex:1 1 100%;justify-content:center;min-height:44px;}
  /* 狀態篩選：一行橫向捲動，唔好摺兩行 */
  .stfilter{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;}
  .stfilter::-webkit-scrollbar{display:none;}
  .stfilter button{flex:none;min-height:44px;}
}


