/* ==========================================================================
   基礎：reset、介面字體、按鈕、輸入框、圖示、焦點、無障礙
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; }
img { display: block; max-width: 100%; }
a { color: var(--primary); }
button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* 圖示（內嵌 SVG sprite） */
.icon {
  width: 1.25em; height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* 按鈕 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 36px; padding: 0 .75em;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--rule); }
.btn[disabled] { opacity: .45; cursor: default; background: transparent; }
.btn-icon { width: 40px; height: 40px; min-height: 40px; padding: 0; color: var(--primary); }
.btn-icon .icon { width: 1.35rem; height: 1.35rem; }
.btn-quiet { color: var(--muted); font-size: .875rem; min-height: 30px; padding: 0 .5em; }
.btn-quiet:hover { color: var(--text); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--head); color: var(--on-primary); }
.btn-outline { border-color: var(--rule); }

/* 輸入框 */
.input {
  width: 100%; min-height: 36px; padding: 0 .6em;
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--rule); border-radius: var(--radius);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* 焦點：一律可見 */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:focus-visible, .input:focus-visible { outline-offset: 1px; }

/* 分段控制（設定面板） */
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.seg > button {
  padding: .35em .8em; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  border-left: 1px solid var(--rule);
}
.seg > button:first-child { border-left: 0; }
.seg > button:hover { background: var(--surface-2); color: var(--text); }
.seg > button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* 開關 */
.switch { display: inline-flex; align-items: center; gap: .6em; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .knob {
  width: 34px; height: 20px; border-radius: 10px; background: var(--rule); position: relative;
  transition: background-color var(--ease);
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); transition: transform var(--ease);
}
.switch input:checked + .knob { background: var(--primary); }
.switch input:checked + .knob::after { transform: translateX(14px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 數字 */
.num { font-variant-numeric: tabular-nums; }

/* 動效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}

/* 工具列品牌標誌（業主提供的印章，去背 PNG；三個頁面共用） */
.brand-mark { flex: none; width: 28px; height: 28px; margin-right: .5rem; border-radius: 50%; }
