/* 曙光教育 v4 — Design Tokens
 * 深夜圖書館：墨藍＋暖紙＋黃銅
 * 2026-10-19：依回饋降低整體對比（主文字改柔白、背景黑提亮、 accent 降飽和），減少刺眼感
 */
:root {
  --ink-950: oklch(0.21 0.03 260);
  --ink-900: oklch(0.25 0.04 260);
  --ink-800: oklch(0.30 0.05 260);
  --paper-50: oklch(0.90 0.02 90);
  --paper-100: oklch(0.86 0.02 90);
  --paper-200: oklch(0.82 0.025 90);
  --paper-400: oklch(0.68 0.025 90);
  --brass-300: oklch(0.78 0.08 85);
  --brass-400: oklch(0.70 0.10 80);
  --brass-500: oklch(0.64 0.11 80);
  --brass-600: oklch(0.58 0.09 80);
  --teal-400: oklch(0.66 0.07 200);
  --signal-green: oklch(0.70 0.10 150);
  --signal-red: oklch(0.62 0.13 25);
  --code-bg: oklch(0.16 0.03 260);

  --font-display: "Noto Serif TC", serif;
  --font-body: "Noto Sans TC", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* 表面覆蓋（深色用白、淺色用墨）：全站 hover/邊框/骨架屏走這組 */
  --wash-02: oklch(1 0 0 / 0.02);
  --wash-03: oklch(1 0 0 / 0.03);
  --wash-04: oklch(1 0 0 / 0.04);
  --wash-05: oklch(1 0 0 / 0.05);
  --wash-06: oklch(1 0 0 / 0.06);
  --wash-07: oklch(1 0 0 / 0.07);
  --wash-08: oklch(1 0 0 / 0.08);
  --wash-10: oklch(1 0 0 / 0.10);
  --wash-12: oklch(1 0 0 / 0.12);
  --wash-15: oklch(1 0 0 / 0.15);
  --wash-25: oklch(1 0 0 / 0.25);
  --topbar-bg: oklch(0.16 0.03 260 / 0.92);
  /* 主題裝飾背景 */
  --hero-bg: linear-gradient(135deg, oklch(0.24 0.05 260), oklch(0.20 0.04 280));
  --iframe-bg: #1a1a2e;
}

/* 淺色模式：暖紙圖書館（白天的樣子） */
[data-theme="light"] {
  --ink-950: oklch(0.93 0.015 95);
  --ink-900: oklch(0.88 0.02 90);
  --ink-800: oklch(0.82 0.02 90);
  --paper-50: oklch(0.24 0.03 260);
  --paper-100: oklch(0.28 0.03 260);
  --paper-200: oklch(0.33 0.03 260);
  --paper-400: oklch(0.40 0.03 260);
  --brass-300: oklch(0.55 0.10 80);
  --brass-400: oklch(0.48 0.11 80);
  --brass-500: oklch(0.62 0.11 80);
  --brass-600: oklch(0.42 0.10 80);
  --teal-400: oklch(0.45 0.08 200);
  --signal-green: oklch(0.50 0.11 150);
  --signal-red: oklch(0.50 0.13 25);
  --code-bg: oklch(0.88 0.02 90);

  --wash-02: oklch(0.25 0.03 260 / 0.02);
  --wash-03: oklch(0.25 0.03 260 / 0.03);
  --wash-04: oklch(0.25 0.03 260 / 0.04);
  --wash-05: oklch(0.25 0.03 260 / 0.05);
  --wash-06: oklch(0.25 0.03 260 / 0.06);
  --wash-07: oklch(0.25 0.03 260 / 0.07);
  --wash-08: oklch(0.25 0.03 260 / 0.08);
  --wash-10: oklch(0.25 0.03 260 / 0.10);
  --wash-12: oklch(0.25 0.03 260 / 0.12);
  --wash-15: oklch(0.25 0.03 260 / 0.15);
  --wash-25: oklch(0.25 0.03 260 / 0.25);
  --topbar-bg: oklch(0.96 0.015 95 / 0.92);
  /* 主題裝飾背景 */
  --hero-bg: linear-gradient(135deg, oklch(0.90 0.03 92), oklch(0.84 0.04 86));
  --iframe-bg: oklch(0.94 0.015 95);
}
[data-theme="light"] .time-bg { opacity: 0.10; }
[data-theme="light"] body::before { opacity: .05; }

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--ink-950);
  color: var(--paper-50);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* 站台字體大小（SETHUB S7）：正本 localStorage dawn:site-font，theme.js 套成 html 屬性。
   站上尺寸以 px 為主，root font-size 縮放無效，故用 zoom 做整頁等比縮放（等同瀏覽器縮放）；
   m（預設）不設屬性、無規則命中，與原行為一致。與島內殼字體（shellPrefs）分開。 */
