/* SUIT (latest) — Korean + Latin variable typeface; same jsDelivr CDN the app already uses */
@font-face {
  font-family: "SUIT Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/gh/sun-typeface/SUIT/fonts/variable/woff2/SUIT-Variable.woff2") format("woff2");
}

:root {
  --bg: #0e1419;
  --panel: #161d24;
  --panel-2: #1c252e;
  --line: #283440;
  --ink: #eef2f4;
  --muted: #a7b3bc;
  --faint: #889aa6;
  --amber: #d98a3d;
  --amber-soft: #e8a960;
  --good: #6fd0c5;
  --mono: "Geist Mono", ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, monospace;
  --sans: "SUIT Variable", system-ui, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* app chrome shouldn't be text-selectable — a long-press mid-drag on mobile popped the iOS
     selection menu (Copy / Look Up). Inputs are re-enabled below. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input,
textarea,
[contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.hidden {
  display: none !important;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #11181f, #0e1419);
  flex: none;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand .mark {
  color: var(--amber);
  font-size: 14px;
  transform: translateY(-1px);
}
.brand .word {
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 15px;
}
.brand .tag {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.02em;
  font-family: var(--mono);
}
.modes {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------- region search ---------- */
.region-box {
  position: relative;
  flex: 1 1 360px;
  max-width: 460px;
}
.io-actions {
  display: flex;
  gap: 8px;
  flex: none;
  align-items: center;
}
/* 한/EN language toggle */
.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--panel-2);
}
.lang-btn {
  padding: 9px 11px;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.lang-btn + .lang-btn {
  border-left: 1px solid var(--line);
}
.lang-btn:hover {
  color: var(--ink);
}
.lang-btn.on {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}
/* color-blind-safe palette checkbox in the slice display section */
.cb-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 8px 0 6px;
  font-size: 12px;
  color: var(--faint);
  cursor: pointer;
}
.cb-toggle input {
  cursor: pointer;
}
.hdr-btn {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.hdr-btn:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
}
.hdr-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#region-search {
  width: 100%;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
}
#region-search:focus {
  border-color: var(--amber);
}
#region-search::placeholder {
  color: var(--faint);
}
.region-results {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.region-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
}
.region-item:last-child {
  border-bottom: 0;
}
.region-item:hover {
  background: var(--panel);
}
.region-name {
  font-size: 13px;
  color: var(--ink);
}
.region-kind {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--faint);
  flex: none;
}
.region-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--faint);
}

/* ---------- per-color weight breakdown ---------- */
.weight-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 2px 0 8px;
  padding: 8px 10px;
  background: var(--panel);
  border-radius: 8px;
}
.wb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.wb-row .sw {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: var(--c);
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex: none;
}
.wb-name {
  color: var(--muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.seg-btn {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.seg-btn.on {
  background: var(--panel-2);
  color: var(--ink);
}
select {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
}
.cta {
  background: var(--amber);
  color: #1a1206;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.cta:hover {
  background: var(--amber-soft);
}
.cta:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* ---------- work area ---------- */
/* full-page 3D stage with a floating map card (frame ↔ minimap) */
.work {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}
#stage {
  position: absolute;
  inset: 0;
}

.map-card {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 30;
  overflow: hidden;
  background: #0a0f13;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  transition: width 0.42s cubic-bezier(0.4, 0, 0.2, 1), height 0.42s cubic-bezier(0.4, 0, 0.2, 1);
}
.map-card.frame {
  width: calc(100% - 32px);
  height: calc(100% - 32px);
}
.map-card.result {
  width: 264px;
  height: 188px;
  cursor: pointer;
  /* until hovered the minimap reads as a quiet, translucent inset with a blurred backdrop */
  opacity: 0.66;
  backdrop-filter: blur(6px);
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.map-card.result:hover {
  border-color: var(--amber);
  opacity: 1;
}
.map-card #map {
  position: absolute;
  inset: 0;
}
.map-card.result #map {
  pointer-events: none;
}
.map-card.result .map-bar,
.map-card.result .admin-note {
  display: none;
}
/* admin shows its real silhouette via the overlay veil, so hide the square hint there */
.map-card.result .map.admin .map-box {
  display: none;
}
.map-card.frame .mini-hint {
  display: none;
}
.mini-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--ink);
  background: rgba(10, 15, 19, 0.72);
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}
.map-bar {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(14, 20, 25, 0.86);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.map-hint {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
}
.range-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 10px;
  color: var(--faint);
}
/* while a capture is running: drop the mode buttons/hint and let the CTA fill the bar */
.map-card.loading .seg,
.map-card.loading .map-hint {
  display: none;
}
.map-card.loading .cta {
  flex: 1;
  width: 100%;
  padding: 15px 16px;
  font-size: 15px;
}
.map.locked {
  cursor: progress;
}
.admin-note {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 5;
  max-width: 320px;
  margin: 0;
  font-size: 12px;
  color: var(--amber-soft);
  background: rgba(14, 20, 25, 0.9);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 8px;
}

