/* ==========================================================
   GUTS CAMERA  スタイル
   配色：背景 #0B0B0B / カード #1C1C1E / 文字 #FFFFFF
         補助文字 #A0A0A0 / アクセント #DFFF00
   ========================================================== */
:root {
  --bg: #0B0B0B;
  --card: #1C1C1E;
  --card-2: #2A2A2D;
  --line: #333336;
  --text: #FFFFFF;
  --sub: #A0A0A0;
  --accent: #DFFF00;
  --danger: #FF453A;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
[hidden] { display: none !important; }

button, select, input, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}
button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
input, textarea { -webkit-user-select: text; user-select: text; }
svg { display: block; }
/* ファイル選択は見えない状態で置く（display:none だと古いSafariで開けない場合があるため） */
.file-input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- 画面の共通レイアウト ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.screen.is-active { display: flex; }

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 max(16px, var(--sar)) calc(24px + var(--sab)) max(16px, var(--sal));
}
.scroll.pad { padding-top: 12px; }

.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(var(--sat) + 6px) max(8px, var(--sar)) 6px max(8px, var(--sal));
  min-height: calc(var(--sat) + 56px);
}
.bar-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}
.bar-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.200; stroke-linecap: round; stroke-linejoin: round; }
.bar-btn:active { background: var(--card); }
.bar-title {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-spacer { flex: none; width: 44px; }
.bar-action {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  background: var(--accent);
  color: #0B0B0B;
  font-size: 14px;
  font-weight: 700;
}

/* ---------- ホーム ---------- */
.home-head {
  padding: calc(var(--sat) + 40px) 4px 28px;
}
.logo {
  margin: 0;
  font-family: "Avenir Next Condensed", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(38px, 12vw, 52px);
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1;
}
.logo span { color: var(--accent); }
.logo-sub {
  margin: 10px 0 0;
  padding-left: 2px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.32em;
}
.menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.menu-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 148px;
  padding: 18px 16px 16px;
  border-radius: 20px;
  background: var(--card);
  text-align: left;
}
.menu-item:active { background: var(--card-2); }
.menu-item svg {
  width: 44px;
  height: 44px;
  margin-bottom: auto;
  fill: none;
  stroke: var(--text);
  stroke-width: 2.400;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.menu-label { font-size: 19px; font-weight: 700; }
.menu-desc { font-size: 12px; color: var(--sub); }
.menu-item.is-primary { background: var(--accent); color: #0B0B0B; }
.menu-item.is-primary:active { background: #C9E600; }
.menu-item.is-primary svg { stroke: #0B0B0B; }
.menu-item.is-primary .menu-desc { color: rgba(11, 11, 11, 0.68); }

.home-foot { padding: 28px 4px 0; }
.foot-line { margin: 0 0 8px; color: var(--sub); font-size: 12px; line-height: 1.6; }
.foot-ver { margin: 16px 0 0; color: #5c5c60; font-size: 11px; letter-spacing: 0.08em; }
.diag-strip { position: fixed; left: 0; right: 0; top: 100%; z-index: 99; height: 160px; background: #FF00FF; color: #000; font-size: 14px; font-weight: 700; text-align: center; line-height: 40px; }

/* ---------- 撮影・取り込み ---------- */
.field-label { margin: 8px 2px 8px; color: var(--sub); font-size: 13px; font-weight: 600; }
.hint { margin: 8px 2px 20px; color: var(--sub); font-size: 13px; }

.seg {
  display: flex;
  padding: 3px;
  border-radius: 14px;
  background: var(--card);
}
.seg button {
  flex: 1;
  height: 46px;
  border-radius: 11px;
  color: var(--sub);
  font-size: 16px;
  font-weight: 700;
}
.seg button.is-on { background: var(--text); color: #0B0B0B; }

.big-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 84px;
  margin-bottom: 12px;
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--card);
  text-align: left;
}
.big-btn:active { background: var(--card-2); }
.big-btn svg { flex: none; width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; }
.big-btn b { display: block; font-size: 18px; }
.big-btn small { display: block; margin-top: 2px; color: var(--sub); font-size: 12px; }
.big-btn.is-primary { background: var(--accent); color: #0B0B0B; }
.big-btn.is-primary:active { background: #C9E600; }
.big-btn.is-primary small { color: rgba(11, 11, 11, 0.68); }

.note {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--sub);
  font-size: 13px;
}
.note p { margin: 0; }
.note p + p { margin-top: 6px; }
.note b { color: var(--text); }

/* ---------- アプリ内カメラ ----------
   プレビューを画面の幅いっぱいに表示するため、上の表示と下の操作ボタンは映像の上に重ねる。
   映像は切り取らず全体を表示する（撮れる範囲と見える範囲を一致させる）。
   映像はステータスバーのすぐ下から表示し、下のボタンが映像の下端（足元・ボール）に
   できるだけ重ならないようにする。 */
.camera { background: #000; }
.cam-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(var(--sat) + 56px);
  padding: calc(var(--sat) + 6px) max(8px, var(--sar)) 14px max(8px, var(--sal));
  background: linear-gradient(to bottom, var(--bg) 0, var(--bg) var(--sat), rgba(0, 0, 0, 0.6) var(--sat), rgba(0, 0, 0, 0) 100%);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.cam-info { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 4px; line-height: 1.350; }
#cam-dir { font-size: 15px; font-weight: 700; }
#cam-quality { min-height: 16px; color: #E0E0E0; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ガイド線（構図合わせ用。画面に重ねて表示するだけで、録画には写らない） */
.cam-guide-btn {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: 17px;
  background: rgba(28, 28, 30, 0.82);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-shadow: none;
  white-space: nowrap;
}
.cam-guide-btn[aria-pressed="true"] { background: var(--accent); color: #0B0B0B; }
.camera.is-rec .cam-guide-btn { display: none; }
.cam-guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-guide line { stroke: rgba(255, 255, 255, 0.72); stroke-width: 1; }
.cam-guide line.shade { stroke: rgba(0, 0, 0, 0.3); stroke-width: 2.500; }
/* 構えの目安（後方から撮影するとき）：人の形（黄色いふち＋うすい塗り）・赤い手元の丸・目標（グリーンと旗）。バッテンはほかのガイド線と同じ白い細線 */
.cam-guide .pose-shade { fill: none; stroke: rgba(0, 0, 0, 0.38); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.cam-guide .pose-body { fill: rgba(255, 255, 255, 0.14); stroke: #7C7C7C; stroke-width: 2; stroke-linejoin: round; }
/* 目標へのライン（カメラ → 手元 → 目標）：白い丸点の点線＋動く矢印＋カップに刺さる矢印の先 */
.cam-guide .pose-dots-shade { fill: none; stroke: rgba(0, 0, 0, 0.45); stroke-width: 5.500; stroke-dasharray: 0.1 9; stroke-linecap: round; }
.cam-guide .pose-dots { fill: none; stroke: #fff; stroke-width: 3.500; stroke-dasharray: 0.1 9; stroke-linecap: round; }
.cam-guide .pose-chev-shade { fill: none; stroke: rgba(0, 0, 0, 0.45); stroke-width: 4.500; stroke-linecap: round; stroke-linejoin: round; }
.cam-guide .pose-chev { fill: none; stroke: #fff; stroke-width: 2.500; stroke-linecap: round; stroke-linejoin: round; }
.cam-guide .pose-arrow-tip { fill: #fff; stroke: none; }
.cam-guide .target-label-bg { fill: #FF3B30; stroke: rgba(0, 0, 0, 0.35); stroke-width: 1; }
.cam-guide text.target-label-text { fill: #fff; font-size: 14px; font-weight: 800; stroke: none; paint-order: normal; font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", -apple-system, system-ui, sans-serif; }
.cam-guide path.pose-shade { stroke-width: 4; }
.cam-guide .pose-hands { fill: none; stroke: #DFFF00; stroke-width: 2; }
.cam-guide circle.pose-shade { stroke-width: 4; }
.cam-guide [data-t="target"] .pose-shade { stroke-width: 4.500; }
.cam-guide .pose-green { fill: rgba(70, 200, 95, 0.32); stroke: rgba(166, 240, 122, 0.95); stroke-width: 1.500; }
.cam-guide .pose-cup { fill: rgba(0, 0, 0, 0.55); }
.cam-guide .pose-pole { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.cam-guide .pose-flag { fill: #FF3B30; stroke: rgba(0, 0, 0, 0.4); stroke-width: 1; stroke-linejoin: round; }
.cam-guide .pose-camera { fill: rgba(255, 255, 255, 0.92); stroke: none; }
.cam-guide .pose-camera-lens { fill: #0B0B0B; }
.cam-guide [data-t="camera"] .pose-shade { stroke-width: 2.500; }
/* ①②の札：①手元を合わせる（赤）②構えた手の高さで撮影（黄色）。白い枠が点滅する */
.cam-guide .step-frame { fill: none; stroke: #fff; stroke-width: 3; }
/* ①手元＝蛍光イエロー、②カメラの高さ＝赤（v1.22.1で入れ替え） */
.cam-guide .is-hands .step-bg { fill: #DFFF00; }
.cam-guide .is-height .step-bg, .cam-guide .step-tip { fill: #FF3B30; }
.cam-guide .is-hands .step-num { fill: #0B0B0B; }
.cam-guide .is-height .step-num { fill: #fff; }
.cam-guide text.step-num-text { font-size: 15px; font-weight: 900; stroke: none; paint-order: normal; font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", -apple-system, system-ui, sans-serif; }
.cam-guide .is-hands text.step-num-text { fill: #DFFF00; }
.cam-guide .is-height text.step-num-text { fill: #FF3B30; }
.cam-guide text.step-text { font-weight: 800; stroke: none; paint-order: normal; font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", -apple-system, system-ui, sans-serif; }
.cam-guide .is-hands text.step-text { fill: #0B0B0B; }
.cam-guide .is-height text.step-text { fill: #fff; }
.cam-guide .pose-ripple { fill: none; stroke: #DFFF00; stroke-width: 3; }
.cam-guide .pose-hands.is-pulse { filter: drop-shadow(0 0 6px rgba(223, 255, 0, 0.95)); }
.cam-guide text { fill: rgba(255, 255, 255, 0.9); font-size: 11px; font-weight: 700; paint-order: stroke; stroke: rgba(0, 0, 0, 0.55); stroke-width: 2.500px; }
.cam-timer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  margin-right: 6px;
  padding: 0 12px;
  border-radius: 17px;
  background: rgba(255, 69, 58, 0.2);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cam-timer i { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.cam-stage { position: absolute; left: 0; right: 0; top: var(--sat); bottom: 0; background: #000; overflow: hidden; touch-action: none; }
#cam-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  background: #000;
  pointer-events: none;
}
#cam-msg { padding-bottom: calc(150px + var(--sab)); }
/* ピントを合わせた位置の目印（タップでのピント合わせに対応している端末だけ表示） */
.cam-focus {
  position: absolute;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border: 1.500px solid var(--accent);
  border-radius: 4px;
  pointer-events: none;
}
.stage-msg button + button { margin-top: -4px; }
.stage-msg button.is-primary { background: var(--accent); color: #0B0B0B; }
.cam-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "lens lens lens" "fps rec flip";
  align-items: center;
  padding: 30px max(20px, var(--sar)) calc(14px + var(--sab)) max(20px, var(--sal));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  pointer-events: none;
}
.cam-bottom > * { pointer-events: auto; }
#cam-fps { grid-area: fps; }
.cam-rec { grid-area: rec; }
#cam-flip { grid-area: flip; }
/* ズームの切り替え（iPhoneのカメラに近い見た目。使える端末だけ表示） */
.cam-lens {
  grid-area: lens;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 4px 6px;
  border-radius: 26px;
  background: rgba(0, 0, 0, 0.36);
  touch-action: none;
}
.cam-lens button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: rgba(28, 28, 30, 0.74);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cam-lens button.is-on {
  width: 44px;
  height: 44px;
  background: rgba(28, 28, 30, 0.92);
  color: var(--accent);
  font-size: 13px;
}
.cam-side {
  justify-self: start;
  display: grid;
  place-items: center;
  min-width: 72px;
  height: 48px;
  padding: 0 14px;
  border-radius: 24px;
  background: rgba(28, 28, 30, 0.86);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cam-side:active { background: var(--card-2); }
#cam-flip { justify-self: end; min-width: 48px; width: 48px; padding: 0; }
#cam-flip svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; }
.cam-rec {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
}
.cam-rec i { display: block; width: 58px; height: 58px; border-radius: 50%; background: var(--danger); }
.cam-rec:disabled { opacity: 0.4; }
.camera.is-rec .cam-rec i { width: 30px; height: 30px; border-radius: 7px; }
.camera.is-rec .cam-side, .camera.is-rec #cam-back, .camera.is-rec .cam-lens { visibility: hidden; }
/* セルフタイマー（インカメのとき）：録画ボタンの上の入り・切りボタン */
.cam-selftimer {
  grid-area: lens; justify-self: center;
  display: flex; align-items: center; gap: 6px;
  height: 36px; margin-bottom: 10px; padding: 0 14px; border-radius: 18px;
  background: rgba(28, 28, 30, 0.86); color: var(--text);
  font-size: 14px; font-weight: 700;
}
.cam-selftimer[hidden] { display: none; }
.cam-selftimer[aria-pressed="true"] { color: var(--accent); }
.cam-selftimer svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* 数えている間：真ん中に大きな数字。録画ボタンは「取り消し」（四角）にし、ほかのボタンは隠す */
.cam-count {
  position: absolute; inset: 0; z-index: 1;
  /* 構えの目安（人の形・手元の丸）を隠さないよう、画面の上のほうに出す */
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: calc(var(--sat) + 56px);
  pointer-events: none;
}
.cam-count[hidden] { display: none; }
.cam-count b {
  font-size: 120px; line-height: 1; font-weight: 900; color: var(--accent);
  font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 3px #0B0B0B; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}
.cam-count span {
  margin-top: 4px; padding: 4px 12px; border-radius: 14px;
  background: rgba(0, 0, 0, 0.6); font-size: 14px; font-weight: 700;
}
.camera.is-count .cam-rec i { width: 30px; height: 30px; border-radius: 7px; background: #fff; }
.camera.is-count .cam-side, .camera.is-count #cam-back, .camera.is-count .cam-selftimer { visibility: hidden; }
.camera.is-rec .cam-selftimer { visibility: hidden; }
@media (orientation: landscape) and (max-height: 560px) {
  /* 横画面：録画ボタンの左隣に置く（ズームの並びと同じ位置） */
  .camera .cam-selftimer {
    position: absolute; right: calc(100% - 4px); top: 50%; transform: translateY(-50%);
    flex-direction: column; height: auto; margin: 0; padding: 8px 6px; gap: 2px; font-size: 11px; border-radius: 14px;
  }
  .cam-count { padding-top: calc(var(--sat) + 40px); }
  .cam-count b { font-size: 110px; }
}

/* 横画面：プレビューを全面に表示し、上の表示と右の操作ボタンを重ねる */
@media (orientation: landscape) and (max-height: 560px) {
  .camera .cam-stage { top: 0; }
  .camera #cam-video { object-position: center; }
  .camera .cam-top {
    right: calc(112px + var(--sar));
    min-height: 0;
    padding: calc(var(--sat) + 4px) 12px 14px max(8px, var(--sal));
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
  }
  .camera .cam-bottom {
    left: auto;
    top: 0;
    width: calc(112px + var(--sar));
    grid-template-columns: none;
    grid-template-rows: 1fr auto 1fr;
    grid-template-areas: "fps" "rec" "flip";
    justify-items: center;
    padding: calc(var(--sat) + 12px) max(12px, var(--sar)) calc(12px + var(--sab)) 12px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  }
  .camera .cam-side { justify-self: center; align-self: start; }
  .camera #cam-flip { justify-self: center; align-self: end; }
  /* 横画面では録画ボタンのすぐ上に縦に並べる */
  /* 横画面では、録画ボタンの左隣に縦に並べる */
  .camera .cam-lens {
    position: absolute;
    right: calc(100% - 4px);
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column-reverse;
    margin: 0;
    padding: 6px 4px;
    gap: 6px;
  }
  #cam-msg { padding-bottom: 24px; padding-right: calc(136px + var(--sar)); }
}

/* ---------- 一覧 ---------- */
.filters {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 4px max(16px, var(--sar)) 12px max(16px, var(--sal));
  overflow-x: auto;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filters select, .chip {
  flex: none;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}
.filters select { padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--sub) 50%), linear-gradient(135deg, var(--sub) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.card {
  position: relative;
  border-radius: 16px;
  background: var(--card);
  overflow: hidden;
}
.card-open { display: block; width: 100%; text-align: left; }
.card-thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #000 center / cover no-repeat;
}
.card-thumb.no-thumb::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  border-style: solid;
  border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent #48484c;
  transform: translate(-40%, -50%);
}
.badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(11, 11, 11, 0.78);
  font-size: 11px;
  font-weight: 700;
}
.badge.model { left: auto; right: 8px; background: var(--text); color: #0B0B0B; }
.card-star {
  position: absolute;
  right: 8px;
  bottom: 8px;
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}
.card-body { padding: 10px 84px 12px 12px; }
/* 一覧：ごみ箱の左に、iPhoneのアルバムに保存 */
.card-album {
  position: absolute; right: 44px; bottom: 0; width: 36px; height: 52px;
  display: grid; place-items: center; color: var(--text);
}
.card-album svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { margin-top: 2px; color: var(--sub); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-del {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 44px;
  height: 52px;
  display: grid;
  place-items: center;
  color: var(--sub);
}
.card-del svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; }
.empty { padding: 64px 16px; color: var(--sub); font-size: 14px; text-align: center; white-space: pre-line; }

/* ---------- 動画分析 ---------- */
.analyze { background: #000; }
.an-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: calc(var(--sat) + 4px) max(8px, var(--sar)) 4px max(8px, var(--sal));
  background: var(--bg);
}
/* 動画のタイトルは表示しない（ボタンを大きくするため）。左右のボタンの間を空ける役目だけ残す */
.an-title {
  visibility: hidden;
  flex: 1;
  min-width: 0;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.star svg { fill: none; }
.star[aria-pressed="true"] { color: var(--accent); }
.star[aria-pressed="true"] svg { fill: var(--accent); }
.save-btn {
  flex: none;
  height: 36px;
  margin-left: 4px;
  padding: 0 16px;
  border-radius: 18px;
  background: var(--accent);
  color: #0B0B0B;
  font-size: 14px;
  font-weight: 700;
}
.save-btn.is-saved { background: var(--card-2); color: var(--text); }
/* 右上：「ガイド線」ボタンの下に「保存」ボタン */
.an-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-left: 4px; }
.an-right .save-btn { margin-left: 0; }
.an-right .cam-guide-btn { height: 36px; border-radius: 18px; }
/* 「編集」の下：iPhoneのアルバムに保存（保存済みの動画だけ表示）。
   上の帯の幅を変えないよう、「編集」の下に重ねて置く（右端そろえ） */
.an-right { position: relative; }
.album-btn {
  position: absolute; top: calc(100% + 6px); right: 0; white-space: nowrap;
  display: flex; align-items: center; gap: 4px;
  height: 36px; padding: 0 12px; border-radius: 18px;
  background: #fff; color: #0B0B0B; font-size: 14px; font-weight: 700;
}
.album-btn[hidden] { display: none; }
/* 横画面：右側の操作パネルに重ならないよう、上の帯の下に「アルバム」の分だけ余白を足す */
@media (orientation: landscape) and (max-height: 560px) {
  .analyze .an-top:has(.album-btn:not([hidden])) { padding-bottom: 44px; }
}
.album-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
}
.frame { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: #000;
  pointer-events: none;
}
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  touch-action: none;
}
.analyze.is-draw #overlay { pointer-events: auto; }
.analyze.is-draw .stage { box-shadow: inset 0 0 0 2px var(--accent); }
#overlay .hit { stroke: transparent; fill: none; pointer-events: stroke; }
#overlay .hit-fill { fill: transparent; stroke: none; pointer-events: fill; }
#overlay .shadow { stroke: rgba(0, 0, 0, 0.45); fill: none; pointer-events: none; }
#overlay .vis { fill: none; pointer-events: none; }
#overlay .handle-hit { fill: transparent; pointer-events: fill; }
#overlay .handle { fill: rgba(0, 0, 0, 0.25); stroke: #fff; stroke-width: 2; pointer-events: none; }
#overlay .handle-dot { fill: #fff; pointer-events: none; }
#overlay .pending { fill: none; stroke: #fff; stroke-width: 2; pointer-events: none; }

.draw-hint {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 6px 14px;
  border-radius: 16px;
  background: rgba(11, 11, 11, 0.82);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
/* 上の帯の「撮影」「録音」ボタン。2つとも同じ大きさにそろえる（大きさは下の --tb-* で決める） */
.an-top { --tb-w: 90px; --tb-h: 44px; --tb-font: 15px; --tb-gap: 6px; }
/* 幅の狭い画面と横画面では、収まるように少し小さくする */
@media (max-width: 399px) {
  .an-top .shoot-btn, .an-top .voice-btn { margin-right: 4px; }
  .an-right { margin-left: 0; }
  .an-right .cam-guide-btn { padding: 0 10px; font-size: 12px; }
}
@media (max-width: 379px) {
  .an-top { --tb-w: 78px; --tb-font: 14px; }
}
@media (max-width: 340px) {
  .an-top { --tb-w: 60px; --tb-gap: 4px; }
  /* 幅が足りないので「画面録画」を「画面／録画」の2行にする */
  .voice-btn:not([aria-pressed="true"]) span { width: 2em; font-size: 12px; line-height: 1.15; white-space: normal; text-align: center; }
  .an-top .shoot-btn, .an-top .voice-btn { margin-right: 3px; }
  .an-right .cam-guide-btn, .an-right .save-btn { padding: 0 8px; font-size: 12px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .an-top { --tb-w: 54px; --tb-font: 13px; --tb-gap: 4px; }
  /* 幅が足りないので「画面録画」を「画面／録画」の2行にする */
  .voice-btn:not([aria-pressed="true"]) span { width: 2em; font-size: 12px; line-height: 1.15; white-space: normal; text-align: center; }
  .an-top .shoot-btn, .an-top .voice-btn { margin-right: 3px; }
  .an-right { margin-left: 0; }
  .an-right .cam-guide-btn { padding: 0 9px; font-size: 12px; }
}
/* 次の動画を撮影するボタン（戻るボタンの隣。蛍光イエローの地に「撮影」の文字） */
.shoot-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tb-w);
  height: var(--tb-h);
  margin: 0 6px 0 2px;
  padding: 0;
  border-radius: 22px;
  background: var(--accent);
  color: #0B0B0B;
  font-size: var(--tb-font);
  font-weight: 800;
  white-space: nowrap;
  text-shadow: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.shoot-btn:active { background: #C9E600; }
/* 解説動画の録音ボタン（撮影ボタンの隣。赤い丸のマーク＋「録音」。録音中は赤地に経過時間を表示する） */
.voice-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--tb-gap);
  width: var(--tb-w);
  height: var(--tb-h);
  margin: 0 6px 0 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 22px;
  background: rgba(28, 28, 30, 0.86);
  color: #fff;
  font-size: var(--tb-font);
  font-weight: 800;
  white-space: nowrap;
  text-shadow: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.voice-btn:active { background: #3a3a3d; }
.voice-btn .dot { flex: none; display: block; width: 14px; height: 14px; border-radius: 50%; background: #FF3B30; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9); }
.voice-btn .stop { flex: none; display: none; width: 12px; height: 12px; border-radius: 3px; background: #fff; }
.voice-btn span { font-variant-numeric: tabular-nums; }
/* 録音中はほかのボタンを隠すので、経過時間が窮屈にならないよう幅を広げてよい */
.voice-btn[aria-pressed="true"] { width: auto; min-width: var(--tb-w); margin-left: 2px; padding: 0 12px; border-color: transparent; background: #FF3B30; }
.voice-btn[aria-pressed="true"] .dot { display: none; }
.voice-btn[aria-pressed="true"] .stop { display: block; }
/* 録音中は、画面を離れる操作（戻る・撮影・保存など）を隠す */
.analyze.is-voice #an-back,
.analyze.is-voice #an-shoot,
.analyze.is-voice #an-fav,
.analyze.is-voice #an-save { display: none; }
/* 録音用に映像と補助線を合成するキャンバス（画面には見せない） */
.voice-canvas { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0.01; pointer-events: none; }
.stage-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: #000;
  color: var(--sub);
  font-size: 14px;
  text-align: center;
  white-space: pre-line;
}
.stage-msg b { color: var(--text); font-size: 16px; }
.stage-msg button {
  height: 46px;
  padding: 0 24px;
  border-radius: 23px;
  background: var(--card-2);
  color: var(--text);
  font-weight: 700;
}

.an-controls {
  flex: none;
  padding: 6px max(12px, var(--sar)) calc(8px + var(--sab)) max(12px, var(--sal));
  background: var(--bg);
}
.analyze.panels-hidden .an-top,
.analyze.panels-hidden .an-controls { display: none; }

.seek-row { display: flex; align-items: center; gap: 10px; }
.seek {
  position: relative;
  flex: 1;
  height: 36px;
  touch-action: none;
  outline: none;
}
.seek-track {
  position: absolute;
  left: 9px; right: 9px; top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: #3a3a3d;
  overflow: hidden;
}
.seek-fill { height: 100%; width: calc(100% * var(--r, 0)); background: var(--text); }
/* 前後カットの編集中：使う範囲を黄色で示す（範囲の外はシークバーの灰色のまま） */
.seek-trim { display: none; position: absolute; top: 50%; height: 8px; margin-top: -4px; left: calc(9px + (100% - 18px) * var(--ta, 0)); width: calc((100% - 18px) * (var(--tb, 1) - var(--ta, 0))); border-radius: 3px; background: rgba(223, 255, 0, 0.45); box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); pointer-events: none; }
.analyze.is-trim .seek-trim { display: block; }
.analyze.is-trim .seek-fill { opacity: 0.5; }
#tools-trim .trim-btn { color: var(--accent); }
#tools-trim .trim-btn.is-set { background: var(--accent); color: #0B0B0B; }
/* 前後カットの「完了」は赤 */
#tools-trim #trim-back { background: #FF3B30; color: #fff; }
#tools-trim #trim-back:active { background: #D92D23; }
.seek-thumb {
  position: absolute;
  top: 50%;
  left: calc(9px + (100% - 18px) * var(--r, 0));
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.seek.is-drag .seek-thumb { transform: scale(1.250); }
.time {
  flex: none;
  min-width: 112px;
  color: var(--sub);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.transport {
  display: grid;
  grid-template-columns: 1fr 76px 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 2px;
}
.t-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 56px;
  border-radius: 16px;
  background: var(--card);
  font-size: 13px;
  font-weight: 700;
  touch-action: none;
}
.t-btn:active, .t-btn.is-held { background: var(--card-2); }
.t-btn svg { width: 22px; height: 22px; fill: currentColor; }
#btn-next svg { order: 2; }
.t-btn.play { height: 60px; border-radius: 30px; background: var(--accent); color: #0B0B0B; touch-action: manipulation; }
.t-btn.play:active { background: #C9E600; }
.t-btn.play svg { width: 28px; height: 28px; }
.t-btn.play .i-pause { display: none; }
.analyze.is-playing .t-btn.play .i-play { display: none; }
.analyze.is-playing .t-btn.play .i-pause { display: block; }

.speed-row { display: flex; gap: 8px; margin-top: 8px; }
.speeds { flex: 1; display: flex; gap: 6px; }
.speeds button {
  flex: 1;
  min-width: 0;
  height: 40px;
  white-space: nowrap;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.speeds button.is-on { background: var(--accent); color: #0B0B0B; }
.fps-chip {
  flex: none;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--sub);
  font-size: 11px;
  line-height: 1.250;
  text-align: center;
  white-space: pre-line;
}

.tools-wrap {
  margin: 8px calc(-1 * max(12px, var(--sar))) 0 calc(-1 * max(12px, var(--sal)));
  /* 右端を薄くして、横にスクロールできることを示す */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent);
}
.tools {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 0 calc(max(12px, var(--sar)) + 22px) 0 max(12px, var(--sal));
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
}
.tools::-webkit-scrollbar { display: none; }
.tool {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 64px;
  height: 54px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 10.500px;
  font-weight: 600;
  white-space: nowrap;
}
.tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; }
.tool svg circle { fill: currentColor; stroke: none; }
.tool svg .dot { fill: var(--accent); }
#tool-style svg circle:first-child, #tool-hide svg circle { fill: none; stroke: currentColor; }
.tool:active { background: var(--card-2); }
.tool.is-on, .tool[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
.tool.mode[aria-pressed="true"] { background: var(--accent); color: #0B0B0B; box-shadow: none; }
.tool.is-dim { opacity: 0.38; }
#tool-hide .slash { display: none; }
#tool-hide[aria-pressed="true"] .slash { display: block; }
.tool-sep { flex: none; width: 1px; margin: 10px 2px; background: var(--line); }

.swatches, .widths { flex: none; display: flex; align-items: center; gap: 6px; }
.swatches button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1.500px #4a4a4e;
}
.swatches button.is-on { box-shadow: 0 0 0 2.500px var(--text); }
.widths button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 52px;
  height: 54px;
  border-radius: 12px;
  background: var(--card);
  font-size: 10.500px;
  font-weight: 600;
}
.widths button i { display: block; width: 26px; border-radius: 3px; background: var(--text); }
.widths button.is-on { box-shadow: inset 0 0 0 2px var(--accent); }

/* 幅の狭い端末：速度ボタンの文字を1行に収める */
@media (max-width: 360px) {
  .speeds { gap: 4px; }
  .speeds button { font-size: 11.500px; }
  .fps-chip { padding: 0 6px; font-size: 10px; }
  .time { min-width: 100px; font-size: 11px; }
  .t-btn { font-size: 12px; }
}

/* 縦画面：動画を画面いっぱいに表示し、上の表示と下の操作パネルを動画の上に重ねる。
   操作パネルは小さくまとめて画面の下端に寄せる（再生モードで動画をタップすると隠せる）。 */
@media (orientation: portrait) {
  .analyze .stage { position: absolute; left: 0; right: 0; top: var(--sat); bottom: 0; }
  .analyze .an-top {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    z-index: 3;
    padding-bottom: 16px;
    background: linear-gradient(to bottom, var(--bg) 0, var(--bg) var(--sat), rgba(0, 0, 0, 0.62) var(--sat), rgba(0, 0, 0, 0) 100%);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    pointer-events: none;   /* ボタン以外の部分は、下の動画をそのまま触れるようにする */
  }
  .analyze .an-top > button, .analyze .an-top .an-right > button { pointer-events: auto; }
  .analyze .draw-hint { top: 62px; }
  /* 前後カットの編集中は、範囲の表示を操作パネルのすぐ上に出す */
  .analyze.is-trim .draw-hint { top: auto; bottom: calc(var(--panel-h, 160px) + 10px); }
  .analyze .an-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    padding: 4px max(10px, var(--sar)) calc(6px + var(--sab)) max(10px, var(--sal));
    background: rgba(11, 11, 11, 0.5);
  }
  .analyze .seek { height: 28px; }
  .analyze .seek-thumb { width: 14px; height: 14px; margin: -7px 0 0 -7px; }
  .analyze .time { min-width: 0; color: #D8D8D8; font-size: 11px; }

  .analyze .transport { grid-template-columns: 1fr 64px 1fr; gap: 8px; margin-top: 0; }
  .analyze .t-btn { height: 40px; border-radius: 12px; background: rgba(28, 28, 30, 0.66); font-size: 12px; }
  .analyze .t-btn:active, .analyze .t-btn.is-held { background: var(--card-2); }
  .analyze .t-btn svg { width: 18px; height: 18px; }
  .analyze .t-btn.play { height: 40px; border-radius: 20px; background: var(--accent); }
  .analyze .t-btn.play:active { background: #C9E600; }
  .analyze .t-btn.play svg { width: 22px; height: 22px; }

  .analyze .speed-row { gap: 6px; margin-top: 6px; }
  .analyze .speeds { gap: 5px; }
  .analyze .speeds button { height: 28px; border-radius: 9px; background: rgba(28, 28, 30, 0.66); font-size: 12px; }
  .analyze .speeds button.is-on { background: var(--accent); }
  .analyze .fps-chip {
    height: 28px;
    padding: 0 8px;
    border-color: rgba(255, 255, 255, 0.22);
    border-radius: 9px;
    background: rgba(28, 28, 30, 0.5);
    color: #D8D8D8;
    font-size: 10px;
    white-space: nowrap;
  }

  .analyze .tools-wrap {
    margin: 6px calc(-1 * max(10px, var(--sar))) 0 calc(-1 * max(10px, var(--sal)));
    -webkit-mask-image: none;
    mask-image: none;
  }
  .analyze .tools { gap: 4px; padding: 0 max(10px, var(--sar)) 0 max(10px, var(--sal)); overflow: visible; }
  .analyze .tool { height: 38px; gap: 1px; border-radius: 10px; background: rgba(28, 28, 30, 0.66); font-size: 8.500px; }
  .analyze .tool:active { background: var(--card-2); }
  .analyze .tool svg { width: 18px; height: 18px; }
  .analyze .tool.mode[aria-pressed="true"] { background: var(--accent); }
  .analyze .tool-sep { display: none; }
  .analyze #tools-main .tool { flex: 1 1 0; min-width: 0; padding: 0; }
  /* 幅が狭いので短いラベルを表示する（横画面では元のラベル） */
  .analyze #tools-main .tool span[data-short] { font-size: 0; }
  .analyze #tools-main .tool span[data-short]::after { content: attr(data-short); font-size: 8px; }

  .analyze #tools-style { align-items: center; gap: 6px; overflow-x: auto; }
  .analyze #tools-style .tool { flex: none; min-width: 42px; padding: 0 4px; }
  .analyze .swatches { gap: 6px; }
  .analyze .swatches button { width: 30px; height: 30px; border-width: 2px; }
  .analyze .widths { gap: 4px; }
  .analyze .widths button { width: 42px; height: 38px; gap: 4px; border-radius: 10px; background: rgba(28, 28, 30, 0.66); font-size: 8.500px; }
  .analyze .widths button i { width: 22px; }
}
@media (orientation: portrait) and (max-width: 360px) {
  .analyze .speeds { gap: 3px; }
  .analyze .speeds button { font-size: 10.500px; }
  .analyze .fps-chip { padding: 0 5px; font-size: 9px; }
  .analyze .t-btn { font-size: 11px; }
  .analyze #tools-main .tool span[data-short]::after { font-size: 7px; }
}
@media (orientation: portrait) and (max-width: 340px) {
  .analyze .tools { gap: 3px; }
  .analyze #tools-main .tool span[data-short]::after { font-size: 6.500px; }
}

/* 横画面：動画を左、操作を右にまとめて動画を覆わない */
@media (orientation: landscape) and (max-height: 560px) {
  .analyze.is-active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) calc(300px + var(--sar));
    grid-template-rows: auto minmax(0, 1fr);
  }
  .analyze .stage { grid-column: 1; grid-row: 1 / 3; margin-left: var(--sal); }
  .analyze .an-top { grid-column: 2; grid-row: 1; padding: calc(var(--sat) + 4px) max(8px, var(--sar)) 2px 8px; }
  .analyze .an-controls {
    grid-column: 2;
    grid-row: 2;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 max(10px, var(--sar)) calc(6px + var(--sab)) 10px;
  }
  .analyze.panels-hidden.is-active { display: flex; }
  .analyze.panels-hidden .stage { margin-left: 0; }
  .analyze .time { min-width: 0; }
  .analyze .seek { height: 30px; }
  .analyze .t-btn { height: 46px; }
  .analyze .t-btn span { display: none; }
  .analyze .t-btn.play { height: 48px; }
  .analyze .transport { grid-template-columns: 1fr 68px 1fr; gap: 8px; }
  .analyze .speed-row { flex-wrap: wrap; margin-top: 6px; gap: 6px; }
  .analyze .speeds { flex-basis: 100%; gap: 4px; }
  .analyze .speeds button { height: 36px; font-size: 12px; }
  .analyze .fps-chip { flex: 1; height: 30px; white-space: nowrap; }
  .analyze .tools-wrap { margin: 6px -10px 0 -10px; margin-right: calc(-1 * max(10px, var(--sar))); -webkit-mask-image: none; mask-image: none; }
  .analyze .tools { overflow: visible; padding: 0 max(10px, var(--sar)) 0 10px; touch-action: pan-y; }
  .analyze #tools-main { display: grid; grid-template-columns: repeat(5, 1fr); }
  .analyze #tools-main .tool span[data-short] { font-size: 0; }
  .analyze #tools-main .tool span[data-short]::after { content: attr(data-short); font-size: 9.500px; }
  .analyze #tools-style { flex-wrap: wrap; row-gap: 6px; }
  .analyze .tool { min-width: 0; height: 48px; padding: 0 2px; }
  .analyze .tool-sep { display: none; }
  .analyze .widths { flex-basis: 100%; }
  .analyze .widths button { flex: 1; height: 48px; }
}

/* ---------- シート・ダイアログ ---------- */
.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.sheet-back.center { align-items: center; padding: 24px; }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: calc(100% - var(--sat) - 12px);
  margin: 0;
  padding: 20px max(18px, var(--sar)) calc(18px + var(--sab)) max(18px, var(--sal));
  border-radius: 22px 22px 0 0;
  background: var(--card);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet h3, .dialog h3 { margin: 0 0 14px; font-size: 18px; }
.sheet-text { margin: 0 0 12px; color: var(--sub); font-size: 14px; }
.sheet-text.small { margin-top: 12px; font-size: 12px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin: 0 2px 6px; color: var(--sub); font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { resize: none; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field input[type="date"] { color-scheme: dark; text-align: left; }
.field .seg { background: var(--bg); border: 1px solid var(--line); }
.field .seg button { height: 40px; }

.switch { display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin-bottom: 14px; font-size: 15px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { position: relative; flex: none; width: 52px; height: 32px; border-radius: 16px; background: #3a3a3d; transition: background 0.15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); background: #0B0B0B; }

#voice-info { white-space: pre-line; }
.voice-preview { display: block; width: 100%; max-height: 38vh; margin: 0 0 10px; border-radius: 12px; background: #000; }
.voice-actions { display: flex; flex-direction: column; gap: 8px; }
.voice-actions .btn { flex: none; }
.sheet-actions, .dialog-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  flex: 1;
  min-height: 50px;
  padding: 0 12px;
  border-radius: 14px;
  background: var(--card-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}
.btn.is-primary { background: var(--accent); color: #0B0B0B; }
.btn.is-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; }

.opt-list { display: flex; flex-direction: column; gap: 6px; }
.opt-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--bg);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}
.opt-list button small { color: var(--sub); font-size: 12px; font-weight: 400; }
.opt-list button.is-on { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }

.dialog {
  width: 100%;
  max-width: 340px;
  padding: 22px 20px 18px;
  border-radius: 20px;
  background: var(--card);
}
.dialog h3 { margin-bottom: 8px; }
.dialog p { margin: 0 0 18px; color: var(--sub); font-size: 14px; white-space: pre-line; }
.dialog-actions { flex-wrap: wrap; }
.dialog-actions .btn { flex: 1 1 120px; }

/* ---------- 読み込み中・トースト・更新バー ---------- */
.busy {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 14px;
}
.busy p { margin: 0; }
.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid #3a3a3d;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sab) + 28px);
  z-index: 70;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(50, 50, 54, 0.96);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  white-space: pre-line;
  pointer-events: none;
}
.toast.is-high { bottom: auto; top: calc(var(--sat) + 72px); }
.update-bar {
  position: fixed;
  left: max(12px, var(--sal));
  right: max(12px, var(--sar));
  top: calc(var(--sat) + 8px);
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  border-radius: 14px;
  background: var(--card-2);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.update-bar button { height: 34px; padding: 0 16px; border-radius: 17px; background: var(--accent); color: #0B0B0B; font-weight: 700; }
