:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f0eef8;
  --border: #e4e1ef;
  --text: #1d1b29;
  --muted: #6c6880;
  --primary: #6d5cff;
  --primary-strong: #5643f0;
  --primary-soft: #ece9ff;
  --on-primary: #ffffff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #1f9d63;
  --success-soft: #e3f6ec;
  --star: #ffb020;
  --shadow: 0 1px 2px rgba(20, 16, 50, 0.04), 0 4px 16px rgba(20, 16, 50, 0.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121119;
    --surface: #1b1a25;
    --surface-2: #24222f;
    --border: #2f2d3d;
    --text: #ecebf3;
    --muted: #9b97ad;
    --primary: #8b7dff;
    --primary-strong: #a194ff;
    --primary-soft: #2a2648;
    --on-primary: #ffffff;
    --danger: #ff6b6f;
    --danger-soft: #3a1e22;
    --success: #3fcf8e;
    --success-soft: #16301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
    'Malgun Gothic', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.container { flex: 1; padding-top: 24px; padding-bottom: 56px; outline: none; }

/* ───── 상단바 ───── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 16px; height: 60px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 8px 12px; border-radius: 10px; font-weight: 600; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { color: var(--primary); background: var(--primary-soft); }
.account { display: flex; align-items: center; gap: 8px; }
.me-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px;
  max-width: 180px;
}
.me-chip .nick-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 640px) {
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 0 12px; padding-top: 10px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; padding: 6px 0 8px; overflow-x: auto; }
  .nav a { flex: 1; text-align: center; }
  .me-chip .nick-text { display: none; }
  .me-chip { padding: 4px; }
}

/* ───── 공통 컴포넌트 ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.roblox { background: #1d1b29; color: #fff; border-color: #1d1b29; }
@media (prefers-color-scheme: dark) { .btn.roblox { background: #fff; color: #111; border-color: #fff; } }

.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; }
.avatar.lg { width: 72px; height: 72px; }
.avatar-fallback {
  display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--primary);
  background: var(--primary-soft);
}
.avatar.lg.avatar-fallback { font-size: 28px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 12px; }
.section-title h2 { font-size: 19px; }
.section-title a { font-size: 14px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge.open { background: var(--success-soft); color: var(--success); }
.badge.closed { background: var(--surface-2); color: var(--muted); }
.badge.pin { background: var(--primary-soft); color: var(--primary); }
.badge.admin { background: var(--primary); color: #fff; height: 20px; font-size: 11px; padding: 0 7px; }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.loading { padding: 64px 0; text-align: center; color: var(--muted); }
.more-wrap { display: flex; justify-content: center; margin-top: 20px; }

/* ───── 폼 ───── */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 700; font-size: 14px; }
.field .req { color: var(--danger); margin-left: 2px; }
.field .hint { color: var(--muted); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); outline: none; transition: border-color 0.15s, box-shadow 0.15s; font-size: 15px;
}
.textarea { height: auto; min-height: 120px; padding: 12px 14px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.form-card { padding: 24px; max-width: 720px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.thumb-preview { aspect-ratio: 16 / 9; width: 100%; max-width: 320px; border-radius: 12px; overflow: hidden; }
.thumb-preview:empty { display: none; }
.thumb-box { width: 112px; flex: none; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; }
.thumb-preview > .thumb, .thumb-box > .thumb { height: 100%; }
.num-label { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 14px; font-weight: 600; }
.num-label .input { flex: 1; min-width: 0; }

/* ───── 섬네일 ───── */
.thumb { position: relative; background: linear-gradient(135deg, var(--primary-soft), var(--surface-2)); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--primary); opacity: 0.6; }

/* ───── 별점 ───── */
.stars { position: relative; display: inline-block; font-size: 16px; line-height: 1; letter-spacing: 1px; color: var(--border); white-space: nowrap; }
.stars::before { content: '★★★★★'; }
.stars .fill { position: absolute; inset: 0; overflow: hidden; color: var(--star); white-space: nowrap; }
.stars .fill::before { content: '★★★★★'; }
.rating-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; }
.star-input { display: inline-flex; gap: 2px; }
.star-input button {
  border: 0; background: none; padding: 2px; font-size: 30px; line-height: 1; cursor: pointer; color: var(--border);
  transition: transform 0.1s, color 0.1s;
}
.star-input button.on { color: var(--star); }
.star-input button:hover { transform: scale(1.12); }

