/* --- Variables --- */
:root[data-theme="dark"] {
  --bg:         #1e1f22;
  --surface:    #2b2d31;
  --surface2:   #35373c;
  --accent:     #00b0f4;
  --accent2:    #38d9f5;
  --ok:         #23a55a;
  --err:        #f23f43;
  --warn:       #f0b232;
  --text:       #dbdee1;
  --text-muted: #80848e;
  --border:     #3f4147;
  --shadow:     rgba(0,0,0,0.55);
  --drop-hover: rgba(0,176,244,0.09);
  --drop-ok:    rgba(35,165,90,0.10);
}
:root[data-theme="light"] {
  --bg:         #f2f3f5;
  --surface:    #ffffff;
  --surface2:   #e3e5e8;
  --accent:     #0096cf;
  --accent2:    #00b0d8;
  --ok:         #2d7d46;
  --err:        #c0392b;
  --warn:       #b07000;
  --text:       #2e3338;
  --text-muted: #5c6370;
  --border:     #d4d7dc;
  --shadow:     rgba(0,0,0,0.08);
  --drop-hover: rgba(0,150,207,0.07);
  --drop-ok:    rgba(45,125,70,0.08);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { -webkit-tap-highlight-color: transparent; appearance: none; cursor: pointer; user-select: none; }
button:focus:not(:focus-visible) { outline: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
  transition: background 0.6s;
}
*:hover::-webkit-scrollbar-thumb {
  background: rgba(120,120,120,0.35);
  transition: background 0.6s;
}
::-webkit-scrollbar-button { height: 0; width: 0; }
img { -webkit-user-drag: none; user-drag: none; }

/* --- Base --- */
html, body {
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', 'Segoe UI', Arial, sans-serif;
  min-height: 100vh;
  overflow: hidden;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
}

/* =====================
   APP HEADER
===================== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 2px 10px var(--shadow);
  z-index: 10;
}
.app-logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  user-select: none;
  cursor: pointer;
  transition: opacity 0.15s;
}
.app-logo:hover { opacity: 0.75; }
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-btn {
  position: relative;
  min-width: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.header-btn:hover { color: var(--accent); border-color: var(--accent); }
.header-btn:active { background: var(--surface2); transform: scale(0.93); transition: transform 0.07s, color 0.15s, border-color 0.15s; }
.header-btn svg.lucide { width: 14px; height: 14px; }

/* =====================
   APP LAYOUT (sidebar + main)
===================== */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: 220px;
  min-width: 72px;
  max-width: 400px;
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  position: relative;
}
.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: var(--accent);
  opacity: 0.5;
}
.sidebar-search-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 4px 10px 0;
  height: 34px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.sidebar-search-wrap:focus-within {
  border-color: var(--accent);
}
.sidebar-search-input {
  flex: 1;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  outline: none;
  min-width: 0;
}
.sidebar-search-input::placeholder { color: var(--text-muted); }
.sidebar-search-btn {
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.sidebar-search-btn:hover { color: var(--accent); background: var(--drop-hover); }
.sidebar-search-status {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 12px 0;
  min-height: 14px;
  flex-shrink: 0;
  white-space: normal;
  overflow: visible;
  line-height: 1.4;
}
.sidebar-search-status.error { color: var(--err); }
.sidebar-search-status.ok    { color: var(--ok); }
.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }
.sidebar-group-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.12s;
}
.sidebar-group-header:hover { color: var(--text); }
.sidebar-group-toggle {
  font-size: 9px;
  transition: transform 0.2s;
  display: inline-block;
}
.sidebar-group-toggle.collapsed { transform: rotate(-90deg); }
.sidebar-channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 12px;
  border-radius: 4px;
  margin: 0 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s, border-radius 0.1s, padding 0.1s, gap 0.1s;
  user-select: none;
}
.sidebar-channel-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.sidebar-channel-item.active {
  background: var(--drop-hover);
  color: var(--accent);
}

.sidebar-ch-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-ch-avatar {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
}
.sidebar-ch-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 13px;
}
.name-inner {
  display: inline-block;
  white-space: nowrap;
}
.sidebar-ch-name:has(.name-inner.overflows),
.sidebar-folder-name:has(.name-inner.overflows) {
  -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
  mask-image:         linear-gradient(to right, black 85%, transparent 100%);
}
@keyframes sidebar-text-slide {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(0); }
  85%  { transform: translateX(var(--slide-dist, 0px)); }
  100% { transform: translateX(var(--slide-dist, 0px)); }
}
.sidebar-channel-item:hover .name-inner.overflows,
.sidebar-folder-header:hover .name-inner.overflows {
  animation: sidebar-text-slide 3.5s ease-in-out infinite alternate;
}
.sidebar-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-manage-btn {
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.sidebar-manage-btn:hover { color: var(--text); border-color: var(--accent); }

/* ── コンパクト（アイコンのみ）モード ── */
.sidebar--compact { overflow: visible; }
.sidebar--compact .sidebar-search-wrap,
.sidebar--compact .sidebar-search-status,
.sidebar--compact .sidebar-footer { display: none; }
.sidebar--compact .sidebar-group-header {
  font-size: 0;
  padding: 4px 0;
  justify-content: center;
}
.sidebar--compact .sidebar-group-header::after {
  content: '';
  display: block;
  width: 32px;
  height: 1px;
  background: var(--border);
}
.sidebar--compact .sidebar-group-toggle { display: none; }
.sidebar--compact .sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overflow-x: visible;
  padding: 8px 0 4px;
}
.sidebar--compact .sidebar-channel-item {
  width: 50px;
  height: 52px;
  padding: 4px 3px;
  margin: 0;
  gap: 0;
  justify-content: center;
  border-radius: 50%;
  transition: border-radius 0.2s, background 0.12s, color 0.12s;
  position: relative;
}
.sidebar--compact .sidebar-channel-item:hover { border-radius: 30%; background: var(--surface2); }
.sidebar--compact .sidebar-channel-item.active { border-radius: 30%; background: var(--drop-hover); }
.sidebar--compact .sidebar-channel-item::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  width: 4px;
  height: 44px;
  border-radius: 0 6px 6px 0;
  background: #fff;
  opacity: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.sidebar--compact .sidebar-channel-item:hover::before {
  opacity: 0.4;
  transform: translateY(-50%) scaleY(0.3);
}
.sidebar--compact .sidebar-channel-item.active::before {
  opacity: 1;
  transform: translateY(-50%) scaleY(1);
}
.sidebar--compact .sidebar-ch-name { display: none; }
.sidebar--compact .sidebar-ch-avatar { width: 44px; height: 44px; }
/* ドラッグ並び替え */
.sidebar-channel-item[style*="opacity: 0.25"],
.sidebar-group-header[style*="opacity: 0.25"] {
  pointer-events: none;
}
/* コンパクト: チャンネル追加ボタン */
.sidebar-compact-add-wrap {
  display: none;
  flex-shrink: 0;
}
.sidebar--compact .sidebar-compact-add-wrap {
  display: flex;
  height: 52px;
  width: 50px;
  justify-content: center;
  align-items: center;
}
.sidebar-compact-add-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, border-radius 0.2s;
}
.sidebar-compact-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--drop-hover);
  border-radius: 30%;
}
/* コンパクト追加ポップオーバー */
.sidebar-compact-add-pop {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 2px 4px 16px var(--shadow);
  padding: 10px;
  z-index: 9999;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}
