:root {
  --brand: #6010A0;
  --brand-deep: #3D0A68;
  --brand-soft: #F1E9FA;
  --brand-line: #DCCBF0;
  --ink: #1F1729;
  --muted: #6C6279;
  --faint: #9A91A6;
  --line: #E9E3F0;
  --surface: #FFFFFF;
  --ground: #F4F1F8;
  --gold: #E0A100;
  --side: 400px;
  --shadow: 0 10px 30px rgba(45, 16, 80, .14), 0 2px 6px rgba(45, 16, 80, .08);
  --body: 'IBM Plex Sans KR', 'Noto Sans', 'Apple SD Gothic Neo', 'Malgun Gothic', 'PingFang SC', 'Hiragino Sans', 'Microsoft YaHei', sans-serif;
  --display: 'Hahmlet', 'IBM Plex Sans KR', serif;
  color-scheme: light;
}
html[lang="ru"], html[lang="mn"], html[lang="vi"] { --body: 'Noto Sans', 'IBM Plex Sans KR', sans-serif; }
html[lang="zh"] { --body: 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', 'IBM Plex Sans KR', sans-serif; }
html[lang="ja"] { --body: 'Noto Sans', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', 'IBM Plex Sans KR', sans-serif; }
html:not([lang="ko"]) { --display: var(--body); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground); color: var(--ink); font: 14px/1.5 var(--body);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#map { position: fixed; inset: 0; }

/* ── 왼쪽 목록 ─────────────────────────── */
#side {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 5; width: var(--side);
  display: flex; flex-direction: column; background: var(--surface);
  border-right: 1px solid var(--line); box-shadow: 4px 0 24px rgba(45, 16, 80, .08);
}
.handle { display: none; }
.top { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: inherit; text-decoration: none; }
.brand img { flex: none; }
.brand span { min-width: 0; }
.brand b { display: block; font: 700 19px/1.2 var(--display); color: var(--brand-deep); letter-spacing: -.01em; }
.brand small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang select {
  height: 32px; max-width: 118px; padding: 0 24px 0 10px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236C6279' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 9px center;
  -webkit-appearance: none; appearance: none; font-size: 12.5px; font-weight: 500; cursor: pointer;
}

.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 42px;
  border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer;
  font-weight: 600; color: var(--muted); white-space: nowrap;
}
.tab svg { width: 17px; height: 17px; }
.tab[aria-selected="true"] { color: var(--tc, var(--brand)); border-bottom-color: var(--tc, var(--brand)); }

.search { position: relative; margin: 12px 16px 0; }
.search svg {
  position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%);
  fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.search input {
  width: 100%; height: 40px; padding: 0 34px 0 36px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--ground); outline: none;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }
#qClear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px;
  border: 0; border-radius: 50%; background: none; color: var(--faint); font-size: 20px; cursor: pointer;
}

