/* 開發者文件頁（/docs）——疊在 styles.css 之上的版面層：
 * 頂欄＋左側固定目錄＋右側內容；code 區塊與表格為主的閱讀排版。
 * 只依賴 styles.css 的設計 token（--ink、--muted、--border、--surface-*、
 * --warning-soft、--page）與 .brand；其餘元件樣式一律自持——dashboard 改版
 * 不得再弄壞本頁（2026-07-14 教訓）。
 * 注意：註解內不得出現「星號緊接斜線」的字元序列（會提前關閉註解——CI biome
 * parse error 的教訓，2026-07-16）。 */

.docs-body {
  background: var(--page);
}

.docs-topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.docs-topbar-inner {
  display: flex;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.7rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  flex-wrap: wrap; /* 放不下時動作群整組換到第二列，不擠品牌字 */
}

/* 品牌＋副題不拆字：360／414px 曾拆成「開發者文／件」「隱私／政策」（09-06 六寬對照圖實錘） */
.docs-topbar-inner .brand {
  white-space: nowrap;
}

.docs-brand-sub {
  margin-left: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.docs-topbar-actions {
  display: flex;
  align-items: baseline;
  gap: 0.6rem 1rem;
  flex-wrap: wrap;
  margin-left: auto; /* 換到第二列時仍靠右 */
}

/* 語言切換（/docs?lang=…；伺服器依 ?lang= → cookie → Accept-Language 挑 docs.html／docs.en.html） */
.docs-lang {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--link);
  text-decoration: none;
}

.docs-lang:hover {
  text-decoration: underline;
}

.docs-console-link {
  font-size: 0.88rem;
  white-space: nowrap;
}

.docs-download {
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.docs-download:hover {
  border-color: var(--link);
  color: var(--link);
  text-decoration: none;
}

.docs-layout {
  display: grid;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

.docs-toc {
  position: sticky;
  top: 4.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.88rem;
}

.docs-toc a {
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-control);
  color: var(--muted);
  text-decoration: none;
}

.docs-toc a:hover {
  color: var(--ink);
  background: var(--surface-subtle);
  text-decoration: none;
}

@media (max-width: 46rem) {
  .docs-layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .docs-toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.2rem 0.35rem;
  }
}

.docs-main {
  min-width: 0;
  /* 蓋掉 styles.css 的全域 main 規則：auto margin 會停用 grid 的 stretch 對齊，
   * main 改依內容的內在寬度（表格 min-content）撐開＝任何窄視窗都橫向溢出。 */
  max-width: none;
  margin: 0;
  padding: 0;
}

/* 錨點跳轉時標題不被 sticky 頂欄蓋住 */
.docs-main section {
  scroll-margin-top: 4.25rem;
}

/* 法律頁在手機上頂欄換成兩列，目錄跳轉須為兩列保留空間。 */
@media (max-width: 46rem) {
  .policy-body .docs-main section {
    scroll-margin-top: 6.5rem;
  }
}

.docs-main h1 {
  margin: 0.25rem 0 0.75rem;
  font-size: 1.5rem;
}

.docs-main h2 {
  margin: 2.25rem 0 0.6rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 1.15rem;
}

.docs-main section:first-child h1 {
  border: none;
}

.docs-main p,
.docs-main li {
  color: var(--ink);
  font-size: 0.92rem;
}

.docs-main ul,
.docs-main ol {
  margin: 0.5rem 0;
  padding-left: 1.4rem;
}

.docs-main li {
  margin: 0.3rem 0;
}

.docs-main code {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-subtle);
  font-size: 0.85em;
  word-break: break-word;
}

.docs-main pre {
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-x: auto;
}

.docs-main pre code {
  padding: 0;
  border: none;
  background: none;
  font-size: inherit;
  word-break: normal;
}

.docs-main table {
  display: block;
  width: 100%;
  margin: 0.75rem 0;
  border-collapse: collapse;
  font-size: 0.88rem;
  overflow-x: auto;
}