.sidebar-compact-add-pop.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.sidebar-compact-add-pop[hidden] { display: none !important; }
.sidebar-compact-add-input-row { display: flex; gap: 4px; }
.sidebar-compact-add-input {
  flex: 1;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  min-width: 0;
}
.sidebar-compact-add-input::placeholder { color: var(--text-muted); }
.sidebar-compact-add-input:focus { border-color: var(--accent); }
.sidebar-compact-add-submit {
  padding: 7px 10px;
  background: var(--accent);
  border: none;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.sidebar-compact-add-submit:hover { opacity: 0.85; }
.sidebar-compact-add-status {
  font-size: 11px;
  color: var(--text-muted);
  min-height: 14px;
}
.sidebar-compact-add-status.error { color: var(--err); }
.sidebar-compact-add-status.ok    { color: var(--ok); }
/* チャンネルツールチップ */
.ch-tooltip {
  position: fixed;
  box-sizing: border-box;
  background: var(--surface2);
  color: var(--text);
  padding: 6px;
  border-radius: 10px;
  pointer-events: none;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.12s, transform 0.12s;
  z-index: 9999;
  border: 1px solid var(--border);
  box-shadow: 2px 4px 12px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 280px;
}
.ch-tooltip.visible { opacity: 1; transform: translateX(0); pointer-events: auto; }
.ch-tooltip-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ch-tooltip-name-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}
.ch-tooltip-gear {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: background 0.1s, color 0.1s;
}
.ch-tooltip-gear:hover { background: var(--drop-hover); color: var(--text); }
.ch-tooltip-gear svg { width: 13px; height: 13px; }
.ch-tooltip-actions { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.ch-tooltip-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
}
.ch-tooltip-btn:hover { background: var(--drop-hover); }
.ch-tooltip-btn.danger { color: var(--err, #f87171); }
.ch-tooltip-btn.danger:hover { background: rgba(248, 113, 113, 0.12); }
/* ツールチップ内インラインリネーム入力 */
.ch-tooltip-rename-input {
  flex: 1;
  min-width: 0;
  height: 20px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  border-radius: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 0;
  outline: none;
  box-sizing: border-box;
}
.ch-tooltip-rename-input:focus { border-bottom-color: var(--accent); }
.ch-compact-rename-pop {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  gap: 4px;
  z-index: 10000;
  box-shadow: 2px 4px 12px var(--shadow);
}
.ch-compact-rename-input {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  padding: 4px 8px;
  width: 160px;
  outline: none;
}
.ch-compact-rename-input:focus { border-color: var(--accent); }
.ch-compact-rename-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.ch-compact-rename-submit:hover { opacity: 0.85; }
/* チャンネル右クリックメニュー */
/* チャンネルアクションボタン */
.ch-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  margin-left: -5px;
  transition: opacity 0.15s ease;
}
.sidebar-channel-item:hover .ch-actions,
.sidebar-folder-header:hover .ch-actions,
.sidebar-channel-item:has(.ch-spinner) .ch-actions,
.sidebar-folder-header:has(.ch-spinner) .ch-actions {
  max-width: 60px;
  opacity: 1;
  margin-left: 0;
}
.sidebar--compact .ch-actions { display: none; }
.ch-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  pointer-events: none;
  transition: color 0.15s;
}
.sidebar-channel-item:hover .ch-action-btn,
.sidebar-folder-header:hover .ch-action-btn { pointer-events: auto; }
.ch-action-btn svg { width: 11px; height: 11px; }
.ch-action-rename:hover  { color: #f0a040; }
.ch-action-refresh:hover { color: var(--accent); }
.ch-action-delete:hover  { color: #f04747; }
.sidebar-channel-item:not(:hover):has(.ch-spinner) .ch-action-delete,
.sidebar-folder-header:not(:hover):has(.ch-spinner) .ch-action-delete,
.sidebar-folder-header:not(:hover):has(.ch-spinner) .ch-action-rename {
  display: none;
}
.ch-action-btn:active { transform: scale(0.88); transition: transform 0.07s, color 0.15s; }
.ch-action-btn:disabled { opacity: 0.6; pointer-events: none; }
@keyframes ch-spin { to { transform: rotate(360deg); } }
.ch-spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ch-spin 0.7s linear infinite;
  vertical-align: middle;
}
/* コンパクトモード: リフレッシュ中スピナーオーバーレイ */
.compact-refreshing .sidebar-ch-avatar-wrap::after,
.compact-refreshing .sidebar-folder-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: 2.5px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.85);
  animation: ch-spin 0.75s linear infinite;
  pointer-events: none;
  z-index: 2;
}
/* 削除確認ポップアップ */
.ch-del-popup {
  position: fixed;
  z-index: 10000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
  font-size: 11px;
  color: var(--text);
  max-width: 220px;
}
.ch-del-popup-msg { line-height: 1.4; }
.ch-del-popup-btns { display: flex; gap: 6px; justify-content: flex-end; }
.ch-del-popup-ok, .ch-del-popup-cancel {
  font-size: 11px;
  font-family: inherit;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.12s;
}
.ch-del-popup-ok:hover, .ch-del-popup-cancel:hover { opacity: 0.8; }
.ch-del-popup-ok { background: var(--err); border: 1px solid color-mix(in srgb, var(--err) 75%, #000); color: #fff; }
.ch-del-popup-ok--refresh { background: var(--accent) !important; border-color: var(--accent2, #357abd) !important; }
.ch-del-popup-cancel { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }

/* --- Main area --- */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* --- Channel header (tabs, category filter) --- */
.channel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 1px 6px var(--shadow);
  z-index: 5;
  position: relative;
}
.ch-avatar {
  width: 28px; height: 28px;
  border-radius: 50%; object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ch-avatar:hover { opacity: 0.75; }
.ch-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: clamp(120px, 20vw, 320px);
  min-width: 0;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
}
.ch-name:hover { color: var(--accent); }
.ch-tabs {
  display: flex;
  gap: 0;
  background: none;
  padding: 0;
  flex-shrink: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
  align-items: stretch;
}
.ch-tab {
  padding: 0 18px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  box-sizing: border-box;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ch-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.ch-tab:hover:not(.active) {
  color: var(--text);
  border-bottom-color: rgba(255,255,255,0.15);
}

/* --- Category filter (in channel header) --- */
.cat-filter {
  display: flex;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.cat-seg-btn {
  padding: 0 10px;
  height: 26px;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.cat-seg-btn:last-child {
  border-right: none;
}
.cat-seg-btn:hover:not(.active) {
  background: var(--surface2);
  color: var(--text);
}
.cat-seg-btn.active {
  background: rgba(88, 101, 242, 0.15);
  color: var(--accent);
}

/* --- screens wrapper --- */
.screen {
  flex: 1;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  padding: 20px 24px;
}
.screen::-webkit-scrollbar-thumb {
  background: rgba(120,120,120,0.25);
  min-height: 48px;
}
.screen:hover::-webkit-scrollbar-thumb {
  background: rgba(120,120,120,0.45);
}

/* --- Welcome screen --- */
.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 20px 56px;
  gap: 40px;
  overflow-y: auto;
  width: 100%;
  min-height: 100%;
  zoom: 1.1;
}
.welcome-card {
  width: 100%;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.welcome-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.welcome-label {
  font-size: 15px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}
.welcome-opt {
  background: rgba(128,132,142,.2);
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}
.welcome-search-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 32px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
[data-theme="light"] .welcome-search-wrap {
  background: #fff;
  border-color: #dfe1e5;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.welcome-search-wrap:focus-within { border-color: var(--accent, #4f9cf9); box-shadow: 0 0 0 3px rgba(79,156,249,.18), 0 2px 10px rgba(0,0,0,.25); }
.welcome-search-input {
  flex: 1;
  min-width: 0;
  padding: 16px 24px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.welcome-search-input::placeholder { color: var(--text-muted); }
.welcome-search-btn {
  width: 56px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3e4147;
  border: none;
  border-radius: 0 32px 32px 0;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.welcome-search-btn:hover { background: #484c54; color: var(--text); }
.welcome-search-btn:disabled { opacity: .45; cursor: default; }
[data-theme="light"] .welcome-search-btn { background: #f1f3f4; color: #555; }
[data-theme="light"] .welcome-search-btn:hover { background: #e8eaed; color: #111; }
.welcome-clear-btn {
  width: 36px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s;
}
.welcome-clear-btn[hidden] { display: none; }
.welcome-clear-btn:hover { color: var(--text); }
.welcome-search-status {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 0;
  padding: 0 2px;
}
.welcome-search-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 0 2px;
}
.welcome-help-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  text-align: center;
  padding-top: 4px;
}
.welcome-help-link:hover { color: var(--accent); text-decoration: underline; }

/* --- Welcome features --- */
.welcome-features {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.wf-card {
  width: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.wf-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .04em;
}
.wf-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.55;
  text-align: center;
  margin: 0;
  white-space: pre-line;
}
.wf-anim-area {
  flex: 0 0 80px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* 投票カード */
.wf-vote-wrap { display: flex; gap: 10px; align-items: center; }
.wf-thumb {
  width: 72px;
  height: 54px;
  border-radius: 6px;
  border: 1.5px solid #bbb;
  background: #fff;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.wf-thumb::before {
  content: '';
  position: absolute;
  inset: 0 0 42% 0;
  background: #f0f0f0;
  border-bottom: 1.5px solid #e0e0e0;
}
.wf-thumb::after {
  content: '';
  position: absolute;
  left: 7px; right: 7px; bottom: 8px;
  height: 2.5px;
  border-radius: 2px;
  background: #d8d8d8;
  box-shadow: 0 5px 0 #e8e8e8;
}
.wf-vs { font-size: 10px; font-weight: 800; color: #ccc; letter-spacing: .05em; flex-shrink: 0; }
.wf-thumb-voted { animation: wfVoteHighlight 4s linear infinite; }
@keyframes wfVoteHighlight {
  0%, 16%  { box-shadow: 0 0 0 0px rgba(0,176,244,0), 0 0 0 0px rgba(0,176,244,0); }
  20%      { box-shadow: 0 0 0 2px rgba(0,176,244,1), 0 0 0 0px rgba(0,176,244,0); }
  37%      { box-shadow: 0 0 0 2px rgba(0,176,244,1), 0 0 0 0px rgba(0,176,244,0); }
  40%      { box-shadow: 0 0 0 2px rgba(0,176,244,1), 0 0 0 0px rgba(0,176,244,.65); animation-timing-function: cubic-bezier(0.15, 0, 0.05, 1); }
  53%      { box-shadow: 0 0 0 2px rgba(0,176,244,1), 0 0 0 11px rgba(0,176,244,0); }
  62%      { box-shadow: 0 0 0 2px rgba(0,176,244,1), 0 0 0 11px rgba(0,176,244,0); }
  72%, 100%{ box-shadow: 0 0 0 0px rgba(0,176,244,0), 0 0 0 0px rgba(0,176,244,0); }
}
.wf-cursor {
  position: absolute;
  left: 0; top: 0;
  width: 16px; height: 16px;
  pointer-events: none;
  z-index: 2;
  animation: wfCursorMove 4s linear infinite;
}
@keyframes wfCursorMove {
  0%   { transform: translate(125px, 70px); opacity: 0; }
  8%   { transform: translate(125px, 70px); opacity: 1; animation-timing-function: cubic-bezier(0.22, 0, 0.12, 1); }
  37%  { transform: translate(43px, 38px) scale(1); animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6); }
  40%  { transform: translate(43px, 38px) scale(.78); opacity: 1; animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
  46%  { transform: translate(43px, 38px) scale(1); opacity: 1; }
  52%  { transform: translate(43px, 38px) scale(1); opacity: 0; }
  100% { transform: translate(43px, 38px) scale(1); opacity: 0; }
}
.wf-thumbsup {
  position: absolute;
  left: 0; top: 0;
  width: 22px; height: 22px;
  pointer-events: none;
  z-index: 3;
  animation: wfThumbsUpPop 4s linear infinite;
}
@keyframes wfThumbsUpPop {
  0%, 38%  { transform: translate(35px, 18px) scale(0); opacity: 0; }
  40%      { transform: translate(35px, 18px) scale(1.25); opacity: 1; animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
  50%      { transform: translate(35px, 18px) scale(1); opacity: 1; }
  62%      { transform: translate(35px, 18px) scale(1); opacity: 1; }
  70%, 100%{ transform: translate(35px, 18px) scale(0.85); opacity: 0; }
}

/* ランキングカード */
.wf-rank-anim { display: flex; flex-direction: column; gap: 7px; width: 160px; }
.wf-rank-row { display: flex; align-items: center; gap: 7px; }
.wf-rank-num { font-size: 10px; font-weight: 800; color: #999; width: 12px; text-align: right; flex-shrink: 0; }
.wf-rank-row:nth-child(1) .wf-rank-num { color: #888; }
.wf-rank-row:nth-child(2) .wf-rank-num { color: #999; }
.wf-rank-row:nth-child(3) .wf-rank-num { color: #aaa; }
.wf-rank-row:nth-child(4) .wf-rank-num { color: #bbb; }
.wf-rank-bar-bg {
  flex: 1;
  height: 10px;
  border-radius: 3px;
  background: #f0f0f0;
  border: 1.5px solid #e0e0e0;
  overflow: hidden;
  position: relative;
}
.wf-rank-bar-fill {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  border-radius: 2px;
  width: 0;
  animation: wfBarGrow 2.4s ease-in-out infinite;
}
.wf-rank-row:nth-child(1) .wf-rank-bar-fill { --w: 90%; animation-delay:  0s;  background: #00b0f4; }
.wf-rank-row:nth-child(2) .wf-rank-bar-fill { --w: 72%; animation-delay: .1s;  background: #33c0f6; }
.wf-rank-row:nth-child(3) .wf-rank-bar-fill { --w: 55%; animation-delay: .2s;  background: #66d0f8; }
.wf-rank-row:nth-child(4) .wf-rank-bar-fill { --w: 40%; animation-delay: .3s;  background: #99e0fa; }
@keyframes wfBarGrow {
  0%, 15%  { width: 0; }
  55%, 80% { width: var(--w); }
  95%, 100%{ width: 0; }
}

/* ここ好きカード */
.wf-reaction-anim { display: flex; flex-direction: column; align-items: stretch; width: 155px; }
.wf-video-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 7px;
  border: 1.5px solid #e0e1e3;
  background: #f4f5f6;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.wf-progress-track {
  position: absolute;
  left: 10px; right: 10px; bottom: 8px;
  height: 5px;
  border-radius: 3px;
  background: #eaebec;
  border: 1px solid #e2e3e5;
  animation: wfSeekFade 4s linear -2s infinite;
}
.wf-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: #cacbcd;
  width: 5%;
  position: relative;
  animation: wfProgressPlay 4s linear -2s infinite;
}
.wf-progress-head {
  position: absolute;
  right: -4px; top: 50%;
  transform: translateY(-50%);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #cacbcd;
}
.wf-pin { position: absolute; transform-origin: bottom center; }
.wf-pin svg { width: 16px; height: 19px; display: block; }
.wf-pin-a { left: 18%; top: 24%; animation: wfPinDropA 4s linear -2s infinite; }
.wf-pin-b { left: 52%; top: 40%; animation: wfPinDropB 4s linear -2s infinite; }
.wf-pin-c { left: 72%; top: 20%; animation: wfPinDropC 4s linear -2s infinite; }
@keyframes wfPinDropA {
  0%, 7%    { opacity: 0; transform: translateY(-12px); }
  12%       { opacity: 1; transform: translateY(0); }
  70%       { opacity: 1; transform: translateY(0); }
  80%, 100% { opacity: 0; transform: translateY(0); }
}
@keyframes wfPinDropB {
  0%, 17%   { opacity: 0; transform: translateY(-12px); }
  22%       { opacity: 1; transform: translateY(0); }
  70%       { opacity: 1; transform: translateY(0); }
  80%, 100% { opacity: 0; transform: translateY(0); }
}
@keyframes wfPinDropC {
  0%, 27%   { opacity: 0; transform: translateY(-12px); }
  32%       { opacity: 1; transform: translateY(0); }
  70%       { opacity: 1; transform: translateY(0); }
  80%, 100% { opacity: 0; transform: translateY(0); }
}
@keyframes wfProgressPlay {
  0%        { width: 5%; }
  50%       { width: 100%; }
  70%       { width: 100%; }
  80%, 100% { width: 5%; }
}
@keyframes wfSeekFade {
  0%   { opacity: 0; }
  5%   { opacity: 1; }
  70%  { opacity: 1; }
  80%  { opacity: 0; }
  100% { opacity: 0; }
}

/* ダークモード: モック要素を暗いトーンに */
[data-theme="dark"] .wf-thumb {
  background: #2c2e33;
  border-color: #4a4c52;
}
[data-theme="dark"] .wf-thumb::before {
  background: #383a40;
  border-bottom-color: #484a50;
}
[data-theme="dark"] .wf-thumb::after {
  background: #484a50;
  box-shadow: 0 5px 0 #383a40;
}
[data-theme="dark"] .wf-vs { color: #555; }
[data-theme="dark"] .wf-rank-bar-bg {
  background: #383a40;
  border-color: #484a50;
}
[data-theme="dark"] .wf-video-frame {
  background: #31343a;
  border-color: #50535c;
}
[data-theme="dark"] .wf-progress-track {
  background: #3e4147;
  border-color: #555860;
}
[data-theme="dark"] .wf-progress-fill { background: #52555c; }
[data-theme="dark"] .wf-progress-head { background: #52555c; }
[data-theme="dark"] .wf-pin path { fill: #31343a; }
[data-theme="dark"] .wf-rank-row:nth-child(1) .wf-rank-bar-fill { background: #00a8e8; }
[data-theme="dark"] .wf-rank-row:nth-child(2) .wf-rank-bar-fill { background: #0090c8; }
[data-theme="dark"] .wf-rank-row:nth-child(3) .wf-rank-bar-fill { background: #0078a8; }
[data-theme="dark"] .wf-rank-row:nth-child(4) .wf-rank-bar-fill { background: #006090; }

/* --- Loading --- */
#loadingMsg {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 0;
  font-size: 14px;
}

/* =====================
   VOTE SCREEN
===================== */

.vote-tutorial {
  margin-bottom: 14px;
}
.vote-tutorial-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.vote-tutorial-body p {
  margin: 0;
  flex: 1;
  line-height: 1.5;
}
.vote-tutorial-close {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.vote-tutorial-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.vote-counter {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.vote-counter span {
  color: var(--accent);
  font-weight: 700;
}

/* 投票ペースゲージ */
.vote-pace-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 11px;
  color: var(--text-muted);
}
.vote-pace-bar-bg {
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface2);
  overflow: hidden;
}
.vote-pace-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s, background 0.4s;
  background: var(--accent);
}
.vote-pace-bar-fill.pace-warm   { background: var(--warn); }
.vote-pace-bar-fill.pace-hot    { background: var(--err); }

.vote-pair-wrap {
  margin-bottom: 16px;
}
#voteScreen:has(.cat-empty-state) {
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  scrollbar-gutter: auto;
}
/* 空状態時は投票UI要素を CSS でも非表示（JS による display:none と二重保証） */
#voteScreen:has(.cat-empty-state) .vote-tutorial,
#voteScreen:has(.cat-empty-state) .vote-counter,
#voteScreen:has(.cat-empty-state) .vote-pace-wrap {
  display: none;
}
.vote-pair-wrap:has(.cat-empty-state) {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
}
.vote-pair:has(.cat-empty-state) {
  width: 100%;
}
#listGrid:has(.cat-empty-state) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  align-content: center;
}
#listScrollBody:has(.cat-empty-state) {
  overflow-y: hidden;
  scrollbar-gutter: auto;
}
#listScrollBody:has(.cat-empty-state) #shortsSentinel {
  display: none;
}
/* ランキング: 空状態時はヘッダーを隠して残り高さに中央揃え */
#rankingScreen:has(.cat-empty-state) {
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  scrollbar-gutter: auto;
}
#rankingScreen:has(.cat-empty-state) .ranking-header {
  display: none;
}
#rankList:has(.cat-empty-state) {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vote-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: center;
}

.vote-vs-sep {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  user-select: none;
  flex-shrink: 0;
  opacity: 0.5;
}

@keyframes vote-good-pop {
  0%   { transform: translate(-50%, -50%) scale(0.15); opacity: 0; }
  22%  { transform: translate(-50%, -50%) scale(1.22); opacity: 1; }
  40%  { transform: translate(-50%, -50%) scale(0.94); opacity: 1; }
  56%  { transform: translate(-50%, -50%) scale(1.04); opacity: 1; }
  78%  { transform: translate(-50%, -50%) scale(1.04); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(1.12); opacity: 0; }
}
.vote-good-overlay {
  position: absolute;
  top: 45%;
  left: 50%;
  width: 88px;
  height: 88px;
  color: #4f9cf9;
  pointer-events: none;
  z-index: 20;
  animation: vote-good-pop 0.55s ease forwards;
  filter: drop-shadow(0 4px 16px rgba(79,156,249,0.55));
}

.vote-card {
  cursor: pointer;
  position: relative;
  perspective: 1000px;
  /* drop shadow で立体感 */
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.65));
  transition: filter 0.2s;
}
.vote-card:hover {
  filter: drop-shadow(0 16px 40px rgba(0,0,0,0.80));
}
/* tilter__figure: TiltFxが回転させる対象 */
.vote-card .tilter__figure {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 0 0 0px var(--accent), 0 0 0px 0px rgba(0,176,244,0);
  transition: box-shadow 0.2s ease;
}
.vote-card .tilter__figure::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.48) 0%, rgba(0,0,0,0.12) 60%, transparent 100%);
  pointer-events: none;
  border-radius: inherit;
  z-index: 1;
}
.vote-card:hover .tilter__figure {
  /* box-shadow: 0 0 0 2px rgba(255,255,255,0.85), 0 0 24px 6px rgba(255,255,255,0.30); */
  box-shadow: 0 0 0 2px var(--accent), 0 0 20px 4px rgba(0,176,244,0.45);
}
/* banner */
.vote-card .card-banner {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}

/* shine グラデーションオーバーレイ */
.vote-card .tilter__deco--shine {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.vote-card .tilter__deco--shine > div {
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  background-image: linear-gradient(45deg, rgba(0,0,0,0.20) 0%, rgba(255,255,255,0.05) 50%, transparent 100%);
  opacity: 0;
  transition: opacity 0.2s;
}
.vote-card:hover .tilter__deco--shine > div {
  opacity: 1;
}
/* ホバー中はCSS transitionでtiltを滑らかに追従（カード間移動時の急な傾きを防ぐ） */
.vote-card .tilter__figure.tilt-smooth,
.vote-card .tilter__caption.tilt-smooth,
.vote-card .tilter__deco--shine > div.tilt-smooth {
  transition: transform 0.2s ease-out;
}
/* タイトルをサムネ下部に重ねる */
.vote-card .tilter__caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 28px 12px 10px;
  margin: 0;
  font-size: clamp(11px, 1.5vw, 14px);
  font-weight: 700;
  line-height: 1.35;
  color: rgba(255,255,255,.97);
  text-shadow: none;
  pointer-events: none;
}
.vote-card.winner {
  filter: drop-shadow(0 0 8px var(--ok)) drop-shadow(0 8px 24px var(--drop-ok));
  animation: flash 0.35s ease;
}
.vote-card.loser {
  opacity: 0.32;
}
.vote-card.winner .tilter__figure,
.vote-card.loser .tilter__figure {
  box-shadow: none;
}
.vote-card.winner .tilter__deco--shine > div,
.vote-card.loser .tilter__deco--shine > div {
  opacity: 0 !important;
}
@keyframes flash {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
  100% { box-shadow: 0 0 0 20px color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* =====================
   RANKING SCREEN
===================== */

.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 4px;
}
.ranking-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.ranking-header small {
  font-size: 12px;
  color: var(--text-muted);
}
.ranking-desc {
  width: 100%;
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* カテゴリ空状態 */
.cat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 14px;
  grid-column: 1 / -1;
  width: 100%;
}
.cat-empty-icon {
  width: 44px;
  height: 44px;
  opacity: 0.35;
}
.cat-empty-text {
  font-size: 13px;
  text-align: center;
  margin: 0;
  line-height: 1.6;
}
.rank-item {
  position: relative;
  display: flex;
  flex-direction: row;
  background: var(--surface);
  border: none;
  border-radius: 4px;
  overflow: hidden;
  transition: box-shadow 0.15s;
  height: 210px;
}
.rank-num-col {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  gap: 4px;
}
.rank-num {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-muted);
  line-height: 1;
  letter-spacing: -1px;
}
.rank-item.rank-1 .rank-num { color: #c9a800; font-size: 26px; }
.rank-item.rank-2 .rank-num { color: #888; font-size: 26px; }
.rank-item.rank-3 .rank-num { color: #a0603a; font-size: 26px; }
.rank-medal-emoji { font-size: 18px; line-height: 1; }
.rank-item:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
.rank-item.rank-1 { box-shadow: 0 0 0 2px rgba(212,175,55,0.7); }
.rank-item.rank-2 { box-shadow: 0 0 0 2px rgba(160,160,160,0.6); }
.rank-item.rank-3 { box-shadow: 0 0 0 2px rgba(180,100,30,0.5); }
.rank-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 373px;
  align-self: stretch;
}

.rank-thumb-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: var(--surface2);
}
.rank-medal {
  font-size: 20px;
  line-height: 1;
  display: none;
}
.rank-meta {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.rank-title {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
  transition: color 0.15s;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rank-title:hover {
  color: var(--accent);
}
.rank-stats { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); }
.rank-stats .elo {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}
.rank-stats .low-battles { opacity: 0.5; }
.rank-thumb-wrap img.rd-low    { opacity: 1; }
.rank-thumb-wrap img.rd-mid    { opacity: 0.72; }
.rank-thumb-wrap img.rd-high   { opacity: 0.42; }
.rank-bar-bg {
  background: var(--surface2);
  border-radius: 4px;
  height: 3px;
  overflow: hidden;
}
.rank-bar-fill {
  height: 100%;
  background: var(--accent);
  opacity: 0.3;
  border-radius: 4px;
  transition: width 0.4s;
}

/* --- Thumb Modal --- */
#thumbModal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.88);
  justify-content: center;
  align-items: center;
  padding: 20px;
}
#thumbModal.open { display: flex; }
.modal-inner {
  position: relative;
  max-width: min(900px, 95vw);
  width: 100%;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
}
.modal-img-wrap {
  position: relative;
  width: 100%;
}
.modal-img-wrap img {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  object-fit: contain;
  background: #000;
}
.modal-badge {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(0,0,0,0.75);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.modal-info {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.modal-stats {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--text-muted);
}
.modal-stats strong {
  color: var(--text);
  font-size: 16px;
}
.modal-bar-bg {
  background: var(--surface2);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
}
.modal-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  padding: 0 20px 16px;
}
.modal-actions a {
  flex: 1;
  display: block;
  text-align: center;
  padding: 9px 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
}
.modal-actions a:hover { opacity: 0.8; }
.modal-yt-btn {
  background: #ff0000;
  color: #fff;
}
.modal-close {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(0,0,0,0.55);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 18px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 10;
}
.modal-close:hover { background: rgba(0,0,0,0.75); }

/* --- Gallery Screen (一覧) --- */
#listGrid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.gallery-row {
  display: flex;
  gap: 12px;
  height: 220px;
}
.gallery-cell {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  cursor: pointer;
  background: var(--surface2);
  min-width: 0;
}
.gallery-img-wrap {
  width: 100%;
  height: 100%;
  position: relative;
}
.gallery-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.gallery-cell:hover .gallery-img-wrap img { transform: scale(1.05); }
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 10px 12px;
}
.gallery-cell:hover .gallery-overlay { opacity: 1; }
.gallery-title {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}
.gallery-meta-item {
  display: flex;
  align-items: center;
  gap: 3px;
  color: rgba(255,255,255,0.55);
  font-size: 10px;
  letter-spacing: 0.02em;
}
/* ギャラリーグリッドカード内では白固定ではなくテーマ色を使う */
.list-info-meta .gallery-meta-item,
.rank-meta-gallery .gallery-meta-item {
  color: var(--text-muted);
}
.gallery-meta-item svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}
.gallery-meta-rank {
  font-size: 9px;
  margin-left: 1px;
}
.gallery-meta-pin-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  align-self: center;
}
@media (max-width: 600px) {
  .gallery-row { height: 140px; }
}
/* ビューバー（埋め込みツールバー） */
.view-bar {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 4px;
  box-shadow: 0 1px 4px var(--shadow);
}
.vb-btn {
  height: 26px;
  padding: 0 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}
.vb-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.vb-sort-key { color: var(--text-muted); min-width: 80px; justify-content: space-between; }
.vb-sort-dir { padding: 0 8px; }
.vb-sort-dir.asc { color: var(--accent); }
.vb-lay { padding: 0 8px; }
.vb-lay.active { color: var(--accent); }
.vb-sep { width: 1px; height: 16px; background: var(--border); flex-shrink: 0; margin: 0 2px; }
.vb-sort-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.vb-sort-key-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.sort-popup {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 0;
  width: 100%;
  min-width: unset;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 100;
  display: none;
}
.sort-popup.open { display: block; }
.sort-popup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  gap: 8px;
  transition: background 0.1s, color 0.1s;
}
.sort-popup-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.sort-popup-item.active { color: var(--accent); }
.sort-popup-dir-hint { font-size: 10px; opacity: .5; white-space: nowrap; }

/* レイアウトトグル + ソート（一覧フロート） */
#listViewBar {
  position: absolute;
  top: 12px;
  right: 24px;
  z-index: 4;
}

/* 一覧画面 */
#listScreen {
  position: relative;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  scrollbar-gutter: auto;
}
#listScrollBody {
  flex: 1;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}
#listScrollBody::-webkit-scrollbar { width: 8px; }
#listScrollBody::-webkit-scrollbar-track { background: transparent; }
#listScrollBody::-webkit-scrollbar-thumb {
  background: rgba(120,120,120,0.25);
  border-radius: 4px;
  min-height: 48px;
}
#listScrollBody:hover::-webkit-scrollbar-thumb { background: rgba(120,120,120,0.45); }

/* グリッドモード */
#listGrid.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
/* ショートギャラリーモード（waterfall + IntersectionObserver） */
#listGrid.mode-shorts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-gap: 8px;
  grid-auto-flow: row dense;
  grid-auto-rows: 68px;
}
/* 3パターンの高さでリズムを作る */
#listGrid.mode-shorts .gallery-cell--short:nth-of-type(3n+1) { grid-row: auto / span 3; }
#listGrid.mode-shorts .gallery-cell--short:nth-of-type(3n+2) { grid-row: auto / span 4; }
#listGrid.mode-shorts .gallery-cell--short:nth-of-type(3n+3) { grid-row: auto / span 5; }
#listGrid.mode-shorts .gallery-cell--short {
  overflow: hidden;
  border-radius: 0;
  background: var(--surface2);
  cursor: pointer;
  position: relative;
  transition: filter 0.5s, opacity 0.5s, box-shadow 0.3s;
}
#listGrid.mode-shorts .gallery-cell--short img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(0.75);
  transform-origin: bottom center;
  transition: transform 0.45s;
}
/* 視野に完全に入ったセル */
#listGrid.mode-shorts .gallery-cell--short.inbound img {
  transform: scale(1);
}
#listGrid.mode-shorts .gallery-cell--short .gallery-overlay {
  opacity: 0;
  transition: opacity 0.25s;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.15) 50%, transparent 72%);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
}
#listGrid.mode-shorts .gallery-cell--short.inbound:hover .gallery-overlay { opacity: 1; }
#listGrid.mode-shorts .gallery-cell--short .gallery-title {
  font-size: 11px;
  -webkit-line-clamp: 3;
}
/* ダークモード */
:root[data-theme="dark"] #listGrid.mode-shorts .gallery-cell--short {
  filter: saturate(0) blur(3px);
  opacity: 0.02;
  background: var(--bg);
}
:root[data-theme="dark"] #listGrid.mode-shorts .gallery-cell--short.inbound {
  filter: saturate(1) blur(0px);
  opacity: 1;
}
/* ライトモード */
:root[data-theme="light"] #listGrid.mode-shorts .gallery-cell--short {
  filter: saturate(0) blur(3px);
  opacity: 0.1;
}
:root[data-theme="light"] #listGrid.mode-shorts .gallery-cell--short.inbound {
  filter: saturate(1) blur(0px);
  opacity: 1;
}
.list-card {
  background: transparent;
  text-decoration: none;
  display: block;
  color: inherit;
  cursor: pointer;
  border-radius: 10px;
  padding: 6px;
  margin: -6px;
  position: relative;
  isolation: isolate;
}
.list-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(to right, var(--surface) 55%, transparent 100%);
  transform: scale(0.88);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.16s ease;
  pointer-events: none;
  z-index: -1;
}
.list-card:hover::before {
  transform: scale(1);
  opacity: 1;
}
:root[data-theme="light"] .list-card::before {
  background: linear-gradient(to right, color-mix(in srgb, var(--text) 14%, transparent) 55%, transparent 100%);
}
.list-thumb-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface2);
  aspect-ratio: 16/9;
}
/* ショートカードは縦長 */
.list-card--short .list-thumb-wrap {
  aspect-ratio: 9/16;
}
.list-thumb-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: opacity 0.15s;
}
.list-duration {
  position: absolute;
  bottom: 5px;
  right: 6px;
  background: rgba(0,0,0,0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.5;
  z-index: 3;
  letter-spacing: 0.02em;
}
.list-info {
  display: flex;
  gap: 10px;
  padding: 8px 2px 0;
}
.list-info-text { flex: 1; min-width: 0; }
.list-info-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  transition: color 0.15s;
}
.list-info-title:hover {
  color: var(--accent);
}
.list-info-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* =====================
   HOME SCREEN (removed - replaced by sidebar layout)
   channel-grid and channel-card kept for future reference
