:root {
  --brand: #0284C7; --brand-soft: #E0F2FE; --sky: #38BDF8; --teal: #2DD4BF; --amber: #FBBF24;
  --ink: #0F172A; --text: #334155; --muted: #64748B; --line: #E2E8F0; --bg: #F8FAFC; --card: #FFFFFF;
  --ok: #059669; --ok-soft: #ECFDF5; --danger: #DC2626; --night: #0B1220; --night-2: #1E293B;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", Meiryo, sans-serif;
  color: var(--text); background: var(--bg); line-height: 1.6; font-size: 16px;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- ふつうの画面 ---------- */
.screen { max-width: 520px; margin: 0 auto; padding: 22px 18px 44px; display: flex; flex-direction: column; gap: 14px; }
.top { padding: 8px 2px 4px; }
.top.small { padding-top: 2px; }
.brand { font-size: 12px; letter-spacing: .12em; color: var(--brand); font-weight: 700; }
.top h1 { font-size: 26px; line-height: 1.3; color: var(--ink); margin-top: 4px; }
.top.small h1 { font-size: 22px; }
.badge { display: inline-block; vertical-align: middle; font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 2px 10px; margin-left: 4px; }
.lead { margin-top: 8px; color: var(--muted); font-size: 15px; }
.back { border: 0; background: none; color: var(--brand); padding: 6px 0; font-size: 15px; }
.status { margin-top: 8px; font-size: 14px; font-weight: 600; }
.status.ok { color: var(--ok); } .status.warn { color: #B45309; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { font-size: 16px; color: var(--ink); }
.card h2 small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.card p { font-size: 14.5px; }
.card.ok { border-color: #A7F3D0; background: var(--ok-soft); }
.card.ok h2 { color: #065F46; }
.card.soft { background: #F1F5F9; border-color: transparent; }
.tick { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--ok); color: #fff; align-items: center; justify-content: center; font-size: 13px; margin-right: 4px; }
.set-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid rgba(15, 23, 42, .07); font-size: 14.5px; }
.set-list li:first-child { border-top: 0; }
.set-list b { font-weight: 500; color: var(--muted); flex: none; }
.set-list span { color: var(--ink); font-weight: 600; text-align: right; }
.dots li { position: relative; padding-left: 16px; font-size: 14.5px; }
.dots li::before { content: ""; position: absolute; left: 3px; top: .68em; width: 6px; height: 6px; border-radius: 50%; background: var(--sky); }
.keys li { display: flex; gap: 10px; padding: 5px 0; font-size: 14.5px; }
.keys b { flex: none; width: 76px; color: var(--ink); }
.mini { font-size: 13px; color: var(--muted); } .center { text-align: center; }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.btn { width: 100%; min-height: 54px; border-radius: 14px; border: 1px solid transparent; font-size: 17px; font-weight: 700; padding: 10px 14px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: #0369A1; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); font-size: 15.5px; min-height: 48px; }
.btn.danger { color: var(--danger); }
.link { border: 0; background: none; color: var(--brand); font-size: 14.5px; text-decoration: underline; padding: 8px; }
.foot { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.tabs { display: flex; background: #E2E8F0; border-radius: 12px; padding: 4px; }
.tab { flex: 1; border: 0; background: none; border-radius: 9px; min-height: 40px; font-weight: 700; color: var(--muted); }
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.steps { counter-reset: n; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: n; position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 12px 52px; }
.steps li::before { content: counter(n); position: absolute; left: 14px; top: 13px; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.steps b { display: block; color: var(--ink); font-size: 15.5px; }
.steps span { font-size: 14px; }

.ex .opts { display: flex; gap: 10px; }
.ex label { flex: 1; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.ex select { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 10px; font-size: 16px; color: var(--ink); }

.q p { font-size: 14.5px; color: var(--ink); font-weight: 600; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 999px; min-height: 40px; padding: 4px 14px; font-size: 14.5px; }
.chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 16px; resize: vertical; }

/* ---------- リモコンの受け口（ボタンの確認・運動）。画面全体で信号を受けるので、動かさない ---------- */
html.padmode, html.padmode body { overflow: hidden; overscroll-behavior: none; }
.pad {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; max-width: none; margin: 0; padding: 0; gap: 0;
  background: var(--night); color: #E2E8F0; touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.pad * { touch-action: none; }
.pad-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; font-size: 14px; color: #94A3B8; font-weight: 600; min-height: 52px; }
.quit { border: 1px solid #334155; background: none; color: #CBD5E1; border-radius: 999px; padding: 6px 14px; font-size: 13.5px; }
.pad-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 4px 20px 10px; text-align: center; overflow: hidden; }
.fingerbar { display: flex; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: #0F172A; border-top: 1px solid #1E293B; }
.fbtn { flex: 1; min-height: 52px; border-radius: 12px; border: 1px solid #334155; background: var(--night-2); color: #E2E8F0; font-size: 14.5px; font-weight: 700; padding: 4px 6px; }
.fbtn.main { background: #334155; }
.fbtn:active { background: #475569; }
.caption { font-size: 13.5px; line-height: 1.55; color: #94A3B8; max-width: 440px; min-height: 4.6em; max-height: 6.2em; overflow: hidden; margin-top: 6px; }

.remote { width: 150px; height: auto; flex: none; }
.r-body { fill: var(--night-2); stroke: #334155; stroke-width: 2; }
.r-led { fill: #F87171; }
.r-key { fill: #94A3B8; transition: fill .15s; }
.r-key.on { fill: var(--sky); animation: pulse 1.1s ease-in-out infinite; }
.r-mark { fill: #0F172A; pointer-events: none; }
.r-key2 { fill: #334155; }
.r-num { fill: #CBD5E1; font-size: 16px; font-weight: 700; text-anchor: middle; }
@keyframes pulse { 50% { fill: #BAE6FD; } }
.pad-ask { font-size: 21px; font-weight: 800; color: #fff; margin-top: 6px; }
.pad-tip { font-size: 13px; color: #94A3B8; }
.pad-got { font-size: 13.5px; color: var(--sky); min-height: 1.6em; }
.checks { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.checks li { display: flex; align-items: center; gap: 8px; background: #111B2E; border: 1px solid #1E293B; border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.checks li.now { border-color: var(--sky); }
.checks b { flex: none; width: 74px; color: #fff; }
.checks .c-name { flex: 1; color: #CBD5E1; }
.checks i { font-style: normal; font-size: 12px; color: #94A3B8; text-align: right; }
.c-mark { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #475569; }
.checks li.done .c-mark { border-color: #34D399; background: #34D399; position: relative; }
.checks li.done .c-mark::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #052E1B; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.help { width: 100%; max-width: 380px; text-align: left; background: #1E293B; border-radius: 12px; padding: 10px 12px; font-size: 13px; color: #CBD5E1; }
.help b { color: var(--amber); font-size: 13.5px; }
.help .dots li { font-size: 13px; }

/* 運動の画面 */
.r-note { font-size: 16px; color: #94A3B8; font-weight: 600; min-height: 1.6em; }
.r-title { font-size: 40px; line-height: 1.2; font-weight: 800; color: #fff; }
.r-big { font-size: 104px; line-height: 1; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; min-height: 104px; }
.r-bar { width: 100%; max-width: 320px; height: 8px; border-radius: 999px; background: #1E293B; overflow: hidden; }
.r-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--sky); transition: width .1s linear; }
.r-dots { display: flex; gap: 8px; margin-top: 10px; min-height: 14px; }
.r-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #475569; }
.r-dots i.on { background: #34D399; border-color: #34D399; }
.r-hint { font-size: 16px; font-weight: 700; color: #BAE6FD; margin-top: 10px; min-height: 1.6em; }
body[data-mode="inhale"] .r-title, body[data-mode="inhale"] .r-big { color: var(--sky); }
body[data-mode="exhale"] .r-title, body[data-mode="exhale"] .r-big { color: var(--teal); }
body[data-mode="exhale"] .r-bar i { background: var(--teal); }
body[data-mode="paused"] .r-title { color: var(--amber); }
body[data-mode="paused"] .r-hint { color: var(--amber); }
body[data-mode="prep"] .r-big, body[data-mode="talk"] .r-big, body[data-mode="rep"] .r-big, body[data-mode="ask"] .r-big,
body[data-mode="intro"] .r-big, body[data-mode="ready"] .r-big, body[data-mode="set"] .r-big, body[data-mode="paused"] .r-big, body[data-mode="closing"] .r-big { min-height: 0; }
body[data-mode="ask"] .r-title, body[data-mode="closing"] .r-title { font-size: 28px; }
.flash { position: fixed; left: 50%; top: 64px; transform: translate(-50%, -8px); background: rgba(56, 189, 248, .96); color: #082F49; font-weight: 800; font-size: 16px; border-radius: 999px; padding: 8px 18px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 5; white-space: nowrap; }
.flash.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 重ねて出すもの ---------- */
.sheet, .overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(15, 23, 42, .55); z-index: 20; display: flex; }
.sheet { align-items: flex-end; justify-content: center; }
.sheet-in { width: 100%; max-width: 520px; max-height: 90%; overflow: auto; background: #fff; border-radius: 18px 18px 0 0; padding: 16px 18px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 18px; color: var(--ink); }
.sheet .quit { border-color: var(--line); color: var(--text); }
.sheet h3 { font-size: 14px; color: var(--muted); margin-top: 6px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--ink); }
.row input { width: 24px; height: 24px; }
.log { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.log li { font-size: 12.5px; display: flex; flex-direction: column; }
.log b { color: var(--ink); font-size: 13.5px; }
.log span { color: var(--muted); }
.overlay { align-items: center; justify-content: center; padding: 24px; }
.box { width: 100%; max-width: 340px; background: #fff; border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; text-align: center; color: var(--ink); font-weight: 600; }
.box .r-bar { background: var(--line); max-width: none; }
.two { display: flex; gap: 10px; }
.two .btn { min-height: 48px; font-size: 15.5px; }

@media (max-height: 640px) {
  .remote { width: 112px; } .r-title { font-size: 32px; } .r-big { font-size: 80px; min-height: 80px; } .caption { min-height: 3.1em; max-height: 4.7em; }
}
@media (prefers-reduced-motion: reduce) { .r-key.on { animation: none; } .flash, .r-bar i { transition: none; } }
