/* ==========================================================================
   MASTER-KEY design system — round 1 foundation
   Dark tech + glass. Gold key accent (brand), NOT the default AI purple.
   Transparency: translucent surfaces + hairline borders; backdrop-blur only
   on the fixed nav (performance guardrail). Motion: transform/opacity only,
   spring-ish cubic-bezier, honors prefers-reduced-motion.
   ========================================================================== */

:root {
  --bg: #09090b;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f5;
  --text-dim: #a1a1aa;
  --text-faint: #71717a;
  --accent: #eab308;          /* master-key gold */
  --accent-soft: #fbbf24;
  --accent-ink: #1c1917;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 20px;
  --radius-sm: 12px;
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

/* hidden 속성이 .card-grid 같은 명시적 display 선언에 지지 않도록 */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Fixed gradient backdrop: dim gold/ember orbs, never repaints on scroll */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px 400px at 12% -8%, rgba(234, 179, 8, 0.13), transparent 65%),
    radial-gradient(700px 500px at 105% 15%, rgba(190, 90, 60, 0.10), transparent 65%),
    radial-gradient(900px 700px at 50% 120%, rgba(120, 90, 220, 0.06), transparent 60%);
  pointer-events: none;
}

/* ---------- entry motion ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

main > * { animation: rise 0.7s var(--ease-spring) backwards; }
main > *:nth-child(2) { animation-delay: 0.06s; }
main > *:nth-child(3) { animation-delay: 0.12s; }
main > *:nth-child(4) { animation-delay: 0.18s; }
main > *:nth-child(5) { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- shell ---------- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 108px 20px 96px;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.4em;
}

h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; margin: 2.2em 0 0.6em; }
h3 { font-size: 1.02rem; font-weight: 600; margin: 1.8em 0 0.5em; }

a { color: var(--text); text-decoration: none; transition: color 0.35s var(--ease-spring); }
a:hover { color: var(--accent-soft); }

small { color: var(--text-faint); }
hr { display: none; }

/* ---------- floating glass nav (only fixed element gets blur) ---------- */

nav {
  position: fixed;
  top: 16px;
  /* transform 대신 margin 중앙정렬 — rise 애니메이션의 transform이 덮어써서
     첫 로드에 우측에 보이다 점프하던 문제 방지 */
  left: 0;
  right: 0;
  margin-inline: auto;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  width: max-content;
  max-width: calc(100vw - 24px);
  border-radius: 999px;
  background: rgba(20, 20, 23, 0.65);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: rise 0.7s var(--ease-spring) backwards;
  white-space: nowrap;
}

nav a {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.35s var(--ease-spring), background 0.35s var(--ease-spring);
}

nav a:hover { color: var(--text); background: var(--surface-strong); }

nav a:first-child,
nav .brand {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: -0.02em;
}

nav .brand { display: inline-flex; align-items: center; gap: 7px; }
.brand-logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: block;
}

/* 홈 히어로 로고 */
.hero-logo {
  width: clamp(120px, 22vw, 170px);
  height: auto;
  border-radius: 28px;
  margin: 0 auto 6px;
  display: block;
  box-shadow: 0 0 60px rgba(234, 179, 8, 0.25);
}

nav .nav-user { padding: 0 12px 0 6px; font-size: 0.85rem; color: var(--text-faint); }

/* ---------- 마이페이지: 방탈력 워터마크 ---------- */

.profile-card { position: relative; overflow: hidden; }

.power-watermark {
  position: absolute;
  top: 2px;
  right: 16px;
  font-size: 5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent-soft);
  opacity: 0.14;
  pointer-events: none;
  user-select: none;
}

/* ---------- 도감 / 업적 ---------- */

.gold-text { color: var(--accent-soft); }

.dex-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
@media (max-width: 640px) { .dex-summary { grid-template-columns: 1fr; } }

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  overflow: hidden;
  margin-top: 8px;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-soft), #d97706);
  transition: width 0.8s var(--ease-spring);
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  padding: 0;
  list-style: none;
}

.achievement { padding: 16px 18px; }
.achievement .card-title { margin: 0 0 2px; }
.achievement p { margin: 6px 0 0; }
.achievement .earned-date { font-size: 0.78rem; margin-top: 4px; }
.achievement.locked { opacity: 0.45; filter: saturate(0.4); }