html[data-site-font="s"] body { zoom: 0.92; }
html[data-site-font="l"] body { zoom: 1.1; }

/* 紙質噪點 */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .035; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 時段背景 */
.time-bg {
  position: fixed; inset: 0; z-index: -1;
  background-size: cover; background-position: center;
  opacity: 0.15; transition: opacity 1s var(--ease-out);
}

/* 頂欄 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid oklch(0.60 0.12 80 / 0.2);
  position: sticky; top: 0; z-index: 60;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
}
.brand {
  font-family: var(--font-display); font-weight: 900; font-size: 17px;
  text-decoration: none; color: var(--paper-50);
}
.brand span { color: var(--brass-400); }

/* 深淺色三段切換 */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--wash-12); border-radius: 999px; padding: 2px;
  background: var(--wash-04); margin-left: 8px; flex: none;
}
.theme-toggle button {
  border: none; background: transparent; cursor: pointer;
  width: 26px; height: 26px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--paper-400); transition: all 150ms var(--ease-out);
}
.theme-toggle button .ico-svg { width: 15px; height: 15px; }
.theme-toggle button:hover { color: var(--paper-50); }
.theme-toggle button.active { background: var(--brass-400); color: var(--ink-950); }

/* ===== 日夜開關（reel 設計：膠囊天空場景） ===== */
.dn-toggle-wrap { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; flex: none; }
.dn-label { font-size: 10px; letter-spacing: 0.18em; color: var(--paper-400); text-transform: uppercase; min-width: 4em; }
.dn-label span { display: inline-block; opacity: 0; transform: translateY(6px); transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1), transform 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.dn-label span.visible { opacity: 0.85; transform: translateY(0); }
.dn-toggle { border: none; background: none; padding: 0; cursor: pointer; position: relative; }
.dn-track {
  position: relative; display: block; width: 72px; height: 36px;
  border-radius: 48px; overflow: hidden;
  transition: background 1.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.8s ease;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.15);
}
.dn-toggle.light .dn-track { background: linear-gradient(180deg, #6ec1f5 0%, #a8dcf9 55%, #d4eefa 100%); }
.dn-toggle.dark .dn-track { background: linear-gradient(180deg, #060a1f 0%, #141b45 60%, #1e2760 100%); box-shadow: inset 0 2px 12px rgba(0,0,0,0.4), 0 0 20px rgba(80,100,255,0.15); }
.dn-sky { position: absolute; inset: 0; }
/* 太陽：多層光暈 */
.dn-sun {
  position: absolute; top: 7px; right: 9px; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle, #fffbe8 0%, #ffed9e 35%, #ffd93b 70%, #ffb700 100%);
  box-shadow: 0 0 16px 4px rgba(255, 217, 59, 0.5), 0 0 32px 8px rgba(255, 217, 59, 0.2);
  transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.dn-toggle.dark .dn-sun { opacity: 0; transform: scale(0.3) translateY(8px); }
/* 月亮：環形山細節 */
.dn-moon {
  position: absolute; top: 7px; right: 9px; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #faf8ef 0%, #e8e4d2 50%, #cfc9b0 100%);
  box-shadow: 0 0 14px 3px rgba(240, 235, 200, 0.35);
  opacity: 0; transform: scale(0.3) translateY(-8px);
  transition: opacity 0.7s ease 0.15s, transform 0.9s cubic-bezier(0.34, 1.3, 0.64, 1) 0.15s;
}
.dn-moon::before, .dn-moon::after { content: ""; position: absolute; border-radius: 50%; background: rgba(160, 155, 130, 0.35); }
.dn-moon::before { width: 6px; height: 6px; top: 5px; left: 6px; }
.dn-moon::after { width: 4px; height: 4px; top: 12px; left: 12px; }
.dn-toggle.dark .dn-moon { opacity: 1; transform: scale(1) translateY(0); }
/* 雲：三層不同速度 */
.dn-cloud { position: absolute; background: #fff; border-radius: 999px; transition: opacity 0.7s ease, transform 1s cubic-bezier(0.4, 0, 0.2, 1); }
.dn-cloud.c1 { width: 26px; height: 9px; bottom: 8px; left: 16px; opacity: 0.95; }
.dn-cloud.c1::before { content: ""; position: absolute; width: 12px; height: 12px; background: #fff; border-radius: 50%; top: -6px; left: 5px; }
.dn-cloud.c2 { width: 16px; height: 7px; bottom: 12px; left: 36px; opacity: 0.75; transition-delay: 0.08s; }
.dn-cloud.c3 { width: 12px; height: 5px; bottom: 6px; left: 44px; opacity: 0.55; transition-delay: 0.15s; }
.dn-toggle.dark .dn-cloud { opacity: 0; transform: translateX(-16px); }
/* 星星：逐顆閃爍 */
.dn-stars { position: absolute; inset: 0; opacity: 0; transition: opacity 0.8s ease 0.4s; }
.dn-toggle.dark .dn-stars { opacity: 1; }
.dn-stars i { position: absolute; background: #fff; border-radius: 50%; animation: dn-twinkle 2.5s ease-in-out infinite; }
.dn-stars i:nth-child(1) { top: 8px; left: 12px; width: 2px; height: 2px; animation-delay: 0s; }
.dn-stars i:nth-child(2) { top: 19px; left: 24px; width: 3px; height: 3px; animation-delay: 0.4s; }
.dn-stars i:nth-child(3) { top: 6px; left: 36px; width: 2px; height: 2px; animation-delay: 0.8s; }
.dn-stars i:nth-child(4) { top: 21px; left: 44px; width: 2px; height: 2px; animation-delay: 1.2s; }
.dn-stars i:nth-child(5) { top: 11px; left: 52px; width: 2.5px; height: 2.5px; animation-delay: 1.6s; }
.dn-stars i:nth-child(6) { top: 16px; left: 8px; width: 1.5px; height: 1.5px; animation-delay: 2s; }
@keyframes dn-twinkle { 0%, 100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }
/* 旋鈕：彈簧物理 */
.dn-knob {
  position: absolute; top: 4px; left: 4px; width: 28px; height: 28px;
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f0f0f0 100%);
  box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 -2px 4px rgba(0,0,0,0.08);
  transition: transform 0.7s cubic-bezier(0.34, 1.8, 0.5, 0.9);
}
.dn-toggle.dark .dn-knob { transform: translateX(36px); }
.dn-knob:active { transform: scale(0.92); }
.dn-toggle.dark .dn-knob:active { transform: translateX(36px) scale(0.92); }
/* 鏡面倒影 */
.dn-toggle::after {
  content: ""; position: absolute; top: 100%; left: 4px; right: 4px; height: 18px;
  background: inherit; border-radius: 0 0 48px 48px; opacity: 0.18;
  filter: blur(3px); transform: scaleY(-0.6); transform-origin: top;
  pointer-events: none;
}
.dn-auto-badge {
  border: 1px solid var(--brass-400); background: none; color: var(--brass-400);
  font-size: 10px; border-radius: 999px; padding: 2px 8px; cursor: pointer;
  transition: all 0.25s ease;
}
.dn-auto-badge:hover { background: var(--brass-400); color: var(--ink-950); }

/* 時段問候列（頂欄下方） */
.greet-bar {
  max-width: 1080px; margin: 0 auto; padding: 14px 24px 0;
  position: relative; z-index: 1;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.greet-main {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  color: var(--paper-50);
}
.greet-sub { font-size: 12px; color: var(--paper-400); }
@media (max-width: 640px) {
  .greet-bar { padding: 10px 16px 0; }
  .greet-main { font-size: 14px; }
  .theme-toggle { margin-left: 4px; }
  .theme-toggle button { width: 24px; height: 24px; }
}
.nav { display: flex; gap: 2px; align-items: center; }
.nav a, .nav-link {
  color: var(--paper-400); text-decoration: none; font-size: 13px;
  padding: 8px 13px; border-radius: 2px; transition: all 120ms var(--ease-out);
  background: none; border: none; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.nav a:hover, .nav-link:hover { color: var(--paper-50); background: var(--wash-05); }
.nav a.active, .nav-link.active { color: var(--brass-300); background: oklch(0.74 0.14 80 / 0.1); }
/* 下拉式分組 */
.nav-drop { position: relative; }
.nav-drop-btn .drop-arrow { font-size: 10px; opacity: 0.6; transition: transform 150ms; }
.nav-drop.open .nav-drop-btn .drop-arrow { transform: rotate(180deg); }
.nav-drop.open .nav-drop-btn { color: var(--paper-50); background: var(--wash-05); }
.nav-drop.active-group > .nav-drop-btn { color: var(--brass-300); }
.nav-drop-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 160px;
  background: var(--ink-800, #1a1a2e); border: none;
  border-radius: 8px; padding: 6px; box-shadow: 0 8px 24px oklch(0 0 0 / 0.4);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: all 150ms var(--ease-out); z-index: 100;
}
.nav-drop.open .nav-drop-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-drop-menu a { display: flex; width: 100%; box-sizing: border-box; padding: 9px 12px; border-radius: 6px; }
.nav-drop-menu a:hover { background: var(--wash-07); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--paper-400); }
.user-chip .pts { font-family: var(--font-mono); color: var(--brass-300); font-weight: 700; }

/* 主體 */
.main { max-width: 1080px; margin: 0 auto; padding: 24px; position: relative; z-index: 1; }
.page-head { margin-bottom: 20px; }
.page-head .en {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--brass-400);
}
.page-head h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: 24px; margin-top: 4px;
}

/* 卡片 */
.card {
  background: var(--ink-900);
  border: 1px solid oklch(0.60 0.12 80 / 0.22);
  border-top: 2px solid var(--brass-400);
  border-radius: 3px; padding: 18px;
}
.card h2 {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  margin-bottom: 12px;
}

/* 網格 */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.span3 { grid-column: span 3; } .span4 { grid-column: span 4; }
.span6 { grid-column: span 6; } .span8 { grid-column: span 8; }
.span12 { grid-column: span 12; }

/* 數字 */
.num { font-family: var(--font-mono); font-weight: 700; font-size: 28px; color: var(--brass-300); }
.num-sm { font-family: var(--font-mono); font-size: 14px; color: var(--brass-300); }
.label { font-size: 12px; color: var(--paper-400); }

/* 進度條 */
.bar { height: 5px; background: var(--wash-08); border-radius: 2px; overflow: hidden; margin: 8px 0; }
.bar > div { height: 100%; background: var(--brass-400); transition: width 300ms var(--ease-out); }

/* 按鈕 */
/* 按鈕：全圓角 ＋ hover 上浮 / active 下壓 / focus 可見輪廓
   （motion.css 已有全域 button:active scale .94，這裡補 .btn 專屬的 hover 與 :active 覆寫） */
.btn {
  display: inline-block; padding: 9px 20px; font-size: 14px; font-weight: 700;
  border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  font-family: var(--font-body); text-decoration: none;
  transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out),
              background-color .15s var(--ease-out), color .15s var(--ease-out),
              border-color .15s var(--ease-out);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px oklch(0.60 0.12 80 / 0.25);
}
.btn:active:not(:disabled) { transform: translateY(0) scale(.97); box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--brass-300); outline-offset: 2px; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 999px; }
.btn-primary { background: var(--brass-400); color: var(--ink-950); }
.btn-primary:hover:not(:disabled) { background: var(--brass-300); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--paper-400); border-color: oklch(0.60 0.12 80 / 0.35); }
.btn-ghost:hover:not(:disabled) { color: var(--brass-300); border-color: var(--brass-400); }
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:hover:not(:disabled) { transform: none; box-shadow: none; }
  .btn:active:not(:disabled) { transform: none; }
}

/* 重要按鈕輕微果凍：學 Reel 的彈性變形，但只取最輕的一層——
 * 適用對象：主要動作 .btn-primary，以及手動標記的 .btn-jelly（例如儲存草稿）。
 * 效果：桌面 hover 時小幅傾斜 -1 度＋橫向微拉 1.02、縱向微壓 0.98，iOS 彈簧回彈；
 * 不拉長、不加手、不換色、不改陰影；手機沒有 hover 所以完全不動，減少動態設定下也完全不動。 */
.btn-primary, .btn-jelly {
  transition: transform 450ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow .15s var(--ease-out),
              background-color .15s var(--ease-out), color .15s var(--ease-out), border-color .15s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled), .btn-jelly:hover:not(:disabled) {
    transform: translateY(-1px) rotate(-1deg) scale(1.02, 0.98);
  }
}
@media (prefers-reduced-motion: reduce) {
  .btn-primary, .btn-jelly { transition: none; }
  .btn-primary:hover:not(:disabled), .btn-jelly:hover:not(:disabled) { transform: none; }
}

/* 標籤 chip（多選篩選共用）：未選中空心，選中金色 */
.tagchip {
  font-size: 12px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--wash-12); background: transparent; color: var(--paper-400);
  transition: all .15s var(--ease-out);
}
.tagchip:hover:not(.on) { border-color: var(--brass-400); color: var(--brass-300); transform: translateY(-1px); }
.tagchip.on { border-color: var(--brass-400); background: oklch(0.74 0.14 80 / 0.12); color: var(--brass-300); }
@media (prefers-reduced-motion: reduce) {
  .tagchip { transition: none; }
  .tagchip:hover:not(.on) { transform: none; }
}

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .15em;
  text-transform: uppercase; color: var(--brass-400); text-align: left;
  padding: 10px 12px; border-bottom: 1px solid oklch(0.60 0.12 80 / 0.3);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--wash-05); }