.docs-main th,
.docs-main td {
  /* 蓋掉 styles.css 的 dashboard 列高（height:48px）：文件表格是多行長句，
   * 窄視窗線性化（td 變 block）後固定高度會讓內容溢出、蓋到下一格 */
  height: auto;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.docs-main th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.docs-anchor {
  margin-left: 0.45rem;
  padding: 0 0.4rem;
  min-height: 0;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--border-strong);
  font-size: 0.85rem;
  cursor: pointer;
  vertical-align: baseline;
}

.docs-anchor:hover:not(:disabled) {
  border-color: transparent;
  color: var(--link);
  background: var(--surface-subtle);
}

@media (max-width: 46rem) {
  /* 窄寬 thead 被 styles.css 隱藏——以 data-label 補回欄位語意（審查二輪 #9） */
  .docs-main td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
  }
}

.docs-note {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--warning-soft);
  font-size: 0.88rem;
}

.docs-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

/* ── 首訪提示卡（负責人需求 2026-07-15：問是否用 AI 開發＋下載餵 AI 動畫） ── */
.ai-hint {
  /* 置中 modal＋模糊背景（負責人 2026-07-19 改判——取代審查二輪 #9 的角落卡）：
     showModal 原生置中；關閉照舊 Esc／點背景／「先看文件就好」 */
  margin: auto;
  width: min(calc(100vw - 32px), 460px);
  max-height: min(78vh, 620px);
  overflow-y: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgb(17 28 40 / 26%);
}

.ai-hint::backdrop {
  background: rgb(17 24 32 / 30%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* 舊引擎不支援 backdrop-filter：以較深的半透明底補足對比 */
@supports not (backdrop-filter: blur(6px)) {
  .ai-hint::backdrop {
    background: rgb(17 24 32 / 55%);
  }
}

.ai-hint[open] {
  animation: ai-hint-in 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes ai-hint-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

.ai-hint-inner {
  position: relative;
  padding: 22px 24px 24px;
}

.ai-hint-x {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3; /* 浮在動畫舞台之上——否則後畫的舞台會蓋住它、且點擊被舞台攔截 */
  display: grid;
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--border); /* 給底色＋框：漸層舞台上仍是清楚可點的按鈕 */
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  place-items: center;
  box-shadow: 0 1px 4px rgb(17 28 40 / 10%);
}

.ai-hint-x:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--ink);
}

.ai-hint h2 {
  margin: 4px 0 8px;
  font-size: 1.22rem;
}

.ai-hint-body {
  margin: 0 0 18px;
  color: var(--muted-strong);
  font-size: 0.9rem;
  line-height: 1.6;
}

.ai-hint-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-hint-optout {
  display: flex;
  min-height: 44px;
  margin-top: var(--field-help-gap);
  align-items: center;
  gap: var(--field-label-gap);
  color: var(--muted);
  font-size: var(--text-help);
  cursor: pointer;
}

.ai-hint-optout input {
  flex: none;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  margin: 0;
  accent-color: var(--link);
  cursor: pointer;
}

.ai-hint-download {
  padding: 0 18px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
}

.ai-hint-download:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  text-decoration: none;
}

/* ── 動畫舞台：文件卡落入對話框 → 變附件 → AI 回覆（純 CSS 循環，4.6s） ── */
.ai-anim {
  position: relative;
  height: 208px;
  margin-bottom: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-subtle), var(--surface));
  overflow: hidden;
}

/* 文件卡：從上方緩緩落下，接近對話框時縮小淡出（被「吸入」） */
.ai-anim-doc {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 66px;
  height: 82px;
  margin-left: -33px;
  padding: 9px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 22px rgb(17 28 40 / 14%);
  animation: ai-doc 4.6s cubic-bezier(0.55, 0.05, 0.35, 1) infinite;
}

.ai-anim-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
}

