*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── カラーテーマ変数 ── */
:root {
  color-scheme: dark;
  --bg:    #0d1117;
  --bg2:   #141920;
  --bg3:   #161b24;
  --bg4:   #1a1f28;
  --bg5:   #1a2030;
  --bg6:   #111620;
  --text:  #e0e0e0;
  --on:    255,255,255;
  --glass: 13,17,23;

  /* ── シーンカラー（8色ローテーション。SCENE_COLORS in index.js と同一値） ── */
  --scene-1: 148,100,220; /* violet */
  --scene-2: 220,160,60;  /* amber */
  --scene-3: 60,185,130;  /* mint */
  --scene-4: 210,90,120;  /* rose */
  --scene-5: 100,160,220; /* sky */
  --scene-6: 220,100,100; /* coral */
  --scene-7: 100,220,160; /* jade */
  --scene-8: 180,130,60;  /* ochre */

  /* ── メモリーレイヤー（閲覧回数バッジ）専用トークン。scene/accentとは独立 ── */
  --memory-rgb: 255,213,106;
  --memory-new-rgb: 40,120,220;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg:    #f4f6fa;
    --bg2:   #ffffff;
    --bg3:   #edf0f6;
    --bg4:   #e3e8f0;
    --bg5:   #dde2ec;
    --bg6:   #eff1f6;
    --text:  #1a1d24;
    --on:    0,0,0;
    --glass: 244,246,250;

    --memory-rgb: 184,101,29;
    --memory-new-rgb: 40,120,220;
  }
}

html, body { width: 100%; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  overflow: hidden;
  user-select: none;
}