td.n { font-family: var(--font-mono); text-align: right; color: var(--brass-300); }

/* 印章徽章 */
.seal {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid var(--brass-400);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 900; font-size: 18px;
  color: var(--brass-300); background: oklch(0.74 0.14 80 / 0.07);
  margin-right: 8px; margin-bottom: 8px;
}

/* 表單 */
.input, .textarea, .select {
  width: 100%; padding: 10px 14px; font-size: 14px;
  font-family: var(--font-body);
  background: var(--ink-800); color: var(--paper-50);
  border: 1px solid oklch(0.60 0.12 80 / 0.25); border-radius: 2px;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--brass-400);
}
.textarea { min-height: 120px; resize: vertical; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--paper-400); margin-bottom: 6px; }

/* 狀態 */
.state-empty, .state-error, .state-loading {
  text-align: center; padding: 48px 24px; color: var(--paper-400);
}
.state-empty img { max-width: 200px; opacity: .6; margin-bottom: 16px; border-radius: 4px; }
.skeleton {
  background: linear-gradient(90deg, var(--wash-04) 25%, var(--wash-08) 50%, var(--wash-04) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
  border-radius: 3px; min-height: 20px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 首次引導 */
.onboarding {
  position: fixed; inset: 0; background: oklch(0 0 0 / 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.onboarding .box {
  background: var(--ink-900); border: 1px solid var(--brass-600);
  border-top: 2px solid var(--brass-400); border-radius: 4px;
  padding: 32px; max-width: 440px; margin: 24px;
}
.onboarding h2 { font-family: var(--font-display); font-size: 20px; margin-bottom: 12px; }
.onboarding ol { margin: 0 0 20px 20px; color: var(--paper-400); font-size: 14px; }
.onboarding ol li { margin-bottom: 8px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink-800); border: 1px solid var(--brass-600);
  color: var(--paper-50); padding: 12px 24px; border-radius: 3px;
  font-size: 14px; z-index: 1000; opacity: 0; transition: opacity 200ms;
  pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; }

/* RWD */
@media (max-width: 768px) {
  .span3, .span4, .span6, .span8 { grid-column: span 12; }
  .nav { display: none; }
  .nav-toggle { display: block !important; }
  .page-head h1 { font-size: 20px; }
  .main { padding: 16px; }
  .topbar { padding: 10px 16px; }
  /* 手機頂欄不擁擠：品牌不換行、模式文字隱藏、使用者名稱隱藏（保留星砂數＋登出） */
  .brand { white-space: nowrap; flex: none; font-size: 15px; }
  .dn-label { display: none; }
  .user-chip { white-space: nowrap; flex: none; }
  .user-chip a:not(.btn) { display: none; }
}

/* 漢堡選單：桌面隱藏，手機顯示 */
.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--wash-15);
  color: var(--paper-50); font-size: 20px;
  width: 40px; height: 40px; border-radius: 2px; cursor: pointer;
}
.mobile-nav {
  display: none;
  position: fixed; top: 60px; left: 0; right: 0; z-index: 100;
  background: var(--ink-900);
  border-bottom: 2px solid var(--brass-400);
  padding: 8px 16px;
  flex-direction: column; gap: 4px;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  color: var(--paper-50); text-decoration: none;
  padding: 12px 8px; font-size: 15px;
  border-bottom: 1px solid var(--wash-06);
}
.mobile-nav a.active { color: var(--brass-400); }
.mobile-nav a:last-child { border-bottom: none; }
.mnav-group { margin-bottom: 4px; }
.mnav-label {
  font-size: 11px; letter-spacing: .15em; color: var(--brass-400);
  padding: 8px 8px 4px; font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; width: 100%; background: none; border: none;
  font-family: var(--font-mono);
}
.mnav-label .drop-arrow { font-size: 12px; opacity: 0.6; transition: transform 150ms; }
.mnav-group.collapsed .mnav-label .drop-arrow { transform: rotate(-90deg); }
.mnav-items { overflow: hidden; transition: max-height 200ms ease-out; }
.mnav-group.collapsed .mnav-items { max-height: 0 !important; }
/* AI 生成圖示 */
.nav-ico {
  width: 22px; height: 22px; border-radius: 6px; object-fit: cover;
  margin-right: 8px; vertical-align: -6px; flex: none;
}
.nav-ico.sm { width: 16px; height: 16px; border-radius: 4px; margin-right: 5px; vertical-align: -3px; }
.task-ico {
  width: 40px; height: 40px; border-radius: 10px; object-fit: cover;
  margin-bottom: 6px;
}
.mode-ico {
  width: 52px; height: 52px; border-radius: 12px; object-fit: cover;
  margin-bottom: 6px;
}
.pet-img {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--brass-400);
}
.inline-ico { width: 18px; height: 18px; border-radius: 5px; object-fit: cover; vertical-align: -4px; }
/* 語義 SVG 符號 */
.ico-svg { width: 1em; height: 1em; vertical-align: -0.12em; flex: none; }
.check-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: oklch(0.55 0.15 150 / 0.18); color: var(--signal-green);
  font-size: 22px; margin-bottom: 6px;
}
.diff-stars { display: inline-flex; gap: 2px; color: var(--brass-300); }
.diff-stars .ico-svg { width: 15px; height: 15px; }
.diff-stars .off { color: var(--wash-25); }