===================== */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.channel-card {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 20px 40px -14px rgba(0,0,0,0.18);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s cubic-bezier(.43,.41,.22,.91), box-shadow 0.22s;
}
.channel-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 28px 52px -10px rgba(0,0,0,0.24);
}
.channel-card:hover .channel-card-thumb {
  filter: contrast(100%);
}
.channel-card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--surface2);
  display: block;
  filter: contrast(72%);
  transition: filter 0.5s cubic-bezier(.43,.41,.22,.91);
}
.list-preview-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  z-index: 2;
  pointer-events: none;
}
.channel-card-rank1-badge {
  position: absolute;
  top: 6px;
  left: 8px;
  background: rgba(0,0,0,0.70);
  color: #ffd700;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1.5;
}
.channel-card-info { padding: 14px 16px 16px; flex: 1 1 auto; display: flex; flex-direction: column; }
.channel-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
  margin-bottom: 5px;
}
.channel-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 0; }
.channel-card-tags { padding: 4px 0 2px; display: flex; flex-wrap: wrap; gap: 3px; }
.channel-tag-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.6;
}
/* --- Sidebar folders --- */
.sidebar-folder {}
.sidebar-folder-header {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 12px;
  margin: 0 4px;
  cursor: pointer; border-radius: 4px; user-select: none;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}