/* ── Top bar ── */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 12px;
  pointer-events: none;
  background: rgba(var(--glass),0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(var(--on),0.06);
}
/* 投稿ボタン（デスクトップ：トップバー右端） */
.upload-nav-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,107,157,0.12);
  color: #ff6b9d;
  border: 1px solid rgba(255,107,157,0.22);
  border-radius: 20px;
  padding: 6px 13px 6px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
  font-family: inherit;
}
.upload-nav-btn:hover { background: rgba(255,107,157,0.22); }
.upload-nav-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
@media (max-width: 767px) {
  .upload-nav-btn { display: none; }
}
.top-bar h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(var(--on),0.75);
}
.top-bar p {
  font-size: 11px;
  color: rgba(var(--on),0.3);
  margin-top: 2px;
  letter-spacing: 0.04em;
}
.mode-switcher {
  display: flex;
  gap: 2px;
  margin-top: 10px;
  background: rgba(var(--on),0.05);
  border-radius: 10px;
  padding: 3px;
  pointer-events: auto;
}
.mode-btn {
  background: none;
  border: none;
  color: rgba(var(--on),0.45);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mode-btn:hover { color: rgba(var(--on),0.7); }
.mode-btn.active {
  background: rgba(167,139,250,0.2);
  color: #a78bfa;
}

/* ── 日フィルターバー（複数日イベントのみ表示） ── */
.day-filter-bar {
  position: fixed;
  top: var(--topbar-only-h, 0px);
  left: 0; right: 0;
  z-index: 19;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 10px;
  background: rgba(var(--glass),0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(var(--on),0.06);
}
.day-select {
  appearance: none;
  background: rgba(var(--on),0.05);
  border: 1px solid rgba(var(--on),0.12);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 28px 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}
.spot-chip-row {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  max-width: 100%;
}
.spot-chip-row::-webkit-scrollbar { display: none; }
.spot-chip {
  flex-shrink: 0; cursor: pointer; white-space: nowrap;
  font-size: 11px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
  color: rgba(var(--on),0.5);
  background: rgba(var(--on),0.05);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.spot-chip.active {
  background: rgba(167,139,250,0.16);
  border-color: rgba(167,139,250,0.4);
  color: #a78bfa;
}

/* ── Views ── */
.view {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: var(--topbar-h, 0px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.view.active {
  opacity: 1;
  pointer-events: auto;
}
#graph-view { z-index: 1; }
#timeline-view { z-index: 1; overflow: hidden; display: flex; flex-direction: column; }
#gallery-view { z-index: 1; }
/* ── シーンジャンプチップ（後方互換） ── */
.scene-jump-chip {
  flex-shrink: 0; padding: 5px 13px; font-size: 11px; font-weight: 600;
  border-radius: 20px; border: 1px solid rgba(var(--on),0.18);
  background: rgba(10,14,21,0.75); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(var(--on),0.65); cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.scene-jump-chip:hover { background: rgba(167,139,250,0.18); border-color: rgba(167,139,250,0.45); color: rgba(167,139,250,1); }
.scene-jump-chip.active { background: rgba(167,139,250,0.22); border-color: rgba(167,139,250,0.55); color: rgba(167,139,250,1); }
@media (prefers-color-scheme: light) {
  .scene-jump-chip { background: rgba(255,255,255,0.82); }
}

/* ── Graph: Legend ── */
.legend {
  position: absolute;
  top: 12px; left: 20px;
  background: rgba(var(--glass),0.85);
  border: 1px solid rgba(var(--on),0.07);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 11px;
  backdrop-filter: blur(12px);
}
.legend h3 { font-size: 11px; font-weight: 600; margin-bottom: 8px; color: rgba(167,139,250,0.9); letter-spacing: 0.04em; }
.legend-item { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; color: rgba(var(--on),0.5); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-line { width: 16px; height: 0; border-top: 1.5px dashed #f59e0b; flex-shrink: 0; }

/* ── Stats ── */
.stats {
  position: absolute;
  top: 12px; right: 20px;
  background: rgba(var(--glass),0.85);
  border: 1px solid rgba(var(--on),0.07);
  border-radius: 10px;
  padding: 12px 16px;
  backdrop-filter: blur(12px);
  text-align: center;
  min-width: 80px;
}
.stats .num { font-size: 26px; font-weight: 700; color: #a78bfa; line-height: 1; display: block; }
.stats .lbl { font-size: 10px; color: rgba(var(--on),0.35); margin-top: 2px; display: block; }
.stats .sub { font-size: 10px; color: rgba(var(--on),0.35); margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(var(--on),0.06); }
.stats .sub span { color: #f59e0b; font-weight: 600; }

/* ── Instructions ── */
.instructions {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(var(--glass),0.8);
  border: 1px solid rgba(var(--on),0.07);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 11px;
  color: rgba(var(--on),0.3);
  backdrop-filter: blur(12px);
  white-space: nowrap;
  z-index: 15;
  pointer-events: none;
}

/* ── Tooltip ── */
.tooltip {
  position: fixed;
  background: rgba(var(--glass),0.96);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 11px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  backdrop-filter: blur(12px);
  z-index: 30;
  line-height: 1.6;
  max-width: 180px;
}
.tooltip strong { display: block; color: rgba(var(--on),0.9); }
.tooltip .hint { color: rgba(167,139,250,0.65); font-size: 10px; margin-top: 2px; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  cursor: zoom-out;
}
.modal-overlay.active { display: flex; }
.modal-frame {
  background: var(--bg2);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 80px rgba(167,139,250,0.2), 0 0 0 1px rgba(var(--on),0.07);
  width: 82vw;
  max-width: 82vw;
  display: flex;
  flex-direction: column;
  cursor: default;
}
.modal-photo-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
/* デスクトップ：複数視点パネルあり */
.modal-frame.has-perspectives {
  flex-direction: row;
  width: min(1100px, 92vw);
  max-width: min(1100px, 92vw);
  align-items: stretch;
}
.modal-frame.has-perspectives .modal-photo-area {
  flex: 1;
  min-width: 0;
}
/* 視点サイドパネル */
.perspective-panel {
  width: 240px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--bg2) 85%, #0a0a18 15%);
  border-left: 1px solid rgba(var(--on),0.07);
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.persp-header {
  font-size: 11px;
  font-weight: 600;
  color: rgba(var(--on),0.4);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0 4px 6px;
  border-bottom: 1px solid rgba(var(--on),0.06);
  margin-bottom: 4px;
}
.persp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.persp-item:hover {
  background: rgba(var(--on),0.06);
}
.persp-item.active {
  background: rgba(167,139,250,0.08);
  border-color: rgba(167,139,250,0.2);
}
.persp-thumb-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(var(--on),0.05);
}
.persp-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s;
}
.persp-item:hover .persp-thumb {
  opacity: 0.85;
}
.persp-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.4;
}
.persp-active-ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(167,139,250,0.7);
  border-radius: 8px;
  pointer-events: none;
}
.persp-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.persp-av {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; flex-shrink: 0;
}
.persp-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.persp-time {
  font-size: 10px;
  color: rgba(var(--on),0.35);
}
.persp-cycle-hint {
  font-size: 10px;
  color: rgba(167,139,250,0.7);
}
.modal-meta {
  padding: 11px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(var(--on),0.06);
}
.modal-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.modal-info strong { font-size: 12px; display: block; }
.modal-info span { font-size: 10px; color: rgba(var(--on),0.4); }
/* img・video は modal-img-wrap に absolute で重ねる */
/* モーダル動画プレーヤー */
/* #modal-video は .modal-img-wrap 内で position:absolute に統合済み */
.modal-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(var(--on),0.08);
  border: 1px solid rgba(var(--on),0.12);
  color: rgba(var(--on),0.7);
  font-size: 28px;
  line-height: 1;
  width: 44px; height: 64px;
  border-radius: 10px;
  cursor: pointer;
  z-index: 110;
  transition: background 0.15s, opacity 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.modal-nav:hover { background: rgba(var(--on),0.15); }
.modal-prev { left: 16px; }
.modal-next { right: 16px; }
.modal-count {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom) + 12px); left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(var(--on),0.35);
  z-index: 110;
  pointer-events: none;
  letter-spacing: 0.06em;
}

/* ── Modal Like Button ── */
.modal-like-btn {
  position: absolute;
  bottom: 12px; right: 12px;
  display: flex; align-items: center; gap: 5px;
  padding: 7px 13px;
  background: rgba(0,0,0,0.52);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 24px;
  cursor: pointer;
  font-size: 13px;
  color: #fff;
  transition: background .15s, border-color .15s, transform .1s;
  z-index: 5;
}
.modal-like-btn:hover { background: rgba(220,30,60,0.35); border-color: rgba(255,100,120,0.45); }
.modal-like-btn.liked { background: rgba(220,30,60,0.3); border-color: rgba(255,100,120,0.5); }
.modal-like-btn:active { transform: scale(0.9); }
.modal-like-heart { font-size: 17px; line-height: 1; display: block; transition: transform .15s; }
.modal-like-btn:active .modal-like-heart { transform: scale(1.4); }
.modal-like-count { font-size: 12px; font-weight: 700; min-width: 8px; text-align: center; }

/* ── 絵文字リアクションバー ── */
.emoji-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(var(--glass),0.6);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  border: 1px solid rgba(var(--on),0.1);
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  white-space: nowrap;
}
.emoji-bar.hidden { display: none; }
.emoji-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 1px;
  background: none; border: none; cursor: pointer;
  padding: 4px 6px;
  border-radius: 10px;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.emoji-btn:active { transform: scale(0.88); }
.emoji-btn.reacted { background: rgba(var(--on),0.12); }
.emoji-btn .e-icon { font-size: 22px; line-height: 1; display: block; }
.emoji-btn .e-count { font-size: 10px; font-weight: 700; color: rgba(var(--on),0.6); min-width: 12px; text-align: center; }
.emoji-btn.reacted .e-count { color: rgba(var(--on),0.9); }

/* ── 保存ボタンエリア ── */
.modal-save-area {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.save-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(var(--on),0.2);
  background: rgba(var(--glass),0.7);
  backdrop-filter: blur(8px);
  color: rgba(var(--on),0.85);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.save-btn:active { transform: scale(0.95); }
.save-btn--ready {
  background: rgba(40,160,80,0.35);
  border-color: rgba(60,200,100,0.5);
  color: #7fffaa;
}
.save-btn[hidden] { display: none !important; }
.save-progress-wrap {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(var(--on),0.15);
  background: rgba(var(--glass),0.7);
  backdrop-filter: blur(8px);
  font-size: 12px; color: rgba(var(--on),0.7);
  min-width: 120px;
}
.save-progress-bar-track {
  flex: 1; height: 4px; background: rgba(var(--on),0.15); border-radius: 2px; overflow: hidden;
}
.save-progress-bar-fill {
  height: 100%; width: 0%; background: rgba(60,200,100,0.8); border-radius: 2px;
  transition: width 0.1s linear;
}
.save-progress-wrap[hidden] { display: none !important; }
.save-size-warn {
  font-size: 11px; color: rgba(255,180,50,0.9); text-align: center;
  padding: 2px 0;
}
.save-size-warn[hidden] { display: none !important; }

/* ── Gallery card like badge ── */
/* ── カードいいねボタン ── */
.card-like-btn {
  position: absolute;
  bottom: 8px; right: 8px;
  display: flex; align-items: center; gap: 3px;
  padding: 5px 7px 5px 6px;
  border-radius: 20px;
  background: rgba(var(--glass),0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(var(--on),0.1);
  cursor: pointer;
  font-size: 14px; line-height: 1;
  transition: opacity 0.18s, transform 0.15s;
  z-index: 3;
  opacity: 0;
}
.photo-card:hover .card-like-btn,
.card-like-btn.liked { opacity: 1; }
.card-like-btn:active { transform: scale(0.88); }
.card-like-btn.liked { background: rgba(200,20,50,0.28); border-color: rgba(255,100,120,0.4); }
.card-like-heart { font-size: 15px; line-height: 1; display: block; }
.card-like-n { font-size: 11px; font-weight: 700; color: rgba(var(--on),0.85); line-height: 1; }
@media (max-width: 767px) { .card-like-btn { opacity: 1; } }

/* ══════════════════════════════════
   TIMELINE VIEW — Density Bar + Photo List
══════════════════════════════════ */
.tl-density-wrap { position: relative; flex-shrink: 0; }
#tl-density {
  display: block; width: 100%;
  cursor: pointer;
  border-bottom: 1px solid rgba(var(--on),0.07);
}
.tl-density-hint {
  position: absolute; top: 8px; right: 12px;
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 20px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em;
  color: rgba(var(--on),0.92);
  background: rgba(var(--glass),0.92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(var(--on),0.12);
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  opacity: 0; transform: translateY(-4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}
.tl-density-hint span { font-size: 12px; line-height: 1; }
.tl-density-hint.show { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .tl-density-hint { transition: opacity 0.2s; }
}
.tl-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tl-scroll::-webkit-scrollbar { display: none; }

@keyframes tl-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .tl-scene-banner, .tl-entry, .tl-gap, .tl-moment-group { animation: none !important; }
}

/* Scene banner (sticky) */
.tl-scene-banner {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px 8px;
  background: rgba(var(--glass),0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(var(--on),0.07);
  animation: tl-rise 0.4s cubic-bezier(0.16,1,0.3,1) both;
}
.tl-scene-accent {
  width: 3px; height: 20px; border-radius: 2px; flex-shrink: 0;
}
.tl-scene-name {
  font-size: 13px; font-weight: 700;
  color: var(--text); flex: 1;
}
.tl-scene-time {
  font-size: 10px; color: rgba(var(--on),0.55);
  font-variant-numeric: tabular-nums;
}
.tl-scene-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  letter-spacing: 0.02em;
}

/* Entry row */
.tl-entry {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 14px; cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s ease-out;
  animation: tl-rise 0.35s cubic-bezier(0.16,1,0.3,1) both;
  animation-delay: var(--tl-delay, 0s);
}
.tl-entry:active { background: rgba(var(--on),0.06); }
@media (hover: hover) and (pointer: fine) {
  .tl-entry:hover { background: rgba(var(--on),0.045); }
  .tl-entry:hover .tl-thumb-ring { transform: scale(1.04); }
  .tl-entry:hover .tl-name { color: var(--text) !important; }
}
.tl-time {
  font-size: 10px; color: rgba(var(--on),0.55);
  width: 36px; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.tl-thumb-ring {
  width: 58px; height: 58px;
  border-radius: 10px; padding: 2px;
  border: 2px solid rgba(var(--on),0.14);
  flex-shrink: 0; overflow: hidden;
  background: var(--bg3);
  transition: transform 0.2s cubic-bezier(0.16,1,0.3,1);
}
.tl-thumb {
  width: 100%; height: 100%;
  border-radius: 7px; object-fit: cover;
  display: block; background: var(--bg3);
  transition: opacity 0.3s ease-out;
}
.tl-thumb[data-lazy] { opacity: 0; }
.tl-info { flex: 1; min-width: 0; }
.tl-name {
  font-size: 12px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color 0.15s;
  color: color-mix(in srgb, var(--pc, #a78bfa) 40%, var(--text) 60%);
}
.tl-scene-tag {
  font-size: 10px; color: rgba(var(--on),0.5); margin-top: 2px;
}

/* Time gap */
.tl-gap {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 14px 3px 60px;
  animation: tl-rise 0.35s cubic-bezier(0.16,1,0.3,1) both;
  animation-delay: var(--tl-delay, 0s);
}
.tl-gap-line { flex: 1; height: 1px; background: rgba(var(--on),0.07); }
.tl-gap-label {
  font-size: 9px; color: rgba(var(--on),0.4);
  white-space: nowrap; letter-spacing: 0.05em;
}

/* Shared moment group */
.tl-moment-group {
  display: flex;
  background: rgba(var(--on),0.03);
  border-top: 1px solid rgba(var(--on),0.06);
  border-bottom: 1px solid rgba(var(--on),0.06);
  margin: 2px 0;
  animation: tl-rise 0.35s cubic-bezier(0.16,1,0.3,1) both;
  animation-delay: var(--tl-delay, 0s);
}
.tl-moment-rail {
  width: 3px; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.tl-moment-rail > span { flex: 1; }
.tl-moment-inner { flex: 1; min-width: 0; }
.tl-moment-hd {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px 4px 12px;
}
.tl-moment-dots { display: flex; gap: 3px; }
.tl-moment-dots > span {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.tl-moment-txt {
  font-size: 10px; font-weight: 600;
  color: rgba(var(--on),0.55);
  letter-spacing: 0.03em;
}

/* ── Desktop: multi-column entry grid (avoids a single narrow
   left-aligned list stranding whitespace on wide screens) ── */
@media (min-width: 768px) {
  .tl-scroll {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    align-content: start;
    gap: 0 20px;
    padding: 0 20px;
    max-width: 1400px;
    margin: 0 auto;
  }
  .tl-scene-banner, .tl-gap, .tl-moment-group, .person-filter-bar {
    grid-column: 1 / -1;
  }
  .tl-scene-banner, .tl-gap, .tl-moment-group {
    margin: 0 -20px;
    padding-left: 20px; padding-right: 20px;
  }
  .tl-entry { border-radius: 10px; }
  .tl-moment-inner {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    align-content: start;
    gap: 0 16px;
  }
  .tl-moment-hd { grid-column: 1 / -1; }
}

/* ══════════════════════════════════
   GALLERY VIEW (O-style)
══════════════════════════════════ */

/* ── アバター行 ── */
.gallery-avatar-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid rgba(var(--on),0.05);
  padding: 10px 0 10px;
}
.gallery-avatar-scroll {
  display: flex; gap: 0;
  overflow-x: auto; padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}
.gallery-avatar-scroll::-webkit-scrollbar { display: none; }

/* ── "すべて" 特別ピル ── */
.g-all-avatar {
  flex-shrink: 0; width: 56px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; padding: 0 4px;
  transition: opacity 0.18s;
}
.g-all-avatar:active { opacity: 0.6; }
.g-all-avatar-ring {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(var(--on),0.07);
  border: 2px solid rgba(var(--on),0.12);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.g-all-avatar.active .g-all-avatar-ring {
  border-color: #a78bfa;
  background: rgba(167,139,250,0.12);
  box-shadow: 0 0 0 2px rgba(167,139,250,0.25);
}
.g-all-avatar-icon {
  font-size: 18px; line-height: 1;
  color: rgba(var(--on),0.4);
}
.g-all-avatar.active .g-all-avatar-icon { color: #a78bfa; }
.g-all-avatar-label {
  font-size: 9px; color: rgba(var(--on),0.35);
  white-space: nowrap; letter-spacing: 0.02em;
  text-align: center;
}
.g-all-avatar.active .g-all-avatar-label { color: #a78bfa; font-weight: 600; }

/* ── "いいね済み" ピル ── */
.g-liked-avatar {
  flex-shrink: 0; width: 56px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; padding: 0 4px;
  transition: opacity 0.18s;
}
.g-liked-avatar:active { opacity: 0.6; }
.g-liked-avatar-ring {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(var(--on),0.07);
  border: 2px solid rgba(var(--on),0.12);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
  position: relative;
}
.g-liked-avatar.active .g-liked-avatar-ring {
  border-color: #ff6b9d;
  background: rgba(255,107,157,0.12);
  box-shadow: 0 0 0 2px rgba(255,107,157,0.25);
}
.g-liked-avatar-icon { font-size: 18px; line-height: 1; }
.g-liked-avatar-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; border-radius: 8px;
  background: #ff6b9d;
  border: 1.5px solid var(--bg);
  font-size: 8px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; line-height: 1;
  transition: opacity 0.2s;
}
.g-liked-avatar-badge.hidden { display: none; }
.g-liked-avatar-label {
  font-size: 9px; color: rgba(var(--on),0.35);
  white-space: nowrap; letter-spacing: 0.02em;
  text-align: center;
}
.g-liked-avatar.active .g-liked-avatar-label { color: #ff6b9d; font-weight: 600; }

/* ── 参加者アバター ── */
.g-p-avatar-wrap {
  flex-shrink: 0; width: 58px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; padding: 0 4px;
  transition: opacity 0.18s;
}
.g-p-avatar-wrap:active { opacity: 0.65; }
.g-p-avatar-ring {
  width: 46px; height: 46px; border-radius: 50%;
  padding: 2.5px;
  position: relative;
  transition: all 0.3s;
}
.g-p-avatar-ring.unread {
  background: conic-gradient(
    var(--pcolor) 0%,
    color-mix(in srgb, var(--pcolor) 60%, white) 50%,
    var(--pcolor) 100%
  );
  box-shadow: 0 0 8px color-mix(in srgb, var(--pcolor) 50%, transparent);
}
.g-p-avatar-ring.read {
  background: rgba(var(--on),0.15);
  box-shadow: none;
}
@keyframes ring-spin {
  to { transform: rotate(360deg); }
}
.g-p-avatar-wrap.active .g-p-avatar-ring {
  background: conic-gradient(
    hsl(0,100%,65%),
    hsl(40,100%,65%),
    hsl(80,100%,60%),
    hsl(140,100%,55%),
    hsl(190,100%,60%),
    hsl(240,100%,65%),
    hsl(280,100%,65%),
    hsl(320,100%,65%),
    hsl(360,100%,65%)
  ) !important;
  box-shadow: 0 0 10px rgba(var(--on),0.25);
  animation: ring-spin 2.5s linear infinite;
}
.g-p-avatar-wrap.active .g-p-avatar-inner {
  filter: none !important;
  animation: ring-spin 2.5s linear infinite reverse;
}
.g-p-avatar-inner {
  width: 100%; height: 100%; border-radius: 50%;
  overflow: hidden;
  background: rgba(var(--on),0.04);
  border: 2.5px solid var(--bg);
  transition: filter 0.3s;
}
.g-p-avatar-ring.read .g-p-avatar-inner {
  filter: brightness(0.65) saturate(0.7);
}
.g-p-avatar-wrap.active .g-p-avatar-ring.read .g-p-avatar-inner {
  filter: brightness(0.85) saturate(0.9);
}
.g-p-avatar-inner img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.g-p-avatar-badge {
  position: absolute; top: 0px; right: 0px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--pcolor);
  border: 1.5px solid var(--bg);
  font-size: 8px; font-weight: 700; color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  transition: opacity 0.25s;
}
.g-p-avatar-ring.read .g-p-avatar-badge { opacity: 0; }
.g-p-avatar-label {
  font-size: 9px; color: rgba(var(--on),0.4);
  letter-spacing: 0.01em;
  text-align: center; max-width: 58px;
  line-height: 1.3; word-break: break-all;
  transition: color 0.2s;
}
.g-p-avatar-wrap.active .g-p-avatar-label { color: var(--pcolor); font-weight: 600; }
.g-p-avatar-ring.read ~ .g-p-avatar-label { color: rgba(var(--on),0.25); }

/* ── Scene divider + chips in avatar bar ── */
.g-scene-divider {
  width: 1px; height: 32px; flex-shrink: 0;
  background: rgba(var(--on),0.1);
  margin: 0 6px; align-self: center;
}
.g-scene-chip-wrap {
  flex-shrink: 0; width: 52px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; padding: 0 2px;
  transition: opacity 0.18s;
}
.g-scene-chip-wrap:active { opacity: 0.6; }
.g-scene-chip-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(var(--on),0.06);
  border: 1.5px solid rgba(var(--on),0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: all 0.2s; flex-shrink: 0;
}
.g-scene-chip-wrap.active .g-scene-chip-icon {
  background: rgba(167,139,250,0.18);
  border-color: rgba(167,139,250,0.5);
  box-shadow: 0 0 0 2px rgba(167,139,250,0.2);
}
.g-scene-chip-label {
  font-size: 9px; color: rgba(var(--on),0.35);
  max-width: 52px; text-align: center;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  line-height: 1.2;
}
.g-scene-chip-wrap.active .g-scene-chip-label { color: #a78bfa; font-weight: 600; }

/* ── Sort bar ── */
.g-sort-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 16px 6px;
  overflow-x: auto; scrollbar-width: none;
}
.g-sort-bar::-webkit-scrollbar { display: none; }
.g-sort-chip {
  flex-shrink: 0;
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 11px; font-weight: 500;
  border: 1px solid rgba(var(--on),0.12);
  background: transparent;
  color: rgba(var(--on),0.4);
  cursor: pointer; font-family: inherit;
  transition: all 0.18s; line-height: 1.6;
}
.g-sort-chip.active {
  background: rgba(167,139,250,0.15);
  border-color: rgba(167,139,250,0.4);
  color: #a78bfa; font-weight: 600;
}

/* ── Modal share button ── */
.modal-share-btn {
  display: flex; align-items: center; gap: 5px;
  background: rgba(var(--glass),0.7);
  backdrop-filter: blur(8px);
  color: rgba(var(--on),0.7);
  border: 1px solid rgba(var(--on),0.18);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.modal-share-btn:hover { background: rgba(var(--on),0.1); }
.modal-share-btn:active { transform: scale(0.95); }

/* ── Liked bulk download button ── */
.g-liked-dl-btn {
  display: none; align-items: center; gap: 4px;
  background: rgba(255,107,157,0.12);
  color: #ff6b9d;
  border: 1px solid rgba(255,107,157,0.25);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all 0.18s; white-space: nowrap;
}
.g-liked-dl-btn.visible { display: flex; }
.g-liked-dl-btn:hover { background: rgba(255,107,157,0.22); }
.g-liked-dl-btn:active { transform: scale(0.93); }

/* ── Filter status bar ── */
.g-filter-status {
  position: absolute; left: 0; right: 0; z-index: 4;
  overflow: hidden;
  transition: height 0.22s ease, opacity 0.18s ease;
  background: var(--bg);
  height: 0; opacity: 0;
}
.g-filter-status-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px;
  font-size: 11px; color: rgba(var(--on),0.4);
  border-bottom: 1px solid rgba(var(--on),0.04);
}
.g-filter-clear {
  background: none; border: none; cursor: pointer;
  color: rgba(var(--on),0.3); font-size: 11px;
  display: flex; align-items: center; gap: 4px; padding: 2px 0;
}

/* ── Gallery grid ── */
.gallery-grid {
  position: absolute;
  top: 80px; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: min-content;
  gap: 3px;
  align-content: start;
}
.gallery-grid::-webkit-scrollbar { display: none; }

.photo-card {
  border-radius: 4px;
  overflow: hidden;
  background: rgba(var(--on),0.04);
  cursor: pointer;
  aspect-ratio: 3/4;
  position: relative;
}
.photo-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
/* すべて表示時：正方形カードで全体表示 */
.gallery-grid.all .photo-card {
  aspect-ratio: 1;
  background: var(--bg6);
}
.gallery-grid.all .photo-card img {
  object-fit: contain;
}
.photo-card:active img { transform: scale(0.97); }
.card-accent { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; }
.photo-card .card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,0.6) 100%);
  display: flex; flex-direction: column;
  justify-content: flex-end; padding: 0 8px 10px; gap: 2px;
}
.card-name { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; text-shadow: 0 1px 3px rgba(0,0,0,0.5); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-time { font-size: 9px; color: rgba(var(--on),0.5); letter-spacing: 0.03em; }
/* 動画カード */
.photo-card.is-video .card-video-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.18);
  pointer-events: none;
}
.card-video-play-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; padding-left: 3px;
  border: 1.5px solid rgba(255,255,255,0.35);
}
.card-video-duration {
  position: absolute; bottom: 6px; right: 6px;
  font-size: 9px; font-weight: 700;
  background: rgba(0,0,0,0.6); color: #fff;
  padding: 1px 5px; border-radius: 4px;
  letter-spacing: 0.04em;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.photo-card.animate { animation: fadeInUp 0.2s ease both; }

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 20px 20px 40px;
  }
  .photo-card { aspect-ratio: 4/3; border-radius: 8px; }
  .photo-card:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 10px 32px rgba(0,0,0,0.6);
    z-index: 2;
  }
}

/* ── Long press overlay ── */
.lp-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(8px) saturate(0.6);
  display: none; align-items: center; justify-content: center; flex-direction: column;
  pointer-events: none;
}
.lp-overlay.show { display: flex; }
@keyframes lpPop {
  from { transform: scale(0.82); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.lp-card {
  width: min(68vw, 260px);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 16px 56px rgba(0,0,0,0.8), 0 0 0 1px rgba(var(--on),0.1);
  animation: lpPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.lp-card-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.lp-card-info {
  background: rgba(18,22,30,0.97);
  padding: 11px 13px;
  display: flex; align-items: center; gap: 9px;
}
.lp-avatar {
  width: 26px; height: 26px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  border: 2px solid var(--lpc, #fff);
}
.lp-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lp-name { font-size: 12px; font-weight: 700; }
.lp-role { font-size: 10px; color: rgba(var(--on),0.3); margin-left: 1px; }
.lp-time { font-size: 11px; color: rgba(var(--on),0.35); margin-left: auto; letter-spacing: 0.03em; }
.lp-hint {
  margin-top: 13px;
  font-size: 10px; color: rgba(var(--on),0.22);
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* ── Modal nearby section ── */
.modal-nearby {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom) + 16px);
  left: 50%; transform: translateX(-50%);
  width: calc(100% - 48px); max-width: 380px;
  background: rgba(18,22,30,0.97);
  border: 1px solid rgba(var(--on),0.08);
  border-radius: 14px;
  padding: 14px;
  z-index: 110;
  backdrop-filter: blur(12px);
  max-height: 52vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.nearby-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.nearby-title {
  font-size: 10px; font-weight: 700; color: rgba(var(--on),0.3);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.nearby-count-badge {
  font-size: 10px; color: rgba(var(--on),0.25);
}
.nearby-avatars {
  display: flex; align-items: flex-end; gap: 8px;
  overflow-x: auto; padding-bottom: 2px;
}
.nearby-avatars::-webkit-scrollbar { display: none; }
.nearby-av-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex-shrink: 0; cursor: pointer;
  transition: transform 0.15s;
}
.nearby-av-item:active { transform: scale(0.93); }
.nearby-av-ring {
  width: 44px; height: 44px; border-radius: 50%;
  padding: 2px;
  background: conic-gradient(var(--pc) 0%, color-mix(in srgb,var(--pc) 55%,white) 50%, var(--pc) 100%);
  box-shadow: 0 0 6px color-mix(in srgb,var(--pc) 40%,transparent);
  transition: all 0.2s;
}
.nearby-av-item.active .nearby-av-ring {
  background: conic-gradient(
    hsl(0,100%,65%), hsl(60,100%,60%), hsl(120,100%,55%),
    hsl(200,100%,60%), hsl(270,100%,65%), hsl(0,100%,65%)
  ) !important;
  box-shadow: 0 0 10px rgba(var(--on),0.25);
}
.nearby-av-inner {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  background: var(--bg4);
  border: 2px solid var(--bg);
}
.nearby-av-inner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nearby-av-label {
  font-size: 9px; color: rgba(var(--on),0.3);
  max-width: 48px; text-align: center;
  line-height: 1.3; word-break: break-all;
}
.nearby-av-item.active .nearby-av-label { color: rgba(var(--on),0.75); font-weight: 700; }
.nearby-more-btn {
  flex-shrink: 0; align-self: center;
  background: rgba(var(--on),0.06);
  border: 1px solid rgba(var(--on),0.1);
  border-radius: 20px;
  color: rgba(var(--on),0.4);
  font-size: 11px; font-weight: 600;
  padding: 8px 12px; cursor: pointer;
  white-space: nowrap; letter-spacing: 0.03em;
  transition: background 0.15s, color 0.15s;
}
.nearby-more-btn:active { background: rgba(var(--on),0.13); color: rgba(var(--on),0.7); }
.nearby-strip {
  margin-top: 12px;
  border-top: 1px solid rgba(var(--on),0.05);
  padding-top: 10px;
  animation: fadeInUp 0.18s ease both;
}
.nearby-strip-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; gap: 8px;
}
.nearby-strip-name { font-size: 12px; font-weight: 700; letter-spacing: 0.01em; }
.nearby-goto-all {
  background: none; border: none; cursor: pointer;
  font-size: 10px; color: rgba(var(--on),0.28);
  padding: 0; letter-spacing: 0.03em; white-space: nowrap;
  transition: color 0.15s;
}
.nearby-goto-all:active { color: rgba(var(--on),0.7); }
.nearby-strip-scroll {
  display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px;
}
.nearby-strip-scroll::-webkit-scrollbar { display: none; }
.nearby-strip-item {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.nearby-strip-photo {
  width: 68px; height: 90px;
  border-radius: 7px; overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.12s;
}
.nearby-strip-photo:active { transform: scale(0.95); }
.nearby-strip-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nearby-strip-time {
  font-size: 8px; color: rgba(var(--on),0.25);
  text-align: center; letter-spacing: 0.03em;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.08; transform: scale(1.35); }
}
.pulse-ring { animation: pulse-ring 2.8s ease-in-out infinite; transform-origin: 50% 50%; }

@keyframes modal-spin { to { transform: rotate(360deg); } }
.modal-spinner {
  width: 28px; height: 28px;
  border: 2px solid rgba(167,139,250,0.15);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: modal-spin 0.7s linear infinite;
}
/* ── モーダルメディアエリア ── */
.modal-img-wrap {
  position: relative;
  width: 100%;
  height: calc(82vh - 60px);
  background: #000;
  overflow: hidden;
}
/* プレースホルダー: サムネをぼかして即表示し、フル解像度読込後にフェードアウトする */
#modal-img-placeholder {
  display: block;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(1.08);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: blur(20px);
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.16,1,0.3,1);
  z-index: 0;
}
/* img: absolute で中央配置。%はコンテナの明示高さを参照するので確実に解決 */
#modal-img {
  display: block;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.15s ease;
  z-index: 1;
}
#modal-img.is-zoomed {
  will-change: transform;
  cursor: grab;
}
/* video: absolute でコンテナ全体を埋める。高さが含まれる要素の explicit heightから解決 */
#modal-video {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
}
#modal-video.active { display: block; }
#modal-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 2;
}

