/* ルーティンノート — ルーズリーフを操作体系にしたモバイルUI */
:root {
  --bg: #282b27;
  --card: #f8f4e9;
  --card2: #e9e3d3;
  --card3: #ddd5c3;
  --sep: rgba(57, 73, 91, .28);
  --text: #23262c;
  --muted: rgba(49, 52, 53, .66);
  --muted2: rgba(49, 52, 53, .38);
  --accent: #a75c24;
  --accent-tint: rgba(189, 113, 64, .15);
  --blue: #39495b;
  --ok: #4e7a52;
  --ok-tint: rgba(78, 122, 82, .16);
  --danger: #b5483f;
  --warn: #a16b19;
  --radius: 6px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --hairline: 0.5px;
  /* テーマ着せ替え用(ルーティンごとに body[data-theme] で上書き) */
  --nav-bg: #eee8d8;
  --sheet-bg: #f8f4e9;
  --on-accent: #ffffff;
  --on-ok: #ffffff;
  --seg-selected: #f8f4e9;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-head: var(--font-ui);        /* 見出しフォント(和テーマ等で明朝に) */
  --app-bg-layer: none;               /* 背景テクスチャ(和紙/グリッド等) */
  /* ルーズリーフ・デザインシステム。まずホームで採用し、編集/分析へ段階的に展開する */
  --sheet-paper: #eee8d8;
  --sheet-paper-raised: #f8f4e9;
  --sheet-ink: #23262c;
  --sheet-muted: #6e6e68;
  --sheet-rule: rgba(73, 99, 124, .11);
  --sheet-margin: rgba(184, 86, 67, .22);
  --sheet-tab-blue: #39495b;
  --sheet-tab-rust: #bd7140;
  --sheet-accent: #e99435;
  --sheet-accent-edge: #9a5b1f;
  --run-shu: #b64234;
  --run-shu-edge: #742a22;
  --sheet-shadow: #c5bda9;
  --paper-rail: #282b27;
  --paper-hole: #aaa598;
  --paper-line: rgba(73, 99, 124, .11);
  --paper-margin: rgba(184, 86, 67, .22);
  --paper-shadow: #c5bda9;
  --paper-header: #eee8d8;
  /* 危険度スケール(緑→赤)。ブランド色とは独立=テーマでアクセントを変えても意味が濁らない */
  --risk-1: #30d158; --risk-1-bg: rgba(48, 209, 88, .16);
  --risk-2: #b6d94a; --risk-2-bg: rgba(168, 216, 74, .16);
  --risk-3: #ffd60a; --risk-3-bg: rgba(255, 214, 10, .14);
  --risk-4: #ff9f0a; --risk-4-bg: rgba(255, 159, 10, .16);
  --risk-5: #ff453a; --risk-5-bg: rgba(255, 69, 58, .18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-ui);
  font-size: 17px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; }
/* テーマの背景テクスチャ(bodyの最背面に固定) */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: var(--app-bg-layer); background-size: var(--app-bg-size, auto);
  background-repeat: var(--app-bg-repeat, repeat); background-position: center; background-attachment: fixed; }
#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(100px + var(--safe-bottom)); }

/* ナビゲーションバー: すりガラス+ヘアライン。戻るがある画面はタイトル中央寄せ */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  margin: 0 -16px 18px; padding: calc(10px + var(--safe-top)) 12px 10px;
  background: var(--nav-bg); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: var(--hairline) solid var(--sep); }
.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.topbar:has(.back-btn) { display: grid; grid-template-columns: minmax(52px, auto) 1fr minmax(52px, auto); }
.topbar:has(.back-btn) h1 { font-size: 17px; font-weight: 600; text-align: center; padding: 0; }
.topbar .sub { color: var(--muted); font-size: 13px; text-align: right; }
.routine-head-actions { min-width: 52px; display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.head-settings-btn { width: 45px; height: 44px; padding: 4px 3px 3px; border-radius: 6px;
  display: inline-flex; flex: 0 0 auto; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--card2); border: var(--hairline) solid var(--sep); color: var(--accent); }