/* view states */
.view-frame .controls,
.view-frame .readout,
.view-frame .panel-reopen,
.view-frame .render-modes,
.view-frame .scale-bar,
.view-frame .elev-tip {
  display: none;
}

/* PBR mode is hidden for now */
.render-mode[data-mode='pbr'] {
  display: none;
}
/* render-mode pill (top-right, above the controls panel) */
.render-modes {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 36;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(20, 27, 34, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}
.render-mode {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.render-mode:hover {
  color: var(--ink);
}
.render-mode.on {
  background: var(--amber);
  color: #1a1206;
}
/* 감상 enter button — sits in the render pill but launches the separate 감상 mode */
.view-enter {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.view-enter:hover {
  color: var(--ink);
}
/* auto-rotate toggle: lives in the same pill but acts as an on/off switch */
.rm-sep {
  width: 1px;
  align-self: stretch;
  margin: 2px 1px;
  background: var(--line);
}
.view-toggle {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.view-toggle:hover {
  color: var(--ink);
}
.view-toggle.on {
  background: var(--amber);
  color: #1a1206;
}
/* speed slider revealed under the pill when auto-rotate is on (mirrors 건물 뭉치기) */
.rotate-speed-row {
  position: absolute;
  top: 60px;
  right: 16px;
  z-index: 36;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: rgba(20, 27, 34, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}
.rotate-speed-row.hidden {
  display: none;
}
.rotate-speed-row label {
  font-size: 11px;
  color: var(--muted);
}
.rotate-speed-row input[type='range'] {
  width: 116px;
}
.view-frame .rotate-speed-row {
  display: none;
}

/* 3D compass — no border; a soft dark shadow centre (from the gizmo's 3D disc, which
   squashes to an ellipse when the view is flat) over a blurred backdrop that fades to fully
   transparent at the rim. */
#compass {
  position: absolute;
  left: 16px;
  bottom: 52px;
  z-index: 35;
  width: 96px;
  height: 96px;
  display: none;
  pointer-events: none;
}
#compass.on {
  display: block;
}
.compass-frost {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  -webkit-mask-image: radial-gradient(circle, #000 36%, transparent 68%);
  mask-image: radial-gradient(circle, #000 36%, transparent 68%);
}
#compass canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.work.collapsed .controls {
  display: none;
}
.panel-reopen {
  position: absolute;
  top: 62px;
  right: 16px;
  z-index: 35;
  background: rgba(20, 27, 34, 0.92);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13px;
  cursor: pointer;
}
/* sticky top bar: panel title on the left, reset + close on the right (so the first
   section's collapse chevron is no longer hidden behind the buttons) */
.panel-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 -14px 0; /* span the panel's horizontal padding */
  padding: 8px 14px;
  background: rgba(20, 27, 34, 0.97);
  border-bottom: 1px solid var(--line);
}
.panel-bar-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.panel-bar-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.panel-collapse {
  width: 26px;
  height: 26px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.panel-collapse:hover {
  color: var(--ink);
}
.panel-reset {
  height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 9px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.panel-reset:hover {
  color: var(--ink);
}
.panel-reset:disabled {
  opacity: 0.4;
  cursor: default;
}
.panel-reset .pr-ico {
  font-size: 13px;
}
.panel-hist {
  width: 26px;
  height: 26px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.panel-hist:hover:not(:disabled) {
  color: var(--ink);
}
.panel-hist:disabled {
  opacity: 0.35;
  cursor: default;
}
.toast-confirm {
  margin-left: 4px;
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid #67c8ff;
  background: #67c8ff;
  color: #08121b;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}
.toast-confirm:hover {
  background: #8ad4ff;
}

/* ---------- slippy map ---------- */
.map {
  position: absolute;
  inset: 0;
  background: #0a0f13;
  cursor: grab;
  touch-action: none;
  overflow: hidden;
}
.map.grabbing {
  cursor: grabbing;
}
.map-tiles {
  position: absolute;
  inset: 0;
  will-change: transform;
}
.map-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.tile {
  position: absolute;
  width: 256px;
  height: 256px;
  user-select: none;
  filter: grayscale(0.25) brightness(0.82) contrast(1.05);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.tile.on {
  opacity: 1;
}
.map-box {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  transform: translate(-50%, -50%);
  border: 1.5px solid var(--amber);
  background: rgba(217, 138, 61, 0.12); /* translucent fill → the area reads as a mesh */
  box-shadow: 0 0 0 9999px rgba(10, 15, 19, 0.45);
  pointer-events: none;
}
.map.admin .map-box {
  border-style: dashed;
  opacity: 0.5;
}
.map-box-label {
  position: absolute;
  top: -22px;
  left: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  background: rgba(14, 20, 25, 0.8);
  padding: 1px 6px;
  border-radius: 4px;
}
.map-btn {
  position: absolute;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: rgba(22, 29, 36, 0.92);
  color: var(--ink);
  border-radius: 7px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.map-zin {
  top: 12px;
}
.map-zout {
  top: 50px;
}
.map-rccw {
  top: 96px;
  font-size: 16px;
}
.map-rcw {
  top: 134px;
  font-size: 16px;
}
/* rotation controls only make sense on the full map (not the minimap) */
.map-card.result .map-rccw,
.map-card.result .map-rcw {
  display: none;
}
/* near a corner of the selection square → a rotate-handle cursor */
.map.rotate-zone,
.map.rotating {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'><g fill='none' stroke='%23000' stroke-opacity='0.45' stroke-width='4.6' stroke-linecap='round' stroke-linejoin='round'><path d='M23 11a9 9 0 1 0 1 7'/><path d='M23 5v6h-6'/></g><g fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M23 11a9 9 0 1 0 1 7'/><path d='M23 5v6h-6'/></g></svg>") 15 15, grab;
}

/* ---------- stage ---------- */
.work {
  background: radial-gradient(120% 120% at 30% 20%, #141b22 0%, #0c1116 70%);
}
.readout {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 10px 18px;
  background: linear-gradient(0deg, rgba(10, 15, 19, 0.92), transparent);
  font-family: var(--mono);
  font-size: 11px;
  pointer-events: none;
}
.rd label {
  color: var(--faint);
  margin-right: 6px;
  letter-spacing: 0.05em;
}
.rd span {
  color: var(--ink);
}

/* ---------- measure: scale bar + ratio + cursor elevation tooltip ---------- */
/* on-screen scale bar sits bottom-right, clear of the readout (bottom-left) */
.scale-bar {
  position: absolute;
  right: 18px;
  bottom: 14px;
  z-index: 28;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  text-align: right;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.scale-bar.hidden {
  display: none;
}
.scale-bar-line {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
.scale-bar-bar {
  display: inline-block;
  height: 7px;
  width: 80px;
  border: 1.5px solid var(--ink);
  border-top: none;
  /* a ruler tick look: two segments via a center divider */
  background: linear-gradient(90deg, var(--ink) 50%, transparent 50%);
  opacity: 0.9;
}
.scale-bar-len {
  color: var(--muted);
}
.scale-bar-ratio {
  margin-top: 3px;
  color: var(--amber-soft);
  letter-spacing: 0.03em;
}
/* cursor elevation tooltip — follows the pointer over the model */
.elev-tip {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(10, 15, 19, 0.86);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
  transform: translate(14px, -50%);
}
.elev-tip.hidden {
  display: none;
}

/* ---------- controls ---------- */
.controls {
  position: absolute;
  top: 62px;
  right: 16px;
  z-index: 35;
  width: 272px;
  max-height: calc(100% - 78px);
  overflow-y: auto;
  background: rgba(20, 27, 34, 0.94);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px 14px;
}
.ctl {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.ctl:last-child {
  border-bottom: 0;
}
.ctl h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ctl h3.sub-h3 {
  margin-top: 12px;
  font-size: 11px;
  color: var(--faint);
}
.ctl h3 .sub {
  color: var(--faint);
  font-weight: 400;
  text-transform: none;
}
.ctl h3 .mono {
  color: var(--amber);
}
/* per-layer show/hide toggle in the header */
.lyr-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.lyr-toggle input {
  accent-color: var(--amber);
  cursor: pointer;
}
/* dim a layer's controls when it's hidden */
.ctl.layer-off > *:not(h3) {
  opacity: 0.35;
  pointer-events: none;
}
/* editable numeric value paired with a slider */
.ctl h3 .val {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  color: var(--faint);
  font-family: var(--mono);
  font-weight: 400;
  text-transform: none;
}
.numval {
  width: 3.4em;
  text-align: right;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  color: var(--amber);
  font: inherit;
  padding: 0 1px;
  -moz-appearance: textfield;
}
.numval::-webkit-outer-spin-button,
.numval::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.numval:hover {
  border-bottom-color: var(--line);
}
.numval:focus {
  outline: none;
  border-bottom-color: var(--amber);
}
.sizes {
  display: flex;
  gap: 6px;
}
.size-preset {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 7px;
  padding: 8px 4px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.size-preset.on {
  border-color: var(--amber);
  color: var(--ink);
}
#size-custom {
  width: 92px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 7px;
  padding: 8px;
  font-family: var(--mono);
  font-size: 12px;
}
.hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--faint);
}
.hint.custom {
  color: var(--amber-soft);
}
input[type='range'] {
  width: 100%;
  accent-color: var(--amber);
}

.filaments {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fila {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  text-align: left;
}
.fila:hover {
  background: var(--panel);
}
.fila.on {
  border-color: var(--amber);
  background: var(--panel);
}
.fila .sw {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--c);
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex: none;
}
.fmeta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.fmeta b {
  font-size: 12px;
  font-weight: 600;
}
.fmeta i {
  font-style: normal;
  font-size: 11px;
  color: var(--faint);
}

/* ---- data attribution credit ---- */
.credits {
  position: absolute;
  right: 10px;
  bottom: 8px;
  z-index: 20;
  font-size: 10px;
  color: var(--faint);
  opacity: 0.65;
  pointer-events: none;
  text-align: right;
  max-width: 60%;
}

.hint.note {
  color: #e8a13a;
  opacity: 0.95;
}

/* ---- lock the UI while a capture is building ---- */
body.capturing .controls,
body.capturing .render-modes,
body.capturing .rotate-speed-row,
body.capturing .region-box,
body.capturing .map-card,
body.capturing .panel-reopen {
  pointer-events: none;
}
body.capturing .controls {
  opacity: 0.5;
}

/* ---- completion toast ---- */
@property --toast-bloom {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
.toast {
  position: absolute;
  left: 50%;
  bottom: 36px;
  transform: translate(-50%, 12px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(18, 26, 22, 0.96);
  border: 1px solid rgba(61, 255, 134, 0.4);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
/* loading toast: a bright spot blooms around the border, travelling the perimeter */
.toast.loading {
  border-color: transparent;
}
.toast.loading::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px; /* ring thickness */
  background: conic-gradient(
    from var(--toast-bloom),
    rgba(61, 255, 134, 0.12) 0deg,
    rgba(61, 255, 134, 0.12) 210deg,
    rgba(61, 255, 134, 0.95) 300deg,
    rgba(207, 232, 255, 1) 340deg,
    rgba(61, 255, 134, 0.12) 360deg
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  animation: toast-bloom 1.5s linear infinite;
}
@keyframes toast-bloom {
  to {
    --toast-bloom: 360deg;
  }
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.warn {
  border-color: rgba(232, 161, 58, 0.5);
}
.toast-cancel {
  margin-left: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
}
.toast-cancel:hover {
  background: rgba(255, 255, 255, 0.16);
}
.toast-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  flex: none;
}
.toast-ico.ok {
  background: #3dff86;
  color: #0a1a10;
}
.toast-ico.bad {
  background: #e8a13a;
  color: #1a1206;
}
.toast-spin {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #cfe8ff;
  animation: toast-spin 0.7s linear infinite;
}
@keyframes toast-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- filament hover tooltip ---- */
.fila-tip {
  position: fixed;
  z-index: 80;
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(12, 16, 20, 0.97);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  white-space: nowrap;
}
.fila-tip.show {
  opacity: 1;
}
.fila-tip-sw {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--c);
  border: 1px solid rgba(255, 255, 255, 0.16);
  flex: none;
}
.fila-tip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.fila-tip-text b {
  font-size: 12px;
}
.fila-tip-text i {
  font-style: normal;
  font-size: 11px;
  color: var(--faint);
}

/* ---- collapsible property sections ---- */
.sect {
  border-bottom: 1px solid var(--line);
}
.sect:last-child {
  border-bottom: 0;
}
.sect-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 11px 2px;
}
.sect-ico {
  font-size: 15px;
  line-height: 1;
}
.sect-title {
  flex: 1;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.sect-head:hover .sect-title {
  color: var(--ink);
}
.sect-chev {
  color: var(--faint);
  font-size: 11px;
  transition: transform 0.18s;
}
.sect.collapsed .sect-chev {
  transform: rotate(-90deg);
}
.sect.collapsed .sect-body {
  display: none;
}
.sect-body > .ctl:first-child {
  padding-top: 2px;
}

/* a feature section whose data didn't load (cancelled/failed): greyed header so it reads as
   unusable; expanding it swaps the controls for a notice + retry button. */
.sect.noload > .sect-head {
  opacity: 0.4;
}
.sect.noload .ctl {
  display: none;
}
.noload-notice {
  padding: 14px 4px 16px;
  text-align: center;
}
.noload-notice.hidden {
  display: none;
}
.noload-notice p {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--faint);
}
.retry-btn {
  background: var(--amber);
  color: #1a1206;
  border: 0;
  border-radius: 7px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.retry-btn:hover {
  filter: brightness(1.06);
}

/* ---- back to edit (from full map) ---- */
.back-edit {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.back-edit:hover {
  background: rgba(255, 255, 255, 0.14);
}
.back-edit.hidden {
  display: none;
}

/* ---- slice preview / 감상 overlay ---- */
/* slice & 감상 modes hide the editor chrome — each provides its own controls */
body.slice-mode .map-card,
body.slice-mode .controls,
body.slice-mode .panel-reopen,
body.slice-mode .render-modes,
body.slice-mode .rotate-speed-row,
body.slice-mode .scale-bar,
body.slice-mode .elev-tip,
body.view-mode .map-card,
body.view-mode .controls,
body.view-mode .panel-reopen,
body.view-mode .render-modes,
body.view-mode .rotate-speed-row,
body.view-mode .readout,
body.view-mode #compass {
  display: none;
}
/* LEFT: the layer scrubber — a dashed vertical track with min/mid/max labels and a wide, thin
   grip carrying the current layer number (no background fill) */
.slice-preview {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 55;
}
.slice-preview.hidden {
  display: none;
}
.slice-slider {
  position: relative;
  width: 56px;
  height: 210px;
  touch-action: none;
  cursor: pointer;
}
/* dashed vertical track line — faint scale */
.slice-slider::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 9px;
  bottom: 9px;
  width: 0;
  border-left: 1px dashed rgba(255, 255, 255, 0.22);
}
/* small layer-number chips sitting ON the bar (max top / mid / min bottom) — a dark, grey-edged
   pill that echoes the grip so the scale reads as one piece */
.slice-tick {
  position: absolute;
  left: 18px;
  transform: translate(-50%, -50%);
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(8, 12, 16, 0.92);
  border: 1px solid var(--line);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
}
#slice-tick-max {
  top: 9px;
}
#slice-tick-mid {
  top: 50%;
}
#slice-tick-min {
  top: calc(100% - 9px);
}
/* the grip: a wide, thin horizontal pill (centred on the line) carrying the layer number */
.slice-thumb {
  position: absolute;
  top: 0;
  left: 18px;
  transform: translateX(-50%);
  width: 44px;
  height: 18px;
  border-radius: 9px;
  background: var(--amber);
  color: #1a1206;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* TOP-RIGHT: slice panel styled like the editor panel — a header bar (title + 저장 + 돌아가기)
   over a foldable 표시 정보 section (reuses .panel-bar / .sect / .sect-head) */
.slice-bar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 56;
  width: 272px;
  max-width: calc(100% - 32px);
  border-radius: 12px;
  background: rgba(20, 27, 34, 0.94);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  padding: 0 14px 6px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.slice-bar.hidden {
  display: none;
}
.slice-bar .panel-bar-title {
  white-space: nowrap;
}
.slice-bar .hdr-btn {
  padding: 5px 9px;
  font-size: 11px;
}
.slice-save {
  border-color: var(--amber);
  background: var(--amber);
  color: #1a1206;
}
.slice-save:hover:not(:disabled) {
  background: var(--amber);
  filter: brightness(1.08);
}
.legend-modes {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.legend-mode {
  flex: 1;
  padding: 7px 0;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.legend-mode.on {
  background: var(--amber);
  color: #1a1206;
  border-color: var(--amber);
}
.legend-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--ink);
}
.legend-info .lg-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* reuse the main panel's filament chip (finish-aware) in the legend, just a touch smaller */
.legend-info .fila-info-sw {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}
.lg-sw {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--c);
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ---- slice nozzle segmented buttons ---- */
.seg-row {
  display: flex;
  gap: 6px;
  margin: 4px 0 8px;
}
.noz-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.noz-btn.on {
  background: var(--amber);
  color: #1a1206;
  border-color: var(--amber);
}
.noz-btn:hover:not(.on) {
  background: rgba(255, 255, 255, 0.1);
}

/* ---- 감상 (view) mode panel ---- */
/* the panel can hold 4 sections — let it scroll on short screens (it inherits .slice-bar) */
.view-bar {
  max-height: calc(100% - 32px);
  overflow-y: auto;
}
/* scene preset chips: icon over a Korean label, 2-up grid */
.view-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 2px 0 6px;
}
.vp-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.vp-btn .vp-ico {
  font-size: 18px;
  line-height: 1;
}
.vp-btn:hover:not(.on) {
  background: rgba(255, 255, 255, 0.1);
}
.vp-btn.on {
  background: var(--amber);
  color: #1a1206;
  border-color: var(--amber);
}
/* composition + resolution chips reuse the nozzle-button look */
.ang-btn,
.res-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.ang-btn.on,
.res-btn.on {
  background: var(--amber);
  color: #1a1206;
  border-color: var(--amber);
}
.ang-btn:hover:not(.on),
.res-btn:hover:not(.on) {
  background: rgba(255, 255, 255, 0.1);
}
.view-bar .range-ends {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--faint);
  margin-top: 2px;
}

/* ---- save / load state ---- */
.io-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.io-row .ghost {
  flex: 1;
  margin: 0;
}

/* ---- on-demand building generation ---- */
.building-gen {
  margin: 0 0 12px;
}
.gen-btn {
  width: 100%;
  background: var(--amber);
  color: #1a1206;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.gen-btn:hover {
  filter: brightness(1.06);
}
.gen-btn:disabled {
  background: #2c3440;
  color: var(--faint);
  cursor: not-allowed;
  filter: none;
}
.building-gen .hint {
  margin: 7px 0 0;
}

/* ---- filament palette ---- */
.fila-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  margin-bottom: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.fila-info-sw {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  flex: none;
  background: var(--c);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.fila-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}
.fila-info-text b {
  font-size: 12px;
  font-weight: 600;
}
.fila-info-text i {
  font-style: normal;
  font-size: 11px;
  color: var(--faint);
}
.fila-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}
.fila-chip {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--c);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0;
  cursor: pointer;
  transition: transform 0.1s;
}
.fila-chip:hover {
  transform: scale(1.1);
  z-index: 2;
}
.fila-chip.on {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}
/* finish cues, shared by chips and the selected-info swatch */
.fila-chip.k-glossy,
.fila-info-sw.k-glossy {
  background-image: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 46%);
}
.fila-chip.k-matte,
.fila-info-sw.k-matte {
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.12);
}
.fila-chip.k-special,
.fila-info-sw.k-special {
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, 0.2) 72%);
}
.fila-chip.k-special::after {
  content: '✦';
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: 8px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.7);
}

.seg-layer,
.seg-dem {
  width: 100%;
}
.seg-layer {
  margin-bottom: 10px;
}
.seg-layer .seg-btn,
.seg-dem .seg-btn {
  flex: 1;
}
.seg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
#detail-wrap {
  margin-top: 10px;
}
.layer-color-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.layer-color-toggle input {
  width: auto;
  accent-color: var(--amber);
}
.layer-filaments {
  margin-top: 8px;
}
#rd-detail.warn {
  color: #e8a13a;
}

