:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181c20;
  --panel-2: #20262b;
  --text: #eef2f4;
  --muted: #99a3ad;
  --line: #303840;
  --accent: #6ec6ff;
  --gold: #ffd166;
  --green: #7bd88f;
  --rose: #ef6f8f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

button, select { font: inherit; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 72px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: #121619;
}

h1, h2, p { margin: 0; }
h1 { font-size: 25px; letter-spacing: 0; }
h2 { margin-bottom: 10px; font-size: 13px; color: #cbd3da; }

.topbar p, .hint, .status, .zoom-readout {
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(620px, 1fr) 420px;
}

.panel {
  min-height: 0;
  overflow: auto;
  background: var(--panel);
}

.controls { border-right: 1px solid var(--line); }
.detail { border-left: 1px solid var(--line); }
.panel section { padding: 16px; border-bottom: 1px solid var(--line); }

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
}

button {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

button:hover { border-color: var(--accent); }
button.active { border-color: var(--accent); color: #081016; background: var(--accent); }
button.favorite-active { border-color: var(--gold); color: #151006; background: var(--gold); }
button.wide-action { width: 100%; margin-top: 10px; }
button.like-button {
  width: 44px;
  height: 36px;
  padding: 0;
  font-size: 18px;
}

.preset-grid, .stats { display: grid; gap: 8px; }
.drop-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.map-wrap {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #0f1113;
}

.map-toolbar {
  min-height: 52px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.map-title { font-size: 15px; font-weight: 700; }

.map {
  position: relative;
  min-height: 0;
  margin: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #101315;
  contain: layout paint;
}

.cluster-popup {
  position: absolute;
  z-index: 5;
  width: min(760px, calc(100% - 24px));
  max-height: min(560px, calc(100% - 24px));
  overflow: hidden;
  border: 1px solid rgba(110, 198, 255, 0.58);
  border-radius: 8px;
  background: rgba(15, 20, 24, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
}

.cluster-popup[hidden] { display: none; }

.cluster-popup-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
}

.cluster-popup-title strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}

.cluster-popup-title span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.cluster-popup-title button {
  width: 26px;
  height: 26px;
  padding: 0;
}

.cluster-popup-grid {
  max-height: 488px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  padding: 12px;
}

.popup-thumb {
  height: auto;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 7px;
  border-color: rgba(220, 229, 235, 0.44);
  background: #273039;
}

.popup-thumb img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
}

.popup-thumb span {
  display: block;
  padding: 3px 2px 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.popup-thumb.selected { border: 3px solid var(--accent); }
.popup-thumb.favorite { box-shadow: inset 0 0 0 3px var(--gold); }

#mapCanvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#mapCanvas.dragging { cursor: grabbing; }

.stat {
  display: grid;
  gap: 4px;
}

.stat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #dce5eb;
  font-size: 12px;
}

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #2b333a;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.rating-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.notice-panel {
  display: grid;
  gap: 12px;
}

.notice-card,
.promo-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a1e;
}

.notice-card strong,
.promo-card strong {
  color: var(--text);
  font-size: 13px;
}

.notice-card p,
.promo-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.promo-card {
  margin-top: 6px;
  border-style: dashed;
  background: #12171a;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 100;
  background: rgba(8, 12, 15, 0.78);
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  pointer-events: none;
}

.drop-overlay.visible {
  display: grid;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  background: rgba(4, 7, 9, 0.72);
  backdrop-filter: blur(3px);
}

.loading-overlay[hidden] { display: none; }

.loading-card {
  width: min(420px, calc(100vw - 48px));
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(216, 226, 232, 0.26);
  border-radius: 8px;
  background: #15191c;
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.56);
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(216, 226, 232, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.loading-card strong {
  color: var(--text);
  font-size: 15px;
}

.loading-card p {
  color: var(--muted);
  font-size: 13px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 28px;
}

.photo-viewer[hidden] { display: none; }

.photo-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 8, 0.74);
  backdrop-filter: blur(3px);
}

