/* All assistant styles are namespaced. Both dark map styles share readable UI
 * colors; the map's own theme mode, filters and brightness remain authoritative. */
.nemap-ai-panel,.nemap-ai-launcher,.nemap-ai-entry,.nemap-ai-backdrop{box-sizing:border-box}
.nemap-ai-panel{
  --nai-bg:#f9fbfe;--nai-raised:#fff;--nai-ink:#18293e;--nai-muted:#57677b;
  --nai-border:#d7e0ea;--nai-accent:#245fc4;--nai-soft:#edf3fc;--nai-user:#e7effb;
  --nai-error:#a52d38;--nai-shadow:0 18px 65px #10233d33;
  position:fixed;z-index:100100;display:flex;flex-direction:column;min-width:0;min-height:0;
  margin:0;padding:0;border:1px solid var(--nai-border);border-radius:16px;
  background:var(--nai-bg);color:var(--nai-ink);box-shadow:var(--nai-shadow);
  overflow:hidden;font:14px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;
  text-align:left;isolation:isolate;color-scheme:light;overscroll-behavior:contain;
}
html[data-theme=dark] .nemap-ai-panel{
  --nai-bg:#151e29;--nai-raised:#1c2836;--nai-ink:#e5edf8;--nai-muted:#a4b4c8;
  --nai-border:#334459;--nai-accent:#95c1ff;--nai-soft:#22334a;--nai-user:#233d60;
  --nai-error:#ffabb4;--nai-shadow:0 18px 65px #0008;color-scheme:dark;
}
html[data-map-style=night] .nemap-ai-panel{--nai-bg:#121b25;--nai-raised:#182432}
.nemap-ai-panel[hidden],.nemap-ai-backdrop[hidden],.nemap-ai-entry[hidden],.nemap-ai-panel [hidden]{display:none!important}
.nemap-ai-panel *{box-sizing:border-box}
.nemap-ai-panel button,.nemap-ai-panel textarea,.nemap-ai-panel summary{font:inherit}
.nemap-ai-panel button{color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
.nemap-ai-panel button:disabled{opacity:.48;cursor:default}
.nemap-ai-panel button:focus-visible,.nemap-ai-panel a:focus-visible,.nemap-ai-panel summary:focus-visible,
.nemap-ai-panel textarea:focus-visible,.nemap-ai-launcher:focus-visible{
  outline:3px solid #73aafa;outline-offset:2px;
}
.nemap-ai-panel a{color:var(--nai-accent);text-decoration:underline;text-underline-offset:2px;overflow-wrap:anywhere}
.nemap-ai-panel p{margin:0}
.nemap-ai-panel svg,.nemap-ai-launcher svg{display:block;flex:0 0 auto;width:20px;height:20px;pointer-events:none}
.nemap-ai-header{
  flex:0 0 auto;display:flex;align-items:center;gap:4px;min-height:64px;
  padding:10px 12px 10px 16px;background:var(--nai-raised);border-bottom:1px solid var(--nai-border);
}
.nemap-ai-heading{flex:1;min-width:0}
.nemap-ai-heading h2{margin:0;font:650 17px/1.3 system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--nai-ink)}
.nemap-ai-heading>span{display:block;margin-top:3px;color:var(--nai-muted);font-size:11px;line-height:1.35}
.nemap-ai-icon-button{display:grid;place-items:center;width:38px;height:40px;padding:0;border:0;border-radius:9px;background:transparent}
.nemap-ai-icon-button:hover{background:var(--nai-soft)}
.nemap-ai-scope{flex:0 0 auto;padding:10px 16px!important;background:var(--nai-soft);color:var(--nai-muted);font-size:11.5px;line-height:1.45;border-bottom:1px solid var(--nai-border)}
.nemap-ai-log{
  flex:1 1 0;min-height:0;min-width:0;padding:18px 16px;overflow-x:hidden;overflow-y:auto;
  display:flex;flex-direction:column;gap:20px;overscroll-behavior:contain;scrollbar-gutter:stable;
  -webkit-overflow-scrolling:touch;scroll-padding-block:12px;
}
.nemap-ai-welcome{margin:auto 0;flex:0 0 auto;padding:10px 0}
.nemap-ai-eyebrow{display:block;color:var(--nai-accent);font-size:10px;letter-spacing:.11em;font-weight:750}
.nemap-ai-welcome h3{margin:8px 0 10px;font-size:23px;line-height:1.22;letter-spacing:-.025em;font-weight:650}
.nemap-ai-welcome>p{color:var(--nai-muted);font-size:13px;line-height:1.55}
.nemap-ai-suggestions{display:flex;flex-direction:column;gap:8px;margin-top:20px}
.nemap-ai-suggestion{display:block;width:100%;min-height:44px;padding:10px 12px;border:1px solid var(--nai-border);border-radius:10px;background:var(--nai-raised);text-align:left;font-size:12.5px!important;line-height:1.45!important}
.nemap-ai-suggestion:hover{border-color:var(--nai-accent);background:var(--nai-soft)}
.nemap-ai-suggestion--help{font-weight:650!important}
.nemap-ai-message{flex:0 0 auto;max-width:100%;min-width:0;margin:0;overflow-wrap:anywhere}
.nemap-ai-message--user{align-self:flex-end;max-width:92%;padding:10px 13px;border-radius:13px 13px 3px 13px;background:var(--nai-user);white-space:pre-wrap}
.nemap-ai-message--assistant{align-self:stretch}
.nemap-ai-answer-label{margin-bottom:7px;font-size:11px;line-height:1.2;font-weight:700;color:var(--nai-muted)}
.nemap-ai-answer{font-size:14px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}
.nemap-ai-answer:empty{display:none}
.nemap-ai-answer--draft{opacity:.86}
.nemap-ai-status{display:flex;align-items:center;gap:8px;min-height:24px;font-size:12px;line-height:1.5;color:var(--nai-muted)}
.nemap-ai-status:not(.nemap-ai-status--error)::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--nai-accent);flex:0 0 auto;animation:nemap-ai-pulse 1.4s ease-in-out infinite}
.nemap-ai-status--error{color:var(--nai-error)}
.nemap-ai-answer-meta{margin-top:8px!important;color:var(--nai-muted);font-size:11px;line-height:1.45}
.nemap-ai-citation{font-size:.9em;font-weight:700;text-decoration:none!important;white-space:nowrap}
.nemap-ai-sources{margin-top:12px;border:1px solid var(--nai-border);border-radius:9px;background:var(--nai-raised)}
.nemap-ai-sources>summary{padding:10px 12px;cursor:pointer;color:var(--nai-accent);font-size:12px;font-weight:650;min-height:40px}
.nemap-ai-sources[open]>summary{border-bottom:1px solid var(--nai-border)}
.nemap-ai-source-list{padding:0 12px}
.nemap-ai-source{padding:12px 0;border-bottom:1px solid var(--nai-border);min-width:0;font-size:12px;line-height:1.5;overflow-wrap:anywhere}
.nemap-ai-source:last-child{border-bottom:0}
.nemap-ai-source-kind{margin-bottom:3px;color:var(--nai-muted);font-size:10px;font-weight:700;letter-spacing:.025em}
.nemap-ai-source-link,.nemap-ai-source-title{font-weight:600}
.nemap-ai-source-meta{display:block;margin-top:4px!important;color:var(--nai-muted);font-size:10.5px;line-height:1.5}
.nemap-ai-source-excerpt{margin-top:7px!important;font-size:11px;white-space:pre-wrap}
.nemap-ai-map-action{display:block;margin:9px 0 0;min-height:36px;padding:7px 10px;border:1px solid var(--nai-border);border-radius:7px;background:var(--nai-soft);color:var(--nai-accent)!important;font-size:11px!important;font-weight:650!important}
.nemap-ai-map-search{margin-top:12px;padding:12px;border:1px solid var(--nai-border);border-radius:9px;background:var(--nai-raised);font-size:12px;line-height:1.5;overflow-wrap:anywhere}
.nemap-ai-map-search-scope{margin-top:6px!important;font-size:12px}
.nemap-ai-map-search-status{margin-top:8px!important;font-size:11px;color:var(--nai-muted)}
.nemap-ai-map-search-status:empty{display:none}
.nemap-ai-map-results{margin-top:10px}
.nemap-ai-map-results>summary{min-height:40px;padding:9px 0;cursor:pointer;font-weight:650;color:var(--nai-accent)}
.nemap-ai-map-result{padding:10px 0;border-top:1px solid var(--nai-border)}
.nemap-ai-map-result>a,.nemap-ai-source-kind~a{display:block;margin:5px 0;overflow-wrap:anywhere}
.nemap-ai-case{margin-top:9px;padding-left:10px;border-left:2px solid var(--nai-border);font-size:11px}
.nemap-ai-feedback{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin-top:12px;color:var(--nai-muted);font-size:10.5px}
.nemap-ai-feedback-button{min-width:34px;min-height:32px;padding:3px 8px;border:1px solid var(--nai-border);border-radius:6px;background:transparent;font-size:11px!important}
.nemap-ai-feedback-status{font-size:11px}
.nemap-ai-form{flex:0 0 auto;margin:0;padding:11px 12px 10px;background:var(--nai-raised);border-top:1px solid var(--nai-border)}
.nemap-ai-compose{display:flex;align-items:flex-end;gap:7px;min-width:0}
.nemap-ai-input{
  display:block;flex:1;min-width:0;width:0;min-height:44px;max-height:92px;margin:0;
  padding:10px 11px;resize:none;overflow-y:auto;border:1px solid var(--nai-border);
  border-radius:10px;background:var(--nai-bg);color:var(--nai-ink);font-size:14px!important;
  line-height:1.5!important;box-shadow:none;overscroll-behavior:contain;
}
.nemap-ai-input::placeholder{color:var(--nai-muted);opacity:1}
.nemap-ai-send,.nemap-ai-cancel{display:grid;place-items:center;flex:0 0 42px;width:42px;min-height:44px;padding:0;border:0;border-radius:10px}
.nemap-ai-send{background:#245fc4;color:#fff!important}
.nemap-ai-send:not(:disabled):hover{background:#164ba6}
.nemap-ai-cancel{border:1px solid var(--nai-border);background:var(--nai-soft);color:var(--nai-ink)!important}
.nemap-ai-form-meta{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:6px;font-size:9px;line-height:1.4;color:var(--nai-muted)}
.nemap-ai-counter{flex:0 0 auto;font-variant-numeric:tabular-nums}
.nemap-ai-form-error,.nemap-ai-announcement{margin-top:6px!important;color:var(--nai-muted);font-size:11px;line-height:1.4}
.nemap-ai-form-error{color:var(--nai-error)}
.nemap-ai-form-error:empty,.nemap-ai-announcement:empty{display:none}
.nemap-ai-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.nemap-ai-backdrop{position:fixed;inset:0;z-index:100090;background:#09142380;overscroll-behavior:contain}
.nemap-ai-entry{position:absolute;z-index:1100;left:12px;top:64px;width:max-content;max-width:calc(100% - 24px);pointer-events:auto}
.nemap-ai-entry--fallback{position:fixed}
.nemap-ai-entry--sidebar{position:relative;inset:auto;flex:0 0 auto;width:100%;max-width:none;margin:0;padding:8px 12px 10px;border-bottom:1px solid #d7e0ea;background:#f9fbfe}
html[data-theme=dark] .nemap-ai-entry--sidebar{border-color:#334459;background:#151e29}
html[data-map-style=night] .nemap-ai-entry--sidebar{background:#121b25}
button.nemap-ai-launcher{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;width:auto;min-width:128px;max-width:100%;
  min-height:44px;padding:10px 16px;margin:0;border:1px solid #b79b00;
  border-radius:8px;background:#ffdf00;color:#171b11;font:750 14px/1.25 system-ui,-apple-system,"Segoe UI",sans-serif;
  cursor:pointer;box-shadow:0 3px 12px #16243b29;overflow:visible;white-space:nowrap;
  -webkit-tap-highlight-color:transparent;touch-action:manipulation;
}
button.nemap-ai-launcher .nemap-ai-launcher-symbol{flex:0 0 auto;font-size:19px;line-height:1}
button.nemap-ai-launcher:hover{background:#ffe83d}
button.nemap-ai-launcher[aria-expanded=true]{background:#f2cc00;box-shadow:0 0 0 2px #fff7,0 3px 12px #16243b29}
html[data-theme=dark] button.nemap-ai-launcher{background:#ffdf00;color:#171b11;border-color:#ffe863;box-shadow:0 3px 14px #0007}
html[data-theme=dark] button.nemap-ai-launcher:hover{background:#ffe83d}
.nemap-ai-is-busy .nemap-ai-launcher-symbol{animation:nemap-ai-pulse 1.4s ease-in-out infinite}
.nemap-ai-panel--mobile{border-radius:14px}
.nemap-ai-panel--mobile .nemap-ai-log{padding:14px 13px}
.nemap-ai-panel--mobile .nemap-ai-heading h2{font-size:16px}
.nemap-ai-panel--mobile .nemap-ai-scope{padding:8px 13px!important;font-size:11px}
.nemap-ai-panel--mobile .nemap-ai-input{font-size:16px!important}
.nemap-ai-panel--mobile .nemap-ai-enter-hint{display:none}
.nemap-ai-panel--mobile .nemap-ai-form-meta{justify-content:flex-end}
.nemap-ai-panel--mobile .nemap-ai-form{padding-bottom:max(8px,env(safe-area-inset-bottom))}
.nemap-ai-panel--compact .nemap-ai-header{min-height:48px;padding-block:4px}
.nemap-ai-panel--compact .nemap-ai-heading>span{display:none}
.nemap-ai-panel--compact .nemap-ai-scope{padding-block:5px!important;font-size:10px}
.nemap-ai-panel--compact .nemap-ai-form{padding-block:6px}
.nemap-ai-panel--compact .nemap-ai-form-meta{display:none}
.nemap-ai-panel--compact .nemap-ai-log{gap:14px;padding-block:10px}
.nemap-ai-panel--compact .nemap-ai-context-bar{padding-block:4px}
.nemap-ai-panel--mobile .nemap-ai-context-bar{padding-inline:10px}
.nemap-ai-panel--mobile .nemap-ai-analyze-screen{font-size:10px!important;padding-inline:6px}
@media(max-height:420px){.nemap-ai-header{min-height:48px;padding-block:4px}.nemap-ai-heading>span{display:none}.nemap-ai-scope{padding-block:5px!important;font-size:10px}.nemap-ai-form{padding-block:6px}.nemap-ai-form-meta{display:none}.nemap-ai-log{gap:14px;padding-block:10px}}
@media(pointer:coarse){.nemap-ai-icon-button{min-width:40px;min-height:44px}.nemap-ai-map-action,.nemap-ai-feedback-button{min-height:42px}.nemap-ai-sources>summary{min-height:44px}}
@keyframes nemap-ai-pulse{0%,100%{opacity:.45}50%{opacity:1}}
@media(prefers-reduced-motion:reduce){.nemap-ai-panel *,.nemap-ai-is-busy .nemap-ai-launcher-symbol{animation:none!important;scroll-behavior:auto!important}}

/* Bounded, keyboard-accessible attachment surfaces on the existing production map. */
.nemap-ai-context-attach{display:inline-flex;align-items:center;justify-content:center;min-height:34px;
  padding:4px 9px;margin:4px 6px;border:1px solid #98a7bc;border-radius:7px;
  color:inherit;background:rgba(35,54,76,.9);font:650 11px/1.3 system-ui,sans-serif;
  white-space:nowrap;cursor:pointer;vertical-align:middle}
.map-popover .nemap-ai-context-attach{background:#f0f6fc;color:#18364a;border-color:#bacddd;min-height:36px}
.risk-trend-tooltip .nemap-ai-context-attach,.risk-point-float .nemap-ai-context-attach{min-height:36px}
.nemap-ai-context-attach:focus-visible,.nemap-ai-chart-tools button:focus-visible{outline:3px solid #73aafa;outline-offset:2px}
.nemap-ai-chart-tools{display:flex;align-items:center;flex-wrap:wrap;gap:6px;padding:6px 8px;min-width:0;
  font:11px/1.35 system-ui,sans-serif}
.nemap-ai-chart-tools button{min-height:36px;padding:5px 9px;border:1px solid #98a7bc;border-radius:7px;
  color:inherit;background:transparent;font:650 11px/1.3 system-ui,sans-serif;cursor:pointer}
.nemap-ai-chart-note{flex:1 1 110px;min-width:90px;overflow-wrap:anywhere}
@media(pointer:coarse){.nemap-ai-context-attach,.nemap-ai-chart-tools button{min-height:44px}}

/* Theme-aware launcher; no geometry, visibility, filter or dialog behavior changes. */
button.nemap-ai-launcher{
  --nai-launch-bg:#e7f0f8;--nai-launch-ink:#204c6f;--nai-launch-border:#7a9eb9;
  --nai-launch-hover:#d5e6f4;--nai-launch-open:#c7dfee;
  background:var(--nai-launch-bg);color:var(--nai-launch-ink);border-color:var(--nai-launch-border);
  box-shadow:0 2px 7px #16243b22;
}
button.nemap-ai-launcher:hover{background:var(--nai-launch-hover)}
button.nemap-ai-launcher[aria-expanded=true]{background:var(--nai-launch-open);box-shadow:0 0 0 2px var(--nai-launch-border),0 2px 7px #16243b22}
html[data-theme=dark] button.nemap-ai-launcher{
  --nai-launch-bg:#20364a;--nai-launch-ink:#d6e7f5;--nai-launch-border:#456980;
  --nai-launch-hover:#2b4962;--nai-launch-open:#315771;
  background:var(--nai-launch-bg);color:var(--nai-launch-ink);border-color:var(--nai-launch-border);box-shadow:0 2px 8px #0004;
}
html[data-theme=dark] button.nemap-ai-launcher:hover{background:var(--nai-launch-hover)}
html[data-theme=dark] button.nemap-ai-launcher[aria-expanded=true]{background:var(--nai-launch-open)}
html[data-map-style=night] button.nemap-ai-launcher{
  --nai-launch-bg:#1c2b36;--nai-launch-ink:#cde1ee;--nai-launch-border:#425f72;
  --nai-launch-hover:#293f50;--nai-launch-open:#304d62;
}

/* Assistant no longer covers the settlement search; keep its own left placement. */
@media(min-width:601px){
 html:has(.place-search-control input) .nemap-ai-entry:not(.nemap-ai-entry--sidebar){top:112px!important}
}
@media(max-width:600px){
 html:has(.place-search-control input) .nemap-ai-entry:not(.nemap-ai-entry--sidebar){top:132px!important}
 html:has(.coordinate-panel-card input[placeholder="lat, lng"]) .nemap-ai-entry:not(.nemap-ai-entry--sidebar){top:265px!important}
 /* Complete guidance remains available from the cluster menu ? button.
    A large automatic hint must never obscure bottom source/news controls. */
 .analysis-guide-hint{display:none!important}
}
.coordinate-panel-card::before{
 content:"Пошук координат";display:block;flex:0 0 auto;color:inherit;
 font:700 13px/1.35 system-ui,-apple-system,"Segoe UI",sans-serif;
}
.coordinate-panel-card input[placeholder="lat, lng"]{font-size:13px!important}

/* A screen snapshot is initial guidance, not a permanent second header.
   Once conversation starts, reclaim its space without disabling automatic
   context for the next request. Settings remain reachable by the header icon. */
.nemap-ai-panel>.nemap-ai-context-bar{
  flex:0 0 auto;min-width:0;max-width:100%;padding:12px 16px;
  border-bottom:1px solid var(--nai-border);background:var(--nai-raised);
  color:var(--nai-muted);font-size:12px;line-height:1.45;
  overflow-wrap:anywhere;
}
.nemap-ai-context-label{
  display:flex;align-items:center;gap:8px;min-width:0;
  font-size:12px;font-weight:650;color:var(--nai-ink);cursor:pointer;
}
.nemap-ai-context-label>span{min-width:0;overflow-wrap:anywhere}
.nemap-ai-context-toggle{appearance:auto;accent-color:var(--nai-accent);flex:0 0 auto;
  width:16px;height:16px;margin:0}
.nemap-ai-context-summary{margin-top:7px;margin-left:24px;min-width:0;
  font-size:11.5px;line-height:1.5;color:var(--nai-muted);overflow-wrap:anywhere}
.nemap-ai-analyze-screen{
  display:inline-flex;align-items:center;justify-content:center;margin:9px 0 0 24px;
  max-width:calc(100% - 24px);min-height:36px;padding:7px 12px;
  color:var(--nai-accent)!important;background:var(--nai-soft);
  border:1px solid var(--nai-border);border-radius:8px;font-weight:650!important;
  font-size:11.5px!important;white-space:normal;text-align:center;overflow-wrap:anywhere;
}
.nemap-ai-analyze-screen:hover:not(:disabled){border-color:var(--nai-accent)}
.nemap-ai-context-settings{display:none!important}
.nemap-ai-panel.nemap-ai-has-messages>.nemap-ai-scope{display:none!important}
.nemap-ai-panel.nemap-ai-has-messages:not(.nemap-ai-context-open)>.nemap-ai-context-bar{display:none!important}
.nemap-ai-panel.nemap-ai-has-messages .nemap-ai-context-settings{display:grid!important}
.nemap-ai-panel--mobile>.nemap-ai-context-bar{padding-inline:13px}
.nemap-ai-panel--compact>.nemap-ai-context-bar{padding-block:8px}
@media(max-width:370px){
  .nemap-ai-context-summary{margin-left:0}
  .nemap-ai-analyze-screen{margin-left:0;max-width:100%}
}

/* Selection attachment action. Fixed-positioned because its coordinates
 * are provided as viewport client rects by showSelectionAction(), not relative
 * to the document or to the Leaflet map.
 */
button.nemap-ai-selection-action{
  position:fixed!important;z-index:100150!important;
  display:inline-flex;align-items:center;justify-content:center;
  box-sizing:border-box;
  width:max-content;max-width:calc(100vw - 16px);
  min-height:40px;padding:8px 12px;margin:0;
  border:1px solid #7b9db7;border-radius:9px;
  background:#e7f0f8;color:#204c6f;
  font:700 12px/1.35 system-ui,-apple-system,"Segoe UI",sans-serif;
  text-align:center;white-space:nowrap;
  cursor:pointer;touch-action:manipulation;
  box-shadow:0 5px 20px #0b1b2c55;
}
button.nemap-ai-selection-action:hover{background:#d5e6f4;border-color:#5181a5}
button.nemap-ai-selection-action:focus-visible{
  outline:3px solid #73aafa;outline-offset:2px;
}
button.nemap-ai-selection-action[hidden]{display:none!important}
html[data-theme=dark] button.nemap-ai-selection-action{
  background:#20364a;color:#e0edfa;border-color:#6184a3;
  box-shadow:0 6px 22px #0009;
}
html[data-theme=dark] button.nemap-ai-selection-action:hover{background:#2b4962}
html[data-map-style=night] button.nemap-ai-selection-action{
  background:#1c2b36;color:#d9e8f4;border-color:#526f85;
}
@media(pointer:coarse){
  button.nemap-ai-selection-action{min-height:44px}
}


/* Explicit stop controls for pending search, not an unlabeled square icon.
   Keep the composer on screen during long retrieval/generation. */
.nemap-ai-form .nemap-ai-cancel{
  flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;
  width:auto;min-width:92px;gap:6px;padding:0 12px;white-space:nowrap;
  border:1px solid var(--nai-error);background:var(--nai-soft);
  color:var(--nai-ink)!important;font-size:12px!important;font-weight:750!important;
}
.nemap-ai-cancel-label{display:inline-block}
.nemap-ai-form .nemap-ai-cancel svg{width:15px;height:15px}
.nemap-ai-form .nemap-ai-cancel:hover:not(:disabled){
  background:var(--nai-raised);box-shadow:inset 0 0 0 1px var(--nai-error);
}
@media(max-width:370px){
 .nemap-ai-form .nemap-ai-cancel{min-width:80px;padding-inline:7px;gap:4px}
}


/* Explicit source references. Keep chips legible and removable in both themes.
   This is additive: launcher/map/traffic/assistant selectors remain untouched. */
.nemap-ai-form .nemap-ai-reference-tray:not([hidden]){
  display:flex;flex-wrap:wrap;align-items:center;gap:5px;
  min-width:0;max-width:100%;max-height:96px;overflow-x:hidden;overflow-y:auto;
  margin:0 0 7px;padding:1px 0 2px;
}
.nemap-ai-form .nemap-ai-reference-tray[hidden]{display:none!important}
.nemap-ai-form .nemap-ai-reference-chip{
  display:inline-flex;align-items:center;gap:3px;
  box-sizing:border-box;min-width:0;max-width:100%;min-height:32px;
  padding:2px 3px 2px 9px;border:1px solid var(--nai-border,#77899c);
  border-radius:18px;background:var(--nai-soft,#243b4c);
  color:var(--nai-ink,inherit);font:600 11px/1.35 system-ui,-apple-system,"Segoe UI",sans-serif;
}
.nemap-ai-form .nemap-ai-reference-title{
  display:inline-block;min-width:0;max-width:min(230px,calc(100vw - 125px));
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.nemap-ai-form button.nemap-ai-reference-remove{
  display:inline-flex!important;align-items:center;justify-content:center;
  flex:0 0 auto;box-sizing:border-box;
  width:30px;min-width:30px;height:30px;min-height:30px;
  margin:0;padding:0!important;border:0!important;border-radius:50%;
  color:inherit!important;background:transparent!important;
  font:700 18px/1 system-ui,-apple-system,"Segoe UI",sans-serif!important;
  cursor:pointer;touch-action:manipulation;
}
.nemap-ai-form button.nemap-ai-reference-remove:hover{
  background:var(--nai-raised,#436078)!important;
}
.nemap-ai-form button.nemap-ai-reference-remove:focus-visible{
  outline:2px solid var(--nai-accent,#5aa7dc);outline-offset:1px;
}
.nemap-ai-message-refs{
  margin-top:5px;color:var(--nai-muted,#97a9bd);
  font-size:10.5px;line-height:1.4;overflow-wrap:anywhere;
}
@media(pointer:coarse){
  .nemap-ai-form .nemap-ai-reference-chip{min-height:42px}
  .nemap-ai-form button.nemap-ai-reference-remove{
    width:40px;min-width:40px;height:40px;min-height:40px;
  }
}

/* Context controls stay reachable without occupying the welcome screen. */
.nemap-ai-context-settings{display:grid!important}
.nemap-ai-panel:not(.nemap-ai-context-open)>.nemap-ai-scope,
.nemap-ai-panel:not(.nemap-ai-context-open)>.nemap-ai-context-bar{display:none!important}