/* ══════════════════════════════════
   MOBILE LAYOUT
══════════════════════════════════ */
@media (max-width: 767px) {
  .top-bar {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0 16px;
    height: 48px;
  }
  .top-bar p,
  .mode-switcher { display: none; }
  .top-bar h1 { font-size: 14px; }

  .view { bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }

  .instructions { display: none; }

  #timeline-view { overflow: hidden; }

  /* ── Mobile Modal ── */
  .modal-overlay { cursor: default; }
  .modal-frame {
    width: 94vw;
    max-width: 94vw;
    will-change: transform;
  }
  .modal-img-wrap {
    height: 72dvh;
  }
  .modal-prev { left: 6px; }
  .modal-next { right: 6px; }
  .modal-count {
    bottom: max(72px, env(safe-area-inset-bottom, 0px) + 60px);
  }

}

/* ── Mobile Modal: 横向き（landscape）── 幅に余裕がある分、画像エリアを高く・フレームを細くする */
@media (max-width: 767px) and (orientation: landscape) {
  .modal-frame {
    width: 70vw;
    max-width: 70vw;
  }
  .modal-img-wrap {
    height: 82dvh;
  }
}

.bottom-nav { display: none; }

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 20;
    background: rgba(var(--glass),0.92);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(var(--on),0.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    align-items: stretch;
  }
  .bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: rgba(var(--on),0.35);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    min-height: 56px;
    padding-top: 6px;
    padding-bottom: 2px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.03em;
  }
  .bottom-nav-btn.active { color: #a78bfa; }
  .bottom-nav-btn svg { width: 22px; height: 22px; stroke-width: 1.8; }
}