/* 컬렉션 테마 선택(관리자 폼) */
.collection-picker { max-height: 420px; overflow-y: auto; }
.picker-cafe { margin: 12px 0 6px; font-weight: 700; }
.picker-cafe:first-child { margin-top: 0; }
.picker-themes { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.picker-item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--text-dim); cursor: pointer; }
.picker-item input { accent-color: var(--accent); }

.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  padding: 0;
  list-style: none;
}

.dex-tile {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--surface);
  transition: transform 0.4s var(--ease-spring), border-color 0.4s var(--ease-spring);
}

a.dex-tile:hover { transform: translateY(-3px); border-color: rgba(234, 179, 8, 0.45); }

.dex-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.dex-name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 8px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dex-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-faint);
}

/* 미수집: 흑백 + 블러 실루엣 */
.dex-locked img { filter: grayscale(1) blur(6px) brightness(0.4); }
.dex-locked .dex-name { color: var(--text-faint); }

.dex-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dex-lock .icon { width: 22px; height: 22px; color: rgba(255, 255, 255, 0.35); }

/* 도감 전체 현황 — 잔디 셀 (이미지 없이 수집 여부만), 지역 그룹 + 현재지역/전체 토글 */
.dex-heat { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.dex-heat-group { margin-top: 14px; }
.dex-heat-group:first-child { margin-top: 6px; }
.dex-heat-label { margin: 0; font-size: 0.86rem; font-weight: 700; }
.dex-heat-subtoggle { display: flex; justify-content: flex-end; gap: 6px; margin: 8px 0 0; }
.dex-cell[data-theme-id] { cursor: pointer; }
.dex-cell[data-theme-id]:hover { transform: scale(1.35); border-color: rgba(234, 179, 8, 0.6); }

/* 잔디 셀 클릭 → 테마 정보 바텀시트 */
.peek-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
}
.peek-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 91;
  max-width: 560px;
  margin-inline: auto;
  padding: 18px 20px 22px;
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--hairline-strong);
  border-bottom: 0;
  background: rgba(20, 20, 23, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translateY(105%);
  transition: transform 0.45s var(--ease-spring);
}
.peek-sheet.open { transform: none; }
.peek-close {
  position: absolute;
  top: 10px; right: 14px;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
}
.peek-body { display: flex; gap: 16px; align-items: flex-start; }
.peek-poster {
  flex: 0 0 84px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--surface);
}
.peek-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.peek-info { min-width: 0; }
.peek-name { margin: 0 0 2px; font-weight: 800; font-size: 1.05rem; }
.peek-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.peek-info .btn { margin-top: 8px; }

/* 리뷰 더보기 시트 — 내부 스크롤 (10개씩 batch-reveal) */
.review-sheet { max-width: 640px; }
.sheet-scroll { max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.dex-cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--hairline);
}
.dex-cell.collected {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  border-color: rgba(234, 179, 8, 0.55);
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.25);
}
.dex-gallery-title { margin: 1.4em 0 0.6em; }

/* 관리자 대시보드 */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  padding: 0;
  list-style: none;
}
.admin-stats li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 16px 10px;
}
.admin-stats strong { font-size: 1.5rem; font-weight: 800; }
.admin-stats span { color: var(--text-dim); font-size: 0.82rem; }
.admin-list { padding: 0; list-style: none; }
.admin-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.role-form { display: flex; gap: 6px; align-items: center; }
.role-form select { padding: 4px 8px; }