.ai-anim-doc i {
  display: block;
  height: 5px;
  margin-top: 7px;
  border-radius: 3px;
  background: var(--surface-strong);
}

.ai-anim-doc i:nth-child(3) {
  width: 82%;
}

.ai-anim-doc i:nth-child(4) {
  width: 58%;
}

@keyframes ai-doc {
  0% {
    transform: translateY(-16px) scale(0.6) rotate(-5deg);
    opacity: 0;
  }
  12% {
    transform: translateY(0) scale(1) rotate(-5deg);
    opacity: 1;
  }
  48% {
    transform: translateY(78px) scale(0.94) rotate(4deg);
    opacity: 1;
  }
  60% {
    transform: translateY(108px) scale(0.32);
    opacity: 0;
  }
  100% {
    transform: translateY(108px) scale(0.32);
    opacity: 0;
  }
}

/* 對話框（釘在底部）：附件 chip 在落下瞬間出現、輸入列＋送出鈕 */
.ai-anim-chat {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgb(17 28 40 / 7%);
}

.ai-anim-chip {
  display: inline-flex;
  max-width: 100%;
  margin-bottom: 8px;
  padding: 3px 8px;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-control);
  background: var(--accent-soft);
  color: var(--link);
  font-size: 11px;
  font-weight: 650;
  animation: ai-chip 4.6s ease infinite;
}

.ai-anim-chip-ico {
  font-size: 10px;
}

@keyframes ai-chip {
  0%,
  52% {
    opacity: 0;
    transform: scale(0.8);
  }
  62% {
    opacity: 1;
    transform: scale(1);
  }
  92% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
}

.ai-anim-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-anim-placeholder {
  color: var(--muted);
  font-size: 12px;
}

.ai-anim-send {
  display: grid;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  line-height: 1;
  place-items: center;
  animation: ai-send 4.6s ease infinite;
}

/* 脈動用 box-shadow 光暈（不改 box 尺寸——scale 放大會讓鈕溢出父容器） */
@keyframes ai-send {
  0%,
  58% {
    box-shadow: 0 0 0 0 rgb(11 95 204 / 0%);
  }
  66% {
    box-shadow: 0 0 0 6px rgb(11 95 204 / 20%);
  }
  82%,
  100% {
    box-shadow: 0 0 0 0 rgb(11 95 204 / 0%);
  }
}

/* AI 回覆泡泡：附件送出後淡入 */
.ai-anim-reply {
  position: absolute;
  bottom: 92px;
  left: 16px;
  max-width: 66%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 3px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgb(17 28 40 / 6%);
  animation: ai-reply 4.6s ease infinite;
}

.ai-anim-reply i {
  display: block;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-strong);
}

.ai-anim-reply i:first-child {
  width: 96px;
}

.ai-anim-reply i + i {
  width: 64px;
  margin-top: 6px;
}

