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

:root {
  --bg-top: #4a343c;
  --bg-bottom: #0d0b0c;
  --card-bg: rgba(255, 255, 255, 0.12);
  --text-main: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.55);
  --accent: #ffffff;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: linear-gradient(to bottom, var(--bg-top) 0%, #2a1f24 40%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- ヘッダー ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  /* iPhoneのステータスバー（ノッチ）と重ならないようセーフエリア分の余白を確保 */
  padding: calc(20px + env(safe-area-inset-top, 0px)) 16px 0;
  background: linear-gradient(to bottom, var(--bg-top) 60%, transparent);
  backdrop-filter: blur(8px);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 12px 14px;
}

.search-icon {
  width: 20px;
  height: 20px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 16px;
}

.search-bar input::placeholder {
  color: var(--text-dim);
}

.tabs {
  display: flex;
  gap: 28px;
  margin-top: 18px;
  padding-bottom: 0;
}

.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  font-weight: 500;
  padding: 6px 2px 12px;
  cursor: pointer;
  position: relative;
}

.tab.active {
  color: var(--text-main);
  font-weight: 700;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

/* ---------- グリッド ---------- */
#main-content {
  flex: 1;
  padding: 20px 16px 90px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 12px;
}

.card {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  text-align: left;
  color: var(--text-main);
}

.card-thumb-wrap {
  position: relative;
}

.card-thumb {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: var(--card-bg);
  display: block;
  transition: transform 0.15s ease;
}

.card-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 999px;
}

.card:active .card-thumb {
  transform: scale(0.96);
}

.card-title {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-message {
  text-align: center;
  color: var(--text-dim);
  margin-top: 60px;
  font-size: 14px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ---------- 下部ナビ ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-around;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: rgba(13, 11, 12, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 20;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  cursor: pointer;
  width: 25%;
}

.nav-item svg {
  width: 26px;
  height: 26px;
}

.nav-item.active {
  color: var(--text-main);
}

/* ---------- マイページ ---------- */
.mypage {
  padding-top: 10px;
}

.mypage-profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.mypage-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.mypage-name {
  font-size: 18px;
  font-weight: 700;
}

.mypage-stats {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}

/* ---------- リール型プレイヤー画面 ---------- */
#player-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
}

#player-screen[hidden] {
  display: none;
}

.player-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
  z-index: 5;
  pointer-events: none;
}

.player-header button {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
}

.player-header button svg {
  width: 22px;
  height: 22px;
}

#favorite-button.is-favorite svg {
  fill: #fff;
}

/* 縦スクロール + スナップでリール切り替え */
#reel-container {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}

#reel-container::-webkit-scrollbar {
  display: none;
}

.reel {
  position: relative;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
}

.reel video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 下部のグラデーション + 作品情報 */
.reel-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 80px 76px 28px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  pointer-events: none;
}

.reel-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  pointer-events: auto;
  cursor: pointer;
  background: none;
  border: none;
  color: #fff;
  padding: 0;
  text-align: left;
}

.reel-title svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.reel-creator {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 6px;
}

.reel-ep {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 6px;
}

.reel-desc {
  font-size: 12px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.7);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 右側の操作ボタン列（ブックマーク/エピソード/共有/ミュート） */
.reel-actions {
  position: absolute;
  right: 10px;
  bottom: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 4;
}

.reel-actions button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  padding: 0;
}

.reel-actions button svg {
  width: 27px;
  height: 27px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.reel-actions button.is-favorite svg {
  fill: #fff;
}

/* エピソード位置インジケーター（右端の点） */
.reel-indicator {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 4;
}

.reel-indicator span {
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
}

.reel-indicator span.active {
  background: #fff;
}

/* 一時停止アイコン */
.reel-paused-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  color: rgba(255, 255, 255, 0.85);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.reel.is-paused .reel-paused-icon {
  opacity: 1;
}

/* ---------- エピソード一覧ボトムシート ---------- */
#episode-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  max-width: 480px;
  margin: 0 auto;
}

#episode-sheet[hidden] {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
}

#episode-sheet.open .sheet-backdrop {
  opacity: 1;
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92%;
  background: #161416;
  border-radius: 18px 18px 0 0;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.35, 1);
  overscroll-behavior: contain;
}

#episode-sheet.open .sheet-panel {
  transform: translateY(0);
}

/* シート上部: ぼかし背景 + ポスター */
.sheet-hero {
  position: relative;
  height: 230px;
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  background: #000;
}

.sheet-hero-bg {
  position: absolute;
  inset: -20px;
  width: calc(100% + 40px);
  height: calc(100% + 40px);
  object-fit: cover;
  filter: blur(24px) brightness(0.55);
}

.sheet-poster {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  height: 198px;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}

#sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#sheet-close svg {
  width: 16px;
  height: 16px;
}

.sheet-body {
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}

#sheet-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.sheet-creator {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 10px;
}

.sheet-desc {
  font-size: 13px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.75);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sheet-desc.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.sheet-more {
  background: none;
  border: none;
  color: #ff5a5a;
  font-size: 13px;
  padding: 4px 0 0;
  cursor: pointer;
}

.sheet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.sheet-tags span {
  background: #2c2a2c;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
}

/* 話数グリッド */
.sheet-episodes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.sheet-episodes button {
  position: relative;
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  background: #2c2a2c;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.sheet-episodes button.current {
  background: #d9d9d9;
  color: #111;
}

.sheet-episodes button.locked {
  color: rgba(255, 255, 255, 0.45);
  cursor: default;
}

.sheet-episodes button.locked svg {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 10px;
  height: 10px;
  stroke: rgba(255, 255, 255, 0.5);
}
