/* petspace — 공통 스타일 (다크 + 오렌지 포인트 1개) */
:root {
  --bg: #0b0b0f;
  --bg-1: #131319;
  --bg-2: #1b1b23;
  --line: #272733;
  --fg: #f2f2f6;
  --muted: #8e8e9c;
  --accent: #ff7a3d;
  --accent-dim: rgba(255, 122, 61, 0.16);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100dvh; }

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

.wordmark {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 17px;
}
.wordmark b { color: var(--accent); font-weight: 700; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}
.btn:hover { background: #23232d; }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0c04;
}
.btn.primary:hover { background: #ff8b56; }
.btn.on {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.btn[disabled] { opacity: 0.45; cursor: default; }

/* ---------- 토스트 ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 118px);
  transform: translate(-50%, 12px);
  background: rgba(20, 20, 27, 0.95);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: 84vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   index.html
   ========================================================= */
.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 22px 18px calc(env(safe-area-inset-bottom, 0px) + 60px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 26px;
}
.topbar .sub { color: var(--muted); font-size: 13px; }

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(23px, 6vw, 34px);
  line-height: 1.32;
  letter-spacing: -0.03em;
  font-weight: 800;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.65;
}

.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 230px;
  padding: 30px 20px;
  border: 1.5px dashed #33333f;
  border-radius: 20px;
  background: linear-gradient(180deg, #101016, #0d0d12);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.drop:hover, .drop.over {
  border-color: var(--accent);
  background: linear-gradient(180deg, #16110e, #0d0d12);
}
.drop .ico {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: var(--accent-dim);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.drop .t { font-size: 15.5px; font-weight: 700; }
.drop .s { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.drop input[type=file] { display: none; }

/* 업로드 진행 */
.uploading { display: none; }
.uploading.show { display: block; }
.drop.busy { pointer-events: none; opacity: 0.55; }

.progress {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
}
.progress .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  margin-bottom: 10px;
}
.progress .row span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar {
  height: 6px;
  border-radius: 99px;
  background: #22222c;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.2s ease;
}
.bar.indet > i {
  width: 38%;
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
.err {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 90, 70, 0.1);
  border: 1px solid rgba(255, 90, 70, 0.35);
  color: #ffb0a2;
  font-size: 13.5px;
}

/* 갤러리 */
.sec-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 42px 0 14px;
}
.sec-title h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.sec-title small { color: var(--muted); font-size: 12.5px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}
.grid a {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}
.grid a:hover img { transform: scale(1.06); }
.grid a::after {
  content: "2.5D";
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(11, 11, 15, 0.72);
  color: var(--accent);
}
.empty {
  color: var(--muted);
  font-size: 13.5px;
  padding: 26px 0;
  line-height: 1.6;
}

/* =========================================================
   view.html
   ========================================================= */
body.viewer { overflow: hidden; height: 100dvh; background: #000; }

#stage {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
}
/* 캔버스는 절대배치 풀블리드. (그리드 아이템으로 두면 캔버스 고유비율이
   행 높이를 밀어올려 크기가 발산한다 — 녹화 해상도 전환 때 실제로 터짐) */
#gl {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
/* 녹화 중에는 캔버스가 1080x1920 이므로 화면에 9:16 그대로 레터박스 */
#stage.rec #gl {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 0 0 1px rgba(255, 122, 61, 0.5), 0 0 40px rgba(255, 122, 61, 0.12);
}

.veil {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(11, 11, 15, 0.86);
  z-index: 40;
  text-align: center;
  padding: 24px;
}
.veil .msg { font-size: 14.5px; color: var(--muted); line-height: 1.7; }
.veil .msg b { display: block; color: var(--fg); font-size: 16px; margin-bottom: 8px; }
.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 2.5px solid #2a2a36;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 상단 바 */
.hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px;
  z-index: 20;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }

.icobtn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(20, 20, 27, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.icobtn:active { transform: scale(0.94); }

/* 하단 컨트롤 */
.hud-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 26px 12px calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.68), rgba(0, 0, 0, 0));
  pointer-events: none;
}
.panel {
  pointer-events: auto;
  max-width: 460px;
  margin: 0 auto;
  background: rgba(19, 19, 25, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 20px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 11px;
}
.slider-row label { font-size: 12.5px; color: var(--muted); flex: none; }
.slider-row output {
  font-size: 12px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  flex: none;
  width: 42px;
  text-align: right;
}
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 22px;
  background: none;
  margin: 0;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: #32323f;
}
input[type=range]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: #32323f;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin-top: -6.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0b0f;
}
input[type=range]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 2px solid #0b0b0f;
  border-radius: 50%;
  background: var(--accent);
}

.ctrl-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chip {
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12.5px;
  font-weight: 600;
  color: #d7d7df;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.chip.on {
  background: var(--accent-dim);
  border-color: rgba(255, 122, 61, 0.55);
  color: var(--accent);
}
.chip:active { transform: scale(0.96); }
.chip.hidden { display: none; }

.rec-btn {
  margin-left: auto;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
}
.rec-btn i {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ff3b30;
  transition: all 0.18s ease;
}
.rec-btn.recording i { width: 19px; height: 19px; border-radius: 5px; }
.rec-btn:active { transform: scale(0.94); }

/* 녹화 상태 */
.rec-hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 62px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(11, 11, 15, 0.8);
  border: 1px solid rgba(255, 59, 48, 0.5);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.rec-hud.show { display: flex; }
.rec-hud .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff3b30;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0.15; } }

.recbar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 30;
  transition: width 0.12s linear;
}

.countdown {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 45;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.countdown.show { display: grid; }
.countdown b {
  font-size: 96px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
  animation: pop 0.75s ease-out;
}
.countdown small {
  position: absolute;
  bottom: 24%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13.5px;
  color: #e6e6ee;
}
@keyframes pop {
  0% { transform: scale(1.55); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.55; }
}

/* 미리보기 시트 */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
  background: rgba(6, 6, 9, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.sheet.show { display: flex; }
.sheet .preview-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: center;
}
/* 비디오는 1080x1920 고유 비율 그대로 줄여서 보여준다 */
.sheet video {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  background: #000;
  border: 1px solid var(--line);
}
.sheet .title { font-size: 15px; font-weight: 700; }
.sheet .note { font-size: 12.5px; color: var(--muted); min-height: 17px; text-align: center; }
.sheet .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
