:root {
  --night: #0E1A14;        /* field at night: workspace */
  --night-2: #142319;      /* rails */
  --night-3: #1C2F23;      /* inputs, wells */
  --line: #2A4233;
  --paper: #EDE7D8;        /* text */
  --paper-dim: #A9B3A6;
  --wheat: #D6B26A;        /* controls, focus */
  --emerald: #34B37A;      /* Vyom output, only */
  --ember: #E08A3C;        /* last-clear-pass baseline, only */
  --cloud: #C9D3DC;
  --danger: #E06A5A;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Manrope", system-ui, sans-serif;
  --num: "Space Grotesk", "Manrope", sans-serif;
  --r-sm: 6px; --r-md: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow-x: hidden; max-width: 100%; }
body { background: var(--night); color: var(--paper); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--wheat); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 330px 1fr; height: 100vh; overflow: hidden; }
.rail { background: var(--night-2); border-right: 1px solid var(--line); overflow-y: auto; padding: 22px 20px 16px;
        display: flex; flex-direction: column; gap: 18px; }
.brand .wordmark { font: 700 15px/1 var(--num); letter-spacing: .02em; color: var(--paper-dim); }
.brand .dot { color: var(--wheat); }
.brand h1 { font: 600 30px/1.05 var(--serif); margin: 10px 0 6px; letter-spacing: -.01em; }
.brand .sub { margin: 0; color: var(--paper-dim); font-size: 13px; }

.mode-switch { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--night-3); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.tab { border: 0; background: transparent; padding: 7px 2px; border-radius: 8px; cursor: pointer; color: var(--paper-dim); font-weight: 600; font-size: 11.5px; text-align: center; white-space: nowrap; }
.tab.is-on { background: var(--paper); color: var(--night); }
.panel { display: flex; flex-direction: column; gap: 8px; }
.panel[hidden] { display: none; }
.side:empty { display: none; }
.field-label { font-size: 12px; font-weight: 600; color: var(--paper-dim); border: 0; padding: 0; margin: 4px 0 0; }
select, input[type=date], input[type=password] { width: 100%; background: var(--night-3); border: 1px solid var(--line);
        border-radius: var(--r-sm); padding: 9px 10px; }
.hint { margin: 0; color: var(--paper-dim); font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--night-3); padding: 8px 12px; border-radius: var(--r-sm);
       cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; }
.btn:hover { border-color: var(--wheat); }
.btn-primary { background: var(--wheat); color: #1A1406; border-color: var(--wheat); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn.is-active { border-color: var(--wheat); color: var(--wheat); }
.tasks { border: 0; padding: 0; margin: 0; display: grid; gap: 4px; }
.tasks label, .toggle { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--wheat); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 5px 11px; font-size: 12.5px;
              cursor: pointer; color: var(--paper-dim); }
.seg button.is-on { background: var(--night-3); color: var(--paper); border-color: var(--wheat); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }

.summary { background: var(--night-3); border-radius: var(--r-md); padding: 14px; gap: 10px; }
.summary:empty { display: none; }
.summary h2 { font: 600 19px/1.2 var(--serif); margin: 0; }
.summary .where { color: var(--paper-dim); font-size: 12.5px; margin: 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--paper-dim); }
.kv dd { margin: 0; font-family: var(--num); text-align: right; }
.kv dd.v { color: var(--emerald); }
.kv dd.b { color: var(--ember); }
.note { font-size: 12px; color: var(--paper-dim); border-left: 2px solid var(--line); padding-left: 8px; margin: 0; }
.rail-foot { margin-top: auto; font-size: 11px; color: var(--paper-dim); display: grid; gap: 4px; }
.rail-foot a { color: var(--wheat); }

.stage { position: relative; overflow: hidden; }
.map { position: absolute; inset: 0; }
.map-right { clip-path: inset(0 0 0 50%); }
.divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; z-index: 5; cursor: ew-resize; touch-action: none; }
.divider::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--wheat);
                   box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.handle { position: absolute; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 8px; }