/* ── Scene View ── */
#scene-view { overflow-y: auto; overflow-x: hidden; }
#scene-container {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── 参加者フィルタ（シーン/タイムライン共通） ── */
.person-filter-bar {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 2px 10px;
  /* CSS Gridの子要素は overflow:auto があると自動最小サイズが0扱いになり
     行トラックごと潰れることがあるため、明示的に高さを確保する */
  align-self: start;
  min-height: 34px;
}
.person-filter-bar::-webkit-scrollbar { display: none; }
.pf-chip {
  flex-shrink: 0; cursor: pointer; white-space: nowrap;
  font-size: 11px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
  color: rgba(var(--on),0.5);
  background: rgba(var(--on),0.05);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pf-chip:not(.pf-chip-all) { color: color-mix(in srgb, var(--pc) 55%, rgba(var(--on),0.55)); }
.pf-chip.active {
  background: rgba(var(--pc, 167,139,250),0.16);
  border-color: rgba(var(--pc, 167,139,250),0.4);
  color: color-mix(in srgb, var(--pc, #a78bfa) 55%, var(--text));
}
.pf-chip-all.active { background: rgba(var(--on),0.12); border-color: rgba(var(--on),0.2); color: var(--text); }
.pf-hidden { display: none !important; }

.scene-card {
  background: rgba(var(--on),0.03);
  border: 1px solid rgba(var(--on),0.07);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.scene-card.multi-view { border-color: rgba(167,139,250,0.2); }
.scene-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px 11px;
  border-bottom: 1px solid rgba(var(--on),0.05);
}
.scene-label {
  font-size: 14px;
  font-weight: 600;
  color: rgba(var(--on),0.85);
  letter-spacing: 0.02em;
}
.scene-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: rgba(var(--on),0.35);
}
.scene-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}
.scene-badge.multi {
  background: rgba(167,139,250,0.15);
  color: #a78bfa;
  border: 1px solid rgba(167,139,250,0.3);
}
.scene-badge.solo {
  background: rgba(var(--on),0.04);
  color: rgba(var(--on),0.25);
  border: 1px solid rgba(var(--on),0.08);
}
.scene-photos {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--on),0.1) transparent;
}
.scene-photos::-webkit-scrollbar { height: 4px; }
.scene-photos::-webkit-scrollbar-track { background: transparent; }
.scene-photos::-webkit-scrollbar-thumb { background: rgba(var(--on),0.1); border-radius: 2px; }
.scene-photo-card {
  flex-shrink: 0;
  width: 120px;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(var(--on),0.03);
  border: 1.5px solid rgba(var(--on),0.06);
  transition: transform 0.18s, border-color 0.18s;
}
.scene-photo-card:hover {
  transform: translateY(-3px);
  border-color: var(--pcolor);
}
.scene-photo-thumb {
  width: 120px;
  height: 120px;
  overflow: hidden;
  background: var(--bg5);
}
.scene-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s;
}
.scene-photo-info {
  padding: 7px 9px 8px;
  border-top: 1px solid rgba(var(--on),0.05);
}
.scene-photo-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--pcolor);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.scene-photo-time {
  font-size: 10px;
  color: rgba(var(--on),0.28);
}
.scene-solo-note {
  font-size: 11px;
  color: rgba(var(--on),0.2);
  padding: 4px 18px 14px;
  font-style: italic;
}

