/* 修改 mkdocs-material 的 Grid Card 背景顏色 */
.grid.cards li {
    background-color: #ecfbf1; /* 你想要的背景顏色 */
}

/* 側邊導覽：頁面 icon 與標題對齊，讓選單更醒目 */
.md-nav--primary .md-nav__link {
    align-items: center;
    gap: 0.45rem;
}

.md-nav--primary .md-nav__link svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: var(--md-primary-fg-color, #4051b5);
    flex-shrink: 0;
}

.md-nav--primary .md-nav__item--active > .md-nav__link svg {
    fill: var(--md-accent-fg-color, #ff2b2b);
}

/* 標題：主標題跟頂欄同色系、淡底；次標題淺灰底＋柔和紅條 */
.md-content .md-typeset :is(h1, h2, h3, h4, h5, h6) {
    --heading-accent: #e25555;
    --heading-bg: #f6f6f7;
    position: relative;
    letter-spacing: 0.02em;
    line-height: 1.45;
}

.md-content .md-typeset h1 {
    font-size: 2em;
    font-weight: 700;
    color: var(--md-primary-fg-color, #4051b5);
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 12%, #ffffff) 0%,
        color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 5%, #ffffff) 72%,
        #ffffff 100%
    );
    border-left: 4px solid var(--md-primary-fg-color, #4051b5);
    padding: 0.4em 1em 0.4em 0.85em;
    margin: 0.1em 0 0.85em;
    border-radius: 0 10px 10px 0;
    box-shadow: none;
}

.md-content .md-typeset h2 {
    font-weight: 700;
    color: #2c2c2c;
    background: var(--heading-bg);
    border-left: 4px solid var(--heading-accent);
    padding: 0.3em 0.9em 0.3em 0.8em;
    margin-top: 2.1em;
    margin-bottom: 0.7em;
    border-radius: 0 8px 8px 0;
}

.md-content .md-typeset h3 {
    font-weight: 700;
    color: #2c2c2c;
    background: #f8f8f8;
    border-left: 3px solid var(--heading-accent);
    padding: 0.24em 0.75em 0.24em 0.7em;
    margin-top: 1.7em;
    margin-bottom: 0.55em;
    border-radius: 0 6px 6px 0;
}

.md-content .md-typeset :is(h4, h5, h6) {
    font-weight: 600;
    color: #333;
    background: none;
    border-left: 2px solid var(--heading-accent);
    padding: 0.1em 0 0.1em 0.6em;
    margin-top: 1.45em;
    margin-bottom: 0.45em;
    border-radius: 0;
}

/* 正文節奏：中文較舒適的行高，標題靠近所屬內容、段落之間留白 */
.md-content .md-typeset {
    line-height: 1.75;
}

.md-content .md-typeset p:not(.admonition-title),
.md-content .md-typeset li {
    line-height: 1.8;
}

.md-content .md-typeset p:not(.admonition-title) {
    margin-block: 0.8em 1.15em;
}

/* Admonition 標題是 <p class="admonition-title">，不要套用正文段落間距 */
.md-content .md-typeset .admonition-title,
.md-content .md-typeset details > summary {
    margin-block: 0;
    line-height: 1.3;
}

.md-content .md-typeset .admonition > p:not(.admonition-title),
.md-content .md-typeset details > p {
    margin-block: 0.35em 0.5em;
}

.md-content .md-typeset .admonition > :last-child,
.md-content .md-typeset details > :last-child {
    margin-bottom: 0.5em;
}

.md-content .md-typeset :is(h1, h2, h3) + p {
    margin-top: 0.15em;
}

.md-content .md-typeset .grid.cards {
    margin: 0.9em 0 0.3em;
}

.md-content .md-typeset pre,
.md-content .md-typeset .highlight {
    margin-block: 0.7em 1.25em;
}

.md-content .md-typeset :is(h1, h2, h3) .twemoji {
    display: inline-flex;
    align-items: center;
    margin-right: 0.4em;
    vertical-align: -0.18em;
}

.md-content .md-typeset h1 .twemoji {
    width: 1.05em;
    height: 1.05em;
}

.md-content .md-typeset :is(h2, h3) .twemoji {
    width: 0.95em;
    height: 0.95em;
}

.md-content .md-typeset h1 .twemoji svg {
    fill: currentColor;
}

.md-content .md-typeset :is(h2, h3) .twemoji svg {
    fill: var(--heading-accent);
}

[data-md-color-scheme="slate"] .md-content .md-typeset :is(h1, h2, h3, h4, h5, h6) {
    --heading-accent: #ff5252;
    --heading-bg: rgba(255, 255, 255, 0.07);
    color: var(--md-default-fg-color);
}

[data-md-color-scheme="slate"] .md-content .md-typeset h1 {
    color: #c5cae9;
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 28%, transparent) 0%,
        color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 8%, transparent) 100%
    );
    box-shadow: none;
}