.sidebar-folder-header:hover { background: var(--surface2); color: var(--text); }
.sidebar-folder--open > .sidebar-folder-header { color: var(--text); }
.sidebar-folder-preview { position: relative; width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; overflow: hidden; background: var(--surface2); }
.sidebar-folder-preview-img {
  position: absolute; width: 30px; height: 30px; border-radius: 50%;
  object-fit: cover; border: 1.5px solid var(--surface2);
}
.sidebar-folder-preview-img:nth-child(1) { top: 0; left: 0; }
.sidebar-folder-preview-img:nth-child(2) { bottom: 0; right: 0; }
.sidebar-folder-preview-ph { background: var(--surface2); }
.sidebar-folder-open-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
  border-radius: 50%;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.sidebar-folder--open .sidebar-folder-open-icon { opacity: 1; }
.sidebar-folder-preview-img {
  transition: opacity 0.18s ease;
}
.sidebar-folder--open .sidebar-folder-preview-img { opacity: 0; }
.sidebar-folder-children {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.2s ease;
  padding-left: 8px;
  margin-left: 22px;
  position: relative;
}
.sidebar-folder--open > .sidebar-folder-children::before {
  content: '';
  position: absolute;
  left: -1px; top: 4px; bottom: 16px;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}
.sidebar-folder--open > .sidebar-folder-children { padding-bottom: 4px; }
.sidebar-folder-name {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: normal;
  overflow: hidden; white-space: nowrap;
  outline: none;
  border-radius: 3px;
}
.sidebar-folder-name[contenteditable]:not([contenteditable="false"]) {
  background: var(--surface2);
  box-shadow: 0 0 0 1px var(--accent, #4f9cf9);
  padding: 1px 4px;
  white-space: nowrap;
  min-width: 40px;
}
.sidebar-folder-badge { font-size: 11px; color: var(--text-muted); }
.sidebar-folder-drop-zone { display: none; }
.sidebar-folder--drop-bottom > .sidebar-folder-children { padding-bottom: 28px !important; }
.sidebar--dragging .sidebar-channel-item:hover::before   { display: none; }
.sidebar--dragging .sidebar-channel-item:hover { background: transparent; color: var(--text-muted); }
.sidebar--dragging .sidebar-folder-header:hover::before { opacity: 0 !important; transform: translateY(-50%) scaleY(0) !important; }
.sidebar--dragging .sidebar-folder-header:hover { background: transparent !important; }
/* ドラッグ中はフォルダ内チャンネルのホバー形状も元に戻す */
.sidebar--dragging .sidebar-folder-children .sidebar-channel-item:hover { border-radius: 50%; }
.sidebar--compact .sidebar-folder-header {
  width: 50px; height: 52px; padding: 4px 3px; margin: 0; gap: 0;
  justify-content: center; border-radius: 50%; position: relative;
  background: transparent;
  transition: border-radius 0.2s, background 0.12s, color 0.12s;
}
.sidebar--compact .sidebar-folder-header:hover { border-radius: 30%; background: var(--surface2); }
.sidebar--compact .sidebar-folder-header::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  width: 4px;
  height: 44px;
  border-radius: 0 6px 6px 0;
  background: #fff;
  opacity: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.sidebar--compact .sidebar-folder-header:hover::before {
  opacity: 0.4;
  transform: translateY(-50%) scaleY(0.3);
}
.sidebar--compact .sidebar-folder--open { width: 50px; background: var(--folder-tint, var(--drop-hover)); border-radius: 15px 15px 10px 10px; margin: 0; padding-bottom: 4px; }
.sidebar--compact .sidebar-folder--open > .sidebar-folder-header { margin: 0; transition: border-radius 0.2s, background 0.12s, color 0.12s; }
.sidebar--compact .sidebar-folder--open > .sidebar-folder-header:hover { background: var(--surface2); }
.sidebar--compact .sidebar-folder-name,
.sidebar--compact .sidebar-folder-badge { display: none; }
.sidebar--compact .sidebar-folder-preview { width: 44px; height: 44px; background: var(--surface2); border-radius: 50%; overflow: hidden; }
.sidebar--compact .sidebar-folder-open-icon { background: transparent; border-radius: 0; }
.sidebar--compact .sidebar-folder--open > .sidebar-folder-header .sidebar-folder-preview { background: transparent; }
.sidebar--compact .sidebar-folder-chevron { display: none; }
.sidebar--compact .sidebar-folder-rename-btn { display: none; }
.sidebar--compact .sidebar-folder-header:hover .sidebar-folder-rename-btn { display: none; }
.sidebar--compact .sidebar-folder-children { padding-left: 8px; margin-left: -8px; margin-right: 0; margin-bottom: 0; }
.sidebar--compact .sidebar-folder--open > .sidebar-folder-children { background: transparent; border-radius: 0; padding-bottom: 0; }
.sidebar--compact .sidebar-folder--open > .sidebar-folder-children::before { display: none; }
.sidebar-merge-hover { box-shadow: 0 0 0 2px var(--accent, #4f9cf9) !important; border-radius: 12px !important; }
/* マージプレビュー: ワイドモード — 青リングのみ（アバターサイズ変更なし＝チラつき防止） */
.sidebar-channel-item.merge-preview {
  background: var(--surface2);
}
.sidebar-channel-item.merge-preview.sidebar-merge-hover { border-radius: 8px !important; }
/* マージプレビュー: コンパクトモード */
.sidebar--compact .sidebar-channel-item.merge-preview {
  background: var(--surface2);
  overflow: hidden;
}
.sidebar--compact .sidebar-channel-item.merge-preview .sidebar-ch-avatar {
  position: absolute;
  width: 30px; height: 30px;
  top: 3px; left: 3px;
  transform: none;
  z-index: 1;
}
.sidebar--compact .sidebar-channel-item.merge-preview.sidebar-merge-hover { border-radius: 12px !important; }
.sidebar-folder-drop-hover { box-shadow: 0 0 0 2px var(--accent, #4f9cf9) !important; border-radius: 8px !important; }
.sidebar-drag-indicator { pointer-events: none; }

/* =====================
   RESPONSIVE
===================== */
@media (max-width: 900px) {
  .rank-thumb-wrap { width: 240px; }
  .rank-item { height: 135px; }
}

@media (max-width: 640px) {
  .sidebar { width: 180px; }

  .screen { padding: 12px; }
  #listScrollBody { padding: 12px; }

  /* 投票: 縦積み */
  .vote-pair-wrap { padding: 16px 12px; border-radius: 8px; }
  .vote-pair { grid-template-columns: 1fr; gap: 10px; }
  .vote-counter { margin-bottom: 10px; }

  /* ランキング: 縦積み */
  .rank-item {
    flex-direction: column;
    height: auto;
  }
  .rank-thumb-wrap {
    width: 100%;
    align-self: auto;
  }
  .rank-thumb-wrap img {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
  }
  .rank-meta { padding: 8px 10px; }

  /* 一覧: 2列 */
  #listGrid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* モーダル */
  .modal-inner { border-radius: 0; }
  .modal-info { padding: 10px 12px; }
  .modal-actions { padding: 0 12px 12px; }
  .modal-stats { gap: 12px; }
}

/* =====================
   LANG POPOVER
===================== */

/* ポップオーバーボタン（ポップオーバー内アクション用） */
.popover-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.popover-btn:hover { border-color: var(--accent); color: var(--accent); }
.popover-btn.popover-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.popover-btn.popover-btn-primary:hover { opacity: 0.88; color: #fff; }

/* アンカー */
.lang-popover-anchor { position: relative; }

/* ポップオーバー本体 */
.lang-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 0;
  min-width: 160px;
  max-width: calc(100vw - 24px);
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 200;
  transform-origin: top right;
  animation: popover-in 0.13s ease;
  overflow: hidden;
}
@keyframes popover-in {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* 言語オプション一覧 */
.lang-option-list { display: flex; flex-direction: column; }
.lang-option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  box-sizing: border-box;
}
.lang-option-item:hover { background: var(--surface2); }
.lang-option-item.active { color: var(--accent); }
.lang-option-check {
  width: 14px;
  flex-shrink: 0;
  color: var(--accent);
  font-size: 11px;
}
.lang-option-add {
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 2px;
}
.lang-option-add:hover { color: var(--accent); background: var(--surface2); }

/* 追加フォーム */
.lang-add-form {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 320px;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
}
.lang-dialog-sep { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ドロップゾーン */
.lang-import-drop {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  height: 64px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.lang-import-drop:hover,
.lang-import-drop.hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--text);
}
.drop-text { display: flex; flex-direction: column; gap: 2px; }
.lang-import-or {
  font-size: 11px;
  color: var(--text-muted);
  margin: -4px 0;
  text-align: center;
}
.lang-import-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  font-family: 'Consolas', 'Menlo', monospace;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
}
.lang-import-textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.lang-import-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.lang-import-actions svg.lucide { width: 14px; height: 14px; }

/* =====================
   API KEY POPOVER
===================== */
.apikey-popover-anchor { position: relative; }

.apikey-indicator {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  border: 1.5px solid var(--surface2);
  pointer-events: none;
}

/* ポップオーバー本体 */
.apikey-popover {
  min-width: 340px;
  padding: 0;
}

/* ヘッダー */
.apikey-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.apikey-popover-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}
.apikey-guide-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}
.apikey-guide-link:hover { text-decoration: underline; }

/* テーブルヘッダー */
.apikey-table-head {
  display: grid;
  grid-template-columns: 160px 1fr;
  padding: 5px 14px 4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.apikey-table-head span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

/* 表示行 */
.apikey-var-row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  align-items: center;
  min-height: 42px;
  padding: 0 6px 0 14px;
  transition: background .1s;
}
.apikey-var-row:hover { background: var(--surface2); }
.apikey-var-name {
  font-size: 12px;
  font-weight: 600;
  font-family: 'Consolas', 'Menlo', monospace;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}
.apikey-var-value {
  font-size: 12px;
  font-family: 'Consolas', 'Menlo', monospace;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apikey-var-value.not-set {
  font-style: italic;
  opacity: .5;
}
.apikey-var-btns {
  display: flex;
  align-items: center;
  gap: 1px;
  opacity: 0;
  transition: opacity .1s;
}
.apikey-var-row:hover .apikey-var-btns { opacity: 1; }

/* アイコンボタン */
.apikey-icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .1s, color .1s;
  flex-shrink: 0;
}
.apikey-icon-btn:hover { background: var(--border); color: var(--text); }
.apikey-icon-btn--danger:hover { color: var(--err); }

/* 編集行 */
.apikey-edit-row {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--surface2);
}
.apikey-edit-varname {
  font-size: 11px;
  font-weight: 700;
  font-family: 'Consolas', 'Menlo', monospace;
  color: var(--text-muted);
}
.apikey-input-wrap {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.apikey-input-wrap:focus-within { border-color: var(--accent); }
.apikey-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12px;
  font-family: 'Consolas', 'Menlo', monospace;
  padding: 0 10px;
  height: 30px;
  min-width: 0;
}
.apikey-input--masked { -webkit-text-security: disc; }
.apikey-input::placeholder { color: var(--text-muted); font-family: inherit; }
.apikey-toggle-btn {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  height: 30px;
  flex-shrink: 0;
}
.apikey-toggle-btn:hover { color: var(--accent); }

.apikey-popover-status {
  font-size: 11px;
  min-height: 14px;
  padding: 0 2px;
}
.apikey-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.apikey-action-btn {
  height: 28px;
  padding: 0 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: background .12s, color .12s, border-color .12s;
}
.apikey-action-btn:hover { background: var(--surface2); border-color: var(--text-muted); }
.apikey-action-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.apikey-action-btn--primary:hover { opacity: .88; }

/* =====================
   SETTINGS MODAL
===================== */
.settings-anchor { position: relative; }

/* バックドロップ */
.settings-modal-backdrop[hidden] { display: none !important; }
.settings-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  animation: fade-in 0.12s ease;
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* モーダル本体 */
.settings-modal {
  display: flex;
  flex: none;
  width: 700px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: modal-in 0.15s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

/* 左ナビ */
.settings-modal-sidebar {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  flex-shrink: 0;
  min-height: 0;
  background: var(--surface2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.settings-modal-sidebar-title {
  padding: 22px 16px 14px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  flex-shrink: 0;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px 16px;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.settings-nav-item:hover { background: var(--border); }
.settings-nav-item.active {
  background: var(--accent);
  color: #fff;
}
.settings-nav-item svg { flex-shrink: 0; opacity: 0.85; }
.settings-nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-nav-item.active svg { opacity: 1; }
.settings-nav-badge {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--err);
  flex-shrink: 0;
  margin-left: auto;
}

/* 右コンテンツ */
.settings-modal-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-modal-heading {
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  margin: 0;
  color: var(--text);
}
.settings-modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}
.settings-modal-close:hover { background: var(--surface2); color: var(--text); }

/* タブ */
.settings-tab {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
}

/* フィールド行 */
.settings-field {
  margin-bottom: 24px;
}
.settings-field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.settings-field-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 0;
  line-height: 1.5;
}
.settings-link {
  color: var(--accent);
  text-decoration: none;
}
.settings-link:hover { text-decoration: underline; }

/* テーマトグル */
.settings-theme-btns {
  display: inline-flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.settings-theme-btn {
  padding: 0 20px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.settings-theme-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}
.settings-theme-btn:not(.active):hover { color: var(--text); }

/* サイドバーデータ */
.settings-data-btns {
  display: flex;
  gap: 8px;
}
.settings-data-btn {
  height: 32px;
  padding: 0 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.settings-data-btn:hover { border-color: var(--text-muted); }
.settings-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  min-height: 16px;
}

/* --- ReactionPin --- */
.reactions-heatmap-layer,
.reactions-pins-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: block;
}
.reactions-heatmap-layer {
  z-index: 1;
  overflow: hidden;
  border-radius: 14px; /* blur の滲みを角丸に合わせてクリップ */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.reactions-pins-layer { z-index: 2; }

.modal-img-wrap.reactions-active .reactions-pins-layer,
.modal-img-wrap.reactions-active .reactions-heatmap-layer {
  visibility: visible;
  opacity: 1;
}

/* pin アニメーション */
/* フローティングピン（アニメーション表示） */
.reactions-pin {
  position: absolute;
  pointer-events: none;
  opacity: 0; /* Web Animations API でフェードイン制御 */
  /* animation は JS から inline で設定 */
}

/* ピンSVG共通 */
.reactions-pin-svg {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.45));
  transform-origin: 50% 100%;
  /* animation は JS から inline で設定 */
}

/* 吹き出しの色: density 低→中→高 = 淡→中→深紅（密集するほど色が濃くなる） */
.reactions-pin.shade-0 .pin-balloon { fill: var(--pin-c0, #fda4af); } /* 低密度: rose-300 */
.reactions-pin.shade-1 .pin-balloon { fill: var(--pin-c1, #f43f5e); } /* 中密度: rose-500 */
.reactions-pin.shade-2 .pin-balloon { fill: var(--pin-c2, #9f1239); } /* 高密度: rose-900 */
.reactions-pin .pin-icon { fill: rgba(255,255,255,0.9); }

@keyframes reactionsPinDrop {
  0%   { transform: translate(-50%, calc(-100% - var(--drop-h, 55px))); animation-timing-function: cubic-bezier(0.6,0,0.9,0.6); }
  6%   { transform: translate(-50%, -100%); animation-timing-function: linear; }
  100% { transform: translate(-50%, -100%); }
}

@keyframes reactionsPinSvgSquash {
  0%   { transform: none; }
  6%   { transform: scaleX(1.24) scaleY(0.80); animation-timing-function: cubic-bezier(0.2,0,0.4,1); }
  14%  { transform: none; }
  100% { transform: none; }
}
@keyframes reactionsPinFloat {
  0%, 100% { transform: translate(-50%, -100%); }
  50%       { transform: translate(-50%, calc(-100% - 5px)); }
}
.rs-seeking .reactions-pin {
  animation: none !important;
  transform: translate(-50%, -100%) !important;
}
/* みんなのピン: 着地後（rs-floating）はフロートを一時停止 */
.rs-paused .reactions-pin.rs-floating {
  animation-play-state: paused !important;
}
@keyframes reactionsPinColorCycle {
  0%, 100% { fill: var(--pin-c0); }
  33%       { fill: var(--pin-c1); }
  66%       { fill: var(--pin-c2); }
}
.reactions-my-pin.color-cycling .pin-balloon {
  animation: reactionsPinColorCycle 6s ease-in-out infinite;
}

/* クリック地点の固定影 */
.reactions-my-pin-shadow {
  position: absolute;
  width: 12px;
  height: 4px;
  border-radius: 50%;
  background: rgba(0,0,0,0.18);
  filter: blur(2px);
  transform: translate(-50%, -50%);
  z-index: 29;
  pointer-events: none;
}

/* ピンカーソル（ホバー追従） - 廃止 */

/* 自分のピン（固定表示）*/
.reactions-my-pin {
  position: absolute;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
}

.reactions-my-pin-label {
  position: absolute;
  /* 吹き出し内部の上端付近（ハートの上）に重ねる */
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 800;
  color: rgba(255,255,255,.96);
  white-space: nowrap;
  letter-spacing: 0.10em;
  line-height: 1;
  text-shadow:
    0 1px 2px rgba(0,0,0,.99),
    0 2px 8px rgba(0,0,0,.85),
    0 0 6px  rgba(255,255,255,.22),
    0 0 18px rgba(255,255,255,.12);
}

/* 自分のピン: パレットと同じ見た目、大きさだけ違う */
.reactions-my-pin .pin-balloon {
  fill: var(--pin-c0, #ec4899);
}
.reactions-my-pin .pin-icon { fill: rgba(255,255,255,0.9); }
.reactions-my-pin-svg {
  filter: drop-shadow(0 3px 12px rgba(0,0,0,0.8));
  transform-origin: 50% 100%;
}

/* リアクションボタン（modal-actions 内） */
.modal-reactions-btn {
  flex: 1;
  padding: 9px 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.modal-reactions-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ReactionPin コントロールバー */
.modal-reactions-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
}

.modal-reactions-controls[hidden] { display: none !important; }

.modal-reactions-mode-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.modal-reactions-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.modal-reactions-back-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s;
}

.modal-reactions-back-btn:hover { color: var(--text); }

/* =====================
   Reactions Full-Screen View
===================== */
#reactionScreen {
  background: var(--bg);
  padding: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  position: relative;
  scrollbar-gutter: auto;
  overflow: hidden;
}
.rs-main {
  flex: 1;
  min-width: 320px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  gap: 6px;
  overflow-y: auto;
  scrollbar-width: none;
}
.rs-main::-webkit-scrollbar { display: none; }
.rs-img-wrap {
  position: relative;
  border-radius: 14px;
  /* overflow:hidden は削除 — ピンが端でクリップされるため */
  box-shadow: 0 6px 24px rgba(0,0,0,0.50), 0 0 0 1px rgba(255,255,255,0.06);
  width: min(100%, calc((100vh - 240px) * 16 / 9));
  will-change: transform;
  transform: translateZ(0);
  isolation: isolate;
  cursor: default;
  user-select: none;
}
.rs-img-wrap img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
  border-radius: 14px; /* replaced element は border-radius だけで角丸クリップされる */
}
.rs-img-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 14px;
  background: var(--surface2, #1e1e2a);
  color: var(--text-muted, #888);
  pointer-events: none;
}
.rs-img-placeholder svg {
  width: 48px;
  height: 48px;
  opacity: 0.35;
}
.rs-img-placeholder p {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* 右サイドバー (gfと同テーマ) */
.rs-sidebar {
  box-sizing: border-box;
  flex-shrink: 0;
  width: 402px;
  min-width: 280px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: scroll;
  position: relative;
  scrollbar-gutter: stable;
}
.rs-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.rs-sidebar-resize-handle {
  position: absolute;
  top: 0;
  left: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}
.rs-sidebar-resize-handle:hover,
.rs-sidebar-resize-handle.dragging {
  background: var(--accent);
  opacity: 0.5;
}
/* カード (gf .card 相当) */
.rs-card {
  padding: 4px 14px 10px;
}
.rs-card--footer {
  padding: 6px 14px 8px;
}
.rs-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  user-select: none;
}
/* セパレータ (gf .panel-sep 相当) */
.rs-sep {
  display: flex;
  align-items: center;
  padding: 0 14px;
  user-select: none;
  flex-shrink: 0;
}
.rs-sep::before,
.rs-sep::after {
  content: '';
  flex: 1;
  height: 1px;
}
.rs-sep::before { background: linear-gradient(to left,  transparent, var(--border)); }
.rs-sep::after  { background: linear-gradient(to right, transparent, var(--border)); }
/* 戻るボタン: 画面左上に絶対配置 */
.rs-back-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.rs-back-btn:hover { color: var(--text); border-color: var(--text-muted); }
/* 左側ゴースト: 削除 */
.rs-sidebar-ghost { display: none; }
.rs-title {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
.rs-video-info {
  width: min(100%, calc((100vh - 240px) * 16 / 9));
  padding: 4px 2px 0;
}
.rs-video-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
a.rs-video-title:hover { color: var(--accent); }
.rs-video-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rs-video-meta .gallery-meta-item {
  color: var(--text-muted);
  font-size: 12px;
}
.rs-video-meta .gallery-meta-item svg {
  width: 12px;
  height: 12px;
}
.rs-mode-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rs-mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  padding: 5px 0;
  width: 100%;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.rs-mode-btn i {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.rs-mode-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface2);
}
.rs-mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
/* カラースウォッチ */
.rs-swatch-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.rs-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.12s, transform 0.12s;
}
.rs-swatch:hover  { transform: scale(1.18); }
.rs-swatch.active { border-color: #fff; transform: scale(1.1); }
/* スライダー行 */
.rs-ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.rs-slider-val {
  font-size: 11px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 20px;
  text-align: right;
}
/* スライダー (gf input[type=range] 相当) */
.rs-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
  outline: none;
  border: none;
  --fill: 25%;
}
.rs-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--border) var(--fill));
}
.rs-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--border) var(--fill));
}
.rs-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 2px var(--bg);
  margin-top: -4px;
  transition: transform 0.1s;
}
.rs-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 0 2px var(--bg);
}
.rs-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.rs-slider::-moz-range-thumb:hover     { transform: scale(1.2); }
/* YouTubeリンクボタン */
.rs-yt-btn {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  text-decoration: none;
  padding: 5px 0;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  transition: color 0.15s, border-color 0.15s;
}
.rs-yt-btn:hover { color: var(--text); border-color: var(--text-muted); }
/* toolbar variant: inline, no padding */
.rs-yt-btn--toolbar {
  display: inline-block;
  padding: 4px 10px;
  white-space: nowrap;
  margin-left: auto;
}