.filters { padding: 8px 16px 0; display: grid; gap: 8px; }
.row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.row select, .listhead select {
  flex: 1; min-width: 0; height: 32px; padding: 0 24px 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236C6279' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 9px center;
  -webkit-appearance: none; appearance: none; font-size: 13px; cursor: pointer;
}
.row select.on { border-color: var(--brand); color: var(--brand-deep); font-weight: 600; }
.check { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: #8A6400; cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--gold); }
.chips {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin; scrollbar-color: var(--brand-line) transparent;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
}
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 12.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--brand)); }
.chip small { color: var(--faint); font-size: 11px; }
.chip:hover { border-color: var(--brand-line); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip[aria-pressed="true"] small { color: rgba(255, 255, 255, .75); }
.chip[aria-pressed="true"] i { background: #fff; }

.listhead {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  margin-top: 10px; padding: 8px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #FCFBFE;
}
.listhead #count { font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listhead #count b { color: var(--ink); }
.listhead #count button { margin-left: 6px; border: 0; background: none; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0; }
.listhead select { flex: none; width: auto; max-width: 52%; border-radius: 999px; }

/* ── 웹진형 카드 ─────────────────────── */
.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.card {
  display: grid; grid-template-columns: 1fr 112px; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s;
}
.card:hover, .card.on { background: var(--brand-soft); }
.card .cat { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.card .cat i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.card h3 { margin: 2px 0 0; font-size: 15.5px; line-height: 1.35; font-weight: 700; color: var(--ink); word-break: keep-all; overflow-wrap: anywhere; }
.card .orig { margin: 1px 0 0; font-size: 12px; color: var(--faint); }
.card .addr { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.card .dist { font-weight: 600; color: var(--brand-deep); }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px;
  background: #EEF2FF; color: #3949AB; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge.visit { background: #FFF4D6; color: #7A5600; }
.thumb {
  width: 112px; height: 80px; border-radius: 10px; overflow: hidden; background: var(--brand-soft);
  border: 1px solid var(--line); align-self: start; display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.thumb.none img { width: 30px; height: auto; opacity: .3; }
.more { display: block; width: calc(100% - 32px); margin: 14px 16px 18px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 600; cursor: pointer; }
.more:hover { border-color: var(--brand-line); background: var(--brand-soft); }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 13.5px; }

.foot { padding: 8px 16px 10px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--faint); }
.foot p { margin: 0 0 4px; }
.foot p:empty { display: none; }
.staff { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.staff button { border: 0; background: none; padding: 2px 0; color: var(--faint); font-size: 11.5px; text-decoration: underline; cursor: pointer; }
#staffName { color: #8A6400; font-weight: 600; }

/* ── 상세 ─────────────────────────────── */
#detail {
  position: fixed; top: 12px; left: calc(var(--side) + 12px); z-index: 6; width: 380px; max-height: calc(100% - 24px);
  overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
#detail[hidden] { display: none; }
.dhead { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; padding: 8px; pointer-events: none; }
.dhead button { pointer-events: auto; }
.back { display: none; height: 34px; padding: 0 12px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .94); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); font-weight: 600; cursor: pointer; }
.x { margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .94); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); font-size: 22px; line-height: 1; cursor: pointer; }
.shot { display: block; margin-top: -50px; aspect-ratio: 650 / 464; background: var(--brand-soft); border-bottom: 1px solid var(--line); overflow: hidden; position: relative; }
.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.shot.none { display: grid; place-items: center; }
.shot.none img { width: 60px; height: auto; opacity: .3; }
.shot.none span { position: absolute; bottom: 12px; font-size: 12px; color: var(--muted); }
.info { padding: 16px 20px 22px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); font-size: 12px; font-weight: 600; }
.tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--brand)); }
.info h2 { margin: 10px 0 2px; font: 700 21px/1.3 var(--display); letter-spacing: -.01em; word-break: keep-all; overflow-wrap: anywhere; }
.info .orig { margin: 0; font-size: 13px; color: var(--muted); }
.info .host { margin: 2px 0 0; font-size: 12.5px; color: var(--faint); word-break: break-all; }
.facts { margin: 14px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.facts li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.facts li > span { flex: none; width: 72px; color: var(--faint); font-size: 12.5px; }
.facts li small { display: block; color: var(--faint); font-size: 12px; }
.facts a { color: var(--ink); }
.langs { display: flex; flex-wrap: wrap; gap: 4px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.btn { display: flex; align-items: center; justify-content: center; height: 44px; border-radius: 12px; font-weight: 600; font-size: 14px; text-decoration: none; text-align: center; padding: 0 8px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); }
.btn.ghost { border: 1px solid var(--line); color: var(--ink); background: #fff; }
.btn.ghost:hover { border-color: var(--brand-line); background: var(--brand-soft); }
.vbox { margin-top: 16px; padding: 14px; border-radius: 12px; background: #FFF9E8; border: 1px solid #F1DFA6; }
.vbox h4 { margin: 0 0 6px; font-size: 13px; color: #7A5600; display: flex; align-items: center; gap: 6px; }
.vbox .stage { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.vbox .sum { margin: 0 0 8px; font-size: 12.5px; color: #5C4A1A; }
.vbox ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.vbox li { font-size: 12.5px; line-height: 1.5; }
.vbox li b { color: #7A5600; font-weight: 600; margin-right: 4px; }
.multi { padding: 4px 18px 18px; }
.multi h2 { margin: 0 0 4px; font: 700 18px/1.3 var(--display); }
.multi p { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.multi ul { margin: 0; padding: 0; list-style: none; }
.multi li button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 11px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.multi li button:hover { background: var(--brand-soft); }
.multi li i { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--brand)); }
.multi li small { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ── 직원 로그인 ─────────────────────── */
#login { border: 0; border-radius: 18px; padding: 0; width: min(380px, calc(100vw - 32px)); box-shadow: var(--shadow); }
#login::backdrop { background: rgba(31, 23, 41, .45); }
#login form { padding: 22px; display: grid; gap: 12px; }
#login h2 { margin: 0; font: 700 19px var(--display); }
#login p { margin: 0; font-size: 13px; color: var(--muted); }
#login label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
#login input { height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; color: var(--ink); }
#login input:focus { outline: 2px solid var(--brand-line); border-color: var(--brand); }
#login .err { color: #C0392B; font-weight: 600; }
.dbtn { display: flex; justify-content: flex-end; gap: 8px; }
.dbtn button { height: 40px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
.dbtn .ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }

/* ── 첫 로딩 ───────────────────────────── */
.loading { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--ground); color: var(--muted); transition: opacity .4s; }
.loading img { animation: pulse 1.4s ease-in-out infinite; }
.loading.done { opacity: 0; pointer-events: none; }
@keyframes pulse { 50% { transform: scale(.88); opacity: .6; } }

.maplibregl-ctrl-group { border-radius: 12px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.maplibregl-ctrl-attrib { font: 11px var(--body); }
.maplibregl-ctrl-attrib a { color: var(--muted); }

/* ── 모바일: 목록은 아래 시트 ───────── */
@media (max-width: 860px) {
  #side {
    top: auto; right: 0; width: auto; border-right: 0; border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(45, 16, 80, .16); transition: height .25s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  #side.sheet-min { height: 132px; }
  #side.sheet-mid { height: 52%; }
  #side.sheet-full { height: calc(100% - 40px); }
  .handle { display: block; height: 18px; border: 0; background: none; cursor: pointer; flex: none; }
  .handle i { display: block; width: 40px; height: 4px; margin: 6px auto 0; border-radius: 4px; background: #D5CCE0; }
  .top { padding: 2px 14px 6px; }
  .brand b { font-size: 17px; }
  .brand small { display: none; }
  .tabs { padding: 0 10px; }
  .tab { height: 38px; font-size: 13.5px; }
  .search { margin: 8px 14px 0; }
  .search input { height: 38px; font-size: 16px; }
  .filters { padding: 6px 14px 0; }
  .listhead { margin-top: 8px; padding: 6px 14px; }
  .card { grid-template-columns: 1fr 92px; padding: 12px 14px; }
  .thumb { width: 92px; height: 66px; }
  #side.sheet-min .search, #side.sheet-min .filters, #side.sheet-min .listhead, #side.sheet-min .list, #side.sheet-min .foot { display: none; }
  #detail { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 72%; border-radius: 18px 18px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .back { display: inline-block; }
  .actions { grid-template-columns: 1fr 1fr; }
  .maplibregl-ctrl-top-right { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .loading img { animation: none; }
  #side { transition: none; }
}
