:root {
  --ink: #1f1b17;
  --paper: #efe5cf;
  --burgundy: #6e1f27;
  --gold: #c99b4f;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { overflow: hidden; color: #f6eddb; background: #12100e; font-family: Georgia, "Times New Roman", "Noto Serif KR", serif; }
button, input { font: inherit; }
button { color: inherit; }

.app-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: radial-gradient(circle at 18% -10%, rgba(177,128,55,.18), transparent 32%), linear-gradient(145deg, #17130f, #0d0c0b 68%);
}

.topbar {
  min-height: 102px;
  display: grid;
  grid-template-columns: minmax(220px,.8fr) minmax(330px,1.25fr) minmax(330px,1fr);
  align-items: center;
  gap: 22px;
  padding: 16px 26px;
  border-bottom: 1px solid rgba(201,155,79,.35);
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
  width: 54px;
  height: 60px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 34px;
  line-height: 1;
  background: linear-gradient(145deg, rgba(110,31,39,.5), rgba(0,0,0,.15));
  clip-path: polygon(50% 0,94% 18%,84% 82%,50% 100%,16% 82%,6% 18%);
}
.brand h1 { margin: 1px 0 0; color: #f8f0df; font-size: clamp(19px,1.7vw,27px); font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }
.eyebrow { margin: 0; color: var(--gold); font: 700 10px/1.2 Arial,sans-serif; letter-spacing: .24em; }

.selection-card {
  min-height: 66px;
  padding: 12px 48px 12px 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  position: relative;
  border: 1px solid rgba(201,155,79,.3);
  background: linear-gradient(100deg, rgba(239,229,207,.08), rgba(239,229,207,.035));
  box-shadow: inset 3px 0 0 rgba(201,155,79,.35);
}
.selection-card.has-selection { border-color: rgba(201,155,79,.65); box-shadow: inset 3px 0 0 var(--gold), 0 0 28px rgba(110,31,39,.2); }
.selection-card > div { min-width: 0; flex: 1; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #706a60; box-shadow: 0 0 0 5px rgba(112,106,96,.13); flex: 0 0 auto; }
.has-selection .status-dot { background: var(--gold); box-shadow: 0 0 0 5px rgba(201,155,79,.14), 0 0 12px rgba(201,155,79,.75); }
.selection-card p { margin: 0 0 4px; color: #aa9f8b; font: 700 10px/1 Arial,sans-serif; text-transform: uppercase; letter-spacing: .16em; }
.selection-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(13px,1.3vw,17px); font-weight: 500; }
.clear-button { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(255,255,255,.07); cursor: pointer; font: 22px/1 Arial,sans-serif; }
.clear-button:hover { background: rgba(255,255,255,.14); }

.session-tools { display: grid; grid-template-columns: minmax(130px,1fr) auto; align-items: end; gap: 7px 8px; }
.name-field span { display: block; margin-bottom: 6px; color: #bfb39e; font: 700 10px/1 Arial,sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.name-field input { width: 100%; min-width: 0; height: 38px; padding: 0 11px; color: #f8f0df; background: rgba(255,255,255,.06); border: 1px solid rgba(201,155,79,.35); outline: none; font-family: Arial,sans-serif; }
.name-field input:focus { border-color: var(--gold); background: rgba(255,255,255,.09); }
.share-button { height: 38px; padding: 0 13px; border: 1px solid var(--gold); background: var(--burgundy); cursor: pointer; font: 700 12px/1 Arial,sans-serif; white-space: nowrap; }
.share-button:hover { background: #852b34; }
.connection-badge { grid-column: 1 / -1; justify-self: end; color: #a99f8d; font: 700 10px/1 Arial,sans-serif; letter-spacing: .08em; }
.connection-badge::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #8b806d; }
.connection-badge[data-state="online"] { color: #d9c79f; }
.connection-badge[data-state="online"]::before { background: #66c78c; box-shadow: 0 0 8px rgba(102,199,140,.8); }
.connection-badge[data-state="offline"]::before { background: #c46868; }

.map-stage { min-height: 0; display: grid; grid-template-rows: 1fr auto; padding: 18px 22px 0; }
.map-viewport {
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(201,155,79,.4);
  background-color: #29241d;
  background-image: linear-gradient(rgba(255,255,255,.02) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.02) 1px,transparent 1px);
  background-size: 28px 28px;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  box-shadow: inset 0 0 80px rgba(0,0,0,.42),0 0 40px rgba(0,0,0,.3);
}
.map-viewport.is-panning { cursor: grabbing; }
.map-layer { position: absolute; left: 0; top: 0; width: 3000px; height: 4231px; transform-origin: 0 0; }
.map-layer > img { display: block; width: 100%; height: 100%; pointer-events: none; box-shadow: 0 0 0 2px rgba(10,8,6,.9),0 16px 60px rgba(0,0,0,.75); }
.markers { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.building-outlines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
[hidden] { display: none !important; }
.map-pin { transform: none; }
.edit-address { margin-right: 24px; flex-shrink: 0; border: 1px solid #c99b4f; padding: 7px; background: #372a20; color: #f6eddb; cursor: pointer; font: 12px Arial,sans-serif; }
.cursor-readout { position: absolute; bottom: 76px; left: 12px; padding: 6px 9px; color: #fff7df; background: #17130fe6; font: 12px ui-monospace,monospace; pointer-events: none; }
.map-tip { pointer-events: none; }
.help-card,.people-panel { cursor: default; }
.map-pin { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 3; color: var(--pin-color); }
.map-pin .pin-ring { position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; border: 2px solid currentColor; border-radius: 50%; background: color-mix(in srgb, currentColor 15%, transparent); box-shadow: 0 0 0 2px #17130f; }
.map-pin.is-me .pin-ring { width: 24px; height: 24px; left: -12px; top: -12px; border-width: 2px; }
.map-pin::after { content: ""; position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: #fff7df; }
.pin-label { position: absolute; left: 21px; top: -17px; display: grid; gap: 2px; min-width: max-content; padding: 6px 9px 7px; color: #fff7e6; border: 1px solid currentColor; background: rgba(30,24,20,.92); box-shadow: 0 5px 15px rgba(0,0,0,.45); font-family: Arial,sans-serif; }
.pin-label b { font-size: 12px; line-height: 1; }
.pin-label span { color: #e8ddc9; font-size: 12px; line-height: 1.3; }
.label-left .pin-label { left: auto; right: 21px; }
@keyframes pinPulse { 0%,55% { box-shadow: 0 0 0 5px color-mix(in srgb,currentColor 28%,transparent),0 0 18px currentColor; } 100% { box-shadow: 0 0 0 18px transparent,0 0 18px color-mix(in srgb,currentColor 50%,transparent); } }

.help-card { position: absolute; left: 22px; top: 22px; max-width: 390px; display: grid; grid-template-columns: 42px 1fr; gap: 13px; padding: 16px 42px 16px 16px; color: #2a231b; background: rgba(239,229,207,.96); border: 1px solid #b79155; box-shadow: 0 12px 30px rgba(0,0,0,.35); z-index: 8; }
.help-card > button { position: absolute; right: 7px; top: 7px; width: 26px; height: 26px; border: 0; color: #675945; background: transparent; cursor: pointer; font: 21px/1 Arial,sans-serif; }
.mouse-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #8e7041; border-radius: 18px; color: var(--burgundy); font: 25px/1 Arial,sans-serif; }
.help-card strong { display: block; margin: 1px 0 6px; font-size: 15px; }
.help-card p { margin: 0; color: #655844; font: 13px/1.55 Arial,sans-serif; }

.people-panel { position: absolute; right: 20px; top: 20px; width: min(220px,32vw); max-height: calc(100% - 90px); overflow: auto; z-index: 7; border: 1px solid rgba(201,155,79,.45); background: rgba(22,18,15,.91); box-shadow: 0 10px 24px rgba(0,0,0,.35); backdrop-filter: blur(8px); }
.people-heading { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: rgba(31,26,22,.96); border-bottom: 1px solid rgba(201,155,79,.22); color: #cdbf9f; font: 700 11px/1 Arial,sans-serif; text-transform: uppercase; letter-spacing: .12em; }
.people-heading b { min-width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: #241d16; background: var(--gold); font-size: 11px; }
.people-panel ul { list-style: none; margin: 0; padding: 6px 0; }
.people-panel li { display: grid; grid-template-columns: 10px 1fr; gap: 8px; align-items: center; padding: 8px 12px; color: #f0e7d5; font: 12px/1.25 Arial,sans-serif; }
.people-panel li i { width: 9px; height: 9px; border-radius: 50%; background: var(--person-color); box-shadow: 0 0 8px var(--person-color); }
.people-panel li small { display: block; margin-top: 2px; color: #9d927f; font-size: 10px; }

.zoom-controls { position: absolute; right: 20px; bottom: 20px; display: grid; grid-template-columns: 43px 54px 43px 43px; height: 43px; z-index: 9; border: 1px solid rgba(201,155,79,.62); background: rgba(25,21,18,.93); box-shadow: 0 8px 24px rgba(0,0,0,.38); }
.zoom-controls button { border: 0; border-right: 1px solid rgba(201,155,79,.32); background: transparent; cursor: pointer; font: 24px/1 Arial,sans-serif; }
.zoom-controls button:hover { background: rgba(201,155,79,.15); }
.zoom-controls span { display: grid; place-items: center; border-right: 1px solid rgba(201,155,79,.32); color: #d6c8ae; font: 700 11px/1 Arial,sans-serif; }
.zoom-controls .fit-button { border-right: 0; color: var(--gold); font-size: 21px; }
.map-tip { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); padding: 9px 14px; color: #d9cdb8; background: rgba(24,20,17,.84); border: 1px solid rgba(201,155,79,.24); font: 11px/1 Arial,sans-serif; letter-spacing: .04em; white-space: nowrap; }
.legend-bar { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 8px 4px; color: #8f8473; font: 10px/1.4 Arial,sans-serif; letter-spacing: .02em; overflow: hidden; white-space: nowrap; }
.legend-title { color: var(--gold); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; }
.legend-bar code { color: #e8d7b6; font-family: ui-monospace,monospace; }
.legend-spacer { width: 1px; height: 13px; background: rgba(201,155,79,.35); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translate(-50%,18px); padding: 10px 15px; color: #281f17; background: #f0dfbd; border: 1px solid var(--gold); box-shadow: 0 10px 30px rgba(0,0,0,.4); font: 700 12px/1 Arial,sans-serif; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; gap: 10px 14px; padding: 12px 14px; }
  .selection-card { grid-column: 1 / -1; grid-row: 2; min-height: 54px; padding-top: 9px; padding-bottom: 9px; }
  .session-tools { grid-column: 2; grid-row: 1; grid-template-columns: 130px auto; }
  .name-field span, .connection-badge { display: none; }
}

@media (max-width: 700px) {
  .brand-mark { width: 42px; height: 48px; font-size: 28px; }
  .brand h1 { font-size: 17px; }
  .eyebrow { font-size: 8px; }
  .session-tools { grid-template-columns: 92px auto; }
  .share-button { padding: 0 9px; font-size: 11px; }
  .map-stage { padding: 10px 10px 0; }
  .map-tip, .legend-bar { display: none; }
  .help-card { left: 12px; top: 12px; right: 12px; max-width: none; }
  .people-panel { top: auto; left: 12px; right: auto; bottom: 12px; width: min(205px,52vw); max-height: 150px; }
  .zoom-controls { right: 12px; bottom: 12px; }
}

@media (max-width: 460px) {
  .topbar { gap: 8px; }
  .brand-mark { display: none; }
  .session-tools { grid-template-columns: 78px auto; }
  .name-field input { padding: 0 7px; }
  .selection-card strong { font-size: 13px; }
  .help-card { grid-template-columns: 34px 1fr; padding-left: 12px; }
  .mouse-icon { width: 34px; height: 38px; }
  .people-panel { width: 48vw; }
}

@media (prefers-reduced-motion: reduce) {
  .map-pin .pin-ring { animation: none; }
  .toast { transition: none; }
}