.head-settings-icon { width: 18px; height: 18px; fill: var(--card); stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }
.head-settings-label { display: block; font-size: 9px; line-height: 1; font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
.head-settings-btn.current { background: var(--accent); color: var(--on-accent); }
.head-settings-btn:active { background: var(--card3); transform: scale(.97); }
.back-btn { background: none; border: none; color: var(--accent); font-size: 17px;
  padding: 6px 8px; text-align: left; display: flex; align-items: center; gap: 2px; }
.back-btn::before { content: "‹"; font-size: 28px; line-height: 1; font-weight: 500;
  margin-top: -3px; }
.nav-action { background: none; border: none; color: var(--accent); font-size: 17px; padding: 6px 8px; }

button { font-family: inherit; cursor: pointer; border: none; color: var(--text); }
button:active { opacity: .75; }

/* グループ化されたカード(inset grouped list) */
.card { background: var(--card); border: none; border-radius: var(--radius);
  padding: 4px 16px; margin-bottom: 22px; }
.card h2 { font-size: 13px; margin: 0 0 2px; padding: 14px 0 6px; color: var(--muted);
  font-weight: 400; letter-spacing: .02em; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 12px; line-height: 1.5; }
#app > .hint { padding: 0 4px; }

/* ボタン */
.btn { display: block; width: 100%; min-height: 50px; border-radius: 12px;
  font-size: 17px; font-weight: 600; background: var(--card); color: var(--accent);
  margin-bottom: 12px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ok { background: var(--ok); color: var(--on-ok); }
.btn.ghost { background: none; color: var(--muted); font-weight: 400; }
.btn.danger-ghost { background: none; color: var(--danger); width: auto; }
.btn.small { min-height: 34px; font-size: 15px; width: auto; padding: 0 14px;
  display: inline-block; margin: 0; border-radius: 17px; background: var(--card2); color: var(--accent); }
.btn.small.primary { background: var(--accent); color: var(--on-accent); }
.btn.small.ghost { background: none; }
.btn:disabled { opacity: .35; }

/* クリーンボタン(最頻操作を最大に) */
.clean-btn { width: 100%; min-height: 88px; border-radius: 16px; font-size: 24px; font-weight: 700;
  background: var(--ok); color: var(--on-ok); margin-bottom: 22px; letter-spacing: .06em; }
.clean-btn .sub { display: block; font-size: 13px; font-weight: 500; opacity: .7; margin-top: 2px; letter-spacing: 0; }
.clean-btn:active { opacity: 1; filter: brightness(.8); }

.routine-card { position: relative; margin: 0 -16px; }
.routine-card:last-child .routine-row { border-bottom: none; }
.routine-row { position: relative; z-index: 1; background: var(--card);
  padding: 12px 56px 14px 16px; border-bottom: var(--hairline) solid var(--sep); }
.routine-row .name { padding-right: 2px; font-weight: 600; font-size: 17px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.routine-row .meta { color: var(--muted); font-size: 13px; display: block; font-weight: 400; margin-top: 1px; }
.routine-row .actions { display: flex; flex-wrap: wrap; gap: 8px; width: calc(100% + 42px); margin-top: 10px; }
.routine-row .actions .btn.small { flex: 1 1 44%; min-height: 48px; border-radius: 19px; }
.routine-row .actions .routine-video-action { display: flex; align-items: center; justify-content: center; gap: 6px; }
.routine-row .actions .routine-video-action small { min-width: 24px; padding-left: 6px; border-left: 1px solid var(--sep);
  color: var(--muted); font-size: 9px; font-weight: 760; }
.routine-quick-note { margin: 12px 2px 0 5px; padding: 9px 2px 1px; border-top: 1px dashed var(--sep);
  width: calc(100% + 42px); box-sizing: border-box; color: var(--text); cursor: pointer; }
.routine-quick-note-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px;
  font-weight: 760; letter-spacing: .06em; }
.routine-quick-note p { overflow: hidden; display: -webkit-box; margin: 0; color: inherit; font-size: 13px;
  line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.routine-quick-note.empty p { color: var(--muted2); }
.routine-quick-note.empty { display: flex; height: 56px; padding: 5px 2px 4px;
  flex-direction: column; justify-content: center; overflow: hidden; }
.routine-quick-note:active { opacity: .62; }
.routine-quick-note:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.routine-memo-full { margin: 14px 0; padding: 13px 14px; border-left: 4px solid var(--blue);
  background: var(--card2); color: var(--text); font-size: 15px; line-height: 1.75;
  white-space: pre-wrap; overflow-wrap: anywhere; }
[data-line-color="blue"] { --line-color: #48667d; }
[data-line-color="rust"] { --line-color: #ad5b23; }
[data-line-color="olive"] { --line-color: #6e7834; }
[data-line-color="mustard"] { --line-color: #b58422; }
[data-line-color="plum"] { --line-color: #76516f; }
[data-line-color="gray"] { --line-color: #77756d; }
[data-line-color="teal"] { --line-color: #2f7473; }
[data-line-color="rose"] { --line-color: #a64f5b; }
[data-line-color="violet"] { --line-color: #5e5687; }
.item-line-color-open { position: absolute; z-index: 3; top: -1px; bottom: -1px; left: -1px; width: 44px;
  padding: 0; border: 0; border-radius: 5px 0 0 5px; background: transparent; box-shadow: none;
  touch-action: manipulation; }
.item-line-color-open::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 7px;
  border-radius: 5px 0 0 5px; background: var(--line-color, var(--blue)); }
.item-line-color-open::after { content: ""; position: absolute; top: 14px; left: 0; width: 21px; height: 32px;
  border-radius: 0 8px 8px 0;
  background: radial-gradient(circle at 12px 50%, rgba(255,255,255,.9) 0 2px, transparent 2.5px),
    var(--line-color, var(--blue));
  box-shadow: 1px 1px 0 color-mix(in srgb, var(--line-color) 58%, var(--paper-shadow)); }
.item-line-color-open:active { opacity: 1; transform: none; background: color-mix(in srgb, var(--line-color) 12%, transparent); }
.item-line-color-open:focus-visible { outline: 3px solid var(--line-color, var(--blue)); outline-offset: 2px; }
.line-color-help { margin: 11px 0 8px; color: var(--muted); font-size: 12px; }
.line-color-palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 16px; }
.line-color-choice { position: relative; display: grid; grid-template-columns: 10px minmax(0, 1fr) 16px;
  align-items: center; gap: 8px; min-height: 54px; padding: 7px 9px; border: 1px solid var(--sep);
  border-radius: 4px; background: var(--card); color: var(--text); text-align: left;
  box-shadow: 0 2px 0 var(--paper-shadow); }
.line-color-choice.selected { border: 2px solid var(--line-color); padding: 6px 8px;
  background: color-mix(in srgb, var(--line-color) 9%, var(--card)); }
.line-color-choice-swatch { display: block; width: 7px; height: 34px; border-radius: 2px;
  background: var(--line-color, var(--blue)); }
.line-color-choice small { overflow: hidden; font-size: 11px; font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }
.line-color-choice b { color: var(--line-color, var(--blue)); font-size: 16px; text-align: center; }
.routine-delete-open { position: absolute; z-index: 2; top: 10px; right: 11px; width: 38px; height: 38px;
  padding: 0; border: 1px solid color-mix(in srgb, var(--danger) 58%, var(--sep)); border-radius: 8px;
  background: var(--card); color: var(--danger); font-size: 18px; font-weight: 750; line-height: 1;
  box-shadow: 0 2px 0 var(--paper-shadow); }
.routine-delete-open:active { opacity: 1; transform: translateY(2px); box-shadow: none; }
.routine-delete-open:focus-visible { outline: 3px solid var(--danger); outline-offset: 2px; }

.part-loop-track { position: relative; height: 48px; margin: 12px 14px 2px;
  background: var(--card2); border-radius: 13px; touch-action: none; cursor: pointer; }
.part-loop-track.disabled { opacity: .4; pointer-events: none; }
.part-loop-range { position: absolute; left: 0; top: 15px; height: 18px; border-radius: 9px;
  background: var(--ok-tint); border: 1px solid var(--ok); }
.part-loop-playhead { position: absolute; top: 10px; bottom: 10px; width: 2px; margin-left: -1px;
  background: var(--accent); border-radius: 2px; pointer-events: none; z-index: 2; }
.part-loop-handle { position: absolute; top: 4px; width: 40px; height: 40px; margin-left: -20px;
  border-radius: 12px; background: var(--text); color: var(--bg); border: 3px solid var(--card);
  box-shadow: 0 3px 12px rgba(0,0,0,.45); z-index: 3; touch-action: none; padding: 0; }
.part-loop-handle span { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  font-size: 13px; font-weight: 800; }
.part-loop-handle.a { color: var(--bg); }
.part-loop-handle.b { background: var(--accent); color: var(--on-accent); }
.part-loop-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.part-loop-scale { display: flex; justify-content: space-between; align-items: center; margin: 5px 0 8px;
  color: var(--muted2); font-size: 10px; font-variant-numeric: tabular-nums; }
.part-loop-scale span:nth-child(2) { color: var(--muted); }
.part-play-modes { margin: 10px 0 2px; }
.part-loop-section { display: block; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--sep); }
.part-loop-section h2 { margin-top: 0; }
.part-point { display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: var(--hairline) solid var(--sep); }
.part-point:last-of-type { border-bottom: none; }
.part-point .pp-label { font-size: 13px; color: var(--muted); width: 48px; flex-shrink: 0; }
.part-point .pp-time { flex: 1; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.part-point .mini-btn { width: 44px; font-size: 12px; }
.part-point .btn.small { white-space: nowrap; font-size: 13px; padding: 0 10px; flex-shrink: 0; }
.part-loop-delay-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 0;
  border-top: 1px dashed var(--sep); border-bottom: 1px dashed var(--sep); }
.part-loop-delay-copy { flex: 1; min-width: 0; }
.part-loop-delay-copy strong { display: block; font-size: 13px; }
.part-loop-delay-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.part-loop-delay-stepper { display: grid; grid-template-columns: 38px 58px 38px; align-items: center; gap: 5px; flex-shrink: 0; }
.part-loop-delay-stepper button { width: 38px; height: 38px; padding: 0; border: 1px solid var(--sep);
  border-radius: 4px; background: var(--card); color: var(--text); font-size: 20px; font-weight: 800;
  box-shadow: 0 3px 0 var(--paper-shadow); }
.part-loop-delay-stepper button:active { opacity: 1; transform: translateY(2px); box-shadow: 0 1px 0 var(--paper-shadow); }
.part-loop-delay-stepper button:disabled { opacity: .32; transform: none; box-shadow: none; }
.part-loop-delay-stepper output { display: flex; min-height: 38px; align-items: center; justify-content: center;
  border: 1px solid var(--sep); border-radius: 4px; background: var(--card2); color: var(--text);
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }

.step-list { display: flex; flex-direction: column; margin: 0 -16px 6px; }
.step-btn { display: flex; align-items: center; gap: 12px; min-height: 50px; text-align: left;
  background: none; border: none; border-bottom: var(--hairline) solid var(--sep);
  padding: 8px 16px; color: var(--text); font-size: 17px; font-weight: 400; }
.step-list .step-btn:last-child { border-bottom: none; }
.step-btn:active { background: var(--card3); opacity: 1; }
.step-btn .no { color: var(--muted2); font-size: 15px; width: 22px; flex-shrink: 0;
  font-variant-numeric: tabular-nums; }
.step-btn .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-btn.transition { min-height: 40px; font-size: 14px; color: var(--muted); }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 12px; font-weight: 600; flex-shrink: 0; }
.badge.hit { background: var(--danger); color: #fff; }
/* リスク度の色(1=安全〜5=危険) 共通 */
.badge.risk-1 { color: var(--risk-1); background: var(--risk-1-bg); }
.badge.risk-2 { color: var(--risk-2); background: var(--risk-2-bg); }
.badge.risk-3 { color: var(--risk-3); background: var(--risk-3-bg); }
.badge.risk-4 { color: var(--risk-4); background: var(--risk-4-bg); }
.badge.risk-5 { color: var(--risk-5); background: var(--risk-5-bg); }

/* 記録画面ステータス行 */
.runbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

/* 編集/通し/パート: 技が変わっても寸法が動かない常設の現在技ドック */
.practice-now { position: sticky; top: calc(var(--safe-top) + 52px); z-index: 16;
  --practice-preview-size: 190px;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--practice-preview-size); gap: 10px;
  align-items: stretch; box-sizing: border-box;
  height: calc(var(--practice-preview-size) + 22px); min-height: calc(var(--practice-preview-size) + 22px);
  padding: 10px; margin: -4px 0 14px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--sep); border-left: 4px solid var(--accent);
  box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.practice-now-copy { min-width: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: 2px 4px; }
.practice-now-copy strong { margin-top: 0; font-size: 17px; line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.practice-now-meta { display: block; margin-top: 5px; color: var(--muted); font-size: 10.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.practice-now.has-editor-player .practice-now-copy { overflow: visible; justify-content: flex-start; padding: 4px 5px 2px; }
.practice-now-player { position: relative; display: grid; gap: 6px; min-width: 0; margin-top: auto; padding-top: 8px;
  border-top: 1px dashed var(--sep); }
.practice-now-player-label { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.practice-now-player-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch; gap: 5px; }
.practice-now-player-controls > .music-pill,
.practice-now-player-controls > .music-btn.text { display: inline-flex; width: 100%; height: 36px; min-height: 36px;
  align-items: center; justify-content: center; margin: 0; padding: 0 5px; border: 1px solid var(--sep);
  border-radius: 4px; box-sizing: border-box; box-shadow: 0 3px 0 var(--paper-shadow); font-size: 11px;
  line-height: 1; white-space: nowrap; }
.practice-now-player-controls > .music-pill { border-color: transparent; }
.practice-now-player-controls > .music-btn.text { background: var(--card); color: var(--accent); }
.practice-now-player-meta { display: grid; grid-template-columns: minmax(0, 1fr) 46px; align-items: center; gap: 5px; }
.practice-now-player-meta > .music-volume-control { position: static; width: 46px; }
.practice-now-player-meta > .music-volume-control > summary { width: 100%; height: 36px; }
.practice-now-player-meta > .music-time { min-width: 0; justify-content: flex-start; font-size: 17px; white-space: nowrap; }
.practice-now-player-meta > .music-time .dur { font-size: 11px; }
.practice-now-player .music-volume-popover { z-index: 30; top: calc(100% + 8px); right: 0; left: 0;
  grid-template-columns: 16px minmax(0, 1fr) 16px; width: auto; box-sizing: border-box; }
.practice-now-player.is-disabled .music-pill,
.practice-now-player.is-disabled .music-btn { opacity: .42; box-shadow: none; }
.practice-now-player button:disabled { cursor: default; }
.practice-now-media { width: var(--practice-preview-size); min-width: var(--practice-preview-size); max-width: var(--practice-preview-size);
  height: var(--practice-preview-size); min-height: var(--practice-preview-size); max-height: var(--practice-preview-size);
  aspect-ratio: 1 / 1; justify-self: end; border-radius: 10px;
  overflow: hidden; background: #000; display: flex; align-items: center; justify-content: center; }
.practice-now-media video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.practice-video-loading,
.practice-video-empty { color: rgba(255,255,255,.65); font-size: 11px; text-align: center; }
.practice-now.name-only {
  display: block; height: auto; min-height: 76px; padding: 8px 11px;
}
.practice-now.name-only .practice-now-copy { min-height: 58px; overflow: visible; justify-content: center; padding: 0; }
.practice-now.name-only .practice-now-copy strong {
  padding-right: 4px; font-size: 20px; line-height: 1.25; -webkit-line-clamp: 1;
}
.practice-now.name-only .practice-now-meta { margin-top: 3px; }
@media (max-width: 350px) {
  .practice-now { --practice-preview-size: 164px; }
  .practice-now-copy strong { font-size: 15px; }
}
@media (max-width: 430px) {
  .practice-now.has-editor-player { --practice-preview-size: clamp(164px, 44vw, 190px); }
  .practice-now.has-editor-player .practice-now-player-controls { gap: 4px; }
}
.runbar .stat { background: var(--card); border-radius: 16px;
  padding: 6px 13px; font-size: 13px; color: var(--muted); }
.runbar .stat b { color: var(--text); font-size: 15px; font-weight: 600; }
.openrun-note { background: var(--accent-tint); color: var(--accent);
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; font-weight: 500; }

/* 下部固定バー(タブバー風すりガラス) */
.bottombar { position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--nav-bg); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: var(--hairline) solid var(--sep);
  padding: 10px 16px calc(10px + var(--safe-bottom)); display: flex; gap: 10px; z-index: 30; }
.bottombar button { flex: 1; min-height: 46px; border-radius: 12px; font-size: 16px; font-weight: 600;
  background: var(--card); color: var(--text); }
.bottombar button.undo { color: var(--warn); }

/* シート(iOSモーダルシート: グラバー+すりガラス) */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--sheet-bg);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .55);
  border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(20px + var(--safe-bottom)); max-width: 560px; margin: 0 auto;
  max-height: 84vh; overflow-y: auto;
  animation: sheetup .28s cubic-bezier(.32, .72, .35, 1); }
@keyframes sheetup { from { transform: translateY(40%); opacity: .6; } to { transform: none; opacity: 1; } }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--card3);
  margin: 4px auto 14px; }
#sheet h3 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
#sheet .sheet-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.hidden { display: none !important; }

/* ルーティン削除: ✕を押した後、右端まで意図的にスライドした場合だけ確定する */
.delete-routine-name { margin: 10px 0 12px; padding: 11px 12px; border-left: 6px solid var(--blue);
  background: var(--card); color: var(--text); font-size: 17px; font-weight: 780; overflow-wrap: anywhere; }
.delete-routine-warning { margin-bottom: 18px; padding: 12px 13px; border: 1px solid color-mix(in srgb, var(--danger) 52%, var(--sep));
  border-radius: 5px; background: color-mix(in srgb, var(--danger) 7%, var(--card)); }
.delete-routine-warning strong { display: block; color: var(--danger); font-size: 15px; }
.delete-routine-warning span { display: block; margin-top: 5px; color: var(--text); font-size: 13px; font-weight: 740; }
.delete-routine-warning p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.delete-media-summary {
  display: flex; margin: 10px 0 12px; padding: 11px 12px; align-items: center; gap: 10px;
  border-left: 6px solid #2f3d4e; background: var(--card); color: var(--text);
}
.delete-media-summary > span { color: #2f3d4e; font-size: 18px; }
.delete-media-summary > b { font-size: 16px; font-variant-numeric: tabular-nums; }
.delete-slide-wrap { margin: 0 0 16px; }
.delete-slide-track { position: relative; height: 62px; overflow: hidden; touch-action: none;
  border: 2px solid var(--sep); border-radius: 7px; background: var(--card2); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.delete-slide-fill { position: absolute; inset: 0 auto 0 0; width: 57px; pointer-events: none;
  background: color-mix(in srgb, var(--danger) 16%, var(--card)); }
.delete-slide-copy { position: absolute; inset: 0 12px 0 66px; display: flex; align-items: center; justify-content: center;
  pointer-events: none; color: var(--muted); font-size: 13px; font-weight: 780; text-align: center; }
.delete-slide-handle { position: absolute; z-index: 2; top: 5px; left: 5px; width: 48px; height: 48px; padding: 0;
  touch-action: none; cursor: grab; border: 2px solid var(--danger); border-radius: 5px; background: var(--card);
  color: var(--danger); font-size: 21px; font-weight: 850; line-height: 1; box-shadow: 0 3px 0 color-mix(in srgb, var(--danger) 32%, var(--paper-shadow)); }
.delete-slide-handle.dragging { cursor: grabbing; box-shadow: 0 1px 0 color-mix(in srgb, var(--danger) 32%, var(--paper-shadow)); }
.delete-slide-track.armed { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--card)); }
.delete-slide-track.armed .delete-slide-fill, .delete-slide-track.armed .delete-slide-handle { background: var(--danger); color: #fff; }
.delete-slide-track.armed .delete-slide-copy { color: var(--danger); }
.delete-slide-track.resetting .delete-slide-handle { transition: transform .2s ease; }
.delete-slide-track.resetting .delete-slide-fill { transition: width .2s ease; }
.delete-slide-track:focus-visible { outline: 3px solid var(--danger); outline-offset: 3px; }
.delete-slide-help { margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.choice { min-height: 58px; border-radius: 12px; background: var(--card2); color: var(--text);
  border: none; font-size: 15px; font-weight: 600; padding: 8px; }
.choice .d { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.choice.selected { background: var(--accent-tint); color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent); }
.choice.selected .d { color: var(--accent); opacity: .8; }
.choice.abort.selected { background: rgba(255, 69, 58, .16); color: var(--danger);
  box-shadow: inset 0 0 0 1.5px var(--danger); }
.choice.abort.selected .d { color: var(--danger); opacity: .8; }

/* セグメンテッドコントロール(体調選択) */
.segmented { display: flex; background: var(--card2); border-radius: 9px; padding: 2px;
  margin-bottom: 6px; }
.segmented .choice { flex: 1; min-height: 36px; border-radius: 7px; background: none;
  font-size: 15px; font-weight: 500; box-shadow: none; }
.segmented .choice.selected { background: var(--seg-selected); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* 設定のON/OFFトグル行(iOS風スイッチ) */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; }
.set-row + .set-row { border-top: var(--hairline) solid var(--sep); }
.set-row .set-text { min-width: 0; }
.set-row .set-label { font-size: 16px; font-weight: 500; }
.set-row .set-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: var(--card3); border-radius: 999px; transition: background .22s ease; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .22s ease; }
.switch input:checked ~ .track { background: var(--ok); }
.switch input:checked ~ .knob { transform: translateX(20px); }

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.tag { padding: 7px 14px; border-radius: 16px; background: var(--card2); color: var(--muted);
  border: none; font-size: 14px; }
.tag.selected { color: var(--accent); background: var(--accent-tint);
  box-shadow: inset 0 0 0 1px var(--accent); }
.tag-label { font-size: 13px; color: var(--muted); margin: 12px 0 8px; }

input[type=text], textarea, select { width: 100%; background: var(--card2); border: none;
  color: var(--text); border-radius: 10px; padding: 12px; font-size: 17px; font-family: inherit;
  -webkit-appearance: none; appearance: none; }
input::placeholder, textarea::placeholder { color: var(--muted2); }
textarea { resize: none; }
label.fld { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 8px; }
/* カード末尾の入力欄は下にも余白を(上のラベル余白と対称に。下端張り付き防止) */
.card > input[type=text]:last-child,
.card > textarea:last-child,
.card > select:last-child { margin-bottom: 12px; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
  linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }

/* エディタ(左の縦長ハンドル / 1段目=シーケンス名 / 2段目=時間と操作) */
.editor-step { position: relative; padding: 10px 0 12px 44px;
  border-bottom: var(--hairline) solid var(--sep); }
.editor-step:last-of-type { border-bottom: none; }
.editor-step .es-row1 { display: flex; align-items: stretch; gap: 7px; }
.editor-step .es-lead { display: flex; flex-direction: column; align-items: center; gap: 1px;
  position: absolute; left: 0; top: 10px; bottom: 12px; width: 34px; max-height: 124px; }
.editor-step .es-row1 .no { color: var(--muted2); font-size: 15px; flex-shrink: 0;
  text-align: center; font-variant-numeric: tabular-nums; }
/* ドラッグ用つまみ(番号の下)。上下に広いタッチ領域でつかみやすくする */
.drag-handle { width: 34px; flex: 1; min-height: 58px; display: flex; align-items: center;
  justify-content: center; color: var(--muted); font-size: 19px; line-height: 1; cursor: grab;
  padding: 8px 4px; border-radius: 9px; border: var(--hairline) solid var(--sep);
  background: var(--card2); touch-action: none; user-select: none; -webkit-user-select: none; }
.drag-handle:active { cursor: grabbing; color: var(--accent); background: var(--accent-tint); }
.editor-step.dragging { position: relative; z-index: 30; background: var(--card2);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.5); border-bottom-color: transparent;
  opacity: .95; }
/* ドラッグ中、他の行はスライドして空きを作る(入れ替えプレビュー) */
body.dragging-active .editor-step:not(.dragging) { transition: transform .18s ease; }
body.dragging-active { user-select: none; -webkit-user-select: none; touch-action: none; }
.editor-step .es-name-field { position: relative; flex: 1; min-width: 0; }
.editor-step .es-name-field input[type=text] { width: 100%; min-width: 0; box-sizing: border-box;
  padding: 11px 12px; font-size: 17px; border-radius: 10px; }
.editor-step .es-name-field.duration-visible input[type=text] {
  padding-right: calc(var(--es-duration-width, 0px) + 22px);
}
.editor-step .es-kind-toggle { flex: 0 0 34px; width: 34px; min-width: 34px; height: 34px; min-height: 34px;
  align-self: center; padding: 0; font-size: 10px; line-height: 1; }
.editor-step .es-delete-top { flex: 0 0 34px; width: 34px; height: 34px;
  align-self: center; padding: 0; }
.editor-step .es-time-stack { flex: 0 0 auto; display: grid; justify-items: start; gap: 2px; min-width: 62px; }
.editor-step .cue-input { width: 62px; text-align: center; padding: 9px 2px;
  font-size: 14px; font-variant-numeric: tabular-nums; color: var(--accent);
  touch-action: pan-y; /* 横スライドで秒数微調整(縦スクロールは通す) */ }
.editor-step .es-duration { position: absolute; z-index: 1; top: 50%; right: 12px;
  color: var(--muted); font-size: 9px; line-height: 1.15; opacity: 0; visibility: hidden;
  font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap;
  pointer-events: none; transform: translateY(-50%); }
.editor-step .es-name-field.duration-visible .es-duration { opacity: 1; visibility: visible; }
.editor-step .cue-input.locked {
  color: var(--text); background: color-mix(in srgb, var(--sheet-tab-rust) 9%, var(--card2));
  box-shadow: inset 3px 0 0 var(--sheet-tab-rust); cursor: default;
}
.editor-step .cue-pin { display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted2); background: var(--card2); border: 1px solid var(--sep); }
.editor-step .cue-pin svg { width: 17px; height: 17px; fill: currentColor; transform: rotate(18deg); }
.editor-step .cue-pin.locked { color: #fff; background: var(--sheet-tab-rust); border-color: var(--sheet-tab-rust);
  box-shadow: 0 3px 0 var(--paper-shadow); }
.editor-step .cue-pin.locked svg { transform: rotate(0deg); }
.editor-step .cue-play { flex: 0 0 auto; width: 34px; height: 34px; font-size: 11px;
  color: var(--ok); background: var(--ok-tint); }
.editor-step.now { background: rgba(48, 209, 88, .1); box-shadow: inset 3px 0 0 var(--ok);
  border-radius: 8px; }
.cue-chip { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
.editor-step .es-row2 { display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: 6px; margin: 8px 0 0; }
.editor-step .es-playback-controls, .editor-step .es-step-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px; min-width: 0; }
.editor-step .es-step-meta { justify-content: flex-end; }
.editor-step .es-spacer { flex: 1; }
.risk-select { flex: 0 0 auto; width: auto; min-height: 34px; padding: 5px 5px; border-radius: 9px;
  background: var(--card2); border: 1.5px solid var(--sep); color: var(--text);
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.risk-select.unset { color: var(--muted2); border-style: dashed; }
.risk-select.risk-1 { color: var(--risk-1); border-color: rgba(48, 209, 88, .4); }
.risk-select.risk-2 { color: var(--risk-2); border-color: rgba(168, 216, 74, .4); }
.risk-select.risk-3 { color: var(--risk-3); border-color: rgba(255, 214, 10, .4); }
.risk-select.risk-4 { color: var(--risk-4); border-color: rgba(255, 159, 10, .45); }
.risk-select.risk-5 { color: var(--risk-5); border-color: rgba(255, 69, 58, .5); }
.mini-btn { width: 36px; height: 36px; border-radius: 18px; background: var(--card2); color: var(--text);
  border: none; font-size: 15px; flex-shrink: 0; }
.mini-btn.del { color: var(--danger); }
.kind-toggle { flex-shrink: 0; height: 34px; border-radius: 17px; background: var(--card2);
  color: var(--muted); border: none; font-size: 12px; font-weight: 600; padding: 0 11px; }
.kind-toggle.t { color: var(--accent); background: var(--accent-tint); }
/* コントロール行のミニボタンは少し小さめにして1行に収めやすく */
.editor-step .es-row2 .mini-btn { width: 34px; height: 34px; }
/* 技／移行は独立した最終列に置き、上段右端の削除と縦位置を揃える */
.editor-step .es-row2 > .es-kind-toggle { margin-left: 0; justify-self: end; }

@media (max-width: 520px) {
  .editor-step .es-row2 { grid-template-columns: minmax(0, 1fr) auto; row-gap: 8px; }
  .editor-step .es-row2:has(.es-step-meta) .es-playback-controls { grid-column: 1 / -1; }
  .editor-step .es-row2:has(.es-step-meta) .es-step-meta { grid-column: 1; justify-self: end; }
  .editor-step .es-row2:has(.es-step-meta) > .es-kind-toggle { grid-column: 2; }
  .part-point { gap: 5px; }
  .part-point .pp-label { width: 42px; font-size: 11px; }
  .part-point .pp-time { flex: 0 0 58px; font-size: 17px; }
  .part-point .mini-btn { width: 40px; }
  .part-point .btn.small { min-width: 0; max-width: 100px; padding-inline: 7px; font-size: 11px; }
}

/* 楽曲プレイヤー・録音 */
.music-card, .rec-card { padding: 12px 16px; }
.music-row { display: flex; align-items: center; gap: 12px; }
.music-btn { width: 46px; height: 46px; border-radius: 23px; background: var(--card2); color: var(--text);
  border: none; font-size: 17px; flex-shrink: 0; }
.music-btn.text { width: auto; padding: 0 14px; font-size: 13px; color: var(--accent); background: none; }
.music-btn.rec-on { color: var(--danger); background: rgba(255, 69, 58, .16); }
.music-time { font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 700; flex: 1;
  display: flex; align-items: baseline; gap: 4px; letter-spacing: .01em; }
.music-time .dur { font-size: 13px; color: var(--muted); font-weight: 400; }
.music-name { font-size: 13px; color: var(--muted); margin: 4px 0 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-time.big { font-size: 40px; justify-content: center; margin: 2px 0 0; letter-spacing: 0; }
.music-time.big .dur { font-size: 15px; }
.music-controls { display: flex; gap: 10px; margin-top: 12px; }
.music-pill { flex: 1; min-height: 46px; border-radius: 23px; background: var(--card2);
  color: var(--text); font-size: 15px; font-weight: 600; }
.music-pill.primary { background: var(--ok); color: var(--on-ok); }
.volume-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.volume-row .vol-ico { font-size: 13px; flex-shrink: 0; opacity: .7; }
.part-speed-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 10px; padding-top: 10px; border-top: var(--hairline) dashed var(--sep); }
.part-speed-row > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.part-speed-controls { display: grid; gap: 6px; }
.part-speed-adjust { display: grid; grid-template-columns: 44px minmax(62px, 1fr) 44px; gap: 5px; }
.part-speed-adjust output { display: flex; align-items: center; justify-content: center; min-height: 36px;
  border: 1px solid var(--accent); border-radius: 4px; background: var(--card2); color: var(--accent);
  font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
.part-speed-presets { display: flex; gap: 5px; }
.part-speed-row button { min-width: 44px; min-height: 36px; padding: 0 8px; border: 1px solid var(--sep);
  border-radius: 4px; background: var(--card); color: var(--text); font-size: 12px; font-weight: 800;
  box-shadow: 0 2px 0 var(--paper-shadow); }
.part-speed-row button:disabled { opacity: .38; box-shadow: none; }
.part-speed-presets button { min-height: 30px; padding-inline: 6px; }
.part-speed-row button.selected { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.part-speed-quality{text-align:right;color:var(--muted);font-size:10px}
#music-vol { flex: 1; accent-color: var(--accent); height: 4px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger);
  display: inline-block; margin-right: 8px; animation: recblink 1.2s infinite; align-self: center; }
@keyframes recblink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
#music-seek { width: 100%; margin-top: 10px; accent-color: var(--accent); height: 4px; }
/* 楽曲カードに統合した「選択/添付」と、添付中の曲名・削除の小さいフッター */
.music-card { padding-top: 3px; padding-bottom: 6px; }
.music-foot { display: flex; align-items: center; gap: 8px; margin-top: 5px;
  padding-top: 5px; border-top: var(--hairline) solid var(--sep); }
.music-foot .mf-name { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-foot-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.music-foot-actions .mini-btn { display: inline-flex; align-items: center; justify-content: center;
  width: auto; min-width: 38px; height: 28px; padding: 0 7px; border: 0; border-radius: 3px;
  background: transparent; box-shadow: none; font-size: 11px; line-height: 1; }
.music-foot .mini-btn.del { width: auto; min-width: 38px; height: 28px; padding: 0 7px; border: 0;
  border-left: 1px dashed var(--sep); border-radius: 0; background: transparent; box-shadow: none;
  font-size: 11px; line-height: 1; }

/* 編集プレイヤーの楽曲シーク */
.music-track-stack { margin-top: 3px; padding: 6px 8px; border: 1px solid var(--sep);
  border-radius: 4px; background: color-mix(in srgb, var(--card2) 68%, transparent); }
.music-track-line { display: grid; grid-template-columns: 36px minmax(72px, 1fr); align-items: center; gap: 7px; min-height: 24px; }
.music-track-label { color: var(--muted); font-size: 10px; font-weight: 760; letter-spacing: .04em; }
.music-track-line #music-seek { width: 100%; height: 18px; margin: 0; }

/* 音量は通常時は一つのボタン。必要なときだけスライダーをポップアップ表示する */
.music-volume-control { position: relative; flex: 0 0 auto; }
.music-volume-control > summary { display: inline-flex; width: 46px; height: 40px; padding: 2px 3px;
  align-items: center; justify-content: center; flex-direction: column; gap: 0; list-style: none;
  border: 1px solid var(--sep); border-radius: 4px; background: var(--card); color: var(--text);
  box-shadow: 0 3px 0 var(--paper-shadow); cursor: pointer; user-select: none; box-sizing: border-box; }
.music-volume-control > summary::-webkit-details-marker { display: none; }
.music-volume-control > summary span { font-size: 13px; line-height: 1; }
.music-volume-control > summary small { margin-top: 2px; color: var(--muted); font-size: 8px; line-height: 1; font-weight: 750; }
.music-volume-control[open] > summary { transform: translateY(2px); box-shadow: 0 1px 0 var(--paper-shadow); }
.music-volume-popover { position: absolute; z-index: 12; top: calc(100% + 8px); right: 0;
  display: grid; grid-template-columns: 18px minmax(140px, 210px) 18px; align-items: center; gap: 7px;
  padding: 13px 12px; border: 1px solid var(--sep); border-top: 5px solid var(--sheet-tab-rust);
  border-radius: 5px; background: var(--card); box-shadow: 0 6px 0 var(--paper-shadow), 0 14px 28px rgba(52,45,31,.2); }
.music-volume-popover .vol-ico { font-size: 12px; opacity: .72; }
.music-volume-popover input[type="range"] { width: 100%; }
.audio-library-volume-bar { position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 0 18px; padding: 9px 10px 10px 12px; border: 1px solid var(--sep);
  border-left: 6px solid var(--sheet-tab-rust); border-radius: 4px; background: var(--card);
  box-shadow: 0 2px 0 var(--paper-shadow); }
.audio-library-volume-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.audio-library-volume-copy b { font-size: 13px; line-height: 1.25; }
.audio-library-volume-copy small { color: var(--muted); font-size: 10px; line-height: 1.3; }
.audio-library-volume-control > summary { width: 58px; }
.audio-library-volume-control .music-volume-popover { right: 0; }

/* ルーティン名は単独の大きなカードにせず、一段の記入行として扱う */
.routine-name-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center;
  gap: 11px; padding: 9px 11px; margin-bottom: 14px; border-left: 6px solid var(--blue); }
.routine-name-card label.fld { margin: 0; font-size: 11px; white-space: nowrap; }
.routine-name-card > input[type="text"]:last-child { min-height: 42px; margin: 0; padding: 8px 10px;
  font-size: 15px; line-height: 1.3; }
.music-empty .me-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.music-empty .row-2 { margin: 0; }

/* 曲位置チップ・録音行 */
.time-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.time-chip { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: var(--accent-tint);
  color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
button.time-chip.tappable { color: var(--text); background: var(--card2); min-height: 34px;
  font-weight: 500; }
.rec-row { padding: 10px 0; border-bottom: var(--hairline) solid var(--sep); }
.rec-row:last-child { border-bottom: none; }
.rec-row .head { display: flex; align-items: center; gap: 8px; }
.rec-row .head .nm { flex: 1; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 統計 */
.version-guide{display:grid;gap:3px;margin:0 0 10px;padding:11px 12px;border-left:4px solid var(--blue);border-bottom:1px dashed var(--sep);background:rgba(255,255,255,.22);color:var(--text)}
.version-guide b{font-size:13px}
.version-guide span{color:var(--muted);font-size:11.5px;line-height:1.45}
.stat-overview{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-bottom:22px}
.stat-box{background:var(--card);border-radius:var(--radius);padding:12px 8px;text-align:center}
.stat-box .v{font-size:21px;font-weight:700;font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.stat-box .l{font-size:11px;color:var(--muted);margin-top:2px}
.stat-overview.analysis-overview{grid-template-columns:repeat(2,minmax(0,1fr));margin-bottom:10px}
.failure-count-estimate{margin:0 0 22px;padding:10px 12px 9px;border:1px solid var(--sep);border-left:5px solid var(--sheet-tab-rust);border-radius:3px;background:rgba(248,244,233,.48);box-shadow:0 3px 0 var(--paper-shadow)}
.failure-count-head{display:flex;align-items:flex-end;justify-content:space-between;gap:10px;margin-bottom:8px}
.failure-count-head>div{min-width:0}
.failure-count-head span{display:block;color:var(--accent);font-size:8px;font-weight:900;letter-spacing:.14em}
.failure-count-head h2{margin:2px 0 0;font-size:14px;line-height:1.3}
.failure-count-head b{flex-shrink:0;color:var(--text);font-size:13px;font-variant-numeric:tabular-nums}
.failure-count-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));border-block:1px dashed var(--sep)}
.failure-count-cell{display:grid;gap:1px;padding:7px 2px;text-align:center;border-right:1px dashed var(--sep)}
.failure-count-cell:last-child{border-right:0}
.failure-count-cell strong{font-size:15px;font-variant-numeric:tabular-nums}
.failure-count-cell span{color:var(--muted);font-size:9px;font-weight:700;white-space:nowrap}
.failure-count-estimate p{margin:7px 0 0;color:var(--muted);font-size:9px;line-height:1.45}

.step-stat{padding:11px 0;border-bottom:var(--hairline) solid var(--sep)}
.step-stat:last-of-type{border-bottom:none}
.step-stat .head{display:flex;align-items:baseline;gap:8px}
.step-stat .head .nm{flex:1;font-weight:500;font-size:16px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.step-stat .head .kn{font-size:13px;color:var(--muted);font-variant-numeric:tabular-nums;flex-shrink:0}
.step-stat.transition .head .nm { color: var(--muted); font-weight: 400; font-size: 13px; }
.gap-note { font-size: 12px; margin-top: 6px; padding: 8px 10px; border-radius: 8px; line-height: 1.5;
  background: rgba(255, 159, 10, .12); color: var(--accent); }
.gap-note b { font-weight: 700; }
.note-caveat { font-size: 12px; color: var(--muted); background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; margin: 10px 0 22px; line-height: 1.6; }
.card .note-caveat { background: var(--card2); margin: 10px 0 14px; }

.bd-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0;
  font-size: 15px; border-bottom: var(--hairline) solid var(--sep); }
.bd-row:last-child { border-bottom: none; }
.bd-row .k { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bd-row .v { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* 選択スロット(A/B分岐) */
.step-btn.slot { align-items: flex-start; padding-top: 10px; padding-bottom: 10px; cursor: pointer; }
.step-btn.slot .no { margin-top: 6px; }
.slot-body { flex: 1; min-width: 0; }
.slot-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.slot-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-chip { padding: 8px 14px; border-radius: 17px; background: var(--card2); color: var(--muted);
  border: none; font-size: 14px; font-weight: 600; }
.opt-chip.selected { background: var(--accent-tint); color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent); }
.opt-chip.small { padding: 4px 10px; font-size: 12px; }
.slot-mark { font-size: 10px; color: var(--accent); background: var(--accent-tint);
  border-radius: 8px; padding: 1px 6px; vertical-align: middle; }
.slot-opt-stat { margin: 8px 0 0 14px; padding: 6px 0; }
.slot-opt-stat .head { display: flex; align-items: baseline; gap: 8px; }
.slot-opt-stat .head .nm { flex: 1; font-size: 14px; color: var(--text); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-opt-stat .head .kn { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.failure-rate-yellow{--failure-line:#aa8920;--failure-bg:rgba(214,177,38,.16)}
.failure-rate-orange{--failure-line:#bd6d2c;--failure-bg:rgba(211,111,35,.14)}
.failure-rate-red{--failure-line:#ae504a;--failure-bg:rgba(190,64,59,.13)}
.step-stat[class*="failure-rate-"],.slot-opt-stat[class*="failure-rate-"]{background:var(--failure-bg);box-shadow:inset 5px 0 var(--failure-line);border-radius:3px}
.step-stat[class*="failure-rate-"]{margin-inline:-8px;padding-inline:10px}
.slot-opt-stat[class*="failure-rate-"]{padding-inline:8px}
.failure-rate-legend{display:flex;gap:6px;flex-wrap:wrap;margin:-4px 0 8px;font-size:10px}
.failure-rate-legend span{padding:3px 7px;border-left:4px solid var(--failure-line);background:var(--failure-bg)}

/* エディタの選択肢行 */
.es-opt { display: flex; align-items: center; gap: 8px; margin: 8px 0 0 32px; }
.es-opt .es-opt-mark { color: var(--accent); font-size: 13px; font-weight: 700; width: 16px; flex-shrink: 0; }
.es-opt input[type=text] { flex: 1; min-width: 0; padding: 9px 10px; font-size: 15px; border-radius: 8px; }
.es-opt .risk-select { min-height: 34px; }
.es-opt .mini-btn { flex: 0 0 auto; }
@media (max-width: 430px) {
  .es-opt { display: grid; grid-template-columns: 16px minmax(0, 1fr) 40px; align-items: center; }
  .es-opt .es-opt-mark { grid-column: 1; grid-row: 1; }
  .es-opt input[type=text] { grid-column: 2; grid-row: 1; }
  .es-opt .video-trim-btn, .es-opt .mini-btn.link { grid-column: 3; grid-row: 1; }
  .es-opt .risk-select { grid-column: 2 / 4; grid-row: 2; justify-self: end; }
  .es-opt:has(.mini-btn.del) .risk-select { grid-column: 2; width: 100%; }
  .es-opt > .mini-btn.del { grid-column: 3; grid-row: 2; }
}

/* セッション開始時の前回リキャップ */
.recap { background: var(--card2); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; }
.recap-h { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.recap-plan { font-size: 14px; color: var(--accent); margin: 4px 0; line-height: 1.5; }
.recap-line { font-size: 13px; color: var(--text); margin: 2px 0; line-height: 1.5; }

/* 履歴 */
.run-block { border-top: var(--hairline) solid var(--sep); padding: 10px 0; }
.run-block .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.run-block .head .k { font-size: 14px; font-weight: 600; }
.run-block.excluded { opacity: .45; }
.run-block.excluded .head .k { text-decoration: line-through; }
.ev-row { position: relative; background: var(--card2); border-radius: 10px; padding: 8px 12px; margin-top: 8px;
  font-size: 13px; cursor: pointer; }
.ev-row:active { background: var(--card3); }
.ev-row .k { color: var(--text); }
.ev-row .ev-tags { display: inline-block; color: var(--accent); font-size: 12px; margin-left: 6px; }
.ev-row .ev-edit { position: absolute; right: 12px; top: 8px; font-size: 11px; color: var(--muted2); }
.note-line { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.note-line.plan { color: var(--accent); }
.run-choice { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.run-choice .k { font-size: 12px; color: var(--muted); }

/* トースト */
#toast { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + var(--safe-bottom)); background: rgba(44, 44, 46, .92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--text); border-radius: 18px; padding: 10px 20px; font-size: 14px; font-weight: 500;
  z-index: 60; box-shadow: 0 8px 28px rgba(0, 0, 0, .5); max-width: 90%; text-align: center;
  animation: toastin .25s cubic-bezier(.32, .72, .35, 1); }
@keyframes toastin { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 14px; line-height: 1.7; }
.help-body { font-size: 14px; color: var(--text); line-height: 1.8; padding: 2px 0 14px; }
.help-body b { color: var(--accent); font-weight: 600; }
.help-guide-card { margin-bottom: 10px; }
.help-guide-card .help-body { line-height: 1.65; padding-bottom: 6px; }
.help-quick-steps { list-style: none; margin: 0; padding: 0 0 4px; border-top: var(--hairline) solid var(--sep); }
.help-quick-steps li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 9px;
  padding: 9px 0; border-bottom: var(--hairline) solid var(--sep); font-size: 14px; line-height: 1.55; }
.help-step-no { padding-top: 1px; color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.help-quick-steps b, .help-topic-line b { color: var(--accent); font-weight: 650; }
.help-topic-line + .help-topic-line { margin-top: 9px; padding-top: 9px; border-top: var(--hairline) solid var(--sep); }

/* ホーム — ルーズリーフを「見た目」ではなく情報構造として扱う */
#app:has(> .home-simple-shell) { padding-bottom: 0; }
.home-simple-shell { position: relative; min-height: 100svh; margin: 0 -16px; overflow: hidden;
  background: #282b27; color: var(--sheet-ink); }
.home-binder-edge { position: absolute; inset: 0 auto 0 0; width: 30px; z-index: 2;
  background: #282b27; border-right: 1px solid rgba(0,0,0,.42); box-shadow: 5px 0 12px rgba(0,0,0,.17); }
.home-binder-edge::before { content: ""; position: absolute; inset: calc(24px + var(--safe-top)) 6px 22px;
  background: radial-gradient(circle, #11130f 0 4px, #aaa598 4.5px 6px, transparent 6.5px) center top / 16px 69px repeat-y; }
.home-paper-sheet { position: relative; display: flex; flex-direction: column; min-height: 100svh;
  margin-left: 24px; padding: 0 16px 0 24px; color: var(--sheet-ink); background-color: var(--sheet-paper);
  background-image:
    linear-gradient(90deg, transparent 0 23px, var(--sheet-margin) 23px 24px, transparent 24px),
    repeating-linear-gradient(180deg, transparent 0 29px, var(--sheet-rule) 29px 30px);
  box-shadow: inset 8px 0 16px rgba(74,61,38,.08); }
.home-simple-head { position: relative; z-index: 1; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; min-height: calc(66px + var(--safe-top));
  padding-top: var(--safe-top); border-bottom: 2px solid #30343b; }
.home-title-block { min-width: 0; }
.home-title-block > small { display: block; margin-bottom: 2px; color: var(--sheet-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; font-weight: 700; letter-spacing: .08em; }
.home-title-block h1 { min-width: 0; margin: 0; overflow: hidden; color: var(--sheet-ink);
  font-size: 18px; line-height: 1.2; font-weight: 750; letter-spacing: -.035em;
  white-space: nowrap; text-overflow: ellipsis; }
.home-head-buttons { display: flex; gap: 6px; flex-shrink: 0; }
.home-head-buttons button { min-height: 44px; padding: 0 10px; border: 1px solid #77766e; border-radius: 5px;
  background: var(--sheet-paper-raised); color: var(--sheet-ink); font-size: 11px; font-weight: 750;
  box-shadow: 0 3px 0 var(--sheet-shadow); }
.home-head-buttons .head-settings-btn { width: 45px; padding: 4px 4px 3px; color: var(--sheet-ink); }
.home-simple-main { position: relative; z-index: 1; flex: 0 0 auto; padding: 30px 0 0; }
.home-practice-button { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; min-height: 78px; padding: 0 17px 0 19px; border: 2px solid var(--sheet-accent-edge);
  border-radius: 5px 13px 13px 5px; background: var(--sheet-accent); color: #1e211f; text-align: left;
  box-shadow: 0 6px 0 #ad681f, 0 10px 19px rgba(60,43,22,.22); }
.home-practice-copy { min-width: 0; }
.home-practice-copy > small { display: block; margin-bottom: 2px; color: #704415;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.home-practice-copy > span { display: block; overflow: hidden; font-size: 18px; font-weight: 850;
  letter-spacing: -.02em; white-space: nowrap; text-overflow: ellipsis; }
.home-button-arrow { flex-shrink: 0; font-size: 27px; line-height: 1; font-weight: 400; }
.home-recent { margin-top: 27px; }
.home-recent h2 { margin: 0 0 9px 2px; color: var(--sheet-muted); font-size: 11px; line-height: 1.2; font-weight: 750; }
.home-recent-button { display: grid; grid-template-columns: 23px minmax(0,1fr) 18px; align-items: stretch;
  gap: 10px; width: 100%; min-height: 84px; padding: 0 13px 0 0; border: 1px solid #8d8a80;
  border-radius: 3px 9px 9px 3px; background: var(--sheet-paper-raised); color: var(--sheet-ink);
  text-align: left; box-shadow: 0 5px 0 #d1c8b4, 0 9px 18px rgba(63,52,31,.16); }
.home-paper-grip { display: flex; flex-direction: column; align-items: center; justify-content: center;
  align-self: stretch; gap: 7px; background: var(--sheet-tab-blue); }
.home-paper-grip i { display: block; width: 7px; height: 3px; border-radius: 2px; background: #d8d4c8; }
.home-recent-copy { min-width: 0; align-self: center; }
.home-recent-copy b { display: block; overflow: hidden; color: var(--sheet-ink); font-size: 16px;
  line-height: 1.35; font-weight: 750; white-space: nowrap; text-overflow: ellipsis; }
.home-recent-copy small { display: block; margin-top: 5px; color: #a85c22; font-size: 11px; font-weight: 700; }
.home-recent-button .home-button-arrow { align-self: center; color: #686a69; font-size: 22px; }
.home-recent-empty { display: flex; align-items: center; min-height: 74px; padding: 14px 17px;
  border: 1px dashed #8d8a80; border-radius: 5px; background: rgba(248,244,233,.62);
  color: var(--sheet-muted); font-size: 14px; }
.home-recent .home-routine-card { margin: 7px 0 13px; isolation: auto; }
.home-routine-card .routine-row { background: var(--sheet-paper-raised); }
.home-routine-card .routine-row .name { color: var(--sheet-ink); overflow: visible; text-overflow: clip; white-space: normal; line-height: 1.25; font-size: 16px; }
.home-routine-card .routine-row .meta { color: var(--sheet-muted); }
.home-paper-space { position: relative; display: flex; flex: 1 1 auto; align-items: end;
  justify-content: space-around; min-height: 0; padding: 0 8px 34px; color: rgba(63,74,82,.26);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.home-paper-space::before { content: ""; position: absolute; left: 8%; right: 4%; bottom: 54px; height: 46px;
  border-top: 1px dashed rgba(49,68,91,.24); border-bottom: 1px dashed rgba(49,68,91,.18);
  transform: skewY(-2deg); }
.home-libraries { position: relative; z-index: 1; flex: 0 0 auto;
  padding: 14px 0 calc(20px + var(--safe-bottom)); border-top: 2px solid #30343b; }
.home-library-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.home-library-grid button { position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 7px; min-width: 0; min-height: 68px; padding: 13px 10px; border: 1px solid #75766e;
  border-radius: 5px; background: var(--sheet-paper-raised); color: var(--sheet-ink); text-align: left;
  box-shadow: 0 4px 0 var(--sheet-shadow); }
.home-library-grid button::before { content: ""; position: absolute; left: 8px; right: 8px; top: -1px;
  height: 5px; background: var(--sheet-tab-blue); }
.home-library-grid .home-library-videos { grid-column: 1 / -1; min-height: 58px; }
.home-library-grid .home-library-videos::before { background: #2f3d4e; }
.home-library-grid .home-library-audios::before { background: var(--sheet-tab-rust); }
.home-library-copy { min-width: 0; }
.home-library-copy b { display: block; overflow: hidden; color: var(--sheet-ink); font-size: 12px;
  line-height: 1.3; font-weight: 750; white-space: nowrap; text-overflow: ellipsis; }
.home-library-copy small { display: block; margin-top: 4px; color: #77766e; font-size: 10px; font-weight: 500; }
.home-library-grid .home-button-arrow { color: #72746f; font-size: 20px; }
.home-practice-button:active, .home-recent-button:active, .home-library-grid button:active,
.home-head-buttons button:active { opacity: 1; filter: none; transform: translateY(3px); }
.home-practice-button:active { box-shadow: 0 3px 0 #ad681f, 0 6px 12px rgba(60,43,22,.2); }
.home-recent-button:active { box-shadow: 0 2px 0 #d1c8b4, 0 5px 10px rgba(63,52,31,.13); }
.home-library-grid button:active, .home-head-buttons button:active { box-shadow: 0 1px 0 var(--sheet-shadow); }
.home-simple-shell button { transition: transform .12s ease, box-shadow .12s ease; }
.home-simple-shell button:focus-visible { outline: 3px solid var(--sheet-tab-blue); outline-offset: 3px; }
@media (max-width: 350px) {
  .home-binder-edge { width: 24px; }
  .home-binder-edge::before { inset-inline: 4px; background-size: 16px 50px; }
  .home-paper-sheet { margin-left: 19px; padding: 0 12px 0 17px; }
  .home-simple-head { min-height: calc(66px + var(--safe-top)); }
  .home-title-block > small { display: none; }
  .home-title-block h1 { font-size: 14px; }
  .home-head-buttons button { min-height: 40px; padding: 0 7px; font-size: 10px; }
  .home-simple-main { padding-top: 17px; }
  .home-practice-button { min-height: 66px; padding-inline: 15px; }
  .home-practice-copy > small { display: none; }
  .home-practice-copy > span { font-size: 15px; }
  .home-recent { margin-top: 18px; }
  .home-recent .home-routine-card { margin-bottom: 10px; }
  .home-routine-card .routine-row .name { font-size: 14px; }
  .home-paper-space { padding-bottom: 8px; }
  .home-paper-space::before { bottom: 24px; height: 18px; }
  .home-libraries { padding-block: 9px calc(12px + var(--safe-bottom)); }
  .home-library-grid button { min-height: 57px; padding-block: 9px; }
  .home-library-copy b { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .home-simple-shell button { transition: none; }
  .delete-slide-track.resetting .delete-slide-handle,
  .delete-slide-track.resetting .delete-slide-fill { transition: none; }
}

.fatal-start-error {
  max-width: 520px;
  margin: max(48px, env(safe-area-inset-top)) auto 0;
  padding: 28px 22px;
  color: var(--text);
  text-align: center;
}
.fatal-start-error h1 { margin: 0 0 12px; font-size: 24px; }
.fatal-start-error p { margin: 0 0 22px; color: var(--muted); line-height: 1.75; }

/* 技ライブラリ */
.trick-row { padding: 10px 0; border-bottom: var(--hairline) solid var(--sep); }
.trick-row:last-child { border-bottom: none; }
.trick-row .head { display: flex; align-items: center; gap: 10px; }
.trick-row .nm { flex: 1; font-size: 16px; font-weight: 500; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trick-row .kn { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.trick-row .head .btn.small { padding: 0 12px; min-height: 32px; }
.trick-video { width: 100%; border-radius: 12px; background: #000; margin-top: 10px; max-height: 60vh; }
.trick-video.main { margin-top: 0; aspect-ratio: 16/9; object-fit: cover; }
.rec-timer { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.clean-btn.recording { background: var(--danger); color: #fff; }
/* 技動画の再生: 外側の操作ボタン内に動画スクリーン枠＋再生マークを描き、音楽再生と区別する */
.mini-btn.play,
.video-play-btn,
.video-trim-btn { position: relative; width: 40px !important; min-width: 40px; height: 34px;
  min-height: 34px !important; padding: 0 !important; border-radius: 5px !important;
  background: var(--accent) !important; color: var(--on-accent) !important; font-size: 0 !important;
  flex-shrink: 0; }
.mini-btn.play::before,
.video-play-btn::before,
.video-trim-btn::before { content: ""; position: absolute; left: 50%; top: 50%;
  width: 24px; height: 16px; transform: translate(-50%,-50%); box-sizing: border-box;
  border: 2px solid var(--on-accent); border-radius: 3px; }
.mini-btn.play::after,
.video-play-btn::after,
.video-trim-btn::after { content: ""; position: absolute; left: 50%; top: 50%;
  width: 0; height: 0; margin: -4px 0 0 -2px;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  border-left: 7px solid var(--on-accent); }
.mini-btn.play.on { background: var(--accent) !important; box-shadow: 0 3px 0 var(--paper-shadow), inset 0 0 0 2px var(--on-accent); }
.mini-btn.play:focus-visible,
.video-play-btn:focus-visible,
.video-trim-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.btn.video-link-change { border-color: color-mix(in srgb, var(--accent) 72%, #000);
  background: var(--accent); color: var(--on-accent); }
.trim-linked-video { margin-bottom: 8px; color: var(--text); }
.mini-btn.link { font-size: 13px; }

.pick-trick-row { display: flex; align-items: center; gap: 10px; padding: 12px 4px;
  border-bottom: var(--hairline) solid var(--sep); cursor: pointer; }
.pick-trick-row:last-of-type { border-bottom: none; }
.pick-trick-row:active { background: var(--card3); }
.pick-trick-row .nm { flex: 1; font-size: 16px; font-weight: 500; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-trick-row .kn { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.b-now-line { min-height: 20px; text-align: center; font-size: 14px; font-weight: 700;
  color: var(--ok); margin-top: 2px; }
.bi-row { display: flex; align-items: center; gap: 7px; padding: 9px 0;
  border-bottom: var(--hairline) solid var(--sep); cursor: pointer; }
.bi-row:last-of-type { border-bottom: none; }
.bi-row:active { background: var(--card3); }
.bi-row.current { background: rgba(48, 209, 88, .12); border-radius: 8px; }
.bi-row .bi-time { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums;
  width: 52px; flex-shrink: 0; }
.bi-row .nm { flex: 1; font-size: 15px; font-weight: 500; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bi-row .kn { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.bi-row .mini-btn { width: 32px; height: 32px; font-size: 13px; }
.center { text-align: center; }
.row-2 { display: flex; gap: 10px; }
.row-2 > * { flex: 1; }

/* ============================================================
   ルーティンごとのテーマ(着せ替え)。body[data-theme] で変数を上書き
   危険度スケール(--risk-1..5)は緑→赤の意味を保ちつつ各世界観に馴染ませる
   ============================================================ */

/* 和 — 高級旅館ニュアンス: 生成りの和紙基調、墨の文字、朱と金、梁と主要ボタンの木目、円相の淡いウォーターマーク */
body[data-theme="wa"] {
  --bg: #e7ddc7; --card: #f6f1e4; --card2: #ece2cd; --card3: #e0d4ba;
  --sep: rgba(150, 120, 60, .3);   /* 金の細罫 */
  --text: #2c2620; --muted: rgba(52, 44, 30, .62); --muted2: rgba(52, 44, 30, .34);
  --accent: #a5432b; --accent-tint: rgba(165, 67, 43, .12); --on-accent: #f7f2e6;
  --ok: #5c7a3f; --ok-tint: rgba(92, 122, 63, .16); --on-ok: #f7f2e6;
  --warn: #a9791b; --danger: #a5342a;
  --nav-bg: #5a3f26; --sheet-bg: #f6f1e4;
  --seg-selected: #fbf7ee;
  --font-head: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --risk-1: #5c7a3f; --risk-1-bg: rgba(92, 122, 63, .16);
  --risk-2: #7c8a2c; --risk-2-bg: rgba(124, 138, 44, .16);
  --risk-3: #a9791b; --risk-3-bg: rgba(169, 121, 27, .16);
  --risk-4: #b3591f; --risk-4-bg: rgba(179, 89, 31, .16);
  --risk-5: #a5342a; --risk-5-bg: rgba(165, 52, 42, .16);
  /* 木目(梁・ボタン用)。木肌の縦グラデ + 横に流れる濃淡の縞 */
  --wa-wood:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='120'%3E%3Cfilter id='wgr'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.008 0.12' numOctaves='5' seed='9' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.55'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23wgr)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #6d4c2d, #573a20 55%, #4a3018);
  /* 和紙の繊維(素材の地に重ねる細かな斑) */
  --wa-paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='wp'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='6' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.06'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23wp)'/%3E%3C/svg%3E");
  /* 黒漆(艶): 斜めの光沢 + 黒地。金字と合わせる */
  --wa-lacquer: radial-gradient(120% 95% at 32% 14%, rgba(255,245,220,.22), rgba(255,245,220,0) 44%), linear-gradient(180deg, #241d18, #100c0a);
  /* 背景アート: 生成りの和紙 + 墨の筆(かすれ/飛沫) + 金砂子。scripts/gen-wa-bg.mjs で生成 */
  --app-bg-layer: url("assets/wa-bg.svg");
  --app-bg-size: cover; --app-bg-repeat: no-repeat;
}
/* カード=固い和紙(繊維の斑+柔らかな浮き彫りの縁) */
body[data-theme="wa"] .card,
body[data-theme="wa"] .routine-row,
body[data-theme="wa"] .es-row1 input[type=text],
body[data-theme="wa"] .cue-input,
body[data-theme="wa"] #sheet {
  background-color: #f6f1e3; background-image: var(--wa-paper);
  border: 0.5px solid rgba(150, 120, 60, .26);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -2px 3px rgba(120,90,40,.09); }
/* 梁(ナビ)を木目に。文字は生成りに反転 */
body[data-theme="wa"] .topbar,
body[data-theme="wa"] .bottombar {
  background-color: #573a20; background-image: var(--wa-wood);
  background-size: 320px 120px, cover; background-blend-mode: multiply, normal;
  border-color: rgba(190, 155, 85, .55); }
body[data-theme="wa"] .topbar h1 { color: #f6efdd; }
body[data-theme="wa"] .topbar .sub { color: rgba(246, 239, 221, .72); }
body[data-theme="wa"] .back-btn,
body[data-theme="wa"] .nav-action { color: #efd9ad; }

/* 主要ボタン=黒漆に金字(艶のある黒地+金の文字) */
body[data-theme="wa"] .btn.primary,
body[data-theme="wa"] .btn.small.primary {
  background-color: #171310; background-image: var(--wa-lacquer);
  color: #e7c86a; border: 1px solid rgba(0,0,0,.5);
  box-shadow: inset 0 1px 0 rgba(255,240,210,.16), 0 1px 3px rgba(0,0,0,.3); }
/* クリーン=緑漆(艶のある深緑+生成りの字)。成功=緑の意味は保つ */
body[data-theme="wa"] .clean-btn {
  background-color: #45602f;
  background-image: radial-gradient(120% 95% at 32% 14%, rgba(255,250,225,.24), rgba(255,250,225,0) 44%), linear-gradient(180deg, #567238, #364c22);
  color: #f4efdc; box-shadow: inset 0 1px 0 rgba(255,245,210,.22), 0 1px 3px rgba(0,0,0,.25); }

/* 小ボタン・札=和紙の質感(浮き彫りの縁)。色は各々の意味色を保つ */
body[data-theme="wa"] .btn.small,
body[data-theme="wa"] .kind-toggle,
body[data-theme="wa"] .mini-btn,
body[data-theme="wa"] .risk-select,
body[data-theme="wa"] .music-pill,
body[data-theme="wa"] .segmented,
body[data-theme="wa"] .choice {
  background-image: var(--wa-paper);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -1px 2px rgba(120,90,40,.1);
  border: 0.5px solid rgba(150,120,60,.3); }
/* 危険度・記録済み等の色札にも和紙の斑を重ねる(意味色の上に紙の質感) */
body[data-theme="wa"] .badge,
body[data-theme="wa"] .opt-chip,
body[data-theme="wa"] .cue-chip {
  background-image: var(--wa-paper);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }

body[data-theme="wa"] .topbar h1,
body[data-theme="wa"] .card h2,
body[data-theme="wa"] .btn.primary,
body[data-theme="wa"] .clean-btn,
body[data-theme="wa"] .mc-title { font-family: var(--font-head); letter-spacing: .04em; }

/* サイバー — 純黒、ネオンのシアン、微かなグリッドとグロー */
body[data-theme="cyber"] {
  --bg: #05070a; --card: #0c1119; --card2: #131c28; --card3: #1c2838;
  --sep: rgba(0, 229, 255, .2);
  --text: #eafcff; --muted: rgba(180, 224, 235, .6); --muted2: rgba(180, 224, 235, .32);
  --accent: #00e5ff; --accent-tint: rgba(0, 229, 255, .14); --on-accent: #00181d;
  --ok: #24f39a; --ok-tint: rgba(36, 243, 154, .16); --on-ok: #00160d;
  --warn: #ffe14d; --danger: #ff2e6e;
  --nav-bg: rgba(5, 7, 10, .82); --sheet-bg: rgba(12, 17, 25, .98);
  --seg-selected: #1f3346;
  --risk-1: #24f39a; --risk-1-bg: rgba(36, 243, 154, .16);
  --risk-2: #8df24d; --risk-2-bg: rgba(141, 242, 77, .16);
  --risk-3: #ffe14d; --risk-3-bg: rgba(255, 225, 77, .16);
  --risk-4: #ff9d3c; --risk-4-bg: rgba(255, 157, 60, .18);
  --risk-5: #ff2e6e; --risk-5-bg: rgba(255, 46, 110, .2);
  --app-bg-layer:
    radial-gradient(100% 60% at 50% -10%, rgba(0, 229, 255, .1), transparent 55%),
    radial-gradient(80% 50% at 100% 100%, rgba(255, 46, 110, .07), transparent 55%),
    repeating-linear-gradient(90deg, rgba(0, 229, 255, .04) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(0deg, rgba(0, 229, 255, .04) 0 1px, transparent 1px 40px);
}
body[data-theme="cyber"] .btn.primary,
body[data-theme="cyber"] .clean-btn { box-shadow: 0 0 18px rgba(0, 229, 255, .35); }
body[data-theme="cyber"] .topbar h1 { letter-spacing: .04em; }

/* マット白 — 生成りのオフホワイト、墨黒の文字、スレートのアクセント(ミニマル) */
body[data-theme="matte"] {
  --bg: #f2f1ec; --card: #ffffff; --card2: #eae8e1; --card3: #e1ded5;
  --sep: rgba(60, 60, 67, .16);
  --text: #1c1b19; --muted: rgba(40, 40, 45, .56); --muted2: rgba(40, 40, 45, .32);
  --accent: #47607a; --accent-tint: rgba(71, 96, 122, .12); --on-accent: #ffffff;
  --ok: #3f9d6b; --ok-tint: rgba(63, 157, 107, .14); --on-ok: #ffffff;
  --warn: #b8860b; --danger: #c0392b;
  --nav-bg: rgba(242, 241, 236, .82); --sheet-bg: rgba(255, 255, 255, .98);
  --seg-selected: #ffffff;
  --risk-1: #3f9d6b; --risk-1-bg: rgba(63, 157, 107, .14);
  --risk-2: #7a9a2e; --risk-2-bg: rgba(122, 154, 46, .14);
  --risk-3: #b8860b; --risk-3-bg: rgba(184, 134, 11, .14);
  --risk-4: #cf7b32; --risk-4-bg: rgba(207, 123, 50, .14);
  --risk-5: #c0392b; --risk-5-bg: rgba(192, 57, 43, .14);
  --app-bg-layer: none;
}
/* ライトテーマでは選択セグメントに軽い影で浮きを出す */
body[data-theme="matte"] .segmented .choice.selected { box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }

.routine-menu-section { margin: 20px 0 0; }
.routine-menu-section h4 { margin: 0 0 8px; color: var(--muted); font-size: 13px;
  font-weight: 500; letter-spacing: .02em; }
.routine-menu-toggle-list { padding: 0 14px; background: var(--card); border-radius: 12px;
  border: var(--hairline) solid var(--sep); }
.routine-menu-note { margin: 7px 4px 0; color: var(--muted); font-size: 12px; }
.routine-menu-close { margin-top: 4px; }
.routine-menu-close .btn { margin-bottom: 0; }
.routine-version-list { overflow: hidden; border: 1px solid var(--sep); border-radius: 4px;
  background: var(--card); box-shadow: 0 3px 0 var(--paper-shadow); }
.routine-version-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 58px; padding: 9px 10px; border-bottom: 1px dashed var(--sep); }
.routine-version-row:last-child { border-bottom: 0; }
.routine-version-row.current { background: color-mix(in srgb, var(--blue) 8%, var(--card)); }
.routine-version-copy { min-width: 0; }
.routine-version-title { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.routine-version-title b { color: var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
.routine-version-title span { overflow: hidden; color: var(--text); font-size: 12px; font-weight: 700;
  text-overflow: ellipsis; white-space: nowrap; }
.routine-version-title em { flex-shrink: 0; padding: 1px 5px; border: 1px solid var(--blue); border-radius: 2px;
  color: var(--blue); font-size: 9px; font-style: normal; font-weight: 800; }
.routine-version-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.routine-version-row > button { min-height: 34px; padding: 0 9px; border: 1px solid var(--sep); border-radius: 4px;
  background: var(--card2); color: var(--accent); font-size: 11px; font-weight: 760;
  box-shadow: 0 2px 0 var(--paper-shadow); }
.version-restore-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 16px 0 10px; padding: 12px; border: 1px solid var(--sep); border-left: 6px solid var(--blue);
  border-radius: 4px; background: var(--card); box-shadow: 0 2px 0 var(--paper-shadow); }
.version-restore-summary b { font-size: 16px; }
.version-restore-summary span { color: var(--muted); font-size: 12px; }
.version-restore-copy { margin: 0 2px 18px; color: var(--text); font-size: 13px; line-height: 1.65; }
.version-restore-notice { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: -7px 0 15px; padding: 9px 10px; border: 1px solid var(--sep); border-left: 6px solid var(--sheet-tab-rust);
  border-radius: 4px; background: color-mix(in srgb, var(--sheet-tab-rust) 9%, var(--card));
  box-shadow: 0 2px 0 var(--paper-shadow); }
.version-restore-notice span { font-size: 12px; }
.version-restore-notice button { min-height: 34px; padding: 0 9px; border: 1px solid var(--sep); border-radius: 4px;
  background: var(--card); color: var(--accent); font-size: 10px; font-weight: 760; box-shadow: 0 2px 0 var(--paper-shadow); }

/* ローディング = ルーズリーフの紙片を準備している共通表示。推測の%は出さない */
#loading { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: rgba(32,35,32,.76); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.loading-sheet { position: relative; display: flex; flex-direction: column; align-items: center;
  width: min(340px, calc(100vw - 44px)); min-height: 218px; padding: 27px 28px 24px;
  border: 1px solid var(--sep); border-top: 7px solid var(--sheet-tab-rust); border-radius: 5px;
  background: var(--card); color: var(--text); box-shadow: 0 9px 0 rgba(61,57,45,.32), 0 24px 54px rgba(0,0,0,.32); }
.loading-sheet::before, .loading-sheet::after { content: ""; position: absolute; z-index: -1;
  left: 10px; right: -7px; top: 8px; bottom: -8px; border: 1px solid var(--sep); border-radius: 4px;
  background: var(--card2); box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.loading-sheet::after { left: 19px; right: -13px; top: 16px; bottom: -15px; z-index: -2; opacity: .78; }
.loading-kicker { color: var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px; font-weight: 850; letter-spacing: .14em; }
.loading-motion { display: flex; align-items: flex-end; justify-content: center; gap: 7px; height: 39px; margin: 13px 0 8px; }
.loading-motion i { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--sheet-tab-rust);
  box-shadow: 0 2px 0 var(--paper-shadow); animation: loadingDot 1.05s ease-in-out infinite; }
.loading-motion i:nth-child(2) { animation-delay: .14s; }
.loading-motion i:nth-child(3) { animation-delay: .28s; }
#loading .msg { max-width: 100%; color: var(--text); font-size: 16px; font-weight: 850; line-height: 1.5; text-align: center; }
.loading-sub { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }
.loading-track { position: relative; width: 100%; height: 4px; margin-top: 18px; overflow: hidden;
  border-radius: 1px; background: color-mix(in srgb, var(--blue) 15%, var(--sep)); }
.loading-track span { position: absolute; top: 0; bottom: 0; width: 38%; background: var(--blue);
  animation: loadingTrack 1.25s ease-in-out infinite; }
@keyframes loadingDot { 0%, 60%, 100% { transform: translateY(0); opacity: .38; } 30% { transform: translateY(-10px); opacity: 1; } }
@keyframes loadingTrack { from { left: -42%; } to { left: 104%; } }

.practice-video-loading { display: inline-flex; flex-direction: column; align-items: center; gap: 9px; padding: 10px; }
.practice-video-loading::before { content: ""; width: 22px; height: 22px; border: 2px solid rgba(255,255,255,.24);
  border-top-color: rgba(255,255,255,.86); border-radius: 50%; animation: loadingSpin .8s linear infinite; }
@keyframes loadingSpin { to { transform: rotate(360deg); } }

/* トリム(長さ調整)のシークバー: 現在位置のプレイヘッド+タップでシーク */
.trim-track { position: relative; height: 16px; background: var(--card2); border-radius: 8px;
  margin: 10px 0 4px; cursor: pointer; overflow: hidden; touch-action: none; }
.trim-track .range { position: absolute; top: 0; bottom: 0; background: rgba(48, 209, 88, .4);
  border-left: 2px solid var(--ok); border-right: 2px solid var(--ok); box-sizing: border-box; }
.trim-track .head { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--accent);
  border-radius: 2px; box-shadow: 0 0 0 1px var(--card); }
.trim-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted2);
  font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.music-trim-audio { display: block; width: 100%; margin: 12px 0 6px; }

/* 見出しの「?」説明ボタン(タップで説明シート) */
.info-btn { display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--card2); color: var(--muted);
  font-size: 12px; font-weight: 700; line-height: 1; margin-left: 7px; padding: 0;
  vertical-align: middle; border: 0.5px solid var(--sep); }
.info-btn:active { background: var(--card3); }

/* ============================================================
   全画面ルーズリーフ・システム
   ホームを「表紙」、それ以外を綴じた実用紙として統一する。
   装飾ではなく、紙片=編集単位 / 罫線=時間 / タブ=操作の意味を持たせる。
   ============================================================ */

body { background: var(--paper-rail); }

/* 綴じた紙面。ホームだけは専用の表紙レイアウトを維持する */
#app:not(:has(> .home-simple-shell)) {
  position: relative; min-height: 100svh;
  padding: 0 16px calc(108px + var(--safe-bottom));
  background-color: var(--paper-header);
  background-image: repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px);
  color: var(--text); box-shadow: 0 0 26px rgba(0,0,0,.28);
}
#app:not(:has(> .home-simple-shell))::before {
  display: none;
}

/* 紙面の見出し。すりガラスをやめ、ページ上端の太い罫線として扱う */
#app:not(:has(> .home-simple-shell)) > .topbar {
  margin: 0 -16px 22px; padding: calc(10px + var(--safe-top)) 10px 10px;
  min-height: calc(62px + var(--safe-top)); background: var(--paper-header);
  background-image: repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px);
  border-bottom: 2px solid var(--text); box-shadow: 0 4px 0 rgba(35,38,44,.08);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.topbar h1 { color: var(--text); font-family: var(--font-head); font-weight: 760; }
.back-btn, .nav-action {
  min-height: 40px; padding: 4px 8px; border: 1px solid var(--sep); border-radius: 4px;
  background: var(--card); color: var(--accent); box-shadow: 0 2px 0 var(--paper-shadow);
  font-size: 14px; font-weight: 700; white-space: nowrap;
}
.back-btn::before { font-size: 24px; }
.head-settings-btn {
  border-radius: 4px; background: var(--card); border: 1px solid var(--sep);
  box-shadow: 0 2px 0 var(--paper-shadow);
}
.head-settings-btn.current { border-color: color-mix(in srgb, var(--accent) 72%, #000); background: var(--accent); color: var(--on-accent); }

/* 紙片。短い影は「持ち上げられる / 押せる」範囲だけに使う */
.card, .stat-box, .note-caveat, .recap {
  position: relative; border: 1px solid var(--sep); border-top: 4px solid var(--blue);
  border-radius: 5px; background: var(--card); box-shadow: 0 4px 0 var(--paper-shadow);
}
.card { padding: 5px 14px; margin-bottom: 20px; }
.card h2 {
  padding: 12px 0 7px; color: var(--muted); font-size: 11px; font-weight: 760;
  letter-spacing: .055em; border-bottom: 1px dashed var(--sep);
}
.music-card, .rec-card { border-top-color: var(--sheet-tab-rust); }
.help-body { color: var(--text); }
.empty { border: 1px dashed var(--sep); border-radius: 4px; margin: 10px 0 14px; background: rgba(255,255,255,.16); }

/* 操作タブ。主要・補助を問わず輪郭と押下ストロークを残す */
.btn, .clean-btn, .choice, .kind-toggle, .mini-btn, .music-btn, .music-pill,
.opt-chip, .tag, button.time-chip.tappable {
  border: 1px solid var(--sep); border-radius: 5px; background: var(--card);
  box-shadow: 0 3px 0 var(--paper-shadow); color: var(--text);
  transition: transform .1s ease, box-shadow .1s ease, background .1s ease;
}
.btn { color: var(--accent); }
.btn.primary { border-color: color-mix(in srgb, var(--accent) 72%, #000); background: var(--accent); color: var(--on-accent); }
.btn.ok, .clean-btn, .music-pill.primary { border-color: color-mix(in srgb, var(--ok) 72%, #000); background: var(--ok); color: var(--on-ok); }
.btn.ghost { border: 1px dashed var(--sep); background: rgba(255,255,255,.18); color: var(--muted); font-weight: 600; }
.btn.danger-ghost { border: 1px solid color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); background: var(--card); }
.btn.small { min-height: 36px; border-radius: 4px; background: var(--card2); }
.routine-row .actions .btn.small { min-height: 48px; border-radius: 4px; }
.clean-btn { min-height: 86px; border-radius: 7px; box-shadow: 0 6px 0 color-mix(in srgb, var(--ok) 72%, #000); }
.btn:active, .clean-btn:active, .choice:active, .kind-toggle:active, .mini-btn:active,
.music-btn:active, .music-pill:active, .opt-chip:active, .tag:active,
.back-btn:active, .nav-action:active, .head-settings-btn:active {
  opacity: 1; filter: none; transform: translateY(2px); box-shadow: 0 1px 0 var(--paper-shadow);
}
.btn:focus-visible, .clean-btn:focus-visible, .choice:focus-visible, .mini-btn:focus-visible,
.back-btn:focus-visible, .nav-action:focus-visible, .head-settings-btn:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 3px;
}

/* 入力欄は別カードではなく、紙面に書き込む白いラベル */
input[type=text], textarea, select {
  background: color-mix(in srgb, var(--card) 88%, #fff); color: var(--text);
  border: 1px solid var(--sep); border-radius: 4px; box-shadow: inset 3px 0 0 var(--blue);
}
input[type=range] { accent-color: var(--accent); }
label.fld { color: var(--muted); font-weight: 700; }

/* 紙が重なる単語帳表現はルーティン一覧だけに使う。ホームの前回カードは一枚の紙。 */
.routine-stack-list { margin: 0 0 22px; padding: 0 4px; }
.routine-stack-list > h2 { margin: 0 0 7px; padding: 10px 1px 7px; border-bottom: 1px dashed var(--sep);
  color: var(--muted); font-size: 11px; font-weight: 760; letter-spacing: .055em; }
.routine-card {
  position: relative; margin: 12px 1px 16px; border: 0; border-radius: 5px;
  background: transparent; box-shadow: none; overflow: visible;
}
.routine-stack-list .routine-card { isolation: isolate; margin: 12px 6px 24px 1px; }
.routine-stack-list .routine-card::before, .routine-stack-list .routine-card::after { content: ""; position: absolute; pointer-events: none;
  border: 1px solid var(--sep); border-radius: 5px; background: var(--card); transform-origin: 16% 50%; }
.routine-stack-list .routine-card::before { z-index: -2; inset: 6px -6px -9px 7px; transform: rotate(.65deg);
  background: color-mix(in srgb, var(--card) 88%, var(--paper-shadow)); }
.routine-stack-list .routine-card::after { z-index: -1; inset: 3px -3px -5px 4px; transform: rotate(-.28deg);
  background: color-mix(in srgb, var(--card) 96%, var(--paper-shadow)); }
.routine-stack-list .routine-card:nth-of-type(even)::before { transform: rotate(-.55deg); }
.routine-stack-list .routine-card:nth-of-type(even)::after { transform: rotate(.22deg); }
.routine-row { padding: 14px 56px 14px 14px; border: 1px solid var(--sep); border-radius: 5px;
  background: var(--card); box-shadow: 0 4px 0 var(--paper-shadow); }
.routine-row .name { padding-left: 30px; font-weight: 760; }
.routine-row .meta { margin-top: 4px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.routine-quick-note { border-top-color: color-mix(in srgb, var(--blue) 45%, var(--sep)); }
.routine-quick-note-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.routine-memo-full { border-radius: 3px; background: color-mix(in srgb, var(--card) 88%, #fff); }

/* 練習画面。現在技はレイアウトを動かさない正方形プレビュー付きの見開きメモ */
.practice-now {
  top: calc(var(--safe-top) + 63px); border: 1px solid var(--sep); border-left: 9px solid var(--blue);
  border-radius: 5px; background: var(--card); box-shadow: 0 5px 0 var(--paper-shadow), 0 10px 22px rgba(52,45,31,.14);
}
.practice-now-copy strong { color: var(--text); }
.practice-now-media { border-radius: 3px; border: 2px solid var(--text); }
.topbar h1.record-mode-head {
  display: flex; min-width: 0; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; line-height: 1.12; white-space: normal;
}
.record-mode-head > span { font-size: 15px; font-weight: 820; letter-spacing: .02em; }
.record-mode-head > small {
  display: block; max-width: 100%; overflow: hidden; color: var(--muted); font-size: 10px;
  font-weight: 650; letter-spacing: .01em; text-overflow: ellipsis; white-space: nowrap;
}
.run-start-btn {
  display: flex; width: 100%; min-height: 154px; margin: 0 0 18px; padding: 14px 18px;
  flex-direction: column; align-items: center; justify-content: center;
  border: 2px solid var(--run-shu-edge); border-radius: 7px;
  background: var(--run-shu); color: #fff;
  box-shadow: 0 7px 0 var(--run-shu-edge), 0 12px 20px rgba(69,26,21,.22);
  text-align: center; transition: transform .12s ease, box-shadow .12s ease;
}
.run-start-btn small {
  color: rgba(255,255,255,.78); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px; font-weight: 900; letter-spacing: .18em;
}
.run-start-number {
  display: block; margin: 2px 0 0; font-size: 35px; line-height: 1.08;
  font-weight: 900; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.run-start-btn strong { display: block; margin: 2px 0 1px; font-size: 19px; line-height: 1.25; font-weight: 880; }
.run-start-total { margin-top: 4px; font-size: 13px; font-weight: 800; }
.run-start-countdown { font-size: 11px; font-weight: 650; opacity: .76; }
.run-start-btn:not(:disabled):active {
  opacity: 1; transform: translateY(4px); box-shadow: 0 3px 0 var(--run-shu-edge), 0 6px 12px rgba(69,26,21,.18);
}
.run-start-btn.active {
  cursor: default; border-color: var(--run-shu); background: var(--card); color: var(--text);
  box-shadow: inset 7px 0 0 var(--run-shu), 0 4px 0 var(--paper-shadow);
}
.run-start-btn.active small { color: var(--run-shu); }
.run-start-btn.active .run-start-number { color: var(--run-shu); font-size: 39px; }
.run-start-btn.active .run-start-total, .run-start-btn.active .run-start-countdown { color: var(--muted); }
.run-start-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.runbar .stat { border: 1px solid var(--sep); border-radius: 4px; background: var(--card); box-shadow: 0 2px 0 var(--paper-shadow); }
.openrun-note, .gap-note { border: 1px dashed var(--accent); border-radius: 4px; }
.record-result-btn { margin-top: -2px; margin-bottom: 25px; }
.clean-btn:disabled {
  cursor: default; border-color: var(--sep); background: var(--card2); color: var(--muted);
  opacity: 1; box-shadow: 0 4px 0 var(--paper-shadow);
}
.step-list { margin: 0 -14px 6px; }
.step-btn { padding: 10px 14px; border-bottom: 1px dashed var(--sep); }
.step-btn .no { color: var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 750; }
.step-btn.now { background: var(--ok-tint); box-shadow: inset 7px 0 0 var(--ok); }
.part-loop-track, .trim-track {
  border: 1px solid var(--sep); border-radius: 4px;
  background-color: var(--card2);
  background-image: repeating-linear-gradient(90deg, transparent 0 19px, var(--sep) 19px 20px);
}
.part-loop-range, .trim-track .range { border-radius: 2px; }
.part-loop-handle { border-radius: 4px; border-color: var(--card); box-shadow: 0 3px 0 var(--paper-shadow); }
.part-point { border-bottom-style: dashed; }

/* 通し開始の確認。数字を大きくし、演技位置からでも判読できる。 */
.run-confirm-note { margin: 4px 0 14px; padding: 11px 12px; border-left: 5px solid var(--blue); background: var(--card); }
.run-confirm-note > div { display: grid; grid-template-columns: 65px minmax(0,1fr); gap: 8px; padding: 4px 0; }
.run-confirm-note span { color: var(--muted); font-size: 11px; }
.run-confirm-note b { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.run-camera-confirm {
  margin: 0 0 14px; padding: 12px; border: 1px solid var(--sep); border-radius: 5px;
  background: var(--card); box-shadow: 0 3px 0 var(--paper-shadow);
}
.run-camera-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.run-camera-head > div { display: flex; min-width: 0; flex-direction: column; }
.run-camera-head b { font-size: 15px; }
.run-camera-head span, .run-camera-confirm > small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.run-video-capacity { flex-shrink: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.run-camera-profile {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 0 0 10px;
}
.run-camera-profile button {
  min-height: 42px; padding: 7px 9px; border: 1px solid var(--sep); border-radius: 4px;
  background: var(--paper); color: var(--muted); font: inherit; font-size: 12px; font-weight: 800;
  box-shadow: 0 3px 0 var(--paper-shadow);
}
.run-camera-profile button.selected {
  border-color: var(--run-shu-edge); background: var(--accent-tint); color: var(--accent);
  box-shadow: inset 4px 0 0 var(--run-shu), 0 3px 0 var(--paper-shadow);
}
.run-camera-profile-guide {
  margin: -2px 2px 10px; color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1.55;
}
.run-camera-orientation {
  display: flex; min-height: 54px; margin: 0 0 10px; padding: 8px 10px; align-items: center; gap: 10px;
  border: 1px solid var(--sep); border-left: 5px solid var(--ok); border-radius: 4px; background: #eef1e8;
}
.run-camera-orientation[hidden] { display: none; }
.run-camera-orientation > span {
  display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center;
  border: 1px solid currentColor; border-radius: 50%; font-size: 20px; font-weight: 900;
}
.run-camera-orientation > div { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.run-camera-orientation b { font-size: 12px; }
.run-camera-orientation small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.run-camera-orientation.is-blocked {
  border-color: #c78367; border-left-color: var(--run-shu); background: #fff0e8; color: var(--accent);
}
.run-camera-orientation.is-ready { color: #426b48; }
.run-camera-preview {
  display: block; width: min(360px, 100%); aspect-ratio: var(--run-camera-aspect, 4/3); margin: 0 auto 10px;
  border: 2px solid var(--text); border-radius: 4px; background: #090909; object-fit: cover;
  transform: scaleX(-1);
}
.run-camera-confirm .btn { min-height: 46px; margin: 0 0 8px; }
.run-camera-status { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 750; text-align: center; }
.run-confirm-count {
  display: flex; min-height: 180px; margin: 0 0 14px; padding: 12px 10px 11px;
  align-items: center; justify-content: center;
  flex-direction: column; border: 2px solid var(--sheet-accent-edge); border-radius: 5px;
  background: var(--accent-tint); box-shadow: 0 4px 0 var(--paper-shadow);
}
.run-confirm-order {
  display: block; margin-bottom: 5px;
  color: var(--text); font-size: 25px; line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums;
}
.run-confirm-count > span { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .18em; }
.run-confirm-adjust {
  display: grid; grid-template-columns: 48px 90px 48px; align-items: center; gap: 7px; margin: 5px 0 2px;
}
.run-confirm-adjust button {
  width: 48px; height: 48px; border: 1px solid var(--sheet-accent-edge); border-radius: 5px;
  background: var(--card); color: var(--text); font-size: 27px; font-weight: 800;
  box-shadow: 0 4px 0 var(--paper-shadow);
}
.run-confirm-adjust button:active { opacity: 1; transform: translateY(3px); box-shadow: 0 1px 0 var(--paper-shadow); }
.run-confirm-adjust strong { text-align: center; font-size: 34px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.run-confirm-count > small { color: var(--muted); font-size: 11px; }
.run-confirm-count > em { margin-top: 4px; color: var(--muted); font-size: 9px; font-style: normal; }
.run-confirm-btn {
  min-height: 64px; border: 2px solid var(--run-shu-edge); background: var(--run-shu) !important;
  color: #fff !important; font-size: 20px; box-shadow: 0 5px 0 var(--run-shu-edge);
}
.run-confirm-btn:active { opacity: 1; transform: translateY(3px); box-shadow: 0 2px 0 var(--run-shu-edge); }
.run-video-live {
  display: flex; min-height: 96px; margin: 0 0 10px; padding: 8px 11px; align-items: center; gap: 11px;
  border: 1px solid #9d3430; border-radius: 4px; background: #fff2ee; color: #8d2825;
  font-variant-numeric: tabular-nums;
}
.run-video-live-dot { width: 10px; height: 10px; border-radius: 50%; background: #c83f38; box-shadow: 0 0 0 3px rgba(200,63,56,.14); }
.run-camera-live-preview {
  flex: 0 0 auto; width: 96px; aspect-ratio: var(--run-camera-aspect, 4/3); border: 1px solid #7f2c29; border-radius: 3px;
  background: #090909; object-fit: cover; transform: scaleX(-1);
}
.run-video-live-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 7px; }
.run-video-live-copy > div { display: flex; align-items: center; gap: 8px; }
.run-video-live b { font-size: 13px; letter-spacing: .08em; }
.run-video-live-copy > div > span:not(.run-video-live-dot) { font-size: 15px; font-weight: 850; }
.run-video-live small { color: #8d5c59; font-size: 10px; }
.run-video-stopped {
  display: grid; grid-template-columns: auto minmax(0, 1fr); margin: 0 0 10px; padding: 9px 11px; align-items: center; gap: 7px 9px;
  border: 1px solid var(--sep); border-radius: 4px; background: var(--card); color: var(--muted);
}
.run-video-stopped > span { color: var(--accent); font-size: 13px; }
.run-video-stopped > div { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.run-video-stopped b { color: var(--text); font-size: 12px; }
.run-video-stopped small { font-size: 10px; line-height: 1.45; }
.run-video-stopped .run-video-instant-preview {
  grid-column: 1 / -1; width: 100%; min-height: 46px; margin: 2px 0 0; padding: 8px 12px;
  border-color: color-mix(in srgb, var(--accent) 72%, #000); background: var(--accent); color: var(--on-accent);
  font-size: 14px; font-weight: 850;
}
.run-video-review {
  display: block; width: min(460px, 100%); aspect-ratio: var(--run-camera-aspect, 4/3); margin: 10px auto 12px;
  border: 2px solid var(--text); border-radius: 4px; background: #000; object-fit: contain;
}
.run-video-audio-sync {
  display: flex; margin: 0 auto 12px; padding: 9px 10px; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid #9aa58d; border-left: 5px solid var(--ok); border-radius: 4px;
  background: #eef1e8; color: var(--text);
}
.run-video-audio-sync > div { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 2px; }
.run-video-audio-sync b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.run-video-audio-sync span { color: var(--muted); font-size: 10px; line-height: 1.45; }
.run-video-audio-sync .btn { width: auto; min-height: 38px; margin: 0; padding: 6px 9px; flex-shrink: 0; }
.run-video-audio-sync.is-video-only, .run-video-audio-sync.is-missing {
  display: flex; flex-direction: column; align-items: flex-start; border-color: var(--sep); border-left-color: var(--muted); background: var(--card);
}
.run-video-audio-sync.is-missing { border-left-color: var(--accent); }
.run-video-audio-sync[hidden], .run-video-audio-sync .btn[hidden] { display: none; }
.run-video-sync-adjust {
  margin: 0 auto 12px; padding: 10px 12px; border: 1px solid var(--sep); border-left: 5px solid var(--sheet-tab-rust);
  border-radius: 4px; background: var(--paper-header);
}
.run-video-sync-adjust-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.run-video-sync-adjust-head > div { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.run-video-sync-adjust-head b { font-size: 12px; }
.run-video-sync-adjust-head span, .run-video-sync-adjust > small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.run-video-sync-adjust output {
  min-width: 58px; padding: 4px 6px; border: 1px solid var(--sep); border-radius: 3px; background: var(--card);
  color: var(--accent); font-size: 12px; font-weight: 850; text-align: center; font-variant-numeric: tabular-nums;
}
.run-video-sync-adjust input[type="range"] { width: 100%; min-height: 38px; margin: 4px 0 0; accent-color: var(--accent); }
.run-video-sync-adjust-scale { display: flex; justify-content: space-between; gap: 8px; margin-top: -3px; color: var(--muted); font-size: 9px; }
.run-video-sync-adjust > small { display: block; margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--sep); }
.run-video-save-note { margin: 0 0 9px; color: var(--muted); font-size: 12px; text-align: center; font-weight: 750; }
.run-video-compose-intro {
  display: flex; margin: 0 auto 10px; padding: 9px 10px; flex-direction: column; gap: 3px;
  border: 1px solid #9aa58d; border-left: 5px solid var(--ok); border-radius: 4px; background: #eef1e8;
}
.run-video-compose-intro b { font-size: 12px; }
.run-video-compose-intro span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.run-video-compose-intro.is-warning { border-color: #c78367; border-left-color: var(--run-shu); background: #fff0e8; }
.run-video-compose-progress { padding: 6px 0 0; text-align: center; }
.run-video-compose-mark {
  display: grid; width: min(250px, 78%); margin: 2px auto 18px; grid-template-columns: 44px minmax(30px, 1fr) 44px;
  align-items: center; color: var(--blue);
}
.run-video-compose-mark span {
  display: grid; width: 44px; height: 44px; place-items: center; border: 2px solid currentColor; border-radius: 4px;
  background: var(--card); font-size: 16px; font-weight: 900; box-shadow: 0 3px 0 var(--paper-shadow);
}
.run-video-compose-mark i { position: relative; height: 2px; background: var(--sep); overflow: hidden; }
.run-video-compose-mark i::after {
  position: absolute; width: 38%; height: 100%; content: ""; background: var(--run-shu);
  animation: run-video-compose-move 1.25s ease-in-out infinite alternate;
}
@keyframes run-video-compose-move { from { transform: translateX(-2%); } to { transform: translateX(168%); } }
.run-video-compose-head > span, .run-video-compose-error > span {
  color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .15em;
}
.run-video-compose-head h3, .run-video-compose-error h3 { margin: 5px 0 5px; }
.run-video-compose-head p, .run-video-compose-error p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.run-video-compose-meter {
  margin: 18px 0 12px; padding: 11px 12px; border: 1px solid var(--sep); border-left: 5px solid var(--blue);
  border-radius: 4px; background: var(--card); text-align: left;
}
.run-video-compose-meter > div { display: flex; margin-bottom: 8px; align-items: baseline; justify-content: space-between; gap: 12px; }
.run-video-compose-meter output { color: var(--accent); font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.run-video-compose-meter span { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.run-video-compose-meter progress {
  display: block; width: 100%; height: 14px; border: 1px solid var(--sep); border-radius: 2px; overflow: hidden;
  appearance: none; background: var(--paper);
}
.run-video-compose-meter progress::-webkit-progress-bar { background: var(--paper); }
.run-video-compose-meter progress::-webkit-progress-value { background: var(--run-shu); }
.run-video-compose-meter progress::-moz-progress-bar { background: var(--run-shu); }
.run-video-compose-note {
  display: flex; margin: 0 0 13px; padding: 9px 10px; flex-direction: column; gap: 3px; text-align: left;
  border-left: 4px solid var(--sheet-tab-rust); background: var(--paper-header);
}
.run-video-compose-note b { font-size: 11px; }
.run-video-compose-note span { color: var(--muted); font-size: 9px; line-height: 1.55; }
.run-video-compose-error { padding-top: 8px; text-align: center; }
.run-video-compose-error small {
  display: block; margin: 12px 0; padding: 7px 9px; border: 1px dashed var(--sep); color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px;
}
.run-video-replace-list { display: grid; gap: 8px; margin: 12px 0; }
.run-video-replace-row, .run-video-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--sep);
}
.run-video-replace-row > div, .run-video-row > div { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 3px; }
.run-video-replace-row b, .run-video-row b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.run-video-replace-row span, .run-video-row span { color: var(--muted); font-size: 10px; }
.run-video-replace-row .btn, .run-video-row .btn { width: auto; margin: 0; flex-shrink: 0; }
.run-video-markers { margin: 8px 0 12px; }
.run-video-current-step{display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px 10px;margin:8px 0 12px;padding:9px 10px;border:1px solid var(--sep);border-left:6px solid var(--sheet-tab-rust);background:var(--card)}
.run-video-current-step span{grid-row:1/3;align-self:center;color:var(--accent);font-size:10px;font-weight:850}
.run-video-current-step strong{overflow:hidden;font-size:15px;line-height:1.3;text-overflow:ellipsis;white-space:nowrap}
.run-video-current-step small{color:var(--muted);font-size:10px}
.run-video-library-card { padding-top: 16px; }
.run-video-library-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.run-video-library-heading h2 { margin: 0; }
.run-video-library-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.run-video-library-heading > strong {
  flex-shrink: 0; padding: 6px 9px; border: 1px solid var(--text); border-radius: 3px;
  background: var(--paper-header); font-size: 16px; font-variant-numeric: tabular-nums;
}
.run-video-library-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin: 13px 0 5px; }
.run-video-library-slots i { height: 7px; border: 1px solid #8b8c86; border-radius: 1px; background: var(--card2); }
.run-video-library-slots i.used { border-color: #2f3d4e; background: #2f3d4e; }
.run-video-library-size { color: var(--muted); font-size: 10px; text-align: right; }
.run-video-library-storage-note {
  margin: 9px 0 0; padding: 8px 10px; border-left: 3px solid #2f3d4e;
  background: color-mix(in srgb, var(--paper-header) 72%, transparent);
  color: var(--muted); font-size: 10px; line-height: 1.55;
}
.run-video-storage-actions {
  display: grid; gap: 9px; margin: 15px 0 8px; padding: 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, var(--sep)); border-radius: 5px;
  background: color-mix(in srgb, var(--danger) 4%, var(--card));
}
.run-video-storage-actions > div { display: flex; flex-direction: column; gap: 3px; }
.run-video-storage-actions b { color: var(--text); font-size: 13px; }
.run-video-storage-actions span, .run-video-storage-actions small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.run-video-storage-actions .btn.danger-ghost {
  width: 100%; min-height: 46px; margin: 0; border: 1px solid color-mix(in srgb, var(--danger) 58%, var(--sep));
  background: var(--card); font-size: 14px; font-weight: 820;
}
.run-video-library-list { margin-top: 9px; border-top: 1px solid var(--sep); }
.run-video-library-row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 13px 0; border-bottom: 1px solid var(--sep);
}
.run-video-library-number { align-self: stretch; display: grid; place-items: center; border-right: 4px solid #2f3d4e;
  color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.run-video-library-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.run-video-library-copy b { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.run-video-library-copy span, .run-video-library-copy small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.run-video-library-actions { display: flex; align-items: center; gap: 6px; }
.run-video-library-actions .btn { width: auto; min-width: 66px; margin: 0; }
.run-video-library-scope { margin: -1px 0 8px; color: var(--muted); font-size: 10px; font-weight: 720; }
.btn.storage-manage-btn { min-height: 44px; margin: 12px 0 7px; font-size: 14px; }
@media (max-width: 390px) {
  .run-video-library-row { grid-template-columns: 24px minmax(0, 1fr); }
  .run-video-library-actions { grid-column: 2; justify-content: flex-end; }
}
.practice-choice-head { margin: 2px 2px 17px; }
.practice-choice-head > small { display: block; margin-bottom: 4px; color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; font-weight: 850; letter-spacing: .1em; }
.practice-choice-head h3 { margin-bottom: 5px !important; }
.practice-choice-head p { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.practice-choice-list { display: grid; gap: 10px; margin-bottom: 14px; }
.practice-choice-button {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  width: 100%; min-height: 82px; padding: 13px 14px 12px 17px; text-align: left;
  border: 1px solid var(--sep); border-left: 7px solid var(--blue); border-radius: 5px;
  background: var(--card); color: var(--text); box-shadow: 0 4px 0 var(--paper-shadow);
}
.practice-choice-button.primary { border-left-color: var(--accent); background: var(--accent); color: var(--on-accent);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 62%, #302218); }
.practice-choice-button span { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.practice-choice-button b { font-size: 17px; line-height: 1.2; }
.practice-choice-button small { color: inherit; font-size: 11px; line-height: 1.45; opacity: .72; }
.practice-choice-button i { font-style: normal; font-size: 25px; line-height: 1; }
.practice-choice-button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--paper-shadow); }
.practice-choice-button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.card-count { float: right; color: var(--muted); font-size: 10px; font-weight: 700; }
.run-countdown-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  background: rgba(24,25,23,.94);
}
.run-countdown-card {
  display: flex; width: min(420px, 100%); min-height: min(470px, 72vh); padding: 34px 22px 25px;
  align-items: center; justify-content: center; flex-direction: column;
  border: 2px solid var(--sep); border-top: 10px solid var(--blue); border-radius: 7px;
  background-color: var(--sheet-bg);
  background-image: repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px);
  box-shadow: 0 10px 0 #171916, 0 24px 60px rgba(0,0,0,.46); text-align: center;
}
.run-countdown-card > small {
  color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; font-weight: 900; letter-spacing: .12em;
}
.run-countdown-order {
  display: block; margin-bottom: 8px; color: var(--text); font-size: 30px; line-height: 1;
  font-weight: 900; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.run-countdown-card > strong {
  display: block; margin: 8px 0; color: var(--text); font-size: clamp(88px, 30vw, 150px);
  line-height: .95; font-weight: 900; letter-spacing: -.07em; font-variant-numeric: tabular-nums;
}
.run-countdown-card.go > strong { color: var(--ok); font-size: clamp(56px, 19vw, 96px); letter-spacing: .02em; }
.run-countdown-card > span { max-width: 100%; overflow: hidden; font-size: 15px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.run-countdown-card > button {
  min-width: 150px; min-height: 44px; margin-top: 32px; border: 1px solid var(--sep); border-radius: 5px;
  background: var(--card); color: var(--muted); font-size: 13px; font-weight: 700; box-shadow: 0 3px 0 var(--paper-shadow);
}

/* 編集 = 紙片をつかんで綴じ直す。ハンドルを綴じ代として明確化 */
.card:has(> .editor-step) { padding: 5px 9px 12px; background: rgba(248,244,233,.38); }
.editor-step {
  margin: 10px 0; padding: 11px 9px 12px 58px; border: 1px solid var(--sep) !important;
  border-radius: 4px; background: var(--card); box-shadow: 0 3px 0 var(--paper-shadow);
}
.editor-step[data-line-color]::before { content: ""; position: absolute; z-index: 1; inset: -1px auto -1px -1px;
  width: 7px; border-radius: 4px 0 0 4px; background: var(--line-color); }
.editor-step .es-lead { left: 0; top: 8px; bottom: 8px; width: 44px; max-height: none; }
.step-line-color-open { position: relative; width: 44px; min-height: 40px; padding: 0; border: 0;
  border-radius: 0 8px 8px 0; background: transparent; box-shadow: none; touch-action: manipulation; }
.step-line-color-open::before { content: ""; position: absolute; inset: 4px auto 4px 0; width: 31px;
  border-radius: 0 8px 8px 0; background: var(--line-color, var(--blue));
  box-shadow: 1px 1px 0 color-mix(in srgb, var(--line-color) 58%, var(--paper-shadow)); }
.editor-step .step-line-color-open .no { position: relative; z-index: 1; display: block; width: 31px; color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; font-weight: 850; text-align: center; }
.step-line-color-open:active { opacity: 1; transform: none; background: color-mix(in srgb, var(--line-color) 11%, transparent); }
.step-line-color-open:focus-visible { outline: 3px solid var(--line-color, var(--blue)); outline-offset: 2px; }
.drag-handle {
  width: 44px; min-height: 66px; padding: 8px 3px; border: 0; border-radius: 0;
  background: transparent; color: var(--muted); box-shadow: none;
}
.drag-handle:active { background: transparent; color: var(--muted); box-shadow: none; transform: none; }
.editor-step.dragging { background: var(--card); box-shadow: 0 12px 26px rgba(0,0,0,.28); transform: rotate(-.4deg); }
.editor-step.now { border-color: var(--ok) !important; box-shadow: inset 6px 0 0 var(--ok), 0 3px 0 var(--paper-shadow); }
.editor-step .cue-input:not(.locked) { box-shadow: inset 3px 0 0 var(--sheet-tab-rust); }
.cue-position-actions{display:inline-flex;gap:5px}
.editor-step .cue-fit{width:38px;height:34px;padding:0;color:var(--blue);font-size:9px;font-weight:900;letter-spacing:.05em}
.cue-interval-alert{display:flex;flex-wrap:wrap;align-items:center;margin:-4px 10px -4px 58px;padding:5px 6px;border-radius:3px;font-size:10px;font-weight:750}
.cue-interval-alert>span{flex:1}
.cue-interval-alert.gap{border-color:var(--warn);background:rgba(161,107,25,.09);color:var(--warn)}
.cue-interval-alert.overlap{border-color:var(--danger);background:rgba(181,72,63,.09);color:var(--danger)}
.cue-interval-dismiss{margin-left:auto;width:26px;height:26px;padding:0;border:0;background:transparent;color:currentColor;box-shadow:none}
.cue-gap-actions,.cue-overlap-actions{display:flex;width:100%;gap:4px;margin-top:3px}
.cue-gap-actions button,.cue-overlap-actions button{flex:1;min-height:27px;padding:2px;border:1px solid currentColor;border-radius:3px;background:rgba(248,244,233,.58);color:inherit;font-size:9px;font-weight:750;box-shadow:0 2px 0 var(--paper-shadow)}
.cue-overlap-actions button{min-height:31px;font-size:10px;font-weight:800}
.kind-toggle, .risk-select, .mini-btn { border-radius: 4px; }
.mini-btn.play, .video-play-btn, .video-trim-btn { border-radius: 5px !important; box-shadow: 0 3px 0 var(--paper-shadow) !important; }
.es-opt { padding-left: 7px; border-left: 3px solid var(--blue); }

.music-row > .music-pill, .music-row > .music-btn {
  align-self: center; display: inline-flex; align-items: center; justify-content: center;
  height: 44px; min-height: 44px; margin: 0; box-sizing: border-box;
}
.music-row > .music-btn.text { width: 70px; padding-inline: 8px; }
.music-row > .music-volume-control { flex: 0 0 70px; width: 70px; }
.music-row > .music-volume-control > summary { width: 100%; height: 44px; margin: 0; }

/* 分析 / 履歴 = 実施後に残った書き込み。数字はスタンプ、事象は追記メモ */
.stat-overview { gap: 8px; }
.stat-box { padding: 12px 6px; border-top-width: 3px; }
.stat-box .v { color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.stat-box .l { color: var(--muted); font-weight: 700; }
.step-stat { padding: 13px 2px; border-bottom: 1px dashed var(--sep); }
.note-caveat { border-top-color: var(--sheet-tab-rust); }
.run-block { margin: 12px 0; padding: 12px; border: 1px solid var(--sep); border-left: 6px solid var(--blue); background: rgba(248,244,233,.46); }
.ev-row { border: 1px dashed var(--sep); border-radius: 3px; background: var(--card2); }
.bd-row { border-bottom-style: dashed; }

/* 技・音源・タイムライン = 差し替え可能なインデックスカード */
.trick-row, .rec-row, .bi-row, .pick-trick-row {
  margin: 9px 0; padding: 10px; border: 1px solid var(--sep); border-left: 6px solid var(--blue);
  border-radius: 4px; background: color-mix(in srgb, var(--card) 92%, transparent);
  box-shadow: 0 2px 0 var(--paper-shadow);
}
.trick-row[data-line-color], .pick-trick-row[data-line-color] { border-left-color: var(--line-color); }
.trick-row[data-line-color] { position: relative; }
.trick-row[data-line-color] > .head { padding-left: 27px; }
.rec-row { border-left-color: var(--sheet-tab-rust); }
.trick-row:last-child, .rec-row:last-child, .bi-row:last-of-type, .pick-trick-row:last-of-type { border-bottom: 1px solid var(--sep); }
.bi-row.current { border-color: var(--ok); box-shadow: inset 5px 0 0 var(--ok), 0 2px 0 var(--paper-shadow); }
.trick-video, .trick-video.main { border: 2px solid var(--text); border-radius: 4px; }

/* 設定・モーダルも同じ綴じ具として扱う */
.set-row + .set-row { border-top-style: dashed; }
.routine-menu-toggle-list { border-radius: 4px; background: var(--card); box-shadow: 0 3px 0 var(--paper-shadow); }
.segmented { border: 1px solid var(--sep); border-radius: 5px; background: var(--card2); }
.segmented .choice { border: 0; border-radius: 3px; box-shadow: none; }
.segmented .choice.selected { background: var(--card); color: var(--text); box-shadow: 0 2px 0 var(--paper-shadow); }
#sheet-backdrop { background: rgba(24,25,23,.58); }
#sheet {
  background-color: var(--sheet-bg); color: var(--text);
  background-image:
    linear-gradient(90deg, transparent 0 29px, var(--paper-margin) 29px 30px, transparent 30px),
    repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px);
  border: 1px solid var(--sep); border-top: 8px solid var(--blue); border-radius: 7px 7px 0 0;
  padding-left: 30px; box-shadow: 0 -9px 0 color-mix(in srgb, var(--paper-shadow) 75%, transparent), 0 -20px 50px rgba(0,0,0,.28);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
/* 動画確認は赤い帳面罫線を外し、左右を同じ余白にして映像・操作系を中央軸へ揃える。 */
#sheet.trim-sheet {
  padding-left: 24px; padding-right: 24px;
  scrollbar-width: none;
  background-image: repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px);
}
#sheet.trim-sheet::-webkit-scrollbar { width: 0; height: 0; }
.grabber { height: 4px; border-radius: 0; background: var(--blue); }
#toast {
  background: var(--paper-rail); color: #fff; border: 1px solid var(--paper-hole); border-radius: 4px;
  box-shadow: 0 4px 0 rgba(0,0,0,.35); backdrop-filter: none; -webkit-backdrop-filter: none;
}

/* 下部バーは用紙の下端に留めたクリップボード */
.bottombar {
  left: 50%; right: auto; width: min(560px, 100%); transform: translateX(-50%);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: var(--paper-header); border-top: 2px solid var(--text); box-shadow: 0 -5px 0 rgba(35,38,44,.09);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.bottombar button { border: 1px solid var(--sep); border-radius: 5px; background: var(--card); box-shadow: 0 3px 0 var(--paper-shadow); }

/* スキンは別レイアウトにせず、紙・インク・タブ・罫線の素材違いとして残す */
body[data-theme="wa"] {
  --paper-rail: #563a22; --paper-hole: #c6ad75; --paper-header: #eee4cf;
  --paper-line: rgba(143,111,58,.13); --paper-margin: rgba(165,67,43,.2); --paper-shadow: #c9b995;
}
body[data-theme="wa"] #app:not(:has(> .home-simple-shell)) {
  background-color: #eee4cf; background-image: var(--wa-paper),
    repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px);
}
body[data-theme="wa"] #app:not(:has(> .home-simple-shell)) > .topbar,
body[data-theme="wa"] .bottombar {
  background-color: #573a20; background-image: var(--wa-wood); color: #f6efdd; border-color: rgba(190,155,85,.7);
}
body[data-theme="wa"] .topbar h1 { color: #f6efdd; }
body[data-theme="wa"] .back-btn, body[data-theme="wa"] .nav-action,
body[data-theme="wa"] .routine-menu-btn { background: rgba(246,241,228,.12); color: #efd9ad; border-color: rgba(239,217,173,.45); }

body[data-theme="cyber"] {
  --paper-rail: #030507; --paper-hole: #00a7ba; --paper-header: #081018;
  --paper-line: rgba(0,229,255,.085); --paper-margin: rgba(255,46,110,.22); --paper-shadow: #001e26;
}
body[data-theme="cyber"] #app:not(:has(> .home-simple-shell)) {
  background-color: #080d13;
  background-image:
    repeating-linear-gradient(90deg, transparent 0 29px, var(--paper-line) 29px 30px),
    repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px);
}
body[data-theme="cyber"] #app:not(:has(> .home-simple-shell)) > .topbar,
body[data-theme="cyber"] .bottombar { background: #081018; border-color: var(--accent); }
body[data-theme="cyber"] .card, body[data-theme="cyber"] .stat-box,
body[data-theme="cyber"] .practice-now, body[data-theme="cyber"] .editor-step { box-shadow: 0 3px 0 #00323b; }

body[data-theme="matte"] {
  --paper-rail: #343c45; --paper-hole: #b8c0c7; --paper-header: #f7f7f4;
  --paper-line: rgba(71,96,122,.08); --paper-margin: rgba(192,57,43,.13); --paper-shadow: #d7d7d1;
}
body[data-theme="matte"] #app:not(:has(> .home-simple-shell)) { background-color: #f7f7f4; }
body[data-theme="matte"] #app:not(:has(> .home-simple-shell)) > .topbar,
body[data-theme="matte"] .bottombar { background: #f7f7f4; }

@media (max-width: 350px) {
  #app:not(:has(> .home-simple-shell)) { padding-inline: 10px; }
  #app:not(:has(> .home-simple-shell)) > .topbar { margin-inline: -10px; }
  .bottombar { padding-inline: 10px; gap: 7px; }
  .topbar:has(.back-btn) { grid-template-columns: 48px minmax(0, 1fr) minmax(93px, auto); gap: 5px; }
  .topbar:has(.back-btn):has(.routine-head-actions.global-only) { grid-template-columns: 48px minmax(0, 1fr) 44px; }
  .topbar:has(.back-btn) h1 { font-size: 15px; }
  .back-btn { padding-inline: 4px; font-size: 11px; }
  .back-btn::before { font-size: 21px; }
  .routine-head-actions { min-width: 93px; gap: 3px; }
  .routine-head-actions.global-only { min-width: 44px; }
  .head-settings-btn { width: 44px; }
  .card { padding-inline: 10px; }
  .routine-row .actions .btn.small { padding-inline: 7px; font-size: 14px; }
  .editor-step { padding-left: 54px; padding-right: 7px; }
  .editor-step .es-row2 { gap: 4px; row-gap: 8px; }
  .editor-step .es-time-stack { min-width: 58px; }
  .editor-step .cue-input { width: 58px; }
  .es-opt { margin-left: 20px; gap: 5px; }
  .es-opt input[type=text] { padding-inline: 7px; font-size: 13px; }
  .music-btn.text { padding-inline: 5px; font-size: 11px; }
  .music-row { gap: 6px; }
  .music-row .music-pill.primary { padding-inline: 10px !important; }
  .music-row > .music-btn.text { width: 52px; }
  .music-row > .music-volume-control { flex-basis: 52px; width: 52px; }
  .music-volume-control > summary { width: 100%; }
  .music-volume-popover { grid-template-columns: 16px minmax(120px, 180px) 16px; }
  .stat-overview { grid-template-columns: 1fr; }
  .run-start-btn { min-height: 144px; padding-inline: 12px; }
  .run-start-number { font-size: 30px; }
  .run-start-btn.active .run-start-number { font-size: 34px; }
  .run-start-btn strong { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .clean-btn, .choice, .kind-toggle, .mini-btn, .music-btn, .music-pill,
  .opt-chip, .tag, .back-btn, .nav-action, .head-settings-btn, .run-start-btn { transition: none; }
  .loading-motion i, .loading-track span, .practice-video-loading::before { animation: none; }
  .loading-motion i { opacity: 1; }
  .loading-track span { left: 31%; }
}