/* 群島地圖 */
.archipelago {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  padding: 18px 14px; border-radius: 8px;
  background:
    radial-gradient(ellipse 60% 40% at 20% 30%, oklch(0.35 0.08 250 / 0.25), transparent),
    radial-gradient(ellipse 50% 35% at 80% 70%, oklch(0.30 0.10 260 / 0.22), transparent),
    linear-gradient(160deg, oklch(0.16 0.05 255), oklch(0.12 0.04 250));
  border: 1px solid var(--wash-08);
}
.isl-card {
  background: var(--ink-900); border: 1px solid var(--wash-10);
  border-radius: 8px; overflow: hidden;
  transform: translateY(var(--d, 0px));
  transition: transform .25s ease, box-shadow .25s ease;
}
.isl-card:hover { transform: translateY(calc(var(--d, 0px) - 4px)); box-shadow: 0 8px 24px oklch(0 0 0 / 0.4); }
.isl-card.lv4, .isl-card.lv5 { border-color: oklch(0.60 0.12 80 / 0.5); box-shadow: 0 0 18px oklch(0.60 0.12 80 / 0.15); }
.isl-img-wrap { position: relative; }
.isl-img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; }
.isl-card.locked .isl-img { filter: grayscale(0.9) brightness(0.55); }
.isl-fog {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, oklch(0.5 0.03 250 / 0.25), oklch(0.4 0.04 250 / 0.45));
  color: var(--paper-300); font-size: 13px; letter-spacing: .1em;
}
.isl-lv {
  position: absolute; top: 8px; left: 8px;
  font-size: 11px; font-family: var(--font-mono); letter-spacing: .05em;
  background: oklch(0 0 0 / 0.55); color: var(--brass-300);
  padding: 3px 8px; border-radius: 20px; border: 1px solid oklch(0.60 0.12 80 / 0.4);
}
.isl-body { padding: 12px 14px 14px; }
.isl-name { font-weight: 700; font-size: 15px; }
@media (max-width: 720px) {
  .archipelago { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px 8px; }
  .isl-card { transform: none; }
}

