/* TWR WONDERLAND AR - flat UI. No glows, no shadows. */
:root {
  --bg: #0c0e11; --surface: #14181d; --surface2: #1b2027; --line: #2a313b; --line2: #38414d;
  --text: #e9ecf0; --muted: #8b95a3; --accent: #e8ff47; --accent-ink: #0c0e11;
  --ok: #4ade80; --warn: #fbbf24; --danger: #f87171; --info: #60a5fa;
  --r: 10px; --r-sm: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; } h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0 0 .8em; }
small, .muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* buttons & inputs */
.btn { appearance: none; border: 1px solid var(--line2); background: var(--surface2); color: var(--text); border-radius: var(--r-sm);
  padding: 8px 13px; font: 600 13px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; touch-action: manipulation; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: #5a2a2a; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn.lg { padding: 12px 18px; font-size: 15px; }
.btn.block { width: 100%; justify-content: center; }
.btn.on { border-color: var(--accent); color: var(--accent); }
input, select, textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line2); border-radius: var(--r-sm);
  padding: 7px 9px; font: 13px var(--font); outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 0; height: 32px; width: 46px; background: none; cursor: pointer; }
input[type=range] { padding: 0; accent-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; cursor: pointer; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row > .grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.err { color: var(--danger); font-size: 12px; min-height: 1em; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 650; border: 1px solid var(--line2); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: #1f5133; } .pill.warn { color: var(--warn); border-color: #5c4718; } .pill.bad { color: var(--danger); border-color: #5a2a2a; }
.pill.accent { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(5, 6, 8, .78); z-index: 1200; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto; }
.modal { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; width: 100%; max-width: 420px; }
.modal.wide { max-width: 980px; }
.modal-x { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1; }

/* toasts */
.toasts { position: fixed; z-index: 2100; left: 50%; transform: translateX(-50%); bottom: 18px; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--surface2); border: 1px solid var(--line2); padding: 9px 14px; border-radius: var(--r-sm); font-weight: 600; font-size: 13px; }
.toast.ok { border-color: #1f5133; color: var(--ok); } .toast.error { border-color: #5a2a2a; color: var(--danger); } .toast.warn { border-color: #5c4718; color: var(--warn); }

/* app shell (index) */
.shell { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); min-height: 54px; }
.brand { font-weight: 800; letter-spacing: .02em; font-size: 16px; }
.brand-dot { width: 10px; height: 10px; background: var(--accent); border-radius: 2px; display: inline-block; margin-right: 8px; }
.topbar .spacer { flex: 1; }
.main { display: grid; grid-template-columns: 380px 1fr; min-height: 0; }
.side { border-right: 1px solid var(--line); overflow: auto; padding: 16px; min-height: 0; }
.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #0f1215; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card + .card { margin-top: 10px; }
.site-card { display: grid; grid-template-columns: 64px 1fr; gap: 12px; cursor: pointer; }
.site-card:hover { border-color: var(--line2); }
.site-card.active { border-color: var(--accent); }
.thumb { width: 64px; height: 64px; border-radius: var(--r-sm); background: var(--surface2) center/cover no-repeat; border: 1px solid var(--line); }
.site-card .t { font-weight: 650; }
.foot { color: var(--muted); font-size: 12px; margin-top: 18px; }
.hero { margin-bottom: 14px; }
.hero p { color: var(--muted); }

@media (max-width: 820px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 46vh 1fr; }
  .mapwrap { order: 1; } .side { order: 2; border-right: 0; border-top: 1px solid var(--line); }
}

