:root {
  --ink: #12324F;
  --muted: #5B7590;
  --line: #D3DCE5;
  --panel: #F5F7F9;
  --accent: #1E6FD9;
  --danger: #C62828;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #D6E4EE; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--ink); }
#app { display: flex; height: 100%; }
#mapwrap { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#stage { display: block; width: 100%; height: 100%; touch-action: none; }

.summary {
  position: absolute; left: 2.2%; bottom: 3.5%;
  background: rgba(255, 255, 255, 0.94);
  padding: 0.45em 0.9em; border-radius: 6px;
  font-size: clamp(14px, 1.5vw, 32px); font-weight: 600;
}
.note {
  position: absolute; right: 1.5%; bottom: 2%;
  background: rgba(18, 50, 79, 0.88); color: #fff;
  padding: 0.4em 0.8em; border-radius: 4px;
  font-size: clamp(11px, 0.8vw, 18px);
}
.hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px;
  font-size: 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); pointer-events: none;
}

/* Editor */
.is-edit [data-role] { cursor: grab; }
.is-edit.is-dragging [data-role] { cursor: grabbing; }
.is-placing #stage { cursor: crosshair; }
#editor {
  width: 360px; flex: none; height: 100%; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--line);
  font-size: 14px;
}
#editor header { padding: 16px 18px 6px; }
#editor h1 { font-size: 18px; margin: 0 0 4px; }
#editor h2 { font-size: 15px; margin: 0 0 10px; display: flex; justify-content: space-between; }
#editor section { padding: 14px 18px; border-top: 1px solid var(--line); }
#editor footer { padding: 14px 18px 24px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
#editor label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
#editor input[type="text"], #editor input[type="number"], #editor select {
  display: block; width: 100%; margin-top: 4px; padding: 7px 8px;
  border: 1px solid #B9C6D3; border-radius: 4px; font: inherit; color: var(--ink); background: #fff;
}
#editor input:focus-visible, #editor select:focus-visible, #editor button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
#editor input[type="range"] { display: block; width: 100%; margin-top: 4px; }
#editor .check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); }
#editor .check input { margin-top: 2px; }
#editor .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#editor .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
#editor button, #editor .filebtn {
  font: inherit; padding: 7px 12px; border-radius: 4px; cursor: pointer;
  border: 1px solid #B9C6D3; background: #fff; color: var(--ink);
}
#editor .filebtn { display: inline-block; color: var(--ink); margin: 0; text-align: center; }
#editor .filebtn input { display: none; }
#editor button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
#editor button.danger { color: var(--danger); }
#editor .help { color: var(--muted); font-size: 12px; margin: 6px 0 0; line-height: 1.45; }
#editor .warn { color: var(--danger); }
#e-list { list-style: none; margin: 10px 0; padding: 0; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
#e-list:empty { display: none; }
#e-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; border-bottom: 1px solid #EEF2F5; }
#e-list li:last-child { border-bottom: 0; }
#e-list li.sel { background: #E3EEFB; }
#e-list .swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#e-list .lname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#e-list .lid { color: var(--muted); font-size: 12px; }
#e-detail { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 12px; }
.statusrow { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: end; margin-bottom: 8px; }
.statusrow input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid #B9C6D3; border-radius: 4px; background: #fff; }
.statusrow label { margin: 0 !important; }

/* Display mode */
.is-display, .is-display * { cursor: none; }

/* Admin save bar */
#editor .savebar { position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
#editor .savebar .state { flex: 1; font-size: 12px; color: var(--muted); }
#editor .savebar .state.dirty { color: #B26A00; font-weight: 600; }
#editor .savebar .state.error { color: var(--danger); font-weight: 600; }
#editor a.view { color: var(--accent); font-size: 13px; }
#editor button:disabled { opacity: 0.45; cursor: default; }