/* Toast 手機版防溢出 */
.toast { max-width: calc(100vw - 32px); }
/* 表格手機版可橫向捲動 */
.table-wrap { overflow-x: auto; }

/* 對話框 */
.modal-overlay {
  position: fixed; inset: 0; background: oklch(0 0 0 / 0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px; box-sizing: border-box;
}
.modal {
  background: var(--ink-800, #1a1a2e); border: 1px solid var(--wash-12);
  border-radius: 12px; padding: 24px; width: 100%; box-sizing: border-box;
  box-shadow: 0 16px 48px oklch(0 0 0 / 0.5);
}
.modal h3 { margin: 0 0 12px; font-size: 17px; }

/* ===== 自定義滾動條（SCROLLBAR・2026-11-14 全站統一優化）=====
 * 細桿 8px＋全圓角 thumb＋暖棕黃銅半透明（深淺頁面皆可見）、hover 加深、track 透明。
 * 原 2026 初版 thumb 偏淡（.3）偏方（radius 4px），使用者實機評預設桿太醜後升級此版。 */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(180, 140, 80, 0.5) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(180, 140, 80, 0.45);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(180, 140, 80, 0.68);
}
*::-webkit-scrollbar-button {
  display: none;
}

@media (max-width:640px){.hide-mobile{display:none!important;}}

/* AI 生成免責聲明（各互動功能頁共用，ui.js 自動掛載） */
.ai-disclaimer {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--paper-400); opacity: 0.85;
  margin: 8px 0 0; line-height: 1.6;
}
.ai-disclaimer::before {
  content: ""; flex: none; width: 5px; height: 5px; border-radius: 50%;
  background: var(--brass-400); opacity: 0.7;
}

