:root { --ink: #1d2433; --muted: #5f6b7d; --line: #dfe4ec; --bg: #f5f7fa; --acc: #ffd23f; --blue: #1f6feb; --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.loading { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: rgba(29,36,51,.85); color: #fff; padding: 7px 14px; border-radius: 99px; font-size: 13px; }
html, body { margin: 0; height: 100%; font: 15px/1.45 var(--font); color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--blue); }
.top { height: 54px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; color: var(--ink); text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.tag { color: var(--muted); font-size: 14px; }
.acts { margin-left: auto; display: flex; gap: 8px; }
.acts button, .btns button, .viewbtns button, .edtools button, .edtools .up { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 11px; cursor: pointer; font-weight: 600; font-size: 14px; }
button:hover { border-color: #b8c2d2; }
.primary { background: var(--ink) !important; color: #fff !important; border-color: var(--ink) !important; border-radius: 9px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.primary:disabled { opacity: .4; cursor: default; }
.app { display: grid; grid-template-columns: 380px 1fr; height: calc(100vh - 54px); height: calc(100dvh - 54px); }
.panel { overflow: auto; background: #fff; border-right: 1px solid var(--line); padding: 6px 16px 16px; }
.panel section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.panel h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.panel h2 span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--acc); font-size: 13px; }
.row { display: flex; gap: 8px; }
.row input, .row select { flex: 1; min-width: 0; }
input, select { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, select:focus { outline: 2px solid #9ec5ff; border-color: #6aa4f8; }
.grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid label, .slider { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.slider { margin: 10px 0 4px; } .slider b { color: var(--ink); }
.slider input { padding: 0; accent-color: var(--ink); }
.wide { width: 100%; margin-top: 10px; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 9px; font-weight: 700; cursor: pointer; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.link { border: 0; background: none; color: var(--blue); padding: 6px 0; cursor: pointer; }
.small { font-size: 13px; } .muted { color: var(--muted); }
.err { color: #c0392b; font-size: 13px; margin: 6px 0 0; min-height: 0; }
.err:empty { display: none; }
.warn { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.warn.ok { background: #e6f7ec; } .warn.mid { background: #fff3dc; } .warn.bad { background: #fde7e5; }
.foot { margin-top: 14px; }
.stage { position: relative; min-width: 0; }
#view { width: 100%; height: 100%; display: block; touch-action: none; }
.viewbtns { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.compass { position: absolute; left: 14px; top: 12px; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.9); display: grid; place-items: center; font-weight: 800; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* dialogs */
.dlg { position: fixed; inset: 0; background: rgba(15,20,30,.55); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 14px; }
.dlg[hidden] { display: none; }
.box { background: #fff; border-radius: 16px; width: min(1100px, 100%); height: min(820px, 100%); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.box header { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.box header h3 { margin: 0; font-size: 17px; }
.box header .row { flex: 1; min-width: 240px; }
.box footer { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.box footer p { margin: 0; flex: 1; min-width: 200px; }
#map { flex: 1; }
.tabs { display: flex; gap: 6px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.edtools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.edtools button.on { background: var(--acc); border-color: #e0b400; }
.edtools .h { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: auto; }
.edtools .h input { width: 70px; }
.edstage { position: relative; flex: 1; min-height: 0; }
#edCanvas { width: 100%; height: 100%; display: block; touch-action: none; }
.calib { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: #fff; border-radius: 12px; padding: 10px; display: flex; gap: 8px; align-items: end; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.calib label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.calib input { width: 110px; }

@media (max-width: 820px) {
  .tag { display: none; }
  .app { grid-template-columns: 1fr; grid-template-rows: 52vh auto; height: auto; }
  .stage { order: -1; height: 52vh; position: sticky; top: 0; z-index: 2; }
  .panel { border-right: 0; }
  .grid { grid-template-columns: 1fr 1fr; }
  .box { height: 100%; border-radius: 12px; }
}

.params { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.params summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.params textarea { width: 100%; margin: 8px 0; font: 12px/1.4 ui-monospace, Menlo, monospace; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
