/* Lot Studio viewer.
   Drawing colours are never written here — they arrive with each layer's style
   from the API, which is the one place colour is decided (invariant 14). What
   this file styles is the furniture around the map. */

:root {
  --paper: #ffffff;
  --shell: #f4f2ed;
  --edge: #d9d5cc;
  --ink: #26241f;
  --muted: #6f6a60;
  --accent: #1f5f8b;
  --warn: #9c3140;
  --radius: 6px;
  --bar: 46px;
  --side: 264px;
  --history: 148px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color: var(--ink);
  background: var(--shell);
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 16px; }
h2 { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

button {
  font: inherit;
  padding: 5px 11px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: #b9b4a8; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 2px; }
button.link:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--warn); }
.spacer { flex: 1; }

.chip {
  font-size: 12px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- sign in */

.gate {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
}

.card {
  width: 340px;
  display: grid;
  gap: 12px;
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
}
.card.wide { width: min(620px, 100%); }
.card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.card input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  color: var(--ink);
}
.card p { margin: 0; }

.projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.projects button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  text-align: left;
  padding: 10px 12px;
}
.projects .name { font-weight: 600; }
.projects .meta { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }

/* ------------------------------------------------------------------- app */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--side) 1fr var(--side);
  grid-template-rows: var(--bar) 1fr var(--history);
  grid-template-areas:
    "bar bar bar"
    "left map right"
    "history history history";
}

.bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--edge);
}
.bar h1 { max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.who { font-size: 12px; color: var(--muted); }

.panel {
  overflow: auto;
  padding: 12px;
  background: var(--paper);
}
.panel.left { grid-area: left; border-right: 1px solid var(--edge); }
.panel.right { grid-area: right; border-left: 1px solid var(--edge); }
.panel h2 { margin-bottom: 6px; }

.layers { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.layers li {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 4px 8px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
}
.layers li:hover { background: #faf8f4; border-color: var(--edge); }
.layers .swatch { width: 14px; height: 14px; border-radius: 3px; }
.layers .name { font-size: 13px; }
.layers .count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.layers .opacity { grid-column: 3 / -1; width: 100%; }
.layers input[type="range"] { width: 100%; height: 14px; }
.layers li.hidden .name { color: var(--muted); text-decoration: line-through; }

/* ------------------------------------------------------------------- map */

.map-wrap { grid-area: map; position: relative; background: var(--paper); }
.map { position: absolute; inset: 0; background: var(--paper); }
.map:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.north {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  padding: 4px 0 2px;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}
.north svg { width: 18px; height: 24px; display: block; margin: 0 auto; }

.legend {
  position: absolute;
  top: 10px;
  left: 10px;
  max-width: 210px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  font-size: 12px;
}
.legend h3 { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.legend ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.legend li { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: center; }
.legend .key { height: 12px; border-radius: 2px; }

.readout {
  position: absolute;
  bottom: 8px;
  right: 10px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  font: 12px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--muted);
  pointer-events: none;
}

.status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(38, 36, 31, 0.86);
  color: #fff;
  font-size: 12px;
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}
.status.show { opacity: 1; }

.ol-scale-line { left: 10px; bottom: 8px; background: rgba(255, 255, 255, 0.92); }
.ol-scale-line-inner { color: var(--muted); border-color: var(--muted); }
.ol-zoom { top: 10px; left: unset; right: 52px; }

/* ------------------------------------------------------------ properties */

.properties { display: grid; gap: 10px; }
.properties table { width: 100%; border-collapse: collapse; font-size: 12px; }
.properties th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  padding: 3px 8px 3px 0;
  vertical-align: top;
  white-space: nowrap;
}
.properties td { padding: 3px 0; word-break: break-word; }
.properties .headline { font-size: 15px; font-weight: 600; }
.properties .id { font: 11px ui-monospace, Consolas, monospace; color: var(--muted); }

/* --------------------------------------------------------------- history */

.history {
  grid-area: history;
  overflow: auto;
  padding: 10px 12px;
  background: var(--paper);
  border-top: 1px solid var(--edge);
}
.history header { display: flex; align-items: center; gap: 10px; }
.history ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; }
.history li {
  display: grid;
  grid-template-columns: 46px 74px 1fr auto;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px solid #f0eee9;
}
.history .seq { color: var(--muted); font-variant-numeric: tabular-nums; }
.history .tool { font-weight: 600; }
.history .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.history li.fresh { animation: flash 1.6s ease-out; }
/* Which adapter did it: the browser and the model share one operation layer, and
   the panel says which one was used. */
.history li.actor-mcp .tool { color: var(--accent); }

@keyframes flash {
  from { background: #fdf1cf; }
  to { background: transparent; }
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 210px 1fr;
    grid-template-areas:
      "bar bar"
      "left map"
      "history history";
  }
  .panel.right { display: none; }
}