/* ── Mobile Scene Collage ── */
.scene-sheet-overlay, .scene-sheet { display: none; }

@media (max-width: 767px) {
  .scene-sheet-overlay, .scene-sheet { display: block; }
  #scene-view { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; }
  #scene-container {
    flex: 1; min-width: 0;
    padding: 10px 10px 80px 6px;
    display: flex; flex-direction: column; gap: 10px;
    max-width: none;
  }

  /* 左端縦レール */
  #scene-rail {
    width: 26px; flex-shrink: 0;
    display: flex; flex-direction: column;
    padding: 10px 3px;
    overflow-y: auto; scrollbar-width: none;
  }
  #scene-rail::-webkit-scrollbar { display: none; }
  .scene-rail-item {
    min-height: 48px; flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    cursor: pointer; border-radius: 4px; margin: 1px 0;
    transition: background 0.25s;
  }
  .scene-rail-item.active { background: rgba(var(--scene-rgb),0.14); }
  .scene-rail-dot {
    width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
    background: rgba(var(--scene-rgb),0.35);
    transition: background 0.25s, transform 0.25s;
  }
  .scene-rail-item.active .scene-rail-dot { background: rgba(var(--scene-rgb),1); transform: scale(1.3); }
  .scene-rail-item span {
    writing-mode: vertical-rl;
    font-size: 9px; font-weight: 600; color: rgba(var(--on),0.32);
    letter-spacing: 0.04em; transition: color 0.25s;
    line-height: 1; overflow: hidden; max-height: 40px; white-space: nowrap;
  }
  .scene-rail-item.active span { color: rgba(var(--scene-rgb),1); font-weight: 700; }

  /* アップロードFAB */
  #mobile-upload-fab {
    display: none; position: fixed;
    right: 20px;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 16px);
    width: 56px; height: 56px; border-radius: 50%;
    background: #a78bfa; color: #fff;
    align-items: center; justify-content: center;
    font-size: 28px; font-weight: 300; line-height: 1;
    text-decoration: none; z-index: 95;
    box-shadow: 0 4px 12px rgba(167,139,250,0.45);
  }
  #mobile-upload-fab.visible { display: flex; }

  .collage-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 95px 95px;
    gap: 2px;
    padding: 0 2px 0;
  }
  .collage-grid.single { grid-template-columns: 1fr; grid-template-rows: 190px; }
  .collage-grid.pair   { grid-template-columns: 1fr 1fr; grid-template-rows: 190px; }

  .collage-main {
    grid-row: 1 / 3;
    position: relative;
    overflow: hidden;
    background: var(--bg5);
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .collage-grid.single .collage-main { border-radius: 8px; grid-row: auto; }
  .collage-grid.pair   .collage-main { border-radius: 8px 0 0 8px; grid-row: auto; }

  .collage-side {
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .collage-sub {
    flex: 1;
    overflow: hidden;
    background: var(--bg5);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .collage-sub:first-child { border-radius: 0 8px 0 0; }
  .collage-sub:last-child  { border-radius: 0 0 8px 0; }
  .collage-grid.pair .collage-sub { border-radius: 0 8px 8px 0; }

  .collage-img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.5s ease;
  }
  .collage-name-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 24px 8px 6px;
    background: linear-gradient(to top, rgba(0,0,0,0.72), transparent);
    font-size: 10px;
    font-weight: 600;
    color: var(--pc, #fff);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .collage-footer {
    font-size: 11px;
    color: #a78bfa;
    padding: 7px 14px 8px;
    text-align: right;
    border-top: 1px solid rgba(var(--on),0.05);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .collage-footer:active { opacity: 0.6; }

  /* ── Scene Bottom Sheet ── */
  .scene-sheet-overlay {
    position: fixed; inset: 0; z-index: 40;
    background: transparent; pointer-events: none;
    transition: background 0.3s ease;
  }
  .scene-sheet-overlay.open {
    background: rgba(0,0,0,0.55); pointer-events: auto;
  }
  .scene-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
    background: var(--bg3);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid rgba(var(--on),0.1);
    display: flex; flex-direction: column;
    max-height: 88dvh;
    transform: translateY(100%);
    transition: transform 0.36s cubic-bezier(0.32,0.72,0,1);
    will-change: transform;
  }
  .scene-sheet.open { transform: translateY(0); }
  .scene-sheet.dragging { transition: none; }
  .scene-sheet-handle-wrap {
    padding: 10px 0 2px; display: flex; justify-content: center;
    flex-shrink: 0; touch-action: none; cursor: grab;
  }
  .scene-sheet-handle {
    width: 36px; height: 4px;
    background: rgba(var(--on),0.18); border-radius: 2px;
  }
  .scene-sheet-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: 4px 18px 12px; flex-shrink: 0;
  }
  .scene-sheet-title { font-size: 17px; font-weight: 700; color: rgba(var(--on),0.92); }
  .scene-sheet-sub   { font-size: 11px; color: rgba(var(--on),0.35); margin-top: 3px; }
  .scene-sheet-close {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(var(--on),0.1); border: none;
    color: rgba(var(--on),0.55); font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; margin-top: 2px;
    -webkit-tap-highlight-color: transparent;
  }
  .scene-sheet-close:active { background: rgba(var(--on),0.18); }
  .scene-sheet-divider { height: 1px; background: rgba(var(--on),0.06); flex-shrink: 0; }
  .scene-sheet-grid {
    flex: 1; overflow-y: auto;
    padding: 10px 10px 40px;
    display: grid; grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: min-content;
    align-content: start;
    gap: 6px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .scene-sheet-photo {
    border-radius: 10px; overflow: hidden; position: relative;
    background: var(--bg); cursor: pointer;
    aspect-ratio: 4/3;
    -webkit-tap-highlight-color: transparent;
  }
  .scene-sheet-photo:active { opacity: 0.82; }
  .scene-sheet-photo img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .scene-sheet-photo-info {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 20px 7px 6px;
    background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  }
  .scene-sheet-photo-name {
    font-size: 10px; font-weight: 600; color: var(--pc, #a78bfa);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
  }
  .scene-sheet-photo-time { font-size: 9px; color: rgba(var(--on),0.38); display: block; margin-top: 1px; }
}

/* ── #4 モードオンボーディング ── */
.mode-onboarding {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(14px);
  align-items: center; justify-content: center;
}
.mode-onboarding-card {
  background: var(--bg2);
  border: 1px solid rgba(var(--on),0.1);
  border-radius: 22px;
  padding: 28px 24px 22px;
  max-width: 310px; width: calc(100% - 48px);
  text-align: center;
}
.mode-onboarding-title {
  font-size: 16px; font-weight: 700; margin-bottom: 18px;
  color: rgba(var(--on),0.9);
}
.mode-onboarding-items {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 22px; text-align: left;
}
.mode-onboarding-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(var(--on),0.04);
}
.mode-onboarding-icon { font-size: 18px; flex-shrink: 0; line-height: 1.4; }
.mode-onboarding-text { font-size: 12px; color: rgba(var(--on),0.6); line-height: 1.5; }
.mode-onboarding-text strong { color: rgba(var(--on),0.9); display: block; font-size: 13px; margin-bottom: 2px; }
.mode-onboarding-btn {
  width: 100%; padding: 12px;
  font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #a78bfa, #c77dff);
  border: none; border-radius: 14px; cursor: pointer;
  font-family: inherit; transition: opacity 0.2s;
}
.mode-onboarding-btn:active { opacity: 0.85; }

/* ── #5 シーン横スクロールフェード ── */
.scene-photos-wrap {
  position: relative;
}
.scene-photos-wrap::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 6px;
  width: 64px;
  background: linear-gradient(to right, transparent, var(--bg2) 90%);
  pointer-events: none;
  z-index: 2;
}