.grip { width: 34px; height: 34px; border-radius: 50%; background: var(--wheat); box-shadow: 0 2px 10px rgba(0,0,0,.45);
        display: block; position: relative; }
.grip::before, .grip::after { content: ""; position: absolute; top: 11px; border: 6px solid transparent; }
.grip::before { left: 3px; border-right-color: #1A1406; }
.grip::after { right: 3px; border-left-color: #1A1406; }
.side { white-space: nowrap; font: 600 12px/1 var(--num); padding: 7px 10px; border-radius: 999px; background: rgba(14,26,20,.86);
        backdrop-filter: blur(4px); border: 1px solid var(--line); }
.side-l { border-color: var(--ember); }
.side-r { border-color: var(--emerald); }
.legend { position: absolute; left: 16px; bottom: 28px; z-index: 4; background: rgba(14,26,20,.88); border: 1px solid var(--line);
          border-radius: var(--r-md); padding: 10px 12px; font-size: 12px; max-width: 260px; }
.legend:empty { display: none; }
.legend .ramp { height: 10px; border-radius: 3px; margin: 6px 0 2px;
                background: linear-gradient(90deg, #a50026, #f46d43, #fee08b, #d9ef8b, #66bd63, #006837); }
.legend .ends { display: flex; justify-content: space-between; font-family: var(--num); color: var(--paper-dim); }
.legend .sw { display: grid; grid-template-columns: 12px 1fr; gap: 4px 8px; align-items: center; }
.legend .sw i { width: 12px; height: 12px; border-radius: 3px; display: block; }
.toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); z-index: 100; max-width: min(560px, 92vw); text-align: center; background: var(--paper); color: var(--night);
         padding: 9px 14px; border-radius: var(--r-sm); font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.4); word-break: break-word; }
.toast[hidden] { display: none !important; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.lbl-toggle { font: 700 11.5px var(--sans) !important; width: auto !important; padding: 0 9px !important; color: #1A1406; }
.lbl-toggle[aria-pressed=false] { color: #8a8f8b; text-decoration: line-through; }

/* map search: top-left of the stage, help shown on focus, results only after Enter (Nominatim policy) */
.search { position: absolute; top: 14px; left: 14px; z-index: 7; width: min(440px, calc(100% - 76px)); }
.search-bar { display: flex; align-items: center; gap: 6px; background: rgba(14,26,20,.94); backdrop-filter: blur(6px);
              border: 1px solid var(--line); border-radius: 999px; padding: 5px 5px 5px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.4); }
.search-bar:focus-within { border-color: var(--wheat); }
.search-ico { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--paper-dim); stroke-width: 2; stroke-linecap: round; }
.search-bar input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--paper); font: 500 14.5px var(--sans); padding: 8px 2px; outline: none; }
.search-bar input::placeholder { color: var(--paper-dim); }
.search-bar input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }
.search-go { border: 0; border-radius: 999px; background: var(--wheat); color: #1A1406; font: 700 13px var(--sans); padding: 9px 14px; cursor: pointer; }
.search-me { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: transparent; cursor: pointer;
             display: grid; place-items: center; }
.search-me svg { width: 18px; height: 18px; fill: none; stroke: var(--paper); stroke-width: 2; stroke-linecap: round; }
.search-me:hover, .search-go:hover { filter: brightness(1.08); }
.search-me.is-busy svg { animation: spin 1s linear infinite; }
.search-pop { margin-top: 8px; background: rgba(14,26,20,.97); border: 1px solid var(--line); border-radius: var(--r-md);
              box-shadow: 0 14px 40px rgba(0,0,0,.45); overflow: hidden; max-height: min(62vh, 520px); overflow-y: auto; }
.search-pop[hidden] { display: none; }
.search-list { list-style: none; margin: 0; padding: 4px; }
.search-list:empty { display: none; }
.search-list li { padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; display: grid; gap: 2px; }
.search-list li[aria-selected=true], .search-list li:hover { background: var(--night-3); }
.search-list li b { font-weight: 700; font-size: 14px; }
.search-list li span { font-size: 12.5px; color: var(--paper-dim); }
.search-list li.msg { cursor: default; color: var(--paper-dim); font-size: 13px; }
.search-list li.msg:hover { background: transparent; }
.search-help { padding: 14px 16px 12px; font-size: 13px; color: var(--paper-dim); border-top: 1px solid var(--line); }
.search-list:empty + .search-help { border-top: 0; }
.search-help b { color: var(--paper); font: 600 15px var(--serif); }
.search-help ol { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 7px; line-height: 1.5; }
.search-help li span { color: var(--paper); font-weight: 600; }
.search-help .eg { border: 1px dashed var(--line); background: transparent; color: var(--wheat); font: 600 12.5px var(--num);
                   padding: 1px 6px; border-radius: 6px; cursor: pointer; }
.search-attr { margin: 0; padding: 8px 16px 10px; font-size: 10.5px; color: var(--paper-dim); border-top: 1px solid var(--line); }
.pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; background: var(--wheat); transform: rotate(-45deg);
       border: 2px solid #1A1406; box-shadow: 0 3px 10px rgba(0,0,0,.5); }


.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 400px; max-width: 100vw; background: var(--night-2);
          border-left: 1px solid var(--line); padding: 22px 20px; overflow-y: auto; z-index: 10;
          transform: translateX(0); transition: transform .28s cubic-bezier(.2,.7,.2,1); }
