html, body {
  margin: 0; padding: 0; height: 100%;
  background: #000; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
#video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
/* メイン再生ビデオ */
#playbackVideo {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 0;
}
/* 右下カメラプレビュー小窓 */
#previewVideo {
  position: fixed;
  bottom: max(env(safe-area-inset-bottom), 16px);
  right: 16px;
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.4);
  z-index: 10;
  background: #111;
  display: none;
}
#topBar {
  position: fixed;
  top: max(env(safe-area-inset-top), 16px);
  left: 16px; right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#status {
  padding: 8px 16px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  border-radius: 10px;
}
#topButtons { display: flex; gap: 10px; }
.iconBtn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 20px;
  -webkit-tap-highlight-color: transparent;
}
#controls {
  position: fixed;
  bottom: max(env(safe-area-inset-bottom), 16px);
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 24px;
}
button { -webkit-tap-highlight-color: transparent; }
#startBtn, #stopBtn {
  width: 130px; height: 58px;
  font-size: 20px; font-weight: 700;
  border: none; border-radius: 14px;
  color: #fff;
}
#startBtn { background: #34c759; }
#stopBtn { background: #ff3b30; }
#startBtn:disabled, #stopBtn:disabled { background: #555; opacity: 0.55; }

#permMsg {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.85);
  color: #fff; text-align: center; padding: 24px;
  font-size: 17px; line-height: 1.6;
}

.modalOverlay {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 50;
  padding: 20px;
}
.modalBox {
  background: #1c1c1e;
  color: #fff;
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}
.modalBox h2 { margin-top: 0; font-size: 20px; }
.modalNote { font-size: 13px; color: #aaa; }
input[type="range"] { width: 100%; margin: 16px 0; }
.primaryBtn {
  width: 100%;
  padding: 12px;
  border: none; border-radius: 10px;
  background: #0a84ff;
  color: #fff;
  font-size: 16px; font-weight: 600;
  margin-top: 12px;
}
.dangerBtn {
  flex: 1;
  padding: 12px;
  border: none; border-radius: 10px;
  background: #ff3b30;
  color: #fff;
  font-size: 15px; font-weight: 600;
}
.galleryBox {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  padding: 0;
  overflow: hidden;
}
.galleryBox h2 {
  margin: 0;
  padding: 16px 20px 8px;
  font-size: 20px;
  flex-shrink: 0;
}
.galleryBox > .modalNote {
  padding: 0 20px 8px;
  flex-shrink: 0;
}
#galleryList {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px;
}
.galleryFooter {
  display: flex;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid #2c2c2e;
  flex-shrink: 0;
}
.galleryFooter .primaryBtn { margin-top: 0; flex: 1; }
.galleryItem {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #333;
  gap: 10px;
}
.galleryDate { font-size: 15px; font-weight: 600; }
.savedTag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #0a84ff;
  background: rgba(10,132,255,0.15);
  border-radius: 6px;
  vertical-align: middle;
}
.gallerySub { font-size: 13px; color: #999; }
.galleryActions { display: flex; gap: 6px; }
.smallBtn {
  padding: 8px 10px;
  border: none; border-radius: 8px;
  background: #2c2c2e;
  color: #fff;
  font-size: 13px;
}
.delBtn { background: #ff3b30; }
.emptyMsg { color: #999; text-align: center; padding: 24px 0; }

.lightboxBox { width: 100%; max-width: 600px; }
#lightboxVideo { width: 100%; border-radius: 12px; background: #000; }
.lightboxBox .primaryBtn { margin-top: 12px; }
.secondaryBtn {
  width: 100%;
  padding: 12px;
  border: none; border-radius: 10px;
  background: #2c2c2e;
  color: #fff;
  font-size: 16px; font-weight: 600;
  margin-top: 8px;
}
.iconBtn svg { display: block; pointer-events: none; }

/* スロー再生オーバーレイ */
#speedOverlay {
  position: fixed;
  bottom: max(env(safe-area-inset-bottom), 16px);
  left: 16px;
  z-index: 10;
  display: none;
}
.speedBtn {
  padding: 8px 16px;
  border: none; border-radius: 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 15px; font-weight: 700;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.speedBtn.slow { color: #ffd60a; }

/* 比較ボタン */
.compareStartBtn {
  flex: 1;
  padding: 12px 8px;
  border: none; border-radius: 10px;
  background: #5e5ce6;
  color: #fff;
  font-size: 13px; font-weight: 600;
}
.compareStartBtn.active { background: #ff9f0a; }

/* 比較選択チェックボックス */
.compareCheck {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid #5e5ce6;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.compareCheck.selected { background: #5e5ce6; }

/* 比較再生モーダル */
.compareBox {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: #000;
  padding: 12px;
  box-sizing: border-box;
  gap: 8px;
}
.compareVideos {
  flex: 1;
  display: flex; flex-direction: row;
  gap: 6px;
  min-height: 0;
}
.comparePane {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.comparePane video {
  flex: 1;
  width: 100%;
  object-fit: contain;
  background: #111;
  border-radius: 8px;
  min-height: 0;
}
.compareVideoWrap {
  flex: 1;
  position: relative;
  display: flex;
  min-height: 0;
}
.compareVideoWrap video {
  flex: 1;
  width: 100%;
  object-fit: contain;
  background: #111;
  border-radius: 8px;
  min-height: 0;
  cursor: pointer;
}
.speakerIcon {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 22px;
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.8));
}
.compareLabel {
  margin: 0;
  color: #aaa;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compareFooter {
  display: flex; gap: 8px;
}
.compareFooter .secondaryBtn,
.compareFooter .primaryBtn { flex: 1; margin-top: 0; }

/* メモ欄 */
.memoArea {
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px solid #3a3a3c;
  border-radius: 8px;
  background: #2c2c2e;
  color: #fff;
  font-size: 13px;
  resize: none;
  box-sizing: border-box;
  font-family: inherit;
}
.memoArea::placeholder { color: #666; }

/* バージョン情報 */
.versionInfo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #2c2c2e;
  margin-top: 12px;
}
.versionLabel { color: #aaa; font-size: 14px; }
.versionValue { color: #fff; font-size: 14px; font-weight: 600; }

/* 認証画面 */
#authScreen {
  position: fixed; inset: 0;
  display: flex;
  align-items: center; justify-content: center;
  background: #000;
  z-index: 100;
  padding: 24px;
}
#authBox {
  width: 100%; max-width: 360px;
  background: #1c1c1e;
  border-radius: 20px;
  padding: 36px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#authIcon { font-size: 48px; }
#authTitle {
  margin: 0;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
}
#authInput {
  width: 100%;
  padding: 14px 16px;
  border: none; border-radius: 12px;
  background: #2c2c2e;
  color: #fff;
  font-size: 17px;
  box-sizing: border-box;
  text-align: center;
  letter-spacing: 0.1em;
}
#authInput::placeholder { color: #666; letter-spacing: normal; }
#authBtn {
  width: 100%;
  padding: 14px;
  border: none; border-radius: 12px;
  background: #0a84ff;
  color: #fff;
  font-size: 17px; font-weight: 700;
}
#authError {
  color: #ff3b30;
  font-size: 14px;
  min-height: 18px;
  margin: 0;
}