/* ── #8 タイムライン操作ヒント ── */
.tl-gesture-hint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(var(--glass),0.94);
  border: 1px solid rgba(var(--on),0.1);
  border-radius: 18px;
  padding: 16px 28px;
  font-size: 14px;
  color: rgba(var(--on),0.72);
  pointer-events: none;
  z-index: 30;
  backdrop-filter: blur(16px);
  text-align: center;
  line-height: 2;
  transition: opacity 0.5s ease;
  letter-spacing: 0.02em;
}

/* Toast notification */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(var(--on), 0.12);
  backdrop-filter: blur(12px);
  color: rgba(var(--on), 0.85);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 999;
  border: 1px solid rgba(var(--on), 0.15);
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}
#toast.visible {
  opacity: 1;
}

/* ═══════════════════════════════════════════════
   SCENE VIEW — Film Strip
═══════════════════════════════════════════════ */
@media (min-width: 768px) {
  #scene-sidebar { display: none !important; }
  /* #scene-rail はモバイル専用ジャンプナビ。一度でも狭幅で構築されると
     内容がDOMに残り続けるため、デスクトップ幅では内容の有無に関わらず必ず隠す */
  #scene-rail { display: none !important; }
  #scene-view { overflow-y: auto !important; overflow-x: hidden !important; display: block !important; -webkit-overflow-scrolling: touch; }
  #scene-container { overflow: visible !important; max-width: none !important; flex: none !important; padding: 0 !important; }
}

