/* =============================================================================
 * 牙周檢查表 — 外觀參照 periodontalchart-online.com（2026 zh-tw 版面）
 * 結構：頂條 / Logo / 選單 / 分頁 / 工具列 / 病人資料 / 檢查表 / 頁底分頁 / 解釋 / 頁腳
 * 右下角另加「語音・快速輸入」浮動面板（可收合，不影響版面）
 * ========================================================================== */

:root {
  --ink: #333;
  --ink-soft: #777;
  --line: #d9d9d9;
  --line-soft: #ececec;
  --pink: #f7d7da;
  --pink-line: #dfaeb3;
  --blue: #dbe8f4;
  --blue-line: #b9d2e8;
  --primary: #7fb3e0;
  --primary-dark: #5b9bd5;
  --brand: #1565b8;
  --red: #c0392b;
  --ok: #1f7a3f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- 頂條 ---------- */
.topstrip { border-bottom: 1px solid var(--line-soft); }
.topstrip-inner {
  max-width: 1680px; margin: 0 auto;
  padding: 6px 24px 6px 168px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: #666;
}
.socials { display: flex; gap: 16px; }
.socials svg { width: 15px; height: 15px; fill: #666; }
.toplinks { display: flex; gap: 26px; }
.toplinks a { color: #666; }
.toplinks a:hover { color: #000; }

/* ---------- Logo ---------- */
.sitehead { border-bottom: 1px solid var(--line-soft); }
.head-inner {
  max-width: 1680px; margin: 0 auto;
  padding: 22px 24px 18px 168px;
  display: flex; align-items: center; gap: 28px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 56px; height: 56px; }
.logo-txt { font-size: 34px; letter-spacing: -0.4px; color: #1b3a5c; }
.logo-txt b { font-weight: 700; color: var(--brand); }
.logo-txt i { font-style: normal; font-weight: 700; color: #8fa6bd; }

.mic-orb {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid #e2e2e2; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  cursor: pointer; display: grid; place-items: center; margin-left: 4px;
}
.mic-orb svg { width: 22px; height: 22px; }
.mic-orb.on { background: #fde8e8; border-color: #e9a8a8; animation: orb 1.6s infinite; }
@keyframes orb { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.35); } 50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); } }

/* ---------- 選單 ---------- */
.site-menu { border-bottom: 1px solid var(--line-soft); }
.menu-inner {
  max-width: 1680px; margin: 0 auto;
  padding: 0 24px 0 168px;
  height: 46px;
  display: flex; align-items: center; gap: 42px;
  font-size: 15px; color: #2b2b2b;
}
.menu-inner > a:hover { color: var(--brand); }
.menu-inner .ph { display: flex; align-items: center; gap: 6px; color: var(--red); font-weight: 600; }
.menu-inner .ph svg { width: 22px; height: 22px; }
.langs { margin-left: auto; cursor: pointer; color: #2b2b2b; }
.langs .caret { color: #888; }

/* ---------- 分頁 ---------- */
.tabs {
  max-width: 1680px; margin: 0 auto;
  display: flex; border-bottom: 1px solid var(--line-soft);
}
.tabs a {
  flex: 1; text-align: center; padding: 18px 0 17px;
  font-size: 15px; color: #bdbdbd; border-bottom: 2px solid transparent;
}
.tabs a.active { color: #111; border-bottom-color: #111; }

/* ---------- 內容區 ---------- */
.content {
  max-width: 1680px; margin: 0 auto;
  padding: 0 24px 60px 168px;
}

/* ---------- 工具列 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 44px; padding: 26px 0 0; }
.toolbar.sub { padding-top: 16px; }
.tbtn {
  min-width: 158px; height: 60px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fbfbfb; border: 1px solid #e2e2e2; border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
  font-size: 15px; color: #2b2b2b; cursor: pointer;
}
.tbtn svg { width: 20px; height: 20px; }
.tbtn:hover { background: #f4f4f4; }
.tbtn:disabled { color: #b9b9b9; cursor: default; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.tbtn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.tbtn.primary:hover { background: var(--primary-dark); }

/* ---------- 病人資料 ---------- */
.patient-form { padding: 26px 0 6px; }
.form-title { font-size: 34px; font-weight: 800; margin: 0 0 26px; letter-spacing: 0.5px; }

.form-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.fl { font-size: 15px; color: #2b2b2b; }
.fld {
  height: 40px; border-radius: 3px; padding: 0 10px;
  font-size: 15px; color: #2b2b2b; font-family: inherit;
  border: 1px solid var(--pink-line); background: var(--pink);
}
.fld.blue { border-color: var(--blue-line); background: var(--blue); }
.fld:focus { outline: 2px solid #8ab6dd; outline-offset: -1px; }
.fld::placeholder { color: #9a9a9a; }
.r1 .fld#pid { width: 380px; }
.r1 .fld#pdate { width: 320px; }
.r2 .fld#plast { width: 390px; }
.r2 .fld#pfirst { width: 390px; }
.r2 .fld#pbirth { width: 360px; }
.r3 .fld#pdoctor { width: 560px; }
.r3 { gap: 14px; }

.cb {
  appearance: none; width: 26px; height: 26px; margin: 0;
  border: 1px solid #c9c9c9; border-radius: 3px; background: #fff; cursor: pointer;
  position: relative;
}
.cb:checked { background: var(--blue); border-color: var(--blue-line); }
.cb:checked::after {
  content: ""; position: absolute; left: 7px; top: 3px; width: 8px; height: 14px;
  border-right: 3px solid #2b6ca3; border-bottom: 3px solid #2b6ca3; transform: rotate(40deg);
}
.cbl { font-size: 15px; color: #2b2b2b; margin-right: 26px; }
.r3 .fl:first-of-type { margin-left: 20px; }

/* ---------- 檢查表 ---------- */
.chart { margin-top: 14px; overflow-x: auto; }

.jawblock { min-width: 1100px; }
table.jaw {
  border-collapse: collapse; table-layout: fixed; width: 100%;
  font-size: 12px;
}
table.jaw th, table.jaw td { border: 1px solid #d5d5d5; padding: 0; height: 25px; }
table.jaw .rowlabel {
  width: 92px; text-align: right; padding-right: 8px;
  font-weight: 400; color: #2b2b2b; background: #fff; white-space: nowrap;
  font-size: 12.5px; border-left: none;
}
table.jaw thead th {
  background: #fff; font-weight: 700; color: #222; font-size: 12.5px;
  text-align: center; height: 26px;
}
table.jaw thead th.tooth { border-right: 1px solid #999; }
table.jaw thead th.quad-start { border-left: 1px solid #999; }

.cell { position: relative; }
.cell input {
  width: 100%; height: 25px; border: 0; background: transparent;
  text-align: center; font-size: 12.5px; color: #222; font-family: inherit;
  padding: 0; outline: none;
}
.cell input:focus { background: #eaf3fb; box-shadow: inset 0 0 0 2px #8ab6dd; }
.cell.mute input { color: #bbb; }
.cell.al input { color: #5a5a5a; background: #fafafa; cursor: default; }
.cell.hi input { background: #e6eef7; }

/* 目前位點 */
.cell.cursor input { background: #dbeafe; box-shadow: inset 0 0 0 2px #2b6ca3; font-weight: 700; }
.cell.cursor::after {
  content: ""; position: absolute; inset: -1px; border: 2px solid #2b6ca3; pointer-events: none;
}

/* 有異常時的淡色提示（唔會蓋住原設計） */
.cell.pd4 input { background: #fff6e0; }
.cell.pd5 input { background: #f2e9ff; color: #5b21b6; font-weight: 700; }
.cell.pd7 input { background: #e6d9ff; color: #4c1d95; font-weight: 700; }
.cell.bopon input { background: #cf3b3b; color: transparent; }
.cell.gmneg input { color: #b3261e; }
.cell.missing { background: #f2f2f2; }
.cell.missing input { color: #c0c0c0; text-decoration: line-through; }

/* 分叉 / 動搖 / 植體 單格 */
.cell.one input { font-weight: 600; }
.cell.furc { display: flex; align-items: stretch; }
.cell.furc input { flex: 1 1 0; min-width: 0; }
.furc-slot { flex: 1 1 0; }
td.gapcell, th.gapcell { border: 0 !important; background: transparent; }
td.artcell { border: 0 !important; background: #fff; padding: 0 !important; }
.cell .mark { display: block; line-height: 25px; text-align: center; color: #999; }

/* BOP 檢視：突顯探測出血行 */
body.bopview tr[data-row^="bop"] td { background: #fff3f3; }
body.bopview tr[data-row^="bop"] .rowlabel { background: #fff3f3; color: #a11414; font-weight: 700; }

/* 牙齒圖 */
svg.arch { display: block; width: 100%; height: 118px; background: #fff; }
svg.arch .pocket { fill: #6b46c1; opacity: .55; }
svg.arch .pocket-sev { fill: #4c1d95; opacity: .75; }
svg.arch .al { stroke: #2b6ca3; stroke-width: 1.4; fill: none; }
svg.arch .toothbody { fill: #fdfdfd; stroke: #444; stroke-width: 1.1; }
svg.arch .toothnum { font-size: 9px; fill: #666; text-anchor: middle; }

/* 統計列 */
tr.summary td {
  background: #f7f7f7; height: 30px; font-size: 12px; text-align: center; color: #222;
}
tr.summary .rowlabel { background: #f7f7f7; }
tr.summary b { font-weight: 700; }

/* ---------- 頁底分頁 ---------- */
.bottombar {
  display: flex; flex-wrap: wrap; gap: 26px; align-items: center;
  margin: 22px 0 8px; padding: 12px 0; border-top: 1px solid var(--line-soft);
}
.bottombar button {
  background: none; border: 0; padding: 2px 0; cursor: pointer;
  font-size: 13px; color: #4a4a4a;
}
.bottombar button.active { color: #111; font-weight: 700; border-bottom: 2px solid #111; }

/* ---------- 頁下面的解釋 ---------- */
.explain {
  max-width: 1120px; margin: 18px 0 40px;
  font-size: 14px; line-height: 1.95; color: #333;
  border-top: 1px solid var(--line-soft); padding-top: 22px;
}
.explain h2 { font-size: 20px; font-weight: 700; margin: 0 0 14px; color: #1b3a5c; }
.explain h3 { font-size: 16.5px; font-weight: 700; margin: 26px 0 10px; color: #1b3a5c; }
.explain h4 { font-size: 14.5px; font-weight: 700; margin: 18px 0 6px; color: #26445f; }
.explain p { margin: 0 0 10px; }
.explain .lead { color: #333; }
.explain .formula {
  background: #f4f8fc; border-left: 3px solid var(--primary);
  padding: 8px 12px; font-weight: 600; color: #1b3a5c;
}
.explain .note { font-size: 13px; color: #5b5b5b; }
.explain ul.grades { margin: 0 0 12px; padding-left: 22px; }
.explain ul.grades li { margin-bottom: 2px; }
.explain ol.refs { margin: 0; padding-left: 22px; font-size: 13px; color: #444; }
.explain ol.refs li { margin-bottom: 6px; }

/* ---------- 頁腳 ---------- */
.sitefoot {
  border-top: 1px solid var(--line-soft); padding: 18px 0 40px;
  font-size: 12px; color: #666;
}
.foot-links { display: flex; flex-wrap: wrap; gap: 28px; }
.foot-links a:hover { color: #000; }
.foot-copy { margin-top: 10px; color: #888; }

/* =============================================================================
 * 語音・快速輸入 面板
 * ========================================================================== */
.dock-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 55;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--brand); border: 0; cursor: pointer;
  box-shadow: 0 6px 18px rgba(15,23,42,.35);
  display: grid; place-items: center;
}
.dock-fab svg { width: 26px; height: 26px; }
.dock-fab.on { background: #dc2626; animation: rec 1.6s infinite; }

.dock {
  position: fixed; right: 18px; top: 92px; z-index: 56;
  width: 340px;
  background: #fff; border: 1px solid #dcdcdc; border-radius: 8px;
  box-shadow: 0 12px 34px rgba(15,23,42,.24);
  font-size: 13px; color: #333;
  max-height: calc(100vh - 120px); overflow: auto;
  transform: translateX(calc(100% + 32px));
  transition: transform .22s ease;
}
.dock.open { transform: none; }
.dock-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: #f6f8fb; border-bottom: 1px solid #e6e9ee;
  border-radius: 8px 8px 0 0; position: sticky; top: 0; z-index: 2;
}
.dock-title { font-weight: 700; font-size: 13px; }
.dock-state { font-size: 11px; color: #8a8a8a; background: #eceff3; border-radius: 10px; padding: 2px 8px; }
.dock-state.on { background: #e6f4ec; color: #1f7a3f; }
.dock-state.err { background: #fdecec; color: #b3261e; }
.dock-min { margin-left: auto; border: 0; background: none; cursor: pointer; color: #888; font-size: 14px; }

.dock-body { padding: 10px 12px 12px; }
.seg { display: flex; border: 1px solid #dfe3e8; border-radius: 6px; overflow: hidden; margin-bottom: 9px; }
.seg button {
  flex: 1; padding: 7px 4px; border: 0; background: #fff; cursor: pointer;
  font-size: 12px; color: #4a4a4a;
}
.seg button + button { border-left: 1px solid #dfe3e8; }
.seg button.on { background: var(--blue); color: #1b4b73; font-weight: 700; }

.microw { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.micbtn {
  flex: 1; padding: 9px 10px; border-radius: 6px; border: 1px solid #d6dbe1;
  background: #fff; font-weight: 700; cursor: pointer; font-size: 13px;
}
.micbtn.on { background: #dc2626; border-color: #dc2626; color: #fff; animation: rec 1.6s infinite; }
@keyframes rec { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); } 50% { box-shadow: 0 0 0 7px rgba(220,38,38,0); } }
.chk { font-size: 11px; color: #666; display: flex; align-items: center; gap: 4px; }

.cursorline {
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
  background: #f1f5f9; border-radius: 6px; padding: 5px 6px;
}
.cursorline #cursorText { flex: 1; text-align: center; font-weight: 700; font-size: 12.5px; color: #1b4b73; }
.step { width: 26px; height: 26px; border-radius: 5px; border: 1px solid #d6dbe1; background: #fff; cursor: pointer; }

.slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 9px; }
.slot {
  border: 1px solid #dfe3e8; border-radius: 5px; height: 40px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; background: #fbfcfd; font-size: 15px; font-weight: 700; color: #222;
}
.slot small { font-size: 9px; font-weight: 400; color: #8a8a8a; margin-top: 1px; }
.slot.active { border-color: #2b6ca3; box-shadow: 0 0 0 2px rgba(43,108,163,.2); background: #eaf3fb; }
.slot.filled { background: #eef7ff; }

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 6px; }
.pad button {
  height: 34px; border-radius: 5px; border: 1px solid #dfe3e8; background: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.pad button:active { background: #eef2f6; }
.pad button.alt { background: #f6f8fa; font-size: 13px; }
.pad2 { display: grid; grid-template-columns: 1.6fr 1fr .7fr; gap: 5px; margin-bottom: 9px; }
.pad2 button {
  height: 32px; border-radius: 5px; border: 1px solid #dfe3e8; background: #fff; cursor: pointer; font-size: 12px;
}
.pad2 button.primary { background: var(--accent, #2b6ca3); border-color: #2b6ca3; color: #fff; font-weight: 700; }

.quickrow { display: flex; gap: 5px; margin-bottom: 9px; }
.quickrow input {
  flex: 1; min-width: 0; height: 30px; border: 1px solid #dfe3e8; border-radius: 5px;
  padding: 0 8px; font-size: 12px; font-family: inherit;
}
.quickrow button { height: 30px; padding: 0 12px; border-radius: 5px; border: 1px solid #dfe3e8; background: #fff; cursor: pointer; font-size: 12px; }

.heardrow { margin-bottom: 8px; }
.heard {
  background: #f1f5f9; border-radius: 6px; padding: 7px 9px; font-size: 13px; font-weight: 700;
  min-height: 30px; word-break: break-all;
}
.heard.interim { color: #6b7280; font-weight: 500; }
.parsed { font-size: 11px; color: #6b7280; margin-top: 3px; min-height: 14px; }
.parsed b { color: #1b4b73; }

.logwrap, .help { border-top: 1px solid #eef1f4; padding-top: 7px; margin-top: 7px; }
.logwrap summary, .help summary { cursor: pointer; font-size: 12px; color: #4a4a4a; display: flex; align-items: center; gap: 6px; }
.mini { border: 1px solid #dfe3e8; background: #fff; border-radius: 4px; padding: 1px 7px; font-size: 11px; cursor: pointer; }
.log { list-style: none; margin: 6px 0 0; padding: 0; max-height: 150px; overflow: auto; }
.log li { font-size: 11px; padding: 4px 6px; border-radius: 4px; background: #f8fafc; margin-bottom: 3px; }
.log li.err { background: #fef2f2; }
.log li .said { color: #6b7280; }
.log li .did { font-weight: 600; }

.exportrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 9px; }
.exportrow button {
  height: 30px; border-radius: 5px; border: 1px solid #dfe3e8; background: #fff; cursor: pointer; font-size: 11.5px;
}
.exportrow button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.exportrow button.danger { color: #b3261e; }

.help-body { font-size: 12px; line-height: 1.75; color: #333; margin-top: 6px; }
.help-body ul { margin: 4px 0 8px; padding-left: 18px; }
.help-body p { margin: 0 0 6px; }

/* 提示橫幅 */
.banner {
  position: fixed; left: 50%; transform: translateX(-50%); top: 12px; z-index: 60;
  background: #fef3c7; border: 1px solid #fcd34d; color: #78350f;
  padding: 8px 14px; border-radius: 6px; font-size: 13px; max-width: 720px;
  box-shadow: 0 4px 14px rgba(0,0,0,.14); display: flex; gap: 12px; align-items: center;
}
.banner[hidden] { display: none; }

/* ---------- 列印 ---------- */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  .topstrip, .sitehead, .site-menu, .tabs, .toolbar, .bottombar,
  .explain, .sitefoot, .dock, .banner { display: none !important; }
  .content { max-width: none; padding: 0; }
  .form-title { font-size: 18pt; margin-bottom: 8px; }
  .patient-form { padding: 0 0 6px; }
  .fld { border: 0; background: transparent; }
  .chart { overflow: visible; }
  .jawblock { min-width: 0; }
  table.jaw th, table.jaw td { height: 17px; }
  .cell input { height: 17px; font-size: 8pt; }
  .cell.cursor input { background: transparent; box-shadow: none; }
  .cell.cursor::after { display: none; }
  svg.arch { height: 70px; }
}