.quote .qrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.qrow .qlabel {
  font-size: 12px;
  color: var(--muted);
}
.qrow.big #price {
  font-size: 22px;
  color: var(--ink);
}
/* 출력 점검 — printability checklist rows (icon + label + reason) */
.printcheck {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.printcheck .pc-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
}
.printcheck .pc-ico {
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1.4;
}
.printcheck .pc-label {
  flex: 0 0 auto;
  color: var(--ink);
  font-weight: 600;
}
.printcheck .pc-reason {
  flex: 1;
  color: var(--faint);
  text-align: right;
}
.printcheck .pc-row.warn .pc-label {
  color: var(--amber-soft);
}
.printcheck .pc-row.warn .pc-reason {
  color: var(--amber);
}
.printcheck .pc-empty {
  color: var(--faint);
  font-size: 12px;
}
/* a small amber dot appended to export/slice buttons when a severe warning is present */
.pc-flag::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--amber);
  vertical-align: middle;
}

.ghost {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--amber);
  color: var(--amber);
  border-radius: 8px;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ghost:hover:not(:disabled) {
  background: rgba(217, 138, 61, 0.1);
}
.ghost:disabled {
  opacity: 0.4;
  border-color: var(--line);
  color: var(--faint);
  cursor: not-allowed;
}