@keyframes ai-reply {
  0%,
  66% {
    opacity: 0;
    transform: translateY(8px);
  }
  78% {
    opacity: 1;
    transform: translateY(0);
  }
  92% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* 尊重減量動畫：停用循環，留可讀的靜止態（文件已成附件＋回覆已到） */
@media (prefers-reduced-motion: reduce) {
  .ai-hint[open],
  .ai-anim-doc,
  .ai-anim-chip,
  .ai-anim-send,
  .ai-anim-reply {
    animation: none;
  }
  .ai-anim-doc {
    opacity: 0;
  }
  .ai-anim-chip,
  .ai-anim-reply {
    opacity: 1;
    transform: none;
  }
}

/* 內文連結不能只靠顏色（a11y link-in-text-block）：底線＋偏移；導覽／按鈕型連結另有樣式 */
.docs-main a:not(.docs-download):not(.docs-console-link) {
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

/* Same material frame as the console; long-form documentation stays open. */
.docs-body {
  background:
    radial-gradient(ellipse 70vw 40rem at 100% 0, var(--canvas-light), transparent 72%), var(--page);
}
.docs-topbar {
  margin: 12px;
  top: 12px;
  border: 1px solid var(--glass-edge);
  border-radius: 24px;
  background: var(--glass-bar-bg);
  box-shadow: var(--glass-inset), var(--glass-elevation);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}
.docs-topbar-inner .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.docs-topbar-inner .brand-symbol img {
  height: 24px;
}
.docs-toc {
  padding: 8px;
  border: 1px solid var(--glass-edge);
  border-radius: 22px;
  background: var(--glass-panel-bg);
  box-shadow: var(--glass-inset), var(--glass-elevation);
}
.docs-topbar-actions :is(.docs-lang, .docs-console-link, .docs-download) {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  background: var(--glass-input-bg);
  box-shadow: var(--glass-inset);
}
.docs-main pre {
  border-radius: 18px;
  border-color: var(--glass-line);
  background: var(--glass-panel-bg);
}
@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
  .docs-topbar,
  .docs-toc {
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
/* Retain pinned legal document text; the shared mark supplies the visible brand. */
.docs-topbar .brand > b {
  display: none;
}

/* Documentation is a first-class page of the same console; the global header stays mounted. */
.console-shell .page-docs {
  max-width: 1200px;
  width: 100%;
  margin-inline: auto;
}
.docs-page-header {
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
}
.docs-workspace .docs-layout {
  max-width: none;
  margin: 0;
  padding: 0 0 64px;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 48px;
}
.docs-workspace .docs-toc {
  top: calc(var(--console-header-end, 160px) + 24px);
  max-height: calc(100dvh - var(--console-header-end, 160px) - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 10px;
  border: 1px solid var(--glass-line);
  border-radius: 24px;
  background: var(--glass-panel-bg);
  backdrop-filter: blur(16px);
}
.docs-workspace .docs-toc a {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  font-size: var(--text-help);
}
.docs-workspace .docs-toc a[aria-current="location"] {
  color: var(--selection-ink);
  background: var(--glass-neutral-selection);
  box-shadow: inset 0 0 0 1px var(--selection-border);
}
.docs-workspace .docs-main :is(p, li) {
  font-size: var(--text-body);
  line-height: 1.8;
}
.docs-workspace .docs-main h1 {
  font-size: 24px;
}
.docs-workspace .docs-main h2 {
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.docs-workspace .docs-main section {
  scroll-margin-top: 24px;
}
.docs-workspace .docs-main pre {
  font-size: var(--text-help);
  line-height: 1.7;
}
.docs-workspace button.docs-anchor {
  display: inline-flex;
  flex: none;
  width: 40px;
  min-height: 40px;
  padding: 10px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.docs-workspace .docs-anchor .ui-icon {
  width: 18px;
  height: 18px;
}
.console-shell .sidebar-account #docs-sign-in {
  min-height: 44px;
  padding: 10px 18px;
  font-size: var(--text-help);
  white-space: nowrap;
}
@media (max-width: 900px) {
  .docs-workspace .docs-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
  .docs-workspace .docs-toc {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
  }
  .docs-workspace .docs-toc a {
    flex: none;
    white-space: nowrap;
  }
  .docs-page-header {
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .docs-workspace .docs-toc {
    background: var(--surface);
    backdrop-filter: none;
  }
  .docs-workspace .docs-toc a[aria-current="location"] {
    background: var(--selection-solid);
  }
}
@media (forced-colors: active) {
  .docs-workspace .docs-toc {
    background: Canvas;
    border-color: CanvasText;
  }
  .docs-workspace .docs-toc a[aria-current="location"] {
    background: Highlight;
    color: HighlightText;
  }
}

/* 產品介紹頁（2026-09-25 L1）：角色表第一欄是短標籤（使用者／開發者），不讓瀏覽器把它斷成兩行 */
.about-roles td:first-child,
.about-roles th:first-child {
  white-space: nowrap;
}