/* ───── 홈 ───── */
.hero {
  position: relative; overflow: hidden; padding: 36px 28px; border-radius: 20px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #a99eff 0%, transparent 55%),
    linear-gradient(135deg, #6d5cff 0%, #4a37e0 100%);
}
.hero h1 { font-size: 30px; letter-spacing: -0.03em; }
.hero p { margin: 8px 0 20px; opacity: 0.9; }
.hero .btn { border-color: transparent; }
.hero .btn.light { background: #fff; color: #4a37e0; }
.hero .btn.outline { background: rgba(255, 255, 255, 0.14); color: #fff; }
.hero-deco { position: absolute; right: -10px; bottom: -24px; font-size: 140px; opacity: 0.14; transform: rotate(-12deg); pointer-events: none; }

/* ───── 공지사항 ───── */
.list { overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item .title { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.article { padding: 28px; }
.article h1 { font-size: 24px; }
.article .meta { color: var(--muted); font-size: 14px; margin: 8px 0 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.article .body { white-space: pre-wrap; font-size: 16px; }

/* ───── 맵 앨범 ───── */
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input { flex: 1; min-width: 160px; height: 40px; }
.toolbar .select { width: auto; height: 40px; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
@media (max-width: 520px) { .album { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.map-card { overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; display: block; }
.map-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(40, 30, 120, 0.14); }
.map-card .thumb { aspect-ratio: 16 / 9; }
.map-card .info { padding: 12px 14px 14px; display: grid; gap: 4px; }
.map-card .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-card .rating-inline { font-size: 13px; }
.map-card .stars { font-size: 13px; }

/* ───── 맵 상세 ───── */
.map-detail { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; padding: 20px; }
@media (max-width: 760px) { .map-detail { grid-template-columns: 1fr; } }
.map-detail .thumb { aspect-ratio: 16 / 9; border-radius: 12px; }
.map-detail .side { display: flex; flex-direction: column; gap: 14px; }
.map-detail h1 { font-size: 26px; letter-spacing: -0.02em; }
.meta-table { display: grid; grid-template-columns: 72px 1fr; gap: 10px 12px; font-size: 15px; align-items: center; }
.meta-table dt { color: var(--muted); font-weight: 600; font-size: 14px; }
.meta-table dd { margin: 0; min-width: 0; }
.meta-table a.link { color: var(--primary); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.big-rating { display: flex; align-items: center; gap: 8px; }
.big-rating .num { font-size: 22px; font-weight: 800; }
.big-rating .stars { font-size: 20px; }
.desc { padding: 20px; margin-top: 16px; white-space: pre-wrap; }
.review-form { padding: 20px; display: grid; gap: 12px; }
.reviews { display: grid; gap: 10px; margin-top: 12px; }
.review { padding: 16px 18px; display: grid; gap: 6px; }
.review .head { display: flex; align-items: center; gap: 8px; }
.review .who { font-weight: 700; }
.review .comment { white-space: pre-wrap; }

/* ───── 모집 메모 ───── */
.tabs { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-2); gap: 2px; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.memos { display: grid; gap: 12px; }
.memo { overflow: hidden; border-left: 5px solid var(--primary); }
.memo.is-closed { border-left-color: var(--border); }
.memo-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; user-select: none; }
.memo-head .thumb { width: 96px; aspect-ratio: 16 / 9; border-radius: 10px; flex: none; }
.memo-head .main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.memo-head .name { font-weight: 800; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memo-head .when { color: var(--muted); font-size: 14px; font-weight: 600; }
.memo-head .actions { display: flex; gap: 6px; align-items: center; flex: none; }
.memo-head .chev { transition: transform 0.2s; color: var(--muted); flex: none; }
.memo.open .chev { transform: rotate(180deg); }
.memo-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.22s ease; }
.memo.open .memo-body { grid-template-rows: 1fr; }
.memo-body > div { overflow: hidden; }
.memo-body .inner { padding: 4px 16px 18px; border-top: 1px dashed var(--border); margin: 0 16px; padding-left: 0; padding-right: 0; display: grid; gap: 14px; }
.memo-body h4 { margin: 14px 0 8px; font-size: 14px; }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--surface-2); font-size: 14px; font-weight: 600; }
.person .avatar { width: 24px; height: 24px; font-size: 11px; }
.person .host { font-size: 11px; color: var(--primary); font-weight: 800; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.note { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
@media (max-width: 640px) {
  .memo-head { flex-wrap: wrap; gap: 10px 12px; padding: 12px; }
  .memo-head .thumb { width: 84px; }
  .memo-head .main { flex: 1 1 0; }
  .memo-head .actions { order: 4; flex-basis: 100%; justify-content: flex-end; }
  .memo-head .chev { order: 3; }
  .memo-body .inner { margin: 0 12px; }
}

/* ───── 마이페이지 ───── */
.profile { padding: 24px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile .who { flex: 1; min-width: 200px; display: grid; gap: 4px; }
.profile .nick { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.mine-list { display: grid; gap: 10px; }
.mine-item { display: flex; gap: 12px; padding: 12px; align-items: center; }
.mine-item .thumb { width: 96px; aspect-ratio: 16 / 9; border-radius: 8px; flex: none; }
.mine-item .main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.mine-item .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-zone { margin-top: 40px; padding: 20px; border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.danger-zone h3 { color: var(--danger); font-size: 16px; }
.danger-zone p { margin: 6px 0 14px; color: var(--muted); font-size: 14px; }

/* ───── 모달 / 토스트 ───── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 12, 30, 0.5);
  display: grid; place-items: center; padding: 16px; animation: fade 0.15s;
}
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; padding: 24px; animation: pop 0.18s; }
.modal h2 { font-size: 19px; margin-bottom: 14px; }
.modal .form-actions { margin-top: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
#toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #1d1b29; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25); animation: pop 0.18s; }
.toast.error { background: var(--danger); }

.footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: 13px; text-align: center; }