.drawer[hidden] { display: block; transform: translateX(105%); visibility: hidden; }
.drawer h2 { font: 600 24px/1.15 var(--serif); margin: 0 0 12px; padding-right: 30px; }
.drawer h3 { font-size: 13px; font-weight: 700; margin: 18px 0 6px; display: flex; align-items: center; gap: 6px; }
.close { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
         background: transparent; cursor: pointer; font-size: 18px; line-height: 1; }
.info { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); background: transparent; font-size: 11px;
        cursor: pointer; padding: 0; color: var(--paper-dim); }
.facts { display: grid; grid-template-columns: 1fr auto; gap: 5px 14px; margin: 0; font-size: 13px; }
.facts dt { color: var(--paper-dim); }
.facts dd { margin: 0; font-family: var(--num); text-align: right; }
.chart-box { background: var(--night-3); border-radius: var(--r-md); padding: 10px; }
.exports { display: grid; gap: 8px; margin-top: 18px; }

dialog { background: var(--night-2); color: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); max-width: 460px; padding: 22px; }
dialog::backdrop { background: rgba(4,8,6,.6); }
dialog h2 { font: 600 22px/1.2 var(--serif); margin: 0 0 8px; }
dialog p, dialog li { color: var(--paper-dim); font-size: 13px; }
dialog ul { padding-left: 18px; display: grid; gap: 6px; }
dialog li b { color: var(--paper); }
dialog .row { justify-content: flex-end; margin-top: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 60vh; height: auto; overflow: visible; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage { height: 60vh; }
  .drawer { width: 100vw; }
}
@media (max-width: 520px) { .search { left: 10px; top: 10px; width: calc(100% - 64px); } .search-go { display: none; } }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