[data-md-color-scheme="slate"] .md-content .md-typeset h2,
[data-md-color-scheme="slate"] .md-content .md-typeset h3 {
    color: var(--md-default-fg-color);
    background: var(--heading-bg);
}

[data-md-color-scheme="slate"] .md-content .md-typeset :is(h4, h5, h6) {
    color: var(--md-default-fg-color);
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__link svg {
    fill: #c5cae9;
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__item--active > .md-nav__link svg {
    fill: var(--md-accent-fg-color, #ff5252);
}

/* 可以根據需要調整 margin 的數值 */
.md-typeset a.md-button {
    margin: 4px;
    padding: 4px 8px;
}

/* .md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
    padding: 4px 4px;
    margin: 4px 4px;
} */

/* table {
    width: auto;  
    font-size: 12px; 
    line-height: 1.0;
}

table th {
    padding: 2px 2px;  
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
}

table td {
    padding: 2px 2px;  
    text-align: left;
    white-space: nowrap; 
}

table, th, td {
    border: 1px solid #ddd;
    border-collapse: collapse;  
} */


/* table {
    width: 100%;
    table-layout: fixed;
}

table th:nth-child(1), table td:nth-child(1) {
    width: 90px; 
}

.md-typeset table:not([class]) {
    display: table;
} */

/* 

table {
    width: auto;  
    font-size: 12px; 
    line-height: 1.0;
}

th, td {
    border: 1px solid var(--md-typeset-table-color);
    border-spacing: 0;
    border-bottom: none;
    border-left: none;
    border-top: none;
    width: auto;
}
*/

.md-typeset__table {
    line-height: 1.6;
    width: auto;
}

.md-typeset__table table:not([class]) {
    font-size: .74rem;
    border: 1px solid black;
}

.md-typeset__table table:not([class]) td,
.md-typeset__table table:not([class]) th {
    padding: 8px 10px;
    line-height: 1.6;
    border: 1px solid gray;
    min-width: 30px;
}

.md-typeset__table tr:nth-child(2n) {
    background-color: #f8f8f8;
}

[data-md-color-scheme="slate"] .md-typeset__table tr:nth-child(2n) {
    background-color: hsla(var(--md-hue),25%,25%,1)
} 


/* 底下的設定是為了不讓 content 上捲時， Nav Bar 跟著向上移動一點點 */

/* 桌面側欄：隱藏 nav title，避免內容上捲時標題列造成位移。
   不可在手機一併隱藏——進到分類後，.md-nav__title 就是返回上一層的按鈕。 */
@media screen and (min-width: 76.25em) {
  .md-nav__title {
    display: none;
  }
}

/* 手機抽屜：回首頁／回上一層列改成與一般 Navbar 選項同高，不要佔 5.6rem。 */
@media screen and (max-width: 76.1875em) {
  .md-nav--primary .md-nav__title {
    display: flex;
    align-items: center;
    height: auto;
    min-height: 0;
    padding: 0.6rem 0.8rem;
    line-height: 1.5;
    font-size: 0.8rem;
  }

  .md-nav--primary .md-nav__title .md-nav__icon {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    width: 1.15rem;
    height: 1.15rem;
    margin: 0 0.45rem 0 0;
    flex-shrink: 0;
  }

  .md-nav--primary .md-nav__title .md-logo {
    position: static;
    left: auto;
    right: auto;
    top: auto;
    display: inline-flex;
    align-items: center;
    padding: 0;
    margin: 0 0.45rem 0 0;
  }

  .md-nav--primary .md-nav__title .md-nav__button.md-logo img,
  .md-nav--primary .md-nav__title .md-nav__button.md-logo svg {
    width: 1.15rem;
    height: 1.15rem;
    max-width: 1.15rem;
  }
}

/* 設定 md-main__inner 的 margin 和 padding 為 0 */
.md-main__inner.md-grid {
    margin-top: 0 !important;
    /* padding: 0 !important; */
}

/* 隱藏 div.mermaid 的原始文字 */
div.mermaid {
    color:transparent;
}

/* 修正 inline <code> 裡面的 css，凸顯他的顯示 */
.md-typeset code:not(pre code) {
    /* font-family: "Courier New", Consolas, monospace; 改字體 */
    font-family: "JetBrains Mono", "Source Code Pro", Consolas, Menlo, monospace;
    font-size: 1em;   
    color: red;
    background-color: #f0f0f0;  /* 底色淡粉紅 (可選) */
    /* font-weight: bold;      */
    padding: 0.1em 0.25em; /* 讓字不會太擠 */
    border-radius: 3px;    /* 圓角 */
}

/* 讓 admonition 裡的文字恢復正常字體大小 */
.md-typeset .admonition,
.md-typeset details {
  font-size: 1em;  /* 預設正文大小 */
}

/* 窄螢幕：頁尾版權與社交圖示維持左右，不要因為 copyright 寬度 100% 而上下疊。 */
.md-footer-meta__inner {
  flex-wrap: nowrap;
  align-items: center;
}

.md-footer-meta .md-copyright {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
}

.md-footer-meta .md-social {
  flex-shrink: 0;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

/* 手機：主題預設隱藏「上一頁」標題，只留箭頭。改回兩邊都顯示頁名。 */
@media screen and (max-width: 44.984375em) {
  .md-footer__link {
    min-width: 0;
    max-width: 50%;
  }

  .md-footer__link--prev {
    flex-shrink: 1;
  }

  .md-footer__link--prev .md-footer__title {
    display: block;
  }
}

/* Front matter 日期列（標題上方：主色圖示） */
.md-content__inner.md-typeset > .doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0 0 0.85em;
  padding: 0.15em 0.15em 0;
  color: var(--md-default-fg-color--light, #666);
  font-size: 0.82em;
}

.md-content__inner.md-typeset > .doc-meta .doc-meta__item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.md-content__inner.md-typeset > .doc-meta .twemoji {
  width: 0.95em;
  height: 0.95em;
}

.md-content__inner.md-typeset > .doc-meta .twemoji svg {
  fill: var(--md-primary-fg-color, #4051b5);
}

/* YouTube／官方影音 iframe（16:9） */
.md-typeset .video-wrapper {
  position: relative;
  display: block;
  width: 100%;
  height: 0;
  margin: 0.75em 0 1.25em;
  padding: 0 0 56.25%;
  overflow: hidden;
  background: #000;
  border-radius: 0.2rem;
}

.md-typeset .video-wrapper > iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
/* ---------- 點擊發音（見 js/tts.js） ---------- */
.md-typeset .tts {
  --tts-bg: #fff6c2;
  --tts-bg-hover: #ffe97a;
  --tts-icon: var(--md-primary-fg-color, #4051b5);
  cursor: pointer;
  background-color: var(--tts-bg);
  border-radius: 4px;
  padding: 0.05em 0.3em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: background-color 0.15s ease;
}

.md-typeset .tts::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-left: 0.3em;
  vertical-align: -0.1em;
  background-color: var(--tts-icon);
  opacity: 0.55;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z"/></svg>') center / contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z"/></svg>') center / contain no-repeat;
}

.md-typeset .tts:hover,
.md-typeset .tts:focus-visible {
  background-color: var(--tts-bg-hover);
  outline: none;
}

.md-typeset .tts:hover::after,
.md-typeset .tts.tts--speaking::after {
  opacity: 1;
}

.md-typeset .tts.tts--speaking {
  background-color: color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 18%, #ffffff);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 45%, transparent);
}

[data-md-color-scheme="slate"] .md-typeset .tts {
  --tts-bg: rgba(255, 235, 59, 0.18);
  --tts-bg-hover: rgba(255, 235, 59, 0.32);
  --tts-icon: #c5cae9;
}

[data-md-color-scheme="slate"] .md-typeset .tts.tts--speaking {
  background-color: rgba(197, 202, 233, 0.25);
}

/* 頁首朗讀工具列（js/tts.js 產生）：上排提示＋停止鈕，下排口音／語速分段按鈕與聲音選單 */
.md-typeset .tts-toolbar {
  --tts-accent: var(--md-primary-fg-color, #4051b5);
  --tts-border: color-mix(in srgb, var(--tts-accent) 18%, transparent);
  --tts-muted: var(--md-default-fg-color--light, #666);
  margin: -0.2em 0 1.5em;
  padding: 0.75rem 0.9rem 0.85rem;
  font-size: 0.72rem;
  line-height: 1.4;
  border: 1px solid var(--tts-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--tts-accent) 5%, var(--md-default-bg-color, #fff));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.md-typeset .tts-toolbar__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.md-typeset .tts-toolbar__badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--tts-accent);
}

.md-typeset .tts-toolbar__badge svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: #fff;
}

.md-typeset .tts-toolbar__hint {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--tts-muted);
}

.md-typeset .tts-toolbar__hint strong {
  display: block;
  font-size: 0.8rem;
  color: var(--md-default-fg-color, #333);
}

.md-typeset .tts-toolbar__sample {
  background: #fff6c2;
  border-radius: 4px;
  padding: 0 0.25em;
  margin: 0 0.15em;
  color: var(--md-default-fg-color, #333);
}

[data-md-color-scheme="slate"] .md-typeset .tts-toolbar__sample {
  background: rgba(255, 235, 59, 0.18);
}

.md-typeset .tts-toolbar__stop {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  font: inherit;
  color: var(--tts-muted);
  background: var(--md-default-bg-color, #fff);
  border: 1px solid var(--tts-border);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.md-typeset .tts-toolbar__stop svg {
  width: 0.75rem;
  height: 0.75rem;
  fill: currentColor;
}

.md-typeset .tts-toolbar__stop:hover {
  color: #e25555;
  border-color: #e25555;
}

/* 朗讀中：喇叭徽章脈動、停止鈕變紅 */
.md-typeset .tts-toolbar--speaking .tts-toolbar__stop {
  color: #fff;
  background: #e25555;
  border-color: #e25555;
}

.md-typeset .tts-toolbar--speaking .tts-toolbar__badge {
  animation: tts-pulse 1.2s ease-in-out infinite;
}

@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 45%, transparent); }
  50% { box-shadow: 0 0 0 7px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .md-typeset .tts-toolbar--speaking .tts-toolbar__badge { animation: none; }
}

.md-typeset .tts-toolbar__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.3rem;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--tts-border);
}

.md-typeset .tts-toolbar__group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.md-typeset .tts-toolbar__group--voice {
  flex: 1 1 13rem;
}

.md-typeset .tts-toolbar__label {
  font-weight: 600;
  color: var(--tts-muted);
  white-space: nowrap;
}

/* 分段按鈕（口音、語速） */
.md-typeset .tts-seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tts-accent) 10%, transparent);
}

.md-typeset .tts-seg__btn {
  padding: 0.25rem 0.75rem;
  font: inherit;
  color: var(--tts-muted);
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.md-typeset .tts-seg__btn:hover {
  color: var(--tts-accent);
}

.md-typeset .tts-seg__btn[aria-checked="true"] {
  color: #fff;
  background: var(--tts-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

/* 聲音選單：圓角外框＋自訂箭頭 */
.md-typeset .tts-select {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 18rem;
}

.md-typeset .tts-select select {
  width: 100%;
  padding: 0.3rem 1.9rem 0.3rem 0.85rem;
  font: inherit;
  color: var(--md-default-fg-color, #333);
  text-overflow: ellipsis;
  background: var(--md-default-bg-color, #fff);
  border: 1px solid var(--tts-border);
  border-radius: 999px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.md-typeset .tts-select select:disabled {
  cursor: default;
  opacity: 0.6;
}

.md-typeset .tts-select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.8rem;
  width: 0.38rem;
  height: 0.38rem;
  border-right: 2px solid var(--tts-muted);
  border-bottom: 2px solid var(--tts-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.md-typeset .tts-toolbar :is(button, select):focus-visible {
  outline: 2px solid var(--tts-accent);
  outline-offset: 2px;
}

.md-typeset .tts-toolbar--unsupported {
  color: var(--md-typeset-color, #333);
  border-color: #e25555;
}

/* 手機：控制項改成一列一組，左標籤、右控制 */
@media screen and (max-width: 30em) {
  .md-typeset .tts-toolbar__controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .md-typeset .tts-toolbar__group {
    justify-content: space-between;
  }

  .md-typeset .tts-toolbar__group--voice {
    flex: none;
  }

  .md-typeset .tts-select {
    max-width: 70%;
  }

  .md-typeset .tts-toolbar__stop span {
    display: none;
  }
}

/* 對話區塊：外框 + 「播放整段對話」按鈕 */
.md-typeset .dialog {
  margin: 0.8em 0 1.4em;
  padding: 0.6em 0.9em 0.2em;
  border-left: 4px solid var(--md-primary-fg-color, #4051b5);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--md-primary-fg-color, #4051b5) 4%, transparent);
}

.md-typeset .dialog .md-typeset__table {
  margin: 0.4em 0 0.6em;
}

.md-typeset .dialog .dialog__play {
  margin: 0.2em 0 0.3em;
  padding: 0.25em 0.9em;
  font-size: 0.75rem;
}
