:root {
  --fg: #1a1a1a;
  --muted: #555;
  --line: #d6d9de;
  --bg: #ffffff;
  --soft: #f3f5f8;
  --brand: #1d4ed8;
  --brand-dark: #1e3a8a;
  --ok: #047857;
  --warn: #b45309;
  --bad: #b91c1c;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 18px;
  line-height: 1.75;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
a { color: var(--brand); }
h1 { font-size: 1.75rem; line-height: 1.35; margin: 1.2rem 0 .5rem; }
h2 { font-size: 1.35rem; line-height: 1.4; margin: 2rem 0 .75rem; }
.lead { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 1rem; margin: .5rem 0; }

.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap { padding-top: 12px; padding-bottom: 12px; }
.site-logo { font-weight: 700; font-size: 1.1rem; color: var(--fg); text-decoration: none; }
/* 頁首工具選單：手機收成「所有工具」下拉，寬螢幕橫排 */
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tool-nav ul { list-style: none; margin: 0; padding: 0; }
.tool-nav a { text-decoration: none; font-weight: 600; }
.tool-nav a[aria-current="page"] { color: var(--fg); }
.tool-links { display: none; }
.tool-menu { position: relative; }
.tool-menu summary { list-style: none; cursor: pointer; padding: 8px 14px; border: 2px solid var(--brand); border-radius: 10px; color: var(--brand); font-weight: 600; }
.tool-menu summary::-webkit-details-marker { display: none; }
.tool-menu summary::after { content: " ▾"; }
.tool-menu[open] summary::after { content: " ▴"; }
.tool-menu ul { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(86vw, 300px); max-height: 75vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; }
.tool-menu li a { display: block; padding: 12px; border-radius: 8px; }
.tool-menu li a:hover, .tool-menu li a[aria-current="page"] { background: #eff4ff; }
/* 工具一多橫排放不下，寬螢幕也用下拉，改成兩欄 */
@media (min-width: 640px) {
  .tool-menu ul { width: 560px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
}
.other-tools { margin-top: 2.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.site-footer { margin-top: 3rem; border-top: 1px solid var(--line); background: var(--soft); font-size: .95rem; color: var(--muted); }
.site-footer .wrap { padding-top: 16px; padding-bottom: 24px; }
[hidden] { display: none !important; } /* 讓 hidden 屬性蓋過 .btn 等元件的 display */
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 1rem; }

.tool-list { list-style: none; padding: 0; margin: 1.5rem 0; }
.tool-list a { display: block; padding: 16px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--fg); }
.tool-list a:hover { border-color: var(--brand); }
.tool-list strong { display: block; font-size: 1.2rem; color: var(--brand); }
.tool-list span { color: var(--muted); font-size: 1rem; }

.privacy-note { background: #ecfdf5; border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 6px; font-size: 1rem; }

.tool { border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 16px; margin: 1.25rem 0; background: #fff; }
.step { padding-top: 8px; }
.step + .step { border-top: 1px dashed var(--line); margin-top: 12px; }
.step-title { font-size: 1.15rem; margin: .75rem 0 .5rem; display: flex; align-items: center; gap: 8px; }
.step-title span { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; align-items: center; justify-content: center; font-size: .95rem; }

.size-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.size-opt { cursor: pointer; }
.size-opt input { position: absolute; opacity: 0; pointer-events: none; }
.size-opt span { display: block; border: 2px solid var(--line); border-radius: 10px; padding: 8px 6px; text-align: center; line-height: 1.35; }
.size-opt strong { display: block; font-size: 1rem; }
.size-opt small { color: var(--muted); font-size: .85rem; }
.size-opt input:checked + span { border-color: var(--brand); background: #eff4ff; }
.size-opt input:focus-visible + span { outline: 3px solid #93b4ff; }

.pick-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 18px; border-radius: 10px;
  border: 2px solid var(--brand); background: #fff; color: var(--brand);
  font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: .95rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.pick-buttons .btn { flex: 1 1 200px; }
.cam { margin: 10px 0; }
.cam video { display: block; width: 100%; max-height: 70vh; background: #000; border-radius: 10px; transform: scaleX(-1); /* 前鏡頭預覽照鏡子方向，拍下來的照片是正向 */ }

.status { min-height: 1.5em; margin: .25rem 0; font-size: 1rem; }
.status.error { color: var(--bad); font-weight: 600; }

.stage-wrap { display: flex; justify-content: center; margin: 8px 0; }
.stage { position: relative; width: min(100%, 320px); touch-action: none; user-select: none; box-shadow: 0 0 0 1px var(--line); background: #fff; }
.stage canvas { display: block; width: 100%; height: auto; }
.stage .guides { position: absolute; inset: 0; height: 100%; cursor: grab; }
.measure { text-align: center; font-weight: 600; margin: .25rem 0; }
.measure.ok { color: var(--ok); }
.measure.bad { color: var(--bad); }
.controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin: 8px 0; }
.controls input[type=range] { flex: 1 1 140px; max-width: 260px; }

.results { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.results figure { margin: 0; text-align: center; }
.results img { width: 100%; height: auto; border: 1px solid var(--line); background: #fff; }
.results figcaption { font-size: .9rem; color: var(--muted); margin: 4px 0 8px; }
.results .btn { width: 100%; }

.ad-slot { margin: 1.5rem 0; }

.content table { border-collapse: collapse; width: 100%; font-size: 1rem; }
.content th, .content td { border: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.content th { background: var(--soft); }
.table-scroll { overflow-x: auto; }
.rules li { margin-bottom: .5rem; }
.faq details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { margin: .5rem 0 0; }
.sources { font-size: .95rem; }

@media (max-width: 480px) {
  body { font-size: 17px; }
  h1 { font-size: 1.5rem; }
  .size-options { grid-template-columns: 1fr; }
  .size-opt span { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; text-align: left; }
  .results { grid-template-columns: 1fr; }
}

/* QR Code 產生器 */
.qr-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0; }
.qr-tabs button { min-height: 48px; padding: 0 4px; border: 2px solid var(--line); border-radius: 10px; background: #fff; font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; color: var(--fg); }
.qr-tabs button[aria-selected="true"] { border-color: var(--brand); background: #eff4ff; color: var(--brand); }
.qr-field { display: block; margin: 10px 0; font-weight: 600; font-size: 1rem; }
.qr-field input[type=text], .qr-field input[type=url], .qr-field input[type=number], .qr-field textarea, .qr-field select {
  display: block; width: 100%; margin-top: 4px; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; background: #fff; color: var(--fg);
}
.qr-field textarea { min-height: 96px; resize: vertical; }
.qr-check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 1rem; }
.qr-check input { width: 22px; height: 22px; }
.qr-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.qr-opts input[type=color] { display: block; width: 100%; height: 44px; margin-top: 4px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.qr-preview { display: flex; justify-content: center; margin: 12px 0; }
.qr-preview canvas { width: min(100%, 240px); height: auto; aspect-ratio: 1; border: 1px solid var(--line); background: #fff; }
.qr-preview canvas.empty { background: var(--soft); }
.qr-warn { color: var(--warn); font-size: 1rem; margin: .5rem 0; }
.qr-dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.qr-dl .btn { width: 100%; }
@media (max-width: 480px) {
  .qr-tabs button { font-size: .9rem; }
  .qr-dl { grid-template-columns: 1fr; }
}

.qr-promise { background: #ecfdf5; border: 2px solid var(--ok); border-radius: 12px; padding: 12px 16px; margin: 1rem 0; }
.qr-promise strong { display: block; font-size: 1.15rem; color: var(--ok); }
.qr-promise p { margin: .35rem 0 0; font-size: 1rem; }

/* 勞工試算（資遣費／特休／加班費） */
.calc fieldset { border: 0; padding: 0; margin: 10px 0; min-width: 0; }
.calc legend { font-weight: 600; font-size: 1rem; padding: 0; margin-bottom: 4px; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.calc-grid > * { min-width: 0; }
.calc .qr-field input[type=date] { display: block; width: 100%; margin-top: 4px; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; background: #fff; color: var(--fg); }
.calc-radios label { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; padding: 10px 12px; margin: 6px 0; border: 2px solid var(--line); border-radius: 10px; font-size: 1rem; cursor: pointer; }
.calc-radios label:has(input:checked) { border-color: var(--brand); background: #eff4ff; }
.calc-radios input { width: 20px; height: 20px; margin: 0; flex: none; }
.calc-radios small { flex-basis: 100%; padding-left: 28px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.calc-radios-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.calc-radios-inline legend { grid-column: 1 / -1; }
.calc-go { width: 100%; }
.calc-result { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.calc-result h3 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
.total-box { background: #eff4ff; border: 2px solid var(--brand); border-radius: 12px; padding: 12px 16px; text-align: center; }
.total-box span { display: block; font-size: 1rem; color: var(--muted); }
.total-box strong { display: block; font-size: 1.9rem; line-height: 1.3; color: var(--brand-dark); }
.calc-sub { margin: .5rem 0; font-size: 1rem; }
.calc-table { border-collapse: collapse; width: 100%; font-size: 1rem; margin: 12px 0; }
.calc-table th, .calc-table td { border: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.calc-table th { background: var(--soft); font-weight: 600; }
.calc-table tbody th { width: 34%; }
.calc-table small { color: var(--muted); font-size: .88rem; }
.calc-table tr.on td { background: #fff7e6; font-weight: 600; }
.calc-notes { font-size: 1rem; padding-left: 1.2em; }
.calc-notes li { margin-bottom: .4rem; }
.calc-legal { font-size: 1rem; margin: .75rem 0 .25rem; }
.disclaimer { color: var(--muted); font-size: .9rem; margin: .25rem 0 0; }
.formula { background: var(--soft); border-radius: 8px; padding: 8px 12px; font-size: 1rem; overflow-wrap: anywhere; }
.ot-row { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 10px 0; background: var(--soft); }
.ot-row-head { display: flex; justify-content: space-between; align-items: center; font-size: 1rem; }
.ot-del { border: 0; background: none; color: var(--bad); font: inherit; font-size: .95rem; cursor: pointer; padding: 6px 4px; min-height: 40px; }
@media (max-width: 480px) {
  .calc-grid { grid-template-columns: 1fr; }
  .total-box strong { font-size: 1.6rem; }
  .calc-table th, .calc-table td { padding: 6px; font-size: .95rem; }
}
#ot-lines td:nth-child(2), #ot-lines td:nth-child(4), #ot-result thead th { white-space: nowrap; }