.photo-viewer-dialog {
  position: relative;
  width: min(1180px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(216, 226, 232, 0.28);
  border-radius: 8px;
  background: #101315;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.62);
}

.photo-viewer-head,
.photo-viewer-foot {
  padding: 12px 14px;
  background: #15191c;
  border-color: var(--line);
}

.photo-viewer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.photo-viewer-head strong,
.photo-viewer-head span {
  display: block;
}

.photo-viewer-head strong {
  font-size: 13px;
  color: var(--text);
}

.photo-viewer-head span,
.viewer-summary {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.photo-viewer-head button {
  width: 30px;
  height: 30px;
  padding: 0;
}

.photo-viewer-body {
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #090c0e;
}

.photo-viewer-body img {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  display: block;
  object-fit: contain;
}

.photo-viewer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
}

.viewer-rating-row {
  margin: 0;
}

.viewer-like-button {
  width: 56px;
  height: 42px;
  font-size: 24px;
}

.guide-modal {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: grid;
  place-items: center;
  padding: 28px;
}

.guide-modal[hidden] { display: none; }

.guide-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 8, 0.72);
  backdrop-filter: blur(3px);
}

.guide-modal-dialog {
  position: relative;
  width: min(1120px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  overflow: auto;
  border: 1px solid rgba(216, 226, 232, 0.28);
  border-radius: 8px;
  background: #101315;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.62);
}

.guide-modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #15191c;
}

.guide-modal-head strong,
.guide-modal-head span {
  display: block;
}

.guide-modal-head strong {
  color: var(--text);
  font-size: 15px;
}

.guide-modal-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.guide-modal-head button {
  width: 30px;
  height: 30px;
  padding: 0;
}

.guide-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.guide-step {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a1e;
}

.guide-step strong {
  color: var(--text);
  font-size: 14px;
}

.guide-step p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.guide-visual {
  position: relative;
  height: 150px;
  overflow: hidden;
  border: 1px solid rgba(216, 226, 232, 0.18);
  border-radius: 8px;
  background: #0b0f11;
}

.visual-map {
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 48px 48px;
}

.heat {
  position: absolute;
  width: 150px;
  height: 110px;
  border-radius: 50%;
  filter: blur(22px);
}

.heat-a { left: 34px; top: 22px; background: rgba(34, 197, 94, 0.38); }
.heat-b { right: 34px; bottom: 20px; background: rgba(14, 165, 233, 0.42); }

.thumb,
.stack,
.large-photo {
  position: absolute;
  border: 2px solid var(--gold);
  border-radius: 7px;
  background: linear-gradient(135deg, #7db7d8, #273039 48%, #d9a45f);
  box-shadow: 0 8px 20px rgba(0,0,0,0.42);
}

.thumb { width: 42px; height: 42px; }
.t1 { left: 62px; top: 54px; }
.t2 { left: 152px; top: 34px; }
.t3 { right: 74px; bottom: 36px; }

.visual-cluster .stack {
  width: 86px;
  height: 72px;
  left: calc(50% - 43px);
  top: 36px;
}

.s1 { transform: translate(16px, -12px); opacity: 0.55; }
.s2 { transform: translate(8px, -6px); opacity: 0.75; }
.s3 { transform: translate(0, 0); }

.badge {
  position: absolute;
  left: calc(50% + 30px);
  top: 26px;
  min-width: 28px;
  height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #151006;
  background: var(--gold);
  font-weight: 700;
  font-size: 12px;
  text-align: center;
}

.large-photo {
  inset: 18px 64px 38px 26px;
  border-color: rgba(216, 226, 232, 0.32);
}

.like-demo {
  position: absolute;
  right: 30px;
  bottom: 24px;
  display: grid;
  place-items: center;
  width: 52px;
  height: 42px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: var(--gold);
  font-size: 22px;
}

.visual-heat {
  display: flex;
  align-items: stretch;
  padding: 34px;
  gap: 6px;
}

.visual-heat span {
  flex: 1;
  border-radius: 6px;
}

.visual-heat span:nth-child(1) { background: #2563eb; opacity: 0.52; }
.visual-heat span:nth-child(2) { background: #06b6d4; opacity: 0.64; }
.visual-heat span:nth-child(3) { background: #22c55e; opacity: 0.78; }
.visual-heat span:nth-child(4) { background: #facc15; opacity: 0.9; }
.visual-heat span:nth-child(5) { background: #ef4444; }