/* 에러 페이지 (404/422/500) — 거대한 코드 워터마크 + 방탈출 컨셉 문구 */
.error-page {
  position: relative;
  text-align: center;
  padding: 9vh 16px 6vh;
}
.error-code {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: clamp(7rem, 24vw, 13rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(160deg, rgba(234, 179, 8, 0.22), rgba(234, 179, 8, 0.05));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  pointer-events: none;
  user-select: none;
}
.error-key {
  position: relative;
  font-size: 2.6rem;
  margin-top: clamp(4rem, 14vw, 7.5rem);
  filter: drop-shadow(0 0 18px rgba(234, 179, 8, 0.35));
  animation: error-sway 3.2s var(--ease-spring) infinite;
}
@keyframes error-sway {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
.error-page h1 { position: relative; margin: 0.5em 0 0.4em; }
.error-page .meta { line-height: 1.7; }
.error-actions { justify-content: center; margin-top: 1.6em; }

/* ---------- 오류 팝업 (<dialog>) ---------- */

dialog.error-dialog {
  margin: auto;
  min-width: 300px;
  max-width: 420px;
  padding: 24px 26px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius);
  background: #141417;
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: rise 0.4s var(--ease-spring);
}

dialog.error-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

dialog.error-dialog h3 { margin: 0 0 10px; color: var(--danger); font-size: 1.05rem; }
dialog.error-dialog ul { margin: 0 0 16px; padding-left: 18px; color: var(--text-dim); }
dialog.error-dialog li { margin: 4px 0; }

/* ---------- flash ---------- */

.flash {
  margin: 0 0 20px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  border: 1px solid var(--hairline-strong);
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.12), rgba(234, 179, 8, 0.04));
}

.flash.alert {
  border-color: rgba(248, 113, 113, 0.35);
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.14), rgba(248, 113, 113, 0.04));
}

/* ---------- glass card ---------- */

.card {
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: linear-gradient(160deg, var(--surface-strong), var(--surface));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 22px 24px;
  transition: transform 0.5s var(--ease-spring), border-color 0.5s var(--ease-spring),
              box-shadow 0.5s var(--ease-spring);
}

a.card:hover, .card.is-link:hover {
  transform: translateY(-3px);
  border-color: rgba(234, 179, 8, 0.35);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 0;
  margin: 20px 0;
  list-style: none;
}

/* ---------- hero (home) ---------- */

.hero { padding: 10vh 0 6vh; text-align: center; }

.hero .eyebrow {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 22px;
}

.hero h1 {
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  background: linear-gradient(120deg, #fafafa 30%, var(--accent-soft) 70%, #d97706 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p { color: var(--text-dim); font-size: 1.08rem; margin: 0.4em auto 2em; max-width: 32em; }

.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- buttons ---------- */

button, input[type="submit"], .btn {
  appearance: none;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  padding: 10px 22px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-strong);
  cursor: pointer;
  transition: transform 0.4s var(--ease-spring), background 0.4s var(--ease-spring),
              border-color 0.4s var(--ease-spring), color 0.4s var(--ease-spring);
}

button:hover, input[type="submit"]:hover, .btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
  color: var(--text);
}

button:active, input[type="submit"]:active, .btn:active { transform: scale(0.97); }