/* インラインツールバー (rs-mainの画像下) */
.rs-toolbar {
  width: min(100%, calc((100vh - 240px) * 16 / 9));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0;
}
.rs-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.rs-toolbar-group--slider {
  gap: 6px;
}
.rs-toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
}
.rs-toolbar-label {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
}
/* toolbar context: mode buttons inline */
.rs-toolbar .rs-mode-btn {
  width: auto;
  padding: 4px 10px;
}
.rs-toolbar .rs-slider {
  width: 80px;
}

/* プレイリストパネル (reactionsScreen 右) */
.rs-playlist {
  position: relative;
  flex-shrink: 0;
  width: clamp(280px, 30vw, 400px);
  min-width: clamp(280px, 30vw, 400px);
  max-width: 400px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease, margin-right 0.3s ease;
}
.rs-playlist-resize-handle { display: none; }
.rs-playlist-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.rs-panel-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.rs-panel-count {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
}
.rs-playlist-header .view-bar {
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}
.rs-playlist-body {
  flex: 1;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}
.rs-playlist-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; min-height: 48px; }
.rs-playlist-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px 8px 8px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.rs-playlist-card:hover { background: var(--surface2); }
.rs-playlist-card.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.rs-playlist-thumb {
  position: relative;
  flex-shrink: 0;
  width: 140px;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
}
.rs-playlist-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.rs-playlist-dur {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(0,0,0,0.82);
  color: #fff;
  border-radius: 3px;
  padding: 1px 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.rs-playlist-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rs-playlist-title {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rs-playlist-card:hover .rs-playlist-title,
.rs-playlist-card.selected .rs-playlist-title { color: var(--text); }
.rs-playlist-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.rs-playlist-meta .gallery-meta-item {
  color: var(--text-muted);
  font-size: 10px;
}
.rs-playlist-meta .gallery-meta-item svg {
  width: 10px;
  height: 10px;
}

/* トースト通知 */
#app-toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 99999;
  pointer-events: none;
}
.app-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: rgba(40, 40, 50, 0.95);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: app-toast-in 0.2s ease;
  pointer-events: none;
}
.app-toast.ok  { border-left: 3px solid #3fb950; }
.app-toast.err { border-left: 3px solid #e5534b; pointer-events: auto; }
.app-toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 0 0 10px;
  flex-shrink: 0;
}
.app-toast-close:hover { opacity: 1; }
.app-toast.out { animation: app-toast-out 0.3s ease forwards; }
@keyframes app-toast-in  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes app-toast-out { from { opacity: 1; transform: translateY(0); }   to { opacity: 0; transform: translateY(8px); } }


/* ===== Reactions Transport Overlay ===== */

.rs-transport {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.0) 100%);
  padding: 32px 12px 10px;
  opacity: 0;
  user-select: none;
  transition: opacity 0.55s ease;
  pointer-events: none;
  border-radius: 0 0 4px 4px;
  display: none;
}
.rs-transport.visible { display: block; }
.rs-img-wrap:hover .rs-transport.visible:not(.rs-transport-off) { opacity: 1; pointer-events: auto; transition: opacity 0.18s ease; }
.rs-transport.visible.rs-transport-off { opacity: 0; pointer-events: none; transition: opacity 0.18s ease; }
.rs-transport.visible.rs-transport-peek { animation: rs-transport-peek 1.0s ease forwards; pointer-events: none; }
@keyframes rs-transport-peek {
  0%   { opacity: 1; }
  40%  { opacity: 1; }
  100% { opacity: 0; }
}