/* admin console */
.console { position: fixed; inset: 0; z-index: 1100; background: var(--bg); display: grid; grid-template-rows: auto 1fr; }
.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tab { padding: 7px 12px; border-radius: var(--r-sm); cursor: pointer; color: var(--muted); font-weight: 650; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab.on { color: var(--text); border-color: var(--line2); background: var(--surface2); }
.console-body { overflow: auto; padding: 18px; }
.console-body > .inner { max-width: 1200px; margin: 0 auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.asset { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.asset .img { aspect-ratio: 1; background: var(--surface2) center/contain no-repeat; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.asset .b { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.asset .n { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset.pick { cursor: pointer; } .asset.pick:hover { border-color: var(--accent); }
.drop { border: 1px dashed var(--line2); border-radius: var(--r); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }
.progress { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .15s; }
.section { margin-bottom: 22px; }

/* anchor maker */
.cropper { position: relative; display: inline-block; max-width: 100%; user-select: none; touch-action: none; }
.cropper img { display: block; max-width: 100%; max-height: 60vh; }
.cropper .box { position: absolute; border: 2px solid var(--accent); background: rgba(232, 255, 71, .08); cursor: move; }
.cropper .box .h { position: absolute; width: 16px; height: 16px; background: var(--accent); right: -8px; bottom: -8px; cursor: nwse-resize; border-radius: 2px; }
.cropper .shade { position: absolute; background: rgba(0, 0, 0, .55); pointer-events: none; }

/* editor */
.ed { display: grid; grid-template-columns: 260px 1fr 330px; grid-template-rows: auto 1fr; height: 100%; }
.ed .topbar { grid-column: 1 / -1; }
.ed .left, .ed .right { overflow: auto; min-height: 0; background: var(--surface); }
.ed .left { border-right: 1px solid var(--line); }
.ed .right { border-left: 1px solid var(--line); }
.ed .center { position: relative; min-height: 0; min-width: 0; }
.ed .center canvas { display: block; width: 100%; height: 100%; outline: none; }
.ed .center #edmap { position: absolute; inset: 0; }
.panel { padding: 12px; border-bottom: 1px solid var(--line); }
.panel h4 { margin-bottom: 8px; }
.olist .o { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; }
.olist .o:hover { background: var(--surface2); }
.olist .o.sel { background: var(--surface2); outline: 1px solid var(--accent); }
.olist .o .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.olist .o .k { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.overlay-tools { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 5; }
.overlay-tools.right { left: auto; right: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--r-sm); overflow: hidden; background: var(--surface2); }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 10px; font: 600 12px var(--font); cursor: pointer; border-right: 1px solid var(--line2); }
.seg button:last-child { border-right: 0; }
.seg button.on { color: var(--accent-ink); background: var(--accent); }
.xyz { display: grid; grid-template-columns: 14px 1fr 14px 1fr 14px 1fr; gap: 4px; align-items: center; }
.xyz span { font-size: 11px; color: var(--muted); font-weight: 700; text-align: center; }
.mat { border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 8px; }
.mat > summary { padding: 7px 9px; cursor: pointer; font-weight: 600; font-size: 12px; list-style: none; display: flex; justify-content: space-between; }
.mat > summary::-webkit-details-marker { display: none; }
.mat .body { padding: 8px 9px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.tex { display: grid; grid-template-columns: 34px 1fr; gap: 6px; align-items: center; }
.tex .sw { width: 34px; height: 34px; border-radius: 4px; border: 1px solid var(--line2); background: var(--surface2) center/cover no-repeat; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; font-size: 12px; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
@media (max-width: 980px) {
  .ed { grid-template-columns: 1fr; grid-template-rows: auto 52vh auto auto; height: auto; min-height: 100%; }
  .ed .left, .ed .right { border: 0; border-top: 1px solid var(--line); }
  .ed .center { order: 1; } .ed .left { order: 3; } .ed .right { order: 2; }
}

/* leaflet tweaks */
.leaflet-container { font: 12px var(--font); background: #0f1215; }
.mk { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid #0c0e11; }
.mk.obj { width: 12px; height: 12px; background: #60a5fa; }
.mk.obj.sel { background: var(--accent); }
.mk.me { background: #4ade80; }
.mk.lm { background: #ff8a3d; border-radius: 3px; }
.mk-site { position: relative; width: 22px; height: 22px; }
.mk-site .d { position: absolute; inset: 3px; background: var(--accent); border: 2px solid #0c0e11; border-radius: 50%; }
.mk-arrow { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 14px solid var(--accent); position: absolute; left: 5px; top: -12px; transform-origin: 6px 23px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: none; border: 1px solid var(--line2); }
.leaflet-bar a { background: var(--surface2); color: var(--text); border-color: var(--line2); }
.leaflet-bar { box-shadow: none !important; border: 1px solid var(--line2) !important; }
.leaflet-control-attribution { background: rgba(12, 14, 17, .8) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--muted); }

/* print */
@media print { .noprint { display: none !important; } body { background: #fff; color: #000; } }

@media (max-width: 640px) { .topbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; } }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h4::before { content: '+ '; }
details.panel[open] > summary h4::before { content: '- '; }

/* 2.1: icons, hover info, drawers, library */
.ico { display: inline-block; vertical-align: -3px; flex: none; }
.tipbox { position: fixed; z-index: 3000; max-width: 300px; background: #f2f4f7; color: #0c0e11; border-radius: 6px; padding: 7px 10px; font-size: 12px; line-height: 1.4; pointer-events: none; display: none; }
i.info { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line2); color: var(--muted); font-size: 10px; font-style: normal; font-weight: 700; cursor: help; margin-left: 6px; vertical-align: 1px; }
i.info:hover { color: var(--accent); border-color: var(--accent); }
details.drawer { border-bottom: 1px solid var(--line); }
details.drawer > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 11px 2px; font-weight: 650; font-size: 13px; color: var(--text); user-select: none; }
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::after { content: ''; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
details.drawer[open] > summary::after { transform: rotate(45deg); }
details.drawer > summary .ico { color: var(--accent); }
details.drawer > .drawer-body { padding: 0 2px 12px; }
details.drawer.sub { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 8px; margin-top: 6px; }
details.drawer.sub > summary { padding: 8px 0; font-size: 12px; }
.ed .left > details.drawer { padding: 0 12px; }
.lib-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 6px; }
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lib-tile { appearance: none; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--text); padding: 9px 4px 7px; display: flex; flex-direction: column; align-items: center; gap: 5px; font: 600 11px var(--font); cursor: pointer; text-align: center; line-height: 1.2; min-height: 64px; }
.lib-tile:hover { border-color: var(--accent); color: var(--accent); }
.lib-tile .ico { color: var(--accent); }
.area-card.on { border-color: var(--accent); }
.blist { max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; }
.tabbar-ico { display: inline-flex; align-items: center; gap: 6px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.kv2 { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12px; }
.kv2 > b { color: var(--muted); font-weight: 600; }
.claim-img { width: 100%; aspect-ratio: 1; border-radius: var(--r); background: var(--surface2) center/cover no-repeat; border: 1px solid var(--line); }
.claim-done { text-align: center; padding: 6px 0; }
/* zone alert banner (AR view and visitor pages) */
.zone-banner { position: fixed; left: 10px; right: 10px; top: calc(64px + env(safe-area-inset-top)); z-index: 40; display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; max-width: 520px; margin: 0 auto; animation: zb-in .25s ease-out; }
.zone-banner .ico { color: var(--accent); flex: none; }
@keyframes zb-in { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