/* ---- v1.2: accounts, field marking, results ---- */
.card { background: var(--night-3); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; display: grid; gap: 10px; }
.card h2 { font: 600 18px/1.2 var(--serif); margin: 0; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
input[type=text] { width: 100%; background: var(--night-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 10px; }
.account { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; }
.account img { width: 34px; height: 34px; border-radius: 50%; background: var(--night-3); object-fit: cover; }
.account img:not([src]), .account img[src=""] { visibility: hidden; }
.account b { display: block; font-size: 13.5px; }
.area-line { margin: 0; font-size: 13px; color: var(--paper-dim); }
.area-line b { font-family: var(--num); color: var(--paper); }
.land-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.land-list li button.land { width: 100%; text-align: left; background: var(--night-3); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; }
.land-list li button.land:hover, .land-list li button.land[aria-current=true] { border-color: var(--wheat); }
.land-list .nm { font-weight: 700; }
.land-list .meta { font-size: 12px; color: var(--paper-dim); }
.land-list .keyrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--night-3);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; }
.keybox { background: var(--night-2); border: 1px dashed var(--wheat); border-radius: var(--r-sm); padding: 10px; display: grid; gap: 6px; }
.keybox code { font-family: var(--num); word-break: break-all; color: var(--wheat); }
.curl summary { cursor: pointer; font-size: 12.5px; color: var(--paper-dim); }
.curl pre { white-space: pre-wrap; word-break: break-all; font-size: 11.5px; background: var(--night-3); padding: 10px; border-radius: var(--r-sm); }
.busy { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; gap: 10px; align-items: center;
  background: var(--paper); color: var(--night); padding: 10px 16px; border-radius: 999px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  max-width: min(560px, 92vw); white-space: nowrap; }