.scene-section { margin-bottom: 0; }
.scene-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 10px;
  position: sticky; top: 0; z-index: 10;
  /* シーン色の面積を増やし、スクロール中に「今どのシーンか」が一目でわかるようにする */
  background:
    linear-gradient(rgba(var(--scene-rgb),0.10), rgba(var(--scene-rgb),0.02)),
    linear-gradient(rgba(var(--glass),0.95), rgba(var(--glass),0.95));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(var(--on),0.06);
  box-shadow: inset 3px 0 0 rgba(var(--scene-rgb),0.9);
}
.scene-hdr .scene-icon {
  font-size: 13px; line-height: 1;
  width: 22px; height: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(var(--scene-rgb),0.28);
}
.scene-hdr .scene-name { font-size: 13px; font-weight: 700; color: rgba(var(--on),0.9); flex: 1; }
.scene-hdr .scene-progress {
  font-family: 'Courier New', monospace;
  font-size: 10px; font-weight: 400;
  color: rgba(var(--scene-rgb),1);
  background: rgba(var(--scene-rgb),0.14);
  border-radius: 999px;
  padding: 2px 7px;
}
.scene-hdr .scene-meta { font-size: 10px; color: rgba(var(--on),0.5); }
.scene-hdr.is-clickable { cursor: pointer; }
.scene-hdr-expand {
  font-size: 10px; font-weight: 600; color: rgba(var(--scene-rgb),0.85);
  flex-shrink: 0; white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
  .scene-hdr.is-clickable:hover { background-color: rgba(var(--scene-rgb),0.05); }
  .scene-hdr.is-clickable:hover .scene-hdr-expand { color: rgba(var(--scene-rgb),1); }
}