.btn-primary, input[type="submit"].btn-primary {
  background: linear-gradient(135deg, var(--accent-soft), #d97706);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 8px 28px rgba(234, 179, 8, 0.25);
}

.btn-primary:hover { background: linear-gradient(135deg, #fcd34d, #ea8a04); color: var(--accent-ink); }

.btn-danger:hover { border-color: rgba(248, 113, 113, 0.5); color: var(--danger); background: rgba(248, 113, 113, 0.08); }

form.button_to { display: inline-block; }

/* ---------- forms ---------- */

input[type="text"], input[type="email"], input[type="url"], input[type="tel"],
input[type="number"], input[type="date"], select, textarea {
  appearance: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color 0.35s var(--ease-spring), background 0.35s var(--ease-spring),
              box-shadow 0.35s var(--ease-spring);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(234, 179, 8, 0.55);
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.15);
  background: rgba(255, 255, 255, 0.06);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

select option { background: #18181b; color: var(--text); }

textarea { width: 100%; min-height: 96px; resize: vertical; }

label { font-size: 0.88rem; font-weight: 600; color: var(--text-dim); }

form p { margin: 14px 0; }

.form-card { max-width: 560px; }

/* 정돈된 폼: 라벨 위 + 입력 아래, 6컬럼 그리드 (기본 전체 폭, w3/w2로 분할) */
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 4px; }
.field-stack { display: flex; flex-direction: column; gap: 6px; grid-column: span 6; }
.field-stack input:not([type="checkbox"]), .field-stack select, .field-stack textarea { width: 100%; }
.field-stack .switch { min-height: 42px; } /* 옆 입력창과 세로 정렬 맞춤 */
.time-pair { display: flex; align-items: center; gap: 6px; }
.time-pair input { min-width: 0; }

@media (min-width: 640px) {
  .field-stack.w3 { grid-column: span 3; }
  .field-stack.w2 { grid-column: span 2; }
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface);
  margin: 18px 0 22px;
}

.filter-bar input[type="text"] { flex: 1 1 180px; }

/* ---------- tables (내 기록 등 데이터 목록) ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  overflow: hidden;
  background: var(--surface);
  font-size: 0.93rem;
}

thead th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.03);
}

tbody td { padding: 12px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.3s var(--ease-spring); }
tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

.table-wrap { overflow-x: auto; }

/* 내 기록 테이블: 좁은 화면에서 찌그러지지 않게 최소 폭 보장 → 가로 스크롤 */
table.records-table { min-width: 860px; }
table.records-table th, table.records-table td { white-space: nowrap; }
table.records-table td:nth-child(2) { min-width: 180px; } /* 테마명 */

/* 메모: 최소 240px 보장, 넘치면 셀 안에서 좌우 스크롤 */
table.records-table .memo-cell { min-width: 240px; max-width: 320px; }
table.records-table .memo-scroll {
  overflow-x: auto;
  white-space: nowrap;
  max-width: 320px;
  padding-bottom: 3px; /* 스크롤바가 글자를 가리지 않게 */
  scrollbar-width: thin;
}

/* 목록(표)형: 엑셀처럼 촘촘하게, 헤더는 스크롤 시 고정 */
table.compact { font-size: 0.86rem; white-space: nowrap; }
table.compact thead th { padding: 9px 12px; position: sticky; top: 0; background: #141417; z-index: 1; }
table.compact tbody td { padding: 8px 12px; }
table.compact tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
table.compact .tag { padding: 1px 8px; font-size: 0.72rem; }
table.compact thead th { cursor: pointer; user-select: none; }
table.compact thead th:hover { color: var(--accent-soft); }
table.compact thead th.sorted-asc::after { content: " ▲"; color: var(--accent); font-size: 0.7em; }
table.compact thead th.sorted-desc::after { content: " ▼"; color: var(--accent); font-size: 0.7em; }
.table-wrap.tall { max-height: 72vh; overflow-y: auto; }

/* ---------- badges & tags ---------- */

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-soft);
  background: rgba(234, 179, 8, 0.10);
  border: 1px solid rgba(234, 179, 8, 0.22);
  transition: background 0.35s var(--ease-spring), transform 0.35s var(--ease-spring);
}

.tag:hover { background: rgba(234, 179, 8, 0.2); transform: translateY(-1px); color: var(--accent-soft); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid var(--hairline-strong);
  color: var(--text-dim);
  background: var(--surface-strong);
}

.badge.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.08); }
.badge.warn { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.08); }
.badge.gold { color: var(--accent-soft); border-color: rgba(234, 179, 8, 0.3); background: rgba(234, 179, 8, 0.08); }

.stars { color: var(--accent); letter-spacing: 0.1em; }

/* ---------- lists ---------- */

ul.plain { list-style: none; padding: 0; margin: 16px 0; }
ul.plain > li { padding: 12px 0; border-bottom: 1px solid var(--hairline); }
ul.plain > li:last-child { border-bottom: none; }

/* 리뷰 입력: 0.5 단위 별점 위젯 + 추천 토글 */
.review-controls { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; margin-bottom: 6px; }
.review-controls .field { display: inline-flex; align-items: center; gap: 10px; }

.stars-widget {
  position: relative;
  display: inline-block;
  font-size: 1.55rem;
  line-height: 1;
  letter-spacing: 3px;
  cursor: pointer;
  user-select: none;
}

.stars-bg { color: rgba(255, 255, 255, 0.14); }

.stars-fg {
  position: absolute;
  inset: 0 auto 0 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--accent-soft);
  pointer-events: none;
  transition: width 0.15s var(--ease-spring);
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { display: none; }

.switch .slider {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--hairline-strong);
  position: relative;
  transition: background 0.35s var(--ease-spring), border-color 0.35s var(--ease-spring);
  flex-shrink: 0;
}

.switch .slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.35s var(--ease-spring), background 0.35s var(--ease-spring);
}