.flash {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -12px);
  background: var(--panel-2);
  border: 1px solid var(--amber);
  color: var(--amber-soft);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.flash.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

*:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
  .region-box {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }
  .map-card.result {
    width: 168px;
    height: 122px;
  }
}

/* phone portrait: properties panel becomes a bottom sheet so the 3D + minimap stay visible */
@media (max-width: 640px) {
  .map-hint {
    display: none;
  }
  .controls {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    max-height: 58vh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding-top: 14px;
  }
  .controls::before {
    content: '';
    position: sticky; /* the drag handle stays at the top of the sheet while scrolling */
    top: 4px;
    display: block;
    margin: 0 auto -8px;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--line);
  }
  /* X stays pinned at the top of the sheet so you can collapse it without scrolling up */
  .panel-collapse {
    position: sticky;
    top: 8px;
    right: auto;
    display: block;
    width: 34px;
    height: 34px;
    margin: -2px 4px -34px auto;
    font-size: 15px;
  }
  .panel-reopen {
    top: auto;
    bottom: 14px;
    right: 14px;
  }
  .readout {
    display: none;
  }
  .map-card.result {
    width: 150px;
    height: 108px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ===== 명소 갤러리 (#30) — 좌측 카테고리 + 우측 썸네일 격자 ===== */
.gallery-open {
  white-space: nowrap;
}

.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: stretch;
}
.gallery-modal.hidden {
  display: none;
}

.gallery-panel {
  width: clamp(420px, 60vw, 940px);
  max-width: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  animation: gallery-slide 0.22s ease;
}
@keyframes gallery-slide {
  from {
    transform: translateX(-24px);
    opacity: 0.3;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* the right strip lets the live app peek through on desktop; clicking it closes (split layout) */
.gallery-peek {
  flex: 1;
  border: 0;
  cursor: pointer;
  background: linear-gradient(90deg, rgba(8, 11, 14, 0.55), rgba(8, 11, 14, 0.18));
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.gallery-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.gallery-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.gallery-title {
  font-weight: 700;
  font-size: 16px;
}
.gallery-sub {
  color: var(--muted);
  font-size: 12px;
}
.gallery-close {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  font-size: 15px;
}
.gallery-close:hover {
  border-color: var(--amber);
  color: var(--amber-soft);
}

.gallery-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.gallery-cats {
  flex: none;
  width: 188px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gallery-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  touch-action: manipulation;
}
.gallery-cat:hover {
  background: var(--panel-2);
  color: var(--ink);
}
.gallery-cat.on {
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--line);
}
.gc-emoji {
  font-size: 15px;
  flex: none;
}
.gc-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gc-count {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}
.gallery-cat.on .gc-count {
  color: var(--amber-soft);
}

.gallery-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 14px;
}
.gallery-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.gallery-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 0;
  font-family: var(--sans);
  transition: border-color 0.12s ease, transform 0.12s ease;
  touch-action: manipulation;
}
.gallery-card:hover {
  border-color: var(--amber);
  transform: translateY(-2px);
}
.gallery-card:focus-visible {
  outline: 2px solid var(--amber-soft);
  outline-offset: 2px;
}
.gallery-card.picked {
  border-color: var(--amber-soft);
  box-shadow: 0 0 0 1px var(--amber-soft) inset;
}
.gcard-thumb {
  display: block;
  aspect-ratio: 1 / 1;
  background: #0c1116;
}
.gcard-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gcard-thumb.no-thumb {
  background: linear-gradient(135deg, #1a2730, #122029);
}
.gcard-cap {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gcard-name {
  font-size: 13px;
  font-weight: 600;
}
.gcard-sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

body.gallery-on {
  overflow: hidden;
}

@media (max-width: 760px) {
  .gallery-panel {
    width: 100%;
  }
  .gallery-peek {
    display: none;
  }
  .gallery-body {
    flex-direction: column;
  }
  .gallery-cats {
    width: auto;
    flex: none;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 6px;
  }
  .gallery-cat {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }
  .gc-count {
    display: none;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}