.film-strip {
  display: flex; gap: 0;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  padding: 12px 16px 16px;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
}
.film-strip::-webkit-scrollbar { display: none; }

.film-card {
  flex-shrink: 0;
  width: 180px;
  margin-right: 10px;
  cursor: pointer;
}
.film-card:active { opacity: 0.85; }
.film-img-wrap {
  width: 180px; height: 135px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg3, #1c2128);
  position: relative;
}
.film-img-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: opacity 0.3s;
}
.film-first-tag {
  position: absolute; top: 7px; left: 7px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  font-size: 9px; font-weight: 700;
  padding: 3px 8px; border-radius: 20px;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.04em;
}
.film-card-meta {
  padding: 6px 2px 0;
  display: flex; align-items: center; gap: 6px;
}
.film-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--pc); }
.film-name {
  font-size: 11px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--pc);
  color: color-mix(in srgb, var(--pc) 38%, var(--text));
}
.film-time { font-size: 10px; color: rgba(var(--on),0.5); margin-left: auto; flex-shrink: 0; }
.scene-divider { height: 1px; background: rgba(var(--on),0.06); margin: 0 16px; }
.scene-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 22px 16px;
  font-size: 12px;
  color: rgba(var(--on),0.4);
}
.scene-empty-icon { font-size: 15px; opacity: 0.6; }
.parent-scene-group { margin-bottom: 0; }
.parent-scene-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 20px 16px 6px;
  border-top: 2px solid rgba(var(--on),0.08);
  margin-top: 8px;
}
.parent-scene-group:first-child .parent-scene-hdr { border-top: none; margin-top: 0; }
.parent-scene-name { font-size: 15px; font-weight: 800; color: rgba(var(--on),0.9); flex: 1; letter-spacing: 0.02em; }
.parent-scene-meta { font-size: 11px; color: rgba(var(--on-dim),0.5); }
.scene-group-divider { height: 6px; background: rgba(var(--on),0.04); margin: 4px 0; }

/* ═══════════════════════════════════════════════
   GALLERY VIEW — Cork Board
═══════════════════════════════════════════════ */
#gallery-view { background: #7a5530; }

/* New participant avatar style (g-p-wrap) */
.g-p-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; flex-shrink: 0;
}
.g-p-wrap:active { opacity: 0.7; }
.g-p-ring {
  width: 44px; height: 44px; border-radius: 50%;
  padding: 2px;
  background: conic-gradient(var(--pc, #a78bfa) 0%, color-mix(in srgb, var(--pc, #a78bfa) 50%, transparent) 100%);
  transition: outline 0.15s;
}
.g-p-wrap.active .g-p-ring { outline: 2px solid var(--pc, #a78bfa); outline-offset: 1px; }
.g-p-inner {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--bg2, #161b22);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; font-size: 13px; font-weight: 700;
  border: 2px solid var(--bg, #0d1117);
}
.g-p-inner img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.g-p-label {
  font-size: 9px; color: rgba(var(--on-dim),0.4);
  max-width: 46px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.g-p-wrap.active .g-p-label { color: var(--pc, #a78bfa); }

/* Scatter/shuffle button */
.g-scatter-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(var(--on),0.45);
  font-size: 15px; width: 32px; height: 32px;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.3s;
}
.g-scatter-btn:active { background: rgba(255,255,255,0.15); }

/* Cork board */
#gallery-board {
  position: absolute; left: 0; right: 0; bottom: 0; top: 0;
  background-color: #7a5530;
  background-image:
    radial-gradient(ellipse at 22% 28%, rgba(255,235,190,0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 78% 72%, rgba(0,0,0,0.14) 0%, transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.68' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.22'/%3E%3C/svg%3E");
  overflow: hidden; cursor: grab; touch-action: none;
}
#gallery-board:active { cursor: grabbing; }
#gallery-canvas {
  position: absolute; width: 3000px; height: 3000px;
  transform-origin: top left;
}

/* Polaroid card */
.polaroid {
  position: absolute; width: 148px;
  background: #fefefa; border-radius: 3px;
  padding: 9px 9px 32px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.18), 0 12px 24px rgba(0,0,0,0.14);
  cursor: pointer; will-change: transform;
  touch-action: none;
  transition: box-shadow 0.15s;
}
.polaroid.dragging {
  box-shadow: 0 8px 16px rgba(0,0,0,0.28), 0 24px 48px rgba(0,0,0,0.22);
  z-index: 999 !important; cursor: grabbing;
}
.polaroid-photo { width: 100%; aspect-ratio: 1; overflow: hidden; background: #e2e2e2; }
.polaroid-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity 0.3s; }
.polaroid-label {
  position: absolute; bottom: 0; left: 0; right: 0; height: 32px;
  display: flex; align-items: center; justify-content: center; gap: 5px; padding: 0 8px;
}
.polaroid-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.polaroid-name {
  font-size: 10px; font-weight: 700; font-family: 'Courier New', monospace;
  letter-spacing: 0.04em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px;
}
.pin { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); width: 16px; height: 16px; pointer-events: none; }
.pin-head { width: 14px; height: 14px; border-radius: 50%; position: absolute; top: 0; left: 1px; box-shadow: inset -2px -2px 5px rgba(0,0,0,0.32), 0 2px 5px rgba(0,0,0,0.3); }
.pin-needle { width: 2px; height: 9px; background: linear-gradient(to bottom, #bbb, #888); position: absolute; bottom: -7px; left: 7px; border-radius: 0 0 1px 1px; }

.gallery-board-hint {
  position: fixed; bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 10px);
  left: 0; right: 0; text-align: center;
  font-size: 11px; color: rgba(255,215,150,0.25); pointer-events: none;
  letter-spacing: 0.05em; z-index: 10; font-weight: 500;
}
.board-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; color: rgba(255,220,150,0.28); pointer-events: none;
  font-size: 13px; font-weight: 600;
}

@keyframes pop-in {
  from { transform: scale(0.75) rotate(var(--ia, 0deg)); opacity: 0; }
  to   { transform: rotate(var(--ia, 0deg)); opacity: 1; }
}
.polaroid.animate { animation: pop-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ── Hover Preview (desktop only) ── */
#hover-preview {
  display: none;
  position: fixed;
  z-index: 300;
  pointer-events: none;
  width: 240px;
  background: var(--bg2);
  border: 1px solid rgba(var(--on), 0.1);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 56px rgba(0,0,0,0.65), 0 0 0 0.5px rgba(var(--on),0.05);
  opacity: 0;
  transform: scale(0.94) translateY(6px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
#hover-preview.hp-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}
#hp-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--bg5);
}
#hp-info {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px 10px;
  border-top: 1px solid rgba(var(--on), 0.06);
}
#hp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
#hp-name {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#hp-time {
  font-size: 11px;
  color: rgba(var(--on), 0.35);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