.switch input:checked + .slider {
  background: linear-gradient(135deg, var(--accent-soft), #d97706);
  border-color: transparent;
}

.switch input:checked + .slider::after { transform: translateX(17px); background: var(--accent-ink); }

/* 버튼 줄 정렬 (서로 다른 폼의 버튼도 한 줄에) */
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.form-actions .back-link { margin-left: auto; }

/* 리뷰: 1행 = 이름/추천/날짜, 2행 = 내용 */
.review-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-head small { color: var(--text-faint); }
.review-head form.button_to { margin-left: auto; }
.review-body { margin: 6px 0 0; color: var(--text); }

.meta { color: var(--text-dim); font-size: 0.9rem; }
.meta strong { color: var(--text); }

/* ---------- media (poster / brand image) ---------- */

.card-media {
  display: block;
  width: calc(100% + 48px);
  height: 150px;
  margin: -22px -24px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  object-fit: cover;
  border-bottom: 1px solid var(--hairline);
}

.card-media.placeholder, .avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: rgba(251, 191, 36, 0.55);
  background:
    radial-gradient(120px 80px at 20% 0%, rgba(234, 179, 8, 0.18), transparent 70%),
    linear-gradient(150deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

.card-media.placeholder { font-size: 2rem; }

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--hairline-strong);
  margin-bottom: 10px;
}

.avatar.lg { width: 68px; height: 68px; border-radius: 18px; margin-bottom: 0; }

.avatar.placeholder { font-size: 1.3rem; }

/* ---------- themes: card / list view toggle ---------- */