.rs-transport-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rs-tbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
  pointer-events: auto;
}
.rs-tbtn:hover {
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 75%);
  transform: scale(1.1);
}
.rs-tbtn svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
  fill: none;
  pointer-events: none;
}
.rs-tbtn.active svg { stroke: var(--accent); }

/* Progress bar */
.rs-progress-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  margin: 0 4px;
  pointer-events: auto;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}
.rs-progress-track::before {
  content: '';
  position: absolute;
  inset: -10px 0;
}
.rs-progress-track:hover { transform: scaleY(1.5); }
.rs-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 3px;
  width: 0%;
  pointer-events: none;
}
.rs-progress-thumb {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  left: 0%;
  transition: transform 0.12s;
}
.rs-progress-track:hover .rs-progress-thumb,
.rs-progress-track.dragging .rs-progress-thumb {
  transform: translate(-50%, -50%) scaleY(calc(1 / 1.5));
}

/* Time label */
.rs-time-label {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 76px;
  text-align: right;
  pointer-events: none;
}

/* Volume popup */
.rs-transport-vol {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.rs-transport-mute-btn { flex-shrink: 0; }
.rs-transport-vol-popup {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  padding: 6px 0;
}
.rs-transport-vol:hover .rs-transport-vol-popup,
.rs-transport-vol.vol-open .rs-transport-vol-popup {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.rs-vol-track-wrap {
  width: 20px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rs-vol-track {
  width: 4px;
  height: 80px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  pointer-events: auto;
}
.rs-vol-track::before {
  content: '';
  position: absolute;
  inset: 0 -10px;
}
.rs-vol-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  border-radius: 3px;
  background: linear-gradient(to top, var(--accent), var(--accent2));
  pointer-events: none;
  height: 100%;
}
.rs-vol-thumb {
  position: absolute;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, 50%) scale(1);
  pointer-events: none;
  bottom: 0%;
  transition: transform 0.12s;
}

/* フルスクリーン中はトランスポートを常時表示 */
.rs-img-wrap:fullscreen .rs-transport.visible,
.rs-img-wrap:-webkit-full-screen .rs-transport.visible {
  opacity: 1;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 0;
  transition: opacity 0.15s ease;
}
.rs-img-wrap:fullscreen .rs-tbtn,
.rs-img-wrap:fullscreen .rs-progress-track,
.rs-img-wrap:-webkit-full-screen .rs-tbtn,
.rs-img-wrap:-webkit-full-screen .rs-progress-track { pointer-events: auto; }
.rs-img-wrap:fullscreen.fs-idle .rs-transport,
.rs-img-wrap:-webkit-full-screen.fs-idle .rs-transport {
  opacity: 0;
  transition: opacity 0.8s ease;
}
.rs-img-wrap:fullscreen.fs-idle { cursor: none; }
.rs-img-wrap:fullscreen img,
.rs-img-wrap:-webkit-full-screen img { max-width: 100%; max-height: 100vh; object-fit: contain; }
.rs-img-wrap:fullscreen,
.rs-img-wrap:-webkit-full-screen {
  background: #000;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
}

/* シアターモード: margin-right で空間を同時に縮め、transform でスライドアウト */
/* playlist 内部の width は 400px のまま変わらないのでリフロー不要 */
#reactionScreen.rs-theater-active .rs-playlist {
  margin-right: -400px;
  transform: translateX(100%);
  opacity: 0;
  border-color: transparent;
  pointer-events: none;
}