:root {
  --bg: #ffffff; --ink: #1f2328; --mute: #7a828a; --line: #e4e7ea;
  --accent: #ff5d8f; --accent-d: #e0407a; --sea: #f3f5f7; --card: #ffffff; --warn: #b4540a;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { touch-action: manipulation; -webkit-text-size-adjust: 100%; font-family: system-ui, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 6px 10px; }
button:hover { border-color: #c5cbd1; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; padding: 11px 14px; width: 100%; font-size: 15px; }
button.primary:hover { background: var(--accent-d); }
button.primary:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--mute); }
button.wide { width: 100%; margin-top: 8px; }

header { height: 58px; flex: none; display: flex; align-items: center; gap: 20px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; white-space: nowrap; }
.brand .logo { font-size: 22px; }
.brand .tag { font-size: 11px; color: var(--accent-d); border: 1px solid var(--accent); border-radius: 99px; padding: 1px 8px; }
.stats { display: flex; gap: 26px; margin-left: auto; }
.stats div { display: flex; flex-direction: column; line-height: 1.15; }
.stats span { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.stats small { color: var(--mute); font-size: 11px; }
.stats .dim span { color: var(--mute); }
/* 지구 채우기 진행 막대. 막대는 "다음 목표"까지의 진행이고, 전체 대비 %는 숫자로 같이 보여 준다 (전체 기준 막대는 오랫동안 비어 보인다) */
header { position: relative; }
.stats.prog { display: block; width: min(420px, 38vw); cursor: pointer; line-height: 1.2; }
.stats.prog div { flex-direction: row; }
.prog-top, .prog-sub { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; white-space: nowrap; }
.prog-top b { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.prog-top span { font-weight: 400; font-size: 13px; }
.prog-top small { color: var(--mute); font-size: 12px; }
.prog-top em { font-style: normal; font-weight: 800; font-size: 14px; color: var(--accent-d); font-variant-numeric: tabular-nums; }
.stats.prog .prog-bar, .progline { display: block; height: 8px; margin: 4px 0 3px; border-radius: 99px; background: #eef0f3; overflow: hidden; }
.prog-bar i, .progline b { display: block; height: 100%; width: 0; border-radius: 99px; transition: width 1.4s cubic-bezier(.2, .8, .2, 1);
  background: linear-gradient(90deg, #ff8fb1, var(--accent) 45%, #ffb347 55%, var(--accent)); background-size: 220% 100%; animation: progshine 2.8s linear infinite; }
@keyframes progshine { from { background-position: 100% 0; } to { background-position: -120% 0; } }
.prog-sub { color: var(--mute); font-size: 11px; }
.prog-sub span { font-weight: 400; font-size: 11px; } .prog-sub b { font-weight: 700; }
.progline { display: none; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; margin: 0; border-radius: 0; background: transparent; }
@media (prefers-reduced-motion: reduce) { .prog-bar i, .progline b { animation: none; transition: none; } }

main { flex: 1; display: flex; min-height: 0; }
#mapWrap { position: relative; flex: 1; min-width: 0; background: radial-gradient(circle at 50% 45%, #fafbfc, #eceff2); overflow: hidden; }
/* 지구본 본체는 #glmap(그래픽 가속)에, 선·선택 영역 같은 덧그림은 그 위의 #map 에 그린다 */
#glmap { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#glmap[hidden] { display: none; }
#map { position: relative; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#map.sel { cursor: crosshair; }
#map.drag { cursor: grabbing; }
.tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; align-items: center; background: rgba(255,255,255,.92); padding: 6px; border-radius: 12px; box-shadow: 0 2px 10px rgba(31,35,40,.12); }
.tools button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tools .sep { width: 1px; height: 22px; background: var(--line); }
.search { position: absolute; top: 64px; left: 12px; }
.search input { font: inherit; width: 230px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.95); box-shadow: 0 2px 10px rgba(31,35,40,.12); }
.hint { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(31,35,40,.78); color: #fff; font-size: 12px; padding: 6px 12px; border-radius: 99px; white-space: nowrap; pointer-events: none; }
#tip { position: absolute; pointer-events: none; background: rgba(31,35,40,.92); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 8px; line-height: 1.45; white-space: nowrap; z-index: 3; }
#tip b { color: #ffd0de; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--sea); font-size: 18px; font-weight: 700; color: #57606a; }

aside { width: var(--side-w, 340px); flex: none; border-left: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; position: relative; }
/* 옆 패널 왼쪽 경계: 끌어서 너비 조절 (PC). 두 번 누르면 원래 너비 */
#sideResize { position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 4; touch-action: none; }
#sideResize::after { content: ""; position: absolute; left: 4px; top: 50%; width: 3px; height: 44px; margin-top: -22px; border-radius: 3px; background: #cfd5da; }
#sideResize:hover::after, body.resizing #sideResize::after { background: var(--accent); height: 72px; margin-top: -36px; }
body.resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }
/* 사진 크게 보기 */
#plotCard img { cursor: zoom-in; }
#photoView { z-index: 20; background: rgba(15,17,20,.88); cursor: zoom-out; }
#photoView img { width: min(94vw, 1100px); height: min(90vh, 1100px); object-fit: contain; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1; border: 0; border-radius: 0; padding: 12px 0; background: transparent; color: var(--mute); font-weight: 700; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab { padding: 16px; overflow-y: auto; flex: 1; }
.tab h3 { margin: 0 0 10px; font-size: 15px; }
.tab h3 small { display: block; font-weight: 400; color: var(--mute); font-size: 12px; margin-top: 2px; }
.empty { text-align: center; color: #57606a; font-size: 14px; line-height: 1.6; padding-top: 20px; }
.empty .big { font-size: 40px; margin: 0; }
#quote table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 12px; }
#quote td { padding: 7px 0; border-bottom: 1px solid var(--line); }
#quote td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
#quote td:first-child { color: var(--mute); }
#quote tr.total td { border-bottom: 0; font-size: 18px; font-weight: 800; color: var(--ink); padding-top: 12px; }
.warn { font-size: 13px; color: var(--warn); background: #fff4e5; border-radius: 8px; padding: 8px 10px; line-height: 1.5; }
#plotCard { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 16px; }
#plotCard img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #f1f3f5; }
#plotCard .body { padding: 12px; font-size: 13px; line-height: 1.6; }
#plotCard .body b.name { font-size: 17px; }
#plotCard .body .meta { color: var(--mute); }

.rank { list-style: none; padding: 0; margin: 0 0 22px; counter-reset: r; }
.rank li { counter-increment: r; position: relative; padding: 7px 8px 7px 30px; font-size: 13px; cursor: pointer; border-radius: 8px; overflow: hidden; display: flex; justify-content: space-between; gap: 8px; }
.rank li::before { content: counter(r); position: absolute; left: 8px; color: var(--mute); font-weight: 700; }
.rank li:hover { background: #f3f5f7; }
.rank li i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); opacity: .7; border-radius: 2px; }
.rank li span:last-child { color: var(--mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
#feed { list-style: none; padding: 0; margin: 0; }
#feed li { font-size: 13px; line-height: 1.5; padding: 9px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
#feed li:hover { background: #f3f5f7; }
#feed li small { color: var(--mute); display: block; }
#feed li.take b.v { color: var(--warn); }

.overlay { position: fixed; inset: 0; background: rgba(31,35,40,.45); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.overlay[hidden], #toast[hidden], #loading[hidden], #tip[hidden] { display: none; }
.sheet { background: var(--card); border-radius: 16px; width: 640px; max-width: 100%; max-height: 100%; overflow: auto; padding: 22px; position: relative; }
.sheet h2 { margin: 0 0 16px; font-size: 19px; }
.sheet .x { position: absolute; right: 14px; top: 12px; border: 0; font-size: 22px; background: transparent; color: var(--mute); }
.cols { display: flex; gap: 18px; flex-wrap: wrap; }
.preview { width: 240px; height: 240px; background: repeating-conic-gradient(#eef0f2 0 25%, #fff 0 50%) 0 0/20px 20px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.form { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.form label { font-size: 13px; font-weight: 700; display: flex; flex-direction: column; gap: 4px; }
.form label small { font-weight: 400; color: var(--mute); }
.form input:not([type=checkbox]):not([type=file]), .form select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.form label.check { flex-direction: row; align-items: flex-start; font-weight: 400; gap: 8px; }
.samples { display: flex; flex-wrap: wrap; gap: 6px; }
.samples img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.samples img.on { border-color: var(--accent); }
.note { font-size: 12px; color: var(--mute); margin: 8px 0 0; }
#mReview { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.step { font-size: 14px; padding: 4px 0; color: var(--mute); }
.step::before { content: '○ '; }
.step.run { color: var(--ink); } .step.run::before { content: '⏳ '; }
.step.ok { color: #1f8a4c; } .step.ok::before { content: '✔ '; }
.foot { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.foot .sum { white-space: nowrap; font-size: 14px; } .foot .sum b { font-size: 20px; margin-left: 6px; }
#toast { position: fixed; bottom: 54px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 20; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }

.grab { display: none; }
.h-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .h-desk { display: none; } .h-touch { display: inline; } }

/* 모바일: 지구본이 화면을 다 쓰고, 패널은 아래에서 올라오는 시트 */
@media (max-width: 820px) {
  header { height: 50px; padding: 0 10px 0 12px; gap: 8px; }
  .brand { font-size: 16px; } .brand .tag { display: none; }
  .stats, .stats.prog { display: none; }
  .progline { display: block; }      /* 폰에서는 헤더 아래 얇은 막대만. 숫자는 랭킹 탭에 있다 */
  button.wallet { margin-left: auto; }
  main { display: block; position: relative; }
  #mapWrap { position: absolute; inset: 0; }
  aside { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: min(64%, 520px); border-left: 0; border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 24px rgba(31,35,40,.16); transform: translateY(calc(100% - 62px)); transition: transform .22s ease; z-index: 5;
    padding-bottom: env(safe-area-inset-bottom, 0px); }
  body.sheet-open aside { transform: none; }
  .grab { display: block; flex: none; width: 100%; height: 18px; border: 0; background: transparent; padding: 0; border-radius: 18px 18px 0 0; }
  .grab i { display: block; width: 40px; height: 4px; border-radius: 4px; background: #cfd5da; margin: 8px auto 0; }
  .tabs button { padding: 11px 0 12px; font-size: 14px; }
  .tab { padding: 14px 16px 20px; -webkit-overflow-scrolling: touch; }
  .tools { top: 10px; left: 10px; right: auto; gap: 6px; padding: 5px; }
  .tools button { min-height: 42px; min-width: 42px; font-size: 15px; }
  .tools .desk, .tools #btnGeo span { display: none; }
  .search { display: none; }
  .hint { bottom: 72px; font-size: 11px; max-width: calc(100% - 20px); white-space: normal; text-align: center; border-radius: 12px; }
  body.sheet-open .hint { display: none; }
  #plotCard img { aspect-ratio: 16/9; }
  .overlay { padding: 0; align-items: flex-end; }
  .sheet, .sheet.narrow { width: 100%; max-height: 94%; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); }
  .cols { gap: 12px; }
  .pcol { width: 100%; display: flex; gap: 12px; align-items: center; }
  .preview { width: 130px; height: 130px; flex: none; } .preview canvas { max-width: 100%; max-height: 100%; }
  .form input:not([type=checkbox]):not([type=file]), .form select { font-size: 16px; padding: 10px; }   /* 16px 미만이면 iOS가 화면을 확대함 */
  .samples img { width: 44px; height: 44px; }
  .foot { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom, 0px)); background: var(--card); margin: 10px -16px 0; padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); gap: 12px; }
  .foot .sum b { font-size: 17px; }
  .packs button { padding: 14px; }
  #toast { bottom: 84px; width: max-content; max-width: calc(100% - 24px); text-align: center; }
}

/* 크레딧 */
.overlay.top { z-index: 15; }
.sheet.narrow { width: 420px; }
button.wallet { margin-left: 4px; white-space: nowrap; border-radius: 99px; padding: 6px 6px 6px 12px; }
button.wallet span { background: var(--ink); color: #fff; border-radius: 99px; padding: 3px 10px; font-size: 12px; margin-left: 6px; }
.balance { display: flex; flex-direction: column; align-items: center; padding: 6px 0 14px; }
.balance small { color: var(--mute); } .balance b { font-size: 30px; } .balance span { color: var(--mute); font-size: 13px; }
.rules { font-size: 12px; color: var(--mute); padding-left: 18px; line-height: 1.7; margin: 12px 0 18px; }
.list { list-style: none; padding: 0; margin: 0 0 20px; font-size: 13px; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.list li[data-p] { cursor: pointer; } .list li[data-p]:hover { background: #f3f5f7; }
.list li small { display: block; color: var(--mute); }
.list li span:last-child { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.list li.refund span:last-child, .list li.top span:last-child { color: #1f8a4c; }
.list li.none { color: var(--mute); justify-content: center; }
.packs { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.packs button { display: flex; align-items: center; gap: 10px; padding: 12px 14px; text-align: left; }
.packs button b { font-size: 16px; min-width: 76px; } .packs button span { color: var(--mute); font-size: 13px; flex: 1; }
.packs button em { font-style: normal; font-weight: 700; }
.packs button.short { opacity: .45; }
.packs button:hover { border-color: var(--accent); }
.foot .sum small { display: block; color: var(--mute); font-size: 12px; }
#plotCard .mine { font-size: 11px; background: var(--ink); color: #fff; border-radius: 99px; padding: 2px 8px; vertical-align: 2px; }

/* 무료 픽셀권 · 보호기간 */
button.freechip { margin-left: auto; white-space: nowrap; border-radius: 99px; padding: 6px 12px; display: flex; align-items: center; gap: 5px; }
button.freechip small { color: var(--mute); font-variant-numeric: tabular-nums; font-size: 12px; }
.stats + button.freechip { margin-left: 0; }
.freebox { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 12px; }
.freebox small { display: block; color: var(--mute); font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.freebox button { font-size: 12px; white-space: nowrap; }
@media (max-width: 820px) {
  button.freechip { margin-left: auto; padding: 6px 10px; }
  button.wallet { margin-left: 0; }
}
@media (max-width: 420px) { .brand b { display: none; } }

/* 서버 연결 버전에서 추가된 것 */
[hidden] { display: none !important; }
button.loginbtn { margin-left: auto; border-radius: 99px; padding: 7px 16px; background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; white-space: nowrap; }
.stats + button.loginbtn { margin-left: 0; }
#stagingBar { flex: none; background: #eef4ff; color: #2f5fb3; border-bottom: 1px solid #cfdcf5; font-size: 12px; padding: 6px 12px; text-align: center; }
#closedBar { flex: none; background: #fff7ea; color: var(--warn); border-bottom: 1px solid #f0d3a8; font-size: 13px; padding: 8px 16px; text-align: center; }
.who { margin: 0 0 4px; text-align: center; color: var(--mute); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err { color: #c6362c; font-size: 13px; margin: 0; min-height: 18px; }
#walletOut button.primary { margin-top: 10px; }
.list li.sub { align-items: center; }
.list li.sub img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; flex: none; background: #f1f3f5; }
.list li.sub > span:nth-child(2) { flex: 1; min-width: 0; font-weight: 400; white-space: normal; }
.list li.sub.pending small { color: var(--warn); } .list li.sub.rejected small { color: #c6362c; }
.list li.sub button { font-size: 12px; padding: 4px 10px; }
#feed li.none { color: var(--mute); cursor: default; text-align: center; padding: 30px 6px; }
#auth .sheet { display: flex; flex: none; }
@media (max-width: 820px) {
  button.loginbtn { margin-left: auto; }
  #closedBar { font-size: 12px; padding: 6px 10px; }
}

@media (max-width: 820px) { #sideResize { display: none; } }
