:root {
  --bg1: #f6efe8;
  --bg2: #e9eef0;
  --ink: #5b5048;
  --muted: #9a8e84;
  --accent: #7fb685;
  --accent-soft: #e9f3e9;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 72% -12%, #fff6ee 0%, transparent 55%),
    radial-gradient(900px 820px at -12% 112%, #e7f0ec 0%, transparent 55%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* HUD */
.hud { position: fixed; top: max(18px, env(safe-area-inset-top)); left: 18px; z-index: 5; pointer-events: none; }
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; letter-spacing: -0.2px;
  background: rgba(255, 255, 255, 0.62); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 8px 14px; border-radius: 999px; box-shadow: 0 8px 24px -12px rgba(90, 70, 55, 0.5);
}
.brand .leaf { filter: drop-shadow(0 2px 2px rgba(120, 160, 120, 0.4)); }
.hint { margin: 9px 6px 0; font-size: 12.5px; color: var(--muted); }

/* loading */
.loading {
  position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; gap: 14px; justify-items: center;
  background: linear-gradient(160deg, var(--bg1), var(--bg2)); color: var(--muted); transition: opacity 0.6s ease;
}
.loading.hide { opacity: 0; pointer-events: none; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #e4d9cf; border-top-color: #bcae9f; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* info 버튼 + 크레딧 카드 (우하단) */
.infobtn {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 6;
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.7); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #7a6e64; box-shadow: 0 6px 18px -8px rgba(90, 70, 55, 0.5); transition: background 0.15s, transform 0.08s;
}
.infobtn svg { width: 20px; height: 20px; }
.infobtn:hover { background: #fff; }
.infobtn:active { transform: scale(0.92); }
.infocard {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: 64px; z-index: 6;
  background: rgba(255, 255, 255, 0.94); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--line, #efe6dd); border-radius: 16px; padding: 13px 16px; max-width: 72vw;
  box-shadow: 0 16px 40px -16px rgba(90, 70, 55, 0.55); animation: pop 0.22s ease;
}
.infocard[hidden] { display: none; }
.infocard__t { margin: 0 0 8px; font-weight: 700; font-size: 14px; color: var(--ink); }
.infocard__r { margin: 3px 0; font-size: 13px; color: var(--muted); }
.infocard__r b { color: var(--ink); font-weight: 600; }

/* ───────────── Reels / Shorts 세로형 뷰어 ───────────── */
.reels {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(24, 18, 16, 0.62); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
  animation: fade 0.25s ease;
}
.reels[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.reels__stage {
  position: relative;
  width: min(430px, 94vw);
  height: min(86vh, calc(94vw * 16 / 9));
  aspect-ratio: 9 / 16;
  background: #1b1714;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.6);
  animation: pop 0.32s cubic-bezier(0.2, 0.9, 0.25, 1.2);
  cursor: pointer;
  --accent: #7fb685;
}
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
.theme-cat .reels__stage, .reels__stage.theme-cat { --accent: #f0a86a; }
.reels__stage.theme-cat { --accent: #f0a86a; }
.reels__stage.theme-dog { --accent: #e7b06a; }
.reels__stage.theme-nature { --accent: #74b98a; }

.reels__media {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity 0.4s ease; background: #1b1714;
}
.reels__media.show { opacity: 1; }
.reels__media.contain { object-fit: contain; } /* 전체보기 */
.reels__shimmer {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(100deg, #2a2420 30%, #3a322c 50%, #2a2420 70%);
  background-size: 200% 100%; animation: sh 1.2s linear infinite;
}
.reels__shimmer.hide { display: none; }
@keyframes sh { to { background-position: -200% 0; } }
.reels__grad {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.15) 32%, transparent 52%),
              linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, transparent 22%);
}

.reels__top { position: absolute; z-index: 3; top: 14px; left: 14px; right: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reels__chip {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; color: #fff;
  background: color-mix(in srgb, var(--accent) 88%, #000 0%); padding: 7px 13px; border-radius: 999px;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,0.6);
}
.reels__icon {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer; flex: none; padding: 0;
  display: flex; align-items: center; justify-content: center; /* X 아이콘 양축 중앙정렬 (UA 기본 패딩 제거) */
  background: rgba(0,0,0,0.4); color: #fff; font-size: 15px; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}

.reels__info { position: absolute; z-index: 3; left: 16px; right: 76px; bottom: 18px; color: #fff; }
.reels__title { margin: 0 0 6px; font-size: 16px; font-weight: 700; line-height: 1.4; text-shadow: 0 2px 8px rgba(0,0,0,0.5); max-height: 2.8em; overflow: hidden; }
.reels__credit { margin: 0; font-size: 12.5px; color: rgba(255,255,255,0.86); text-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.reels__credit a { color: #fff; font-weight: 600; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.5); }
.reels__hint { margin: 10px 0 0; font-size: 11.5px; color: rgba(255,255,255,0.62); }

.reels__rail { position: absolute; z-index: 3; right: 12px; bottom: 22px; display: flex; flex-direction: column; gap: 16px; }
.reels__act {
  display: flex; flex-direction: column; align-items: center; gap: 4px; border: none; background: none; cursor: pointer; color: #fff;
}
.reels__act .ico {
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-size: 21px;
  background: rgba(0,0,0,0.42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  box-shadow: 0 6px 16px -6px rgba(0,0,0,0.5); transition: transform 0.12s, background 0.15s;
}
.reels__act:active .ico { transform: scale(0.9); }
#vmore .ico { background: var(--accent); }
.reels__act small { font-size: 11px; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.reels__act[disabled] { opacity: 0.5; cursor: default; }
.reels__icon svg { width: 16px; height: 16px; display: block; }
.reels__act .ico svg { width: 23px; height: 23px; display: block; }

/* mobile: full-bleed reels */
@media (max-width: 540px) {
  .reels__stage { width: 100vw; height: 100dvh; border-radius: 0; aspect-ratio: auto; }
  .reels__info { bottom: max(20px, env(safe-area-inset-bottom)); }
  .reels__top { top: max(14px, env(safe-area-inset-top)); }
  .brand { font-size: 15px; }
}