.busy[hidden] { display: none !important; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(14,26,20,.25); border-top-color: var(--night); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.vtx { width: 14px; height: 14px; border-radius: 50%; background: var(--wheat); border: 2px solid #1A1406; cursor: grab; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.mid { width: 9px; height: 9px; border-radius: 50%; background: rgba(214,178,106,.55); border: 1px solid #1A1406; cursor: copy; }
.divider[hidden] { display: none; }
.drawer h3 { font-size: 13px; font-weight: 700; margin: 18px 0 6px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tiles figure { margin: 0; }
.tiles img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; display: block; background: var(--night-3); }
.tiles figcaption { font-size: 11.5px; color: var(--paper-dim); margin-top: 4px; line-height: 1.35; }
.tiles figcaption b { color: var(--paper); font-weight: 600; display: block; }
.verdict { border-left: 3px solid var(--wheat); padding: 6px 10px; margin: 12px 0 0; font-size: 13px; background: var(--night-3); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.actions { display: grid; gap: 8px; margin-top: 14px; }
.runlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 12.5px; }
.runlist li { background: var(--night-3); border-radius: var(--r-sm); padding: 8px 10px; cursor: pointer; }
.runlist li:hover { outline: 1px solid var(--wheat); }
.danger { color: var(--danger); border-color: rgba(224,106,90,.4); }

.rail [hidden], .keybox[hidden] { display: none !important; }
.btn-primary.is-active { color: #1A1406; box-shadow: 0 0 0 2px var(--night-2), 0 0 0 4px var(--wheat); }
a.btn { color: var(--paper); }
a.btn-primary { color: #1A1406; }
.stack { display: grid; gap: 8px; margin: 0; }
.stack[hidden] { display: none; }
input[type=email] { width: 100%; background: var(--night-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 10px; }
#code-input { font-family: var(--num); letter-spacing: .3em; font-size: 18px; }

/* ---- Segmented Land Crop Panel (R1) ---- */
#crop-preview-box.crop-card {
  margin-top: 8px;
  background: var(--night-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.crop-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.crop-header .field-label {
  margin: 0;
  color: var(--paper);
  font-weight: 600;
  font-size: 13px;
}
.crop-header .hint {
  font-size: 11.5px;
  color: var(--paper-dim);
  font-family: var(--num);
}
.crop-frame {
  background: repeating-conic-gradient(#142319 0% 25%, #1C2F23 0% 50%) 50% / 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  max-height: 240px;
  padding: 8px;
}
.crop-img {
  /* a field is often only a few 10 m pixels across: scale the crop up to the card, with crisp pixels */
  width: 100%;
  height: 220px;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.45));
  display: block;
}
.crop-legend {
  font-size: 11.5px;
  color: var(--paper-dim);
}
.crop-legend .ramp {
  height: 8px;
  border-radius: 999px;
  margin: 4px 0 2px;
  background: linear-gradient(90deg, #A50026, #D73027, #F46D43, #FDAE61, #FEE08B, #FFFFBF, #D9EF8B, #A6D96A, #66BD63, #1A9850, #006837);
}
.crop-legend .ends {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-family: var(--num);
  color: var(--paper-dim);
}
.crop-legend .sw {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 11px;
}
.crop-legend .sw i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ------------------------------------------------------------------ Chat Panel (#p-chat) */
#p-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100vh - 170px);
}
#p-chat[hidden] {
  display: none !important;
}

.chat-ctx-card {
  background: var(--night-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-ctx-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
#chat-ctx-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-ctx-badge {
  font-size: 10.5px;
  font-family: var(--num);
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(52, 179, 122, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(52, 179, 122, 0.35);
  white-space: nowrap;
}
.chat-ctx-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 11.5px;
  color: var(--paper-dim);
  font-family: var(--num);
}
.chat-ctx-meta span {
  white-space: nowrap;
}
#chat-ctx-hint {
  font-size: 11px;
  margin: 0;
  color: var(--paper-dim);
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 90px;
  overflow-y: auto;
}
.chat-chip {
  background: var(--night-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11.5px;
  color: var(--paper-dim);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.chat-chip:hover {
  border-color: var(--wheat);
  color: var(--paper);
  background: rgba(214, 178, 106, 0.1);
}

.chat-messages {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 4px 6px 0;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: fadeInMsg 0.2s ease-out;
}
@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
  align-self: flex-end;
}
.chat-msg.user .chat-bubble {
  background: #253D2C;
  border: 1px solid var(--wheat);
  color: var(--paper);
  border-radius: 10px 10px 2px 10px;
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.assistant {
  align-self: flex-start;
  max-width: 95%;
}
.chat-msg.assistant .chat-bubble {
  background: var(--night-3);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: 10px 10px 10px 2px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  word-break: break-word;
}
.chat-msg.assistant .chat-bubble b,
.chat-msg.assistant .chat-bubble strong {
  color: var(--wheat);
}
.chat-msg.assistant .chat-bubble p {
  margin: 0 0 6px;
}
.chat-msg.assistant .chat-bubble p:last-child {
  margin: 0;
}
.chat-msg.assistant .chat-bubble ul {
  margin: 4px 0 6px;
  padding-left: 16px;
}
.chat-msg.assistant .chat-bubble li {
  margin-bottom: 2px;
}
.chat-msg.assistant .chat-provider {
  font-size: 10px;
  color: var(--paper-dim);
  margin-top: 3px;
  font-family: var(--num);
}

.chat-msg.loading .chat-bubble {
  background: var(--night-3);
  border: 1px dashed var(--line);
  color: var(--paper-dim);
  padding: 8px 12px;
  font-size: 12px;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-dot-flashing {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--wheat);
  animation: dotFlashing 1s infinite alternate;
}
@keyframes dotFlashing {
  0% { opacity: 0.2; }
  100% { opacity: 1; }
}

.chat-form {
  margin-top: auto;
}
#chat-input-bar {
  display: flex;
  gap: 6px;
  align-items: center;
}
#chat-input {
  flex: 1;
  background: var(--night-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--paper);
}
#chat-input:focus {
  border-color: var(--wheat);
}
#btn-chat-send {
  padding: 8px 14px;
  font-size: 12.5px;
  white-space: nowrap;
}

/* ======================================================================================================
   Vyom Earth (v2): the map is the whole screen, a globe at low zoom; panels float over it as glass.
   ====================================================================================================== */
:root { --glass: rgba(7, 12, 21, .84); --glass-line: rgba(255, 255, 255, .09); --space: #03050A; }
body { background: var(--space); overflow: hidden; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; color: inherit; }
a.btn-primary { color: #1A1406; }
.lnk { color: var(--wheat); }
.app { display: block; position: relative; height: 100vh; height: 100svh; overflow: hidden; grid-template-columns: none; }
.stage { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 55%, #08121F 0%, var(--space) 70%); }
.map { background: transparent; }

.topbar { position: absolute; top: 0; left: 0; right: 0; height: 58px; z-index: 12; display: flex; align-items: center; gap: 10px;
          padding: 0 12px; background: linear-gradient(to bottom, rgba(3, 5, 10, .88), rgba(3, 5, 10, 0)); pointer-events: none; }
.topbar > * { pointer-events: auto; }
.tb-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--glass-line); background: var(--glass); display: grid; place-items: center;
          cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tb-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--paper); stroke-width: 1.8; stroke-linecap: round; }
.tb-brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--paper); }
.tb-brand svg { width: 26px; height: 26px; }
.tb-brand span { font: 600 20px/1 var(--serif); letter-spacing: -.01em; }
.tb-brand i { font-style: italic; font-weight: 500; color: var(--wheat); }
.tb-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tb-link { text-decoration: none; color: var(--paper); font-weight: 700; font-size: 13.5px; padding: 8px 14px; border-radius: 999px;
           border: 1px solid var(--glass-line); background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tb-link:hover { border-color: var(--wheat); }
.tb-cta { background: var(--wheat); color: #1A1406; border-color: var(--wheat); }

.rail { position: absolute; top: 64px; left: 12px; bottom: 12px; width: 344px; z-index: 11; border: 1px solid var(--glass-line); border-right: 1px solid var(--glass-line);
        border-radius: 18px; background: var(--glass); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
        box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8); padding: 18px 16px 14px; transition: transform .28s cubic-bezier(.2, .7, .2, 1), opacity .2s; }
.app.rail-closed .rail { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
.brand h1 { font: 600 26px/1.05 var(--serif); margin: 0 0 4px; }
.search { top: 9px; left: 232px; width: min(440px, calc(100% - 460px)); z-index: 13; }
.search-bar { background: var(--glass); border-color: var(--glass-line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.search-pop { background: rgba(7, 12, 21, .97); border-color: var(--glass-line); }
.maplibregl-ctrl-top-right { top: 58px; }
.maplibregl-ctrl-group { background: var(--glass) !important; border: 1px solid var(--glass-line); backdrop-filter: blur(10px); }
.maplibregl-ctrl-group button + button { border-top-color: var(--glass-line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(1.6); }
.lbl-toggle { color: var(--paper) !important; }
.lbl-toggle[aria-pressed=false] { color: #6f7889 !important; }
.drawer { top: 64px; right: 12px; bottom: 12px; height: auto; width: 400px; border-radius: 18px; border: 1px solid var(--glass-line);
          background: var(--glass); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8); }
.drawer[hidden] { transform: translateX(calc(100% + 24px)); }
.legend { left: 368px; bottom: 34px; background: var(--glass); border-color: var(--glass-line); backdrop-filter: blur(10px); transition: left .28s; }
.app.rail-closed .legend { left: 12px; }
.coords { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 4; font: 600 11px/1 var(--num); color: rgba(237, 231, 216, .75);
          background: rgba(3, 5, 10, .55); padding: 5px 10px; border-radius: 999px; pointer-events: none; white-space: nowrap; letter-spacing: .02em; }
.coords:empty { display: none; }
.card { background: rgba(28, 47, 35, .0); background: rgba(255, 255, 255, .035); border-color: var(--glass-line); }
.rail select, .rail input[type=date], .rail input[type=text], .drawer input[type=date] { background: rgba(0, 0, 0, .3); border-color: var(--glass-line); }
.mode-switch { background: rgba(0, 0, 0, .3); }

@media (max-width: 900px) {
  .app { display: block; height: 100vh; height: 100svh; overflow: hidden; grid-template-rows: none; }
  .stage { height: auto; }
  .rail { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 52vh; border-radius: 18px; }
  .app.rail-closed .rail { transform: translateY(calc(100% + 20px)); }
  .search { top: 58px; left: 10px; right: 10px; width: auto; }
  .maplibregl-ctrl-top-right { top: 108px; }
  .drawer { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: 100vw; max-height: 78vh; border-radius: 18px 18px 0 0; }
  .drawer[hidden] { transform: translateY(105%); }
  .legend, .app.rail-closed .legend { left: 10px; bottom: auto; top: 108px; }
  .app:not(.rail-closed) .coords { display: none; }
  .tb-brand span { font-size: 18px; }
}
@media (max-width: 520px) { .search { left: 10px; top: 58px; width: auto; right: 10px; } }

.stage .stars { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.stage .map { z-index: 1; }
@media (max-width: 900px) { .coords { bottom: 34px; } }

/* ---- Phones: one bottom sheet at a time, map layers float over the map ---- */
.sheet-handle { display: none; }
.m-layers { display: none; }
@media (max-width: 900px) {
  .drawer { z-index: 12; max-height: 42vh; max-height: 42svh; padding-top: 30px; transition: max-height .28s cubic-bezier(.2,.7,.2,1), transform .28s cubic-bezier(.2,.7,.2,1); }
  .drawer.full { max-height: 88vh; max-height: 88svh; }
  .sheet-handle { display: block; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 120px; height: 28px;
                  border: 0; background: transparent; cursor: pointer; padding: 0; }
  .sheet-handle span { display: block; width: 44px; height: 5px; margin: 10px auto 0; border-radius: 5px; background: rgba(237,231,216,.45); }
  .drawer .close { top: 10px; right: 10px; }
  .drawer h2 { font-size: 21px; padding-right: 40px; }
  .m-layers { display: block; position: absolute; top: 112px; left: 10px; right: 58px; z-index: 6; }
  .m-layers:empty { display: none; }
  .m-layers #layer-box { margin: 0; padding: 10px; gap: 6px; border-radius: 14px; border: 1px solid var(--glass-line);
                         background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
  .m-layers #layer-box .field-label { font-size: 10.5px; margin: 0; }
  .m-layers #layer-box .seg { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .m-layers #layer-box .seg::-webkit-scrollbar { display: none; }
  .m-layers #layer-box .seg button { flex: none; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
  .m-layers .crop-card { padding: 6px; gap: 4px; }
  .m-layers .crop-frame { overflow: hidden; display: flex; justify-content: center; }
  .m-layers .crop-img { width: 100%; height: 24vh; height: 24svh; margin: 0 auto; display: block; }
  .m-layers .crop-legend { font-size: 10.5px; }
  .legend, .app.rail-closed .legend { top: auto; bottom: calc(42vh + 12px); bottom: calc(42svh + 12px); left: 10px; max-width: 70vw; font-size: 11px; padding: 8px 10px; }
  .maplibregl-ctrl-top-right { top: 108px; }
  .divider .side { font-size: 10.5px; padding: 5px 8px; }
}
@media (max-width: 900px) {
  .m-layers .crop-card .crop-header { cursor: pointer; }
  .m-layers .crop-card .crop-header::after { content: "Hide ▴"; font: 700 11px var(--num); color: var(--wheat); margin-left: auto; }
  .m-layers .crop-card.shut .crop-header::after { content: "Show ▾"; }
  .m-layers .crop-card.shut .crop-frame, .m-layers .crop-card.shut .crop-legend { display: none; }
  .m-layers .crop-frame { max-height: 26vh; max-height: 26svh; }
  .m-layers .crop-img { max-height: 24vh; max-height: 24svh; }
}