.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 4px 0 10px; }
.view-toggle { margin-left: auto; display: inline-flex; gap: 6px; }
.btn.active { background: linear-gradient(135deg, var(--accent-soft), #d97706); color: var(--accent-ink); border-color: transparent; }

/* theme card 공통 구조 (그리드 기본) */
.theme-card { display: flex; flex-direction: column; }
.card-media-link { display: block; }
.theme-card .card-title a { color: var(--text); }
.theme-card .card-title a:hover { color: var(--accent-soft); }
.theme-card .card-row { margin: 8px 0 2px; }

.icon { width: 15px; height: 15px; flex-shrink: 0; vertical-align: -2px; color: var(--accent); }

/* 카드 우측 상단 설정(수정) 아이콘 버튼 */
.card-holder { position: relative; }

.card-gear {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(20, 20, 23, 0.7);
  border: 1px solid var(--hairline-strong);
  transition: transform 0.5s var(--ease-spring), border-color 0.5s var(--ease-spring);
}

.card-gear .icon { width: 16px; height: 16px; color: var(--text-dim); transition: color 0.3s var(--ease-spring); }
.card-gear:hover { transform: rotate(45deg); border-color: rgba(234, 179, 8, 0.5); }
.card-gear:hover .icon { color: var(--accent-soft); }

.info-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.info { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.info strong { color: var(--text); }
.info.gold { color: var(--accent-soft); }

.card-cta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

.card-cta .price { color: var(--text-dim); font-size: 0.9rem; font-weight: 600; }

.btn-reserve, a.btn-reserve {
  border-color: rgba(234, 179, 8, 0.5);
  color: var(--accent-soft);
  background: rgba(234, 179, 8, 0.06);
  font-weight: 700;
  padding: 8px 18px;
}

.btn-reserve:hover { background: rgba(234, 179, 8, 0.16); border-color: var(--accent-soft); color: var(--accent-soft); }

/* 리스트형: 좌측 큰 포스터 + 우측 정보 + 우하단 CTA (참고 레이아웃) */
.card-grid.as-list { display: flex; flex-direction: column; gap: 12px; }

.card-grid.as-list .theme-card {
  flex-direction: row;
  align-items: stretch;
  gap: 20px;
  padding: 16px;
}

.card-grid.as-list .card-media {
  width: 168px;
  height: 168px;
  margin: 0;
  border-radius: 16px;
  border-bottom: none;
}

.card-grid.as-list .card-media.placeholder { font-size: 1.8rem; }
.card-grid.as-list .card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-grid.as-list .card-body .card-title { font-size: 1.25rem; margin: 2px 0 2px; }
.card-grid.as-list .info-grid { margin-top: auto; padding-top: 12px; }
.card-grid.as-list .card-cta { flex-direction: column; align-items: flex-end; justify-content: flex-end; margin-top: 0; }

@media (max-width: 640px) {
  .card-grid.as-list .theme-card { gap: 12px; padding: 12px; }
  .card-grid.as-list .card-media { width: 96px; height: 96px; }
  .card-grid.as-list .card-cta .price { display: none; }
}

/* cafe list: region grouping + chips */
.region-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.tag.active { background: linear-gradient(135deg, var(--accent-soft), #d97706); color: var(--accent-ink); border-color: transparent; }
.region-section h2 { margin-top: 1.6em; }
.region-section + .region-section h2 { margin-top: 2em; }

/* cafe list card: head link + circular theme thumbnails */
.cafe-head { display: flex; align-items: center; gap: 12px; }
.cafe-head .avatar { margin-bottom: 0; flex-shrink: 0; }
.cafe-head .card-title { display: block; }
.cafe-head .card-sub { display: block; margin: 0; }
.cafe-head:hover .card-title { color: var(--accent-soft); }

.theme-dots { display: flex; align-items: center; margin: 14px 0 2px; padding-left: 6px; }
.theme-dots a { display: inline-flex; }

.dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #1c1c20;
  margin-left: -6px;
  background: var(--surface-strong);
  transition: transform 0.4s var(--ease-spring), border-color 0.4s var(--ease-spring);
}

.theme-dots a:hover .dot { transform: translateY(-3px) scale(1.12); border-color: rgba(234, 179, 8, 0.6); z-index: 1; position: relative; }

.dot.placeholder, .dot.more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
}

.dot.more { color: var(--accent-soft); background: rgba(234, 179, 8, 0.1); }

.btn-sm, a.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
/* 뱃지(탈출 성공/실패)와 같은 크기의 초소형 버튼 */
.btn-xs, a.btn-xs, button.btn-xs, input.btn-xs { padding: 3px 10px; font-size: 0.76rem; font-weight: 700; }

.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.page-head h1 { margin: 0; }

.action-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 6px; }

/* PC/태블릿: 포스터(좌) + 정보/소개(우) 2열 — 모바일은 세로 스택 */
@media (min-width: 768px) {
  .detail-grid {
    display: grid;
    grid-template-columns: minmax(280px, 400px) 1fr;
    gap: 20px;
    align-items: start;
  }
  .detail-grid .poster-hero-wrap { margin: 4px 0 0; position: sticky; top: 88px; }
  .detail-grid .poster-hero { max-height: 560px; width: 100%; }
  .detail-grid .section-card { margin-top: 16px; }
}

/* 세로형 포스터 대응: 원본 비율 유지 + 같은 이미지의 블러 배경으로 여백을 채움 */
.poster-hero-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  overflow: hidden;
  margin: 4px 0 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.poster-hero-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--poster) center / cover;
  filter: blur(28px) brightness(0.45);
  transform: scale(1.25);
}

.poster-hero {
  position: relative;
  display: block;
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
}

/* theme detail head */
.theme-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.theme-head-row h1 { margin-bottom: 0.1em; }
.theme-head-row .card-row { margin-top: 6px; }

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  margin-top: 18px;
  border-top: 1px solid var(--hairline);
  padding-top: 16px;
}

.stat {
  flex: 1 1 0;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  text-align: center;
}

.stat + .stat { border-left: 1px solid var(--hairline); }
.stat .icon { width: 18px; height: 18px; }
.stat strong { font-size: 1.02rem; letter-spacing: -0.01em; }
.stat small { color: var(--text-faint); font-size: 0.75rem; }

