/* /tools/breathing 睡覺呼吸次數計時器（2026-12-02）。只有這一頁載入。
 * 頁面跟著手機的深淺色走；數呼吸的畫面不管深淺色都是暗的，晚上不刺眼、不吵醒寶貝。 */
[hidden] { display: none !important; } /* .btn 自己有 display，hidden 要蓋得過 */

.br-basis { margin: -6px 0 14px; }
.br-basis a { color: var(--teal); text-underline-offset: 3px; padding: 4px 0; }
.br-start fieldset { margin-bottom: 12px; }
.br-start .choice { justify-content: center; min-height: 52px; font-size: 1rem; font-weight: 700; }
.br-start .hint { margin: 6px 0 0; }
.br-start .error { margin: 6px 0 0; }
.br-go { min-height: 56px; font-size: 1.1rem; margin-top: 4px; }
.br-note { margin: 10px 0 0; }
#br-msg:empty, #br-rmsg:empty, #br-hmsg:empty { display: none; }
#br-msg, #br-rmsg, #br-hmsg { margin: 10px 0 0; }

/* 結果 */
.br-result, #br-hist { scroll-margin-top: 88px; }
.br-big { margin: 2px 0 2px; font-size: 3.4rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.br-unit { margin: 0 8px; font-size: 1.05rem; font-weight: 700; letter-spacing: 0; color: var(--muted); }
.br-unit:first-child { margin-left: 0; }
.br-band { margin: 10px 0 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.br-band h3 { font-size: 1.05rem; margin: 0 0 4px; }
.br-band p { margin: 0; }
.br-band p + p { margin-top: 8px; }
.br-band[data-band="ok"] { background: var(--ok-soft); border-color: #c9ddd5; color: var(--forest); }
.br-band[data-band="high"] { background: var(--warn-bg); border-color: #f0d49a; color: var(--warn-ink); }
.br-band[data-band="higher"] { background: var(--sos-soft); border-color: #efc6bd; color: #6e1d14; }
body.on-doc .card .br-band a:not(.btn) { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.br-band-er a { display: inline-block; padding: 12px 0; margin: -12px 0; } /* 字不變大，手指按得到 */
.br-trend { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-ink); }

/* 急診、怎麼數、紀錄、來源 */
.br-er .dots { margin-bottom: 12px; }
.br-steps { margin: 0 0 10px; padding-left: 1.4em; }
.br-steps li { margin: 0 0 8px; }
.br-list { list-style: none; margin: 0 0 12px; padding: 0; font-variant-numeric: tabular-nums; }
.br-list li { display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.br-list li:first-child { border-top: 0; }
.br-list time { color: var(--muted); font-size: .9rem; }
.br-li-pet { color: var(--muted); font-size: .9rem; }
.br-tag { font-size: .8rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--ok-soft); color: var(--forest); }
.br-tag[data-band="high"] { background: var(--warn-bg); color: var(--warn-ink); }
.br-tag[data-band="higher"] { background: var(--sos-soft); color: #7a2117; }
#br-copybox { margin: 10px 0 0; background: var(--teal-soft); }
.br-src-list { margin: 0; padding-left: 1.2em; line-height: 1.6; }
.br-src-list li { margin: 0 0 8px; overflow-wrap: anywhere; }
.br-src-list a { display: inline; }

/* ---------- 數呼吸的畫面：整個螢幕，下半部整片都是按鈕 ---------- */
dialog.br-count {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none;
  background: #141116; color: #ddd3e1; overflow: hidden;
}
dialog.br-count[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
dialog.br-count::backdrop { background: #141116; }
/* 慢慢變暗、慢慢變亮，不要一下子黑掉（Jenny 2026-12-02） */
dialog.br-count[open], dialog.br-count[open]::backdrop { animation: br-dim-in 1.2s ease-out both; }
dialog.br-count.leaving, dialog.br-count.leaving::backdrop { animation: br-dim-out .6s ease-in both; }
@keyframes br-dim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes br-dim-out { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  dialog.br-count[open], dialog.br-count[open]::backdrop { animation-duration: .5s; }
  dialog.br-count.leaving, dialog.br-count.leaving::backdrop { animation-duration: .25s; }
}
.br-top { width: 100%; max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; text-align: center; }
.br-top-row { display: flex; justify-content: center; gap: 8px; margin: 0; font-size: .95rem; color: #b5a8bb; }
.br-pet { font-weight: 700; color: #d9c2d6; }
.br-left { margin: 2px 0 6px; font-size: clamp(3.5rem, 17vw, 6rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: #eee5f1; }
.br-sec { margin-left: 4px; font-size: .3em; font-weight: 700; color: #b5a8bb; }
.br-bar { height: 4px; margin: 0 0 10px; border-radius: 4px; background: #2c2531; overflow: hidden; }
.br-bar span { display: block; height: 100%; background: #9b6b94; transform: scaleX(0); transform-origin: left center; }
.br-n { margin: 0 0 10px; font-size: 1.05rem; color: #c9bdcd; font-variant-numeric: tabular-nums; }
.br-n strong { font-size: 1.6rem; color: #eee5f1; margin: 0 2px; }
.br-ctl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.br-ctl .btn { min-height: 48px; background: transparent; color: #ddd3e1; border-color: #4a3d50; font-weight: 600; }
.br-tap {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% - 32px); max-width: 720px; min-height: 0; height: auto;
  margin: 4px auto calc(16px + env(safe-area-inset-bottom));
  border: 2px solid #4a3d50; border-radius: 28px; background: #251e29; color: #eee5f1;
  font: inherit; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.br-tap strong { font-size: clamp(1.4rem, 6vw, 2rem); letter-spacing: .02em; }
.br-tap span { font-size: .95rem; color: #b5a8bb; }
.br-tap:active, .br-tap.hit { background: #3a2d40; border-color: #9b6b94; }
.br-ctl .btn:active { background: #241e28; }
dialog.br-count :focus-visible { outline: 3px solid #e3b6dc; outline-offset: 3px; }
dialog.br-count .br-tap:focus-visible { outline-color: #9b6b94; outline-offset: -8px; } /* 大按鈕的框暗一點，鍵盤一樣看得到 */
@media (max-height: 560px) {
  .br-left { font-size: 3rem; }
  .br-top { padding-bottom: 4px; }
}

@media (hover: hover) {
  .br-tap:hover { background: #2c2431; }
  .br-ctl .btn:hover { background: #211b24; }
  .br-band a:hover { text-decoration-thickness: 2px; }
}

/* ---------- 深色：跟著手機設定 ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18151a; --surface: #221e25; --surface-2: #1d1a20; --ink: #ece5ee; --muted: #b3a8b5; --line: #3a333e;
    --primary-soft: #3a2530; --teal-soft: #30233a; --sos-soft: #3a1f1b; --warn-bg: #352a17; --warn-ink: #f0cf96;
    --ok-soft: #17302a; --forest-soft: #17302a; --lav-soft: #29283a; --focus: #e3b6dc;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
  body { background: #0f0d10; }
  .brand-logo { filter: invert(1) hue-rotate(180deg) brightness(1.15); }
  .back { color: #e7a8b6; }
  body.on-doc .card a:not(.btn), .page-head a:not(.back) { color: #e3b6dc; }
  .choice { background: var(--surface); border-color: #4a4150; }
  .choice:has(input:checked) { border-color: #e7a8b6; background: var(--primary-soft); }
  .btn.outline { border-color: #4a4150; }
  .card.danger { border-color: #6a3027; color: #f6d0c8; }
  .error { color: #ff9c8a; }
  textarea { background: var(--surface); border-color: #4a4150; color: var(--ink); }
  .br-band[data-band="ok"], .br-tag { color: #a7dcc8; border-color: #2c5146; }
  .br-band[data-band="high"] { border-color: #6a5326; }
  .br-band[data-band="higher"], .br-tag[data-band="higher"] { color: #f6d0c8; border-color: #6a3027; }
  .foot { border-color: var(--line); }
}