/* ===== 曙光寶庫雜誌式（精選＋瀑布流，非條列）===== */
.vault-feat {
  display: flex; background: var(--ink-900);
  border: 1px solid oklch(0.60 0.12 80 / 0.25); border-radius: 16px;
  overflow: hidden; margin-bottom: 20px; cursor: pointer;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.vault-feat:hover { transform: translateY(-3px); box-shadow: 0 12px 32px oklch(0 0 0 / 0.35); }
.vault-feat-img { width: 42%; min-height: 240px; object-fit: cover; flex: none; }
.vault-feat-body { padding: 28px 30px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.vault-eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em;
  color: var(--brass-400); margin-bottom: 10px;
}
.vault-feat-title {
  font-family: var(--font-display); font-size: 26px; font-weight: 700;
  line-height: 1.4; margin-bottom: 12px; color: var(--paper-50);
}
.vault-feat-ex {
  font-size: 14px; color: var(--paper-400); line-height: 1.8; margin-bottom: 16px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.vault-grid { columns: 3; column-gap: 16px; }
.vault-card {
  break-inside: avoid; margin-bottom: 16px; background: var(--ink-900);
  border: 1px solid oklch(0.60 0.12 80 / 0.22); border-radius: 16px;
  overflow: hidden; cursor: pointer;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.vault-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px oklch(0 0 0 / 0.35); }
.vault-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.vault-card-body { padding: 16px 18px 14px; }
.vault-title {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  line-height: 1.5; margin: 6px 0 8px; color: var(--paper-50);
}
.vault-ex {
  font-size: 13px; color: var(--paper-400); line-height: 1.75;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.vault-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.vault-meta {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
  padding-top: 10px; border-top: 1px solid var(--wash-06);
  font-size: 12px; color: var(--paper-400); flex-wrap: wrap;
}
.vault-meta .spacer { flex: 1; }
.vault-act {
  border: 1px solid var(--wash-12); background: transparent; color: var(--paper-400);
  font-size: 12px; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  transition: all .15s var(--ease-out); font-family: inherit;
}
.vault-act:hover { border-color: var(--brass-400); color: var(--brass-300); }
.vault-act.danger:hover { border-color: var(--signal-red); color: var(--signal-red); }
.vault-chip {
  font-size: 11px; padding: 2px 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--wash-12); background: transparent; color: var(--paper-400); font-family: inherit;
}
.vault-chip:hover { border-color: var(--brass-400); color: var(--brass-300); }
.vault-chip.gold { border-color: oklch(0.75 0.15 80 / 0.45); color: var(--brass-300); background: oklch(0.74 0.14 80 / 0.08); cursor: default; }
@media (max-width: 960px) {
  .vault-grid { columns: 2; }
  .vault-feat { flex-direction: column; }
  .vault-feat-img { width: 100%; min-height: 180px; max-height: 220px; }
  .vault-feat-title { font-size: 22px; }
  .vault-feat-body { padding: 22px; }
}
@media (max-width: 620px) { .vault-grid { columns: 1; } }
@media (prefers-reduced-motion: reduce) {
  .vault-feat, .vault-card { transition: none; }
  .vault-feat:hover, .vault-card:hover { transform: none; }
}

/* ===== 導覽列泡泡框（淺綠色彈性外框，跟著滑標移動） ===== */
.topbar .nav {
  position: relative; background: #0d1526;
  border: none; border-radius: 999px;
  padding: 5px 6px; gap: 2px; overflow: visible;
  box-shadow: 0 8px 24px oklch(0 0 0 / 0.35);
}
.topbar .nav a, .topbar .nav .nav-link { background: transparent; border-radius: 999px; }
/* 泡泡框本身就會跟著滑標與 focus 走，原生 focus 外框是多餘的——
   瀏覽器在點過的群組按鈕與選單項目上畫的白框就是它，關掉只留泡泡框 */
.topbar .nav a, .topbar .nav .nav-link, .topbar .nav .nav-drop-menu a { outline: none; }
.topbar .nav a:focus-visible, .topbar .nav .nav-link:focus-visible, .topbar .nav .nav-drop-menu a:focus-visible { outline: none; }
.topbar .nav a.active, .topbar .nav .nav-link.active { background: transparent; color: var(--paper-50); }
.topbar .nav-drop.active-group > .nav-drop-btn { color: var(--paper-50); }
.topbar .nav .meni-btn { opacity: 0.62; }
.topbar .nav .meni-btn:hover { opacity: 1; }
.topbar .nav .meni-btn.active,
.topbar .nav .active-group > .meni-btn { opacity: 1; }
.nav-bubble {
  position: absolute; z-index: 200; pointer-events: none;
  border: 2px solid #C4703F; border-radius: 999px;
  background: oklch(0.62 0.10 50 / 0.12);
  box-shadow: 0 0 18px oklch(0.62 0.10 50 / 0.35);
  transition: left 450ms cubic-bezier(0.34, 1.56, 0.64, 1),
    top 450ms cubic-bezier(0.34, 1.56, 0.64, 1),
    width 450ms cubic-bezier(0.34, 1.56, 0.64, 1),
    height 450ms cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 200ms;
}

/* 淺色模式導覽列：藥丸變暖紙白、綠框加深以保對比（下拉選單本身已用主題變數，會自動變淺） */
[data-theme="light"] .topbar .nav {
  background: oklch(0.99 0.005 95);
  border-color: oklch(0.25 0.03 260 / 0.12);
  box-shadow: 0 8px 24px oklch(0.25 0.03 260 / 0.12);
}
[data-theme="light"] .nav-bubble {
  border-color: oklch(0.55 0.12 145);
  background: oklch(0.55 0.12 145 / 0.10);
  box-shadow: 0 0 14px oklch(0.55 0.12 145 / 0.30);
}

/* MD 渲染：標題跟段落間距一致，標題不再用瀏覽器預設大間距 */
.md-h { margin:24px 0 8px; line-height:1.8; }
.md-h:first-child { margin-top:0; }
.md-p, .md-list { margin:8px 0; line-height:1.8; }
.md-list { padding-left:1.6em; }
.md-list li { margin-bottom:4px; }