.highlight-strip {
  margin: 16px 0 0;
  padding: 10px 16px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-soft);
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.14), rgba(234, 179, 8, 0.05));
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.section-card { margin-top: 16px; }
.section-card h2 { margin-top: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.section-badges { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* 공포도: 단계가 오를수록 붉게 */
.badge.horror-1 { color: #fecaca; background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.22); }
.badge.horror-2 { color: #fca5a5; background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.32); }
.badge.horror-3 { color: #fecaca; background: rgba(239, 68, 68, 0.30); border-color: rgba(239, 68, 68, 0.45); }
.badge.horror-4 { color: #fff;    background: rgba(220, 38, 38, 0.48); border-color: rgba(239, 68, 68, 0.6); }
.badge.horror-5 { color: #fff;    background: rgba(185, 28, 28, 0.75); border-color: #ef4444; }

/* 활동성: 단계가 오를수록 초록이 진하게 */
.badge.activity-1 { color: #bbf7d0; background: rgba(52, 211, 153, 0.08); border-color: rgba(52, 211, 153, 0.22); }
.badge.activity-2 { color: #86efac; background: rgba(52, 211, 153, 0.16); border-color: rgba(52, 211, 153, 0.32); }
.badge.activity-3 { color: #d1fae5; background: rgba(16, 185, 129, 0.30); border-color: rgba(16, 185, 129, 0.45); }
.badge.activity-4 { color: #fff;    background: rgba(5, 150, 105, 0.5);  border-color: rgba(16, 185, 129, 0.6); }
.badge.activity-5 { color: #fff;    background: rgba(4, 120, 87, 0.8);   border-color: #10b981; }

/* 하단 고정 CTA 바 (sticky라 blur 허용) */
.cta-bar {
  position: sticky;
  bottom: 14px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline-strong);
  background: rgba(20, 20, 23, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.cta-bar .cta-price { font-size: 1.25rem; font-weight: 800; margin: 0 6px; }
.cta-actions { display: flex; gap: 8px; align-items: center; }
.btn-lg, a.btn-lg { padding: 12px 30px; font-size: 1rem; }

@media (max-width: 640px) {
  .stat { min-width: 30%; }
  .stat:nth-child(4) { border-left: none; }
}

/* theme card internals */
.card .card-title { font-size: 1.06rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 2px; }
.card .card-sub { color: var(--text-dim); font-size: 0.86rem; margin: 0 0 10px; }
.card .card-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.summary-line {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.92rem;
}

.summary-line strong { color: var(--accent-soft); }

/* ---------- 기록 히트맵 (깃허브 잔디) ---------- */

.heatmap-card { margin: 18px 0; padding: 18px 20px 12px; }
.heatmap-wrap { overflow-x: auto; }
.heatmap { display: flex; gap: 3px; width: max-content; }
.hm-week { display: flex; flex-direction: column; gap: 3px; }

.hm-label {
  height: 13px;
  font-size: 0.62rem;
  color: var(--text-faint);
  line-height: 13px;
  white-space: nowrap;
}

.hm-dow { margin-right: 4px; }
.hm-dow .hm-label { text-align: right; }

.hm-cell { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
.hm-void { background: transparent; }
.hm-0 { background: rgba(255, 255, 255, 0.05); }
.hm-1 { background: rgba(16, 185, 129, 0.30); }
.hm-2 { background: rgba(16, 185, 129, 0.55); }
.hm-3 { background: rgba(16, 185, 129, 0.78); }
.hm-4 { background: #34d399; }
.hm-cell[title]:hover { outline: 1px solid var(--accent-soft); }
a.hm-cell { cursor: pointer; }

.hm-legend { display: flex; align-items: center; gap: 4px; margin: 10px 0 0; font-size: 0.78rem; }

/* ---------- 기록 캘린더 ---------- */

.cal-nav { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 6px 0 12px; }
.cal-nav h2 { margin: 0; }

table.calendar { table-layout: fixed; }
table.calendar thead th { text-align: center; position: static; }
table.calendar td { height: 92px; vertical-align: top; padding: 6px 8px; }
table.calendar td.other-month { opacity: 0.35; }
table.calendar td.today { background: rgba(234, 179, 8, 0.08); box-shadow: inset 0 0 0 1px rgba(234, 179, 8, 0.35); }
table.calendar .day-num { display: block; font-size: 0.78rem; color: var(--text-faint); margin-bottom: 4px; }

.cal-rec { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; margin: 2px 0; min-width: 0; }
.cal-rec .cal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cal-rec.ok .cal-dot { background: var(--ok); }
.cal-rec.fail .cal-dot { background: var(--danger); }

@media (max-width: 640px) {
  main { padding-top: 92px; }
  nav { gap: 0; padding: 6px; }
  nav a { padding: 7px 10px; font-size: 0.82rem; }
  nav .nav-user { display: none; }
}
