/* 淺色為預設值；深色由系統偏好或 data-theme 覆蓋 */
:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #565656;
  --panel: #f4f4f4;
  --border: #dddddd;
  --rule: #e3e3e3;
  --link: #0a58ca;

  --btn-bg: #ffffff;
  --btn-fg: #4a4a4a;
  --btn-on-bg: #1a1a1a;
  --btn-on-fg: #ffffff;
}

/* 跟隨系統（沒有手動指定淺色時） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --fg: #e6e6e6;
    --muted: #a8a8a8;
    --panel: #1e1e20;
    --border: #3a3a3c;
    --rule: #2e2e30;
    --link: #7ab8ff;

    --btn-bg: #1e1e20;
    --btn-fg: #c8c8c8;
    --btn-on-bg: #e6e6e6;
    --btn-on-fg: #121212;
  }
}

/* 手動指定深色 */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #121212;
  --fg: #e6e6e6;
  --muted: #a8a8a8;
  --panel: #1e1e20;
  --border: #3a3a3c;
  --rule: #2e2e30;
  --link: #7ab8ff;

  --btn-bg: #1e1e20;
  --btn-fg: #c8c8c8;
  --btn-on-bg: #e6e6e6;
  --btn-on-fg: #121212;
}

/* 手動指定淺色 */
:root[data-theme="light"] {
  color-scheme: light;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 40px;
  max-width: 880px;
  margin: auto;
  line-height: 1.7;
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--link);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 28px 0;
}

/* 英文對照段落 */
.en {
  color: var(--muted);
}

.notice {
  background: var(--panel);
  padding: 12px 16px;
  border-radius: 6px;
}

.footer {
  color: var(--muted);
  font-size: 14px;
}

table.legal {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}

table.legal th,
table.legal td {
  text-align: left;
  padding: 8px;
  border: 1px solid var(--border);
}

table.legal thead tr {
  background: var(--panel);
}

table.legal th .en {
  font-weight: normal;
}

/* 主題切換器 */
.theme-switch {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.theme-switch .group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.theme-switch button {
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  padding: 7px 11px;
  margin: 0;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.theme-switch button:first-child {
  border-left: 0;
}

.theme-switch button[aria-pressed="true"] {
  background: var(--btn-on-bg);
  color: var(--btn-on-fg);
}

/* 未載入 JS 時不顯示切換器，避免出現按不動的按鈕 */
html:not(.js) .theme-switch {
  display: none;
}
