/* ==========================================================================
   KROVEN DESIGN SYSTEM
   Warm graphite, one electric-lime accent, and the agent colours. Two
   typefaces, self-hosted (SIL OFL, licences in /fonts):
     Bricolage Grotesque  - the wordmark, numbers, headings
     Instrument Sans      - everything you read
   No gradients. Light comes from the devices themselves: glow is the only
   ornament, and it means something (live watts).
   ========================================================================== */

@font-face {
  font-family: "Bricolage";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/bricolage-grotesque-latin-wght-normal.woff2) format("woff2-variations");
}
@font-face {
  font-family: "Instrument";
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url(fonts/instrument-sans-latin-wght-normal.woff2) format("woff2-variations");
}

:root {
  color-scheme: dark;
  /* surfaces, darkest to lightest */
  --bg: #12110f;
  --bg-2: #181714;
  --surface: #1f1d1a;
  --surface-2: #272420;
  --hover: #2e2b26;
  --line: #34302a;
  --line-strong: #4a443b;
  /* ink */
  --ink: #f3efe7;
  --ink-2: #bdb5a7;
  --ink-3: #8a8275;
  /* the one accent: actions, focus, "yes" */
  --accent: #d6ff3d;
  --accent-ink: #12110f;
  --accent-tint: rgba(214, 255, 61, 0.12);
  /* meaning */
  --warn: #ff9e4f;
  --warn-tint: rgba(255, 158, 79, 0.12);
  --danger: #ff6b5b;
  --danger-tint: rgba(255, 107, 91, 0.12);
  /* agents (unchanged from before, so a device keeps its colour) */
  --solar: #e0a44e;
  --battery: #54c98c;
  --grid: #a98ce8;
  --forecast: #e8749f;
  --you: #7fb0ff;

  --display: "Bricolage", ui-sans-serif, system-ui, sans-serif;
  --body: "Instrument", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --r-card: 16px;
  --r-control: 10px;
  --r-chip: 7px;
  --shadow-card: 0 0 0 1px var(--line), 0 18px 40px rgba(0, 0, 0, 0.45);
  --shadow-hairline: 0 0 0 1px var(--line);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 14px; border: 0; border-radius: 999px;
  font-weight: 600; font-size: 13.5px; line-height: 1; white-space: nowrap;
  transition: transform .15s ease-out, background-color .15s, opacity .15s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #e3ff74; }
.btn-quiet { background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow-hairline); }
.btn-quiet:hover { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); background: var(--hover); }
.btn-danger { background: var(--danger); color: #1a0d0b; }
.btn-ok { background: var(--surface-2); color: var(--accent); box-shadow: 0 0 0 1px rgba(214,255,61,.35); }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.field {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--r-control);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font-size: 16px;
}
.field:focus { border-color: var(--accent); outline: none; }
.field::placeholder { color: var(--ink-3); }
label.lab { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 14px 0 6px; }

/* ================================================================ SPLASH */
#splash {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-b)); background: var(--bg); z-index: 50;
}
.wordmark { font-family: var(--display); font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
#splash .wordmark { font-size: clamp(56px, 13vw, 96px); margin: 0 0 36px; }
#splash .wordmark i { font-style: normal; color: var(--accent); }
.auth { width: min(360px, 100%); }
.auth-row { position: relative; margin-bottom: 10px; }
.auth-row .field { padding-right: 52px; }
.auth-go {
  position: absolute; right: 5px; top: 5px; width: 36px; height: 36px; border-radius: 9px; border: 0;
  background: var(--surface-2); color: var(--ink-3); display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, transform .15s;
}
.auth-go.ready { background: var(--accent); color: var(--accent-ink); }
.auth-go:active { transform: scale(.94); }
.auth-eye { position: absolute; right: 46px; top: 5px; width: 36px; height: 36px; border: 0; background: none; color: var(--ink-3); }
.auth-pass .field { padding-right: 92px; }
.auth-msg { min-height: 22px; font-size: 13.5px; color: var(--ink-2); text-align: center; margin-top: 4px; }
.auth-msg.bad { color: var(--danger); }
.auth-switch { display: block; margin: 8px auto 0; background: none; border: 0; color: var(--ink-2); font-size: 14px; padding: 10px; }
.auth-switch b { color: var(--ink); font-weight: 600; }
.legal { position: absolute; bottom: calc(14px + var(--safe-b)); left: 0; right: 0; text-align: center; font-size: 12px; color: var(--ink-3); }
.legal a { color: var(--ink-3); margin: 0 6px; }
.legal a:hover { color: var(--ink); }

/* ================================================================= STAGE */
#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; background: var(--bg); }
#map { position: absolute; inset: 0; }
#plain {
  position: absolute; inset: 0;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M48 0H0V48' fill='none' stroke='%231c1b18' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 48px 48px;
}
/* the plain floor when no address is set: a hairline grid and the home's outline */
#plain .home-outline {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%);
  width: min(78vw, 640px); height: min(52vh, 420px);
  border: 1.5px solid var(--line-strong); border-radius: 22px;
}
#plain .home-outline > span {
  position: absolute; top: -11px; left: 18px; padding: 0 8px; background: var(--bg);
  font: 600 12px var(--body); color: var(--ink-3); letter-spacing: .02em;
}

/* --------------------------------------------------------- the device blip */
.blip {
  --c: var(--you); --g: 0; --size: 16px; --period: 2.6s;
  position: absolute; transform: translate(-50%, -50%);
  width: 64px; height: 64px; border: 0; padding: 0; background: none;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.mapboxgl-marker.blip { position: absolute; }
.blip .core {
  width: var(--size); height: var(--size); border-radius: 50%;
  background: var(--c);
  box-shadow:
    0 0 0 3px var(--bg),
    0 0 calc(8px + 22px * var(--g)) calc(2px + 6px * var(--g)) color-mix(in srgb, var(--c) calc(45% + 45% * var(--g)), transparent),
    0 0 calc(30px + 70px * var(--g)) calc(6px + 22px * var(--g)) color-mix(in srgb, var(--c) calc(12% + 26% * var(--g)), transparent);
  transition: width .4s var(--ease), height .4s var(--ease), box-shadow .6s var(--ease);
  position: relative; z-index: 1;
}
.blip .ring {
  position: absolute; left: 50%; top: 50%; width: var(--size); height: var(--size);
  margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2); border-radius: 50%;
  border: 2px solid var(--c); opacity: 0;
  animation: pulse var(--period) var(--ease) infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: calc(.25 + .55 * var(--g)); }
  100% { transform: scale(calc(2 + 1.6 * var(--g))); opacity: 0; }
}
.blip.off .core { background: var(--bg); box-shadow: inset 0 0 0 2.5px var(--c), 0 0 0 3px var(--bg); }
.blip.off .ring, .blip.unknown .ring { animation: none; }
.blip.unknown .core { background: var(--bg); box-shadow: inset 0 0 0 2px var(--ink-3), 0 0 0 3px var(--bg); }
.blip.waiting .core::after {
  content: ""; position: absolute; right: -4px; top: -4px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--bg);
}
.blip .tag {
  position: absolute; top: calc(50% + var(--size) / 2 + 8px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--ink);
  padding: 3px 8px; border-radius: 999px; background: rgba(18, 17, 15, .82); box-shadow: var(--shadow-hairline);
  pointer-events: none;
}
.blip .tag b { font-family: var(--display); font-weight: 600; color: var(--c); margin-left: 4px; font-variant-numeric: tabular-nums; }
.blip.unknown .tag b, .blip.off .tag b { color: var(--ink-3); }
.blip .tag { display: flex; align-items: baseline; max-width: 170px; }
.blip .tag .nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.blip .tag b { flex: none; }
.blip.selected .core { outline: 2px solid var(--ink); outline-offset: 5px; }
@media (prefers-reduced-motion: reduce) { .blip .ring { animation: none; } }

.home-pin {
  width: 14px; height: 14px; border-radius: 4px; background: var(--bg);
  box-shadow: 0 0 0 2px var(--ink-3); transform: rotate(45deg);
}

/* ================================================================ TOP BAR */
#top {
  position: absolute; z-index: 20; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + var(--safe-t)) 10px 8px;
  pointer-events: none;
}
#top > * { pointer-events: auto; }
#top .wordmark { font-size: 22px; padding: 0 4px; }
#top .wordmark i { font-style: normal; color: var(--accent); }
#top .spacer { flex: 1; pointer-events: none; }
.now {
  font-size: 13px; color: var(--ink-2); padding: 7px 12px; border-radius: 999px;
  background: rgba(18, 17, 15, .82); box-shadow: var(--shadow-hairline);
}
.now b { font-family: var(--display); color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
#bell { position: relative; }
#bell .n {
  position: absolute; top: 7px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font: 700 10px/16px var(--body); text-align: center;
}
#bell .n:empty { display: none; }

/* ================================================================ ASK BAR */
#ask {
  position: absolute; z-index: 25; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + var(--safe-b)); width: min(560px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
#ask > * { pointer-events: auto; }
#convo {
  max-height: min(58vh, 520px); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: rgba(24, 23, 20, .96); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  scrollbar-width: thin;
}
#convo .convo-h { display: flex; align-items: center; justify-content: space-between; margin: -4px -4px 0 0; }
#convo .convo-h span { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.askbar {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 16px;
  background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-card);
}
.askbar input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; height: 40px; }
.askbar input::placeholder { color: var(--ink-3); }
.askbar .send {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s;
}
.askbar .send.ready { background: var(--accent); color: var(--accent-ink); }

.msg { max-width: 92%; font-size: 15px; line-height: 1.5; animation: rise .26s var(--ease) both; }
.msg.me { align-self: flex-end; background: var(--surface-2); padding: 8px 12px; border-radius: 14px 14px 4px 14px; color: var(--ink); }
.msg.kv { align-self: flex-start; color: var(--ink); }
.msg.kv::before { content: "kroven"; display: block; font: 700 11px var(--display); color: var(--accent); letter-spacing: -0.01em; margin-bottom: 2px; }
.thinking { align-self: flex-start; display: inline-flex; gap: 5px; padding: 8px 2px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: dot 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg, .kui { animation: none !important; } }

/* ============================================================ DEVICE POP */
#pop {
  position: absolute; z-index: 30; width: 320px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - 196px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  animation: rise .22s var(--ease) both;
}
.pop-h { display: flex; align-items: flex-start; gap: 10px; padding: 14px 10px 0 16px; }
.pop-h .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); margin-top: 7px; box-shadow: 0 0 12px var(--c); flex: none; }
.pop-h h2 { font: 650 19px/1.25 var(--display); letter-spacing: -0.02em; margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pop-h .icon-btn { width: 36px; height: 36px; margin-top: -4px; }
.pop-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); box-shadow: var(--shadow-hairline);
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink-3)); }
.pop-watts { display: flex; align-items: baseline; gap: 8px; padding: 14px 16px 4px; }
.pop-watts .big { font: 600 40px/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.pop-watts .unit { font-size: 14px; color: var(--ink-2); }
.pop-watts .st { margin-left: auto; font-size: 13px; color: var(--ink-2); }
.pop-ctl { padding: 8px 16px 0; }
.switchrow { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 10px; }
.switch {
  position: relative; width: 52px; height: 30px; border-radius: 999px; border: 0; background: var(--line-strong);
  transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); transition: transform .25s var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(22px); background: var(--accent-ink); }
.presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 3px; border-radius: 12px; background: var(--bg-2); box-shadow: var(--shadow-hairline); }
.presets button {
  min-height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2);
  font: 600 13px var(--display); font-variant-numeric: tabular-nums;
}
.presets button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }
.presets button:disabled { color: var(--line-strong); cursor: not-allowed; }
.hint { font-size: 12.5px; color: var(--ink-3); margin: 6px 0 0; }
.pop-wait { margin: 12px 16px 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-tint); font-size: 13.5px; }
.pop-wait .row { display: flex; gap: 6px; margin-top: 8px; }
#pop > * { flex: none; }
/* The conversation takes whatever height is left, and scrolls on its own,
   so the device's name and controls never scroll out of view. */
#pop > .pop-chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.pop-chat { margin-top: 14px; border-top: 1px solid var(--line); padding: 10px 12px 12px; }
.pop-chat .out {
  display: flex; flex-direction: column; gap: 8px; margin: 0 -4px 8px; padding: 0 4px;
  flex: 1 1 auto; min-height: 120px; overflow-y: auto; overscroll-behavior: contain;
}
#pop:has(.out:not(:empty)) { width: 380px; }
#pop.steady { animation: none; }
#pop .msg { font-size: 14px; }
#pop .msg.me { max-width: 85%; }
#pop, #convo, .pop-chat .out { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.pop-chat .out:empty { display: none; }
.pop-chat .askbar { box-shadow: var(--shadow-hairline); background: var(--bg-2); }
.pop-chat .askbar input { height: 34px; font-size: 15px; }
.pop-chat .askbar .send { width: 34px; height: 34px; }

/* =============================================================== SHEETS */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 9, 8, .6); animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
#menu {
  position: fixed; z-index: 41; top: 0; bottom: 0; left: 0; width: min(380px, 100vw);
  background: var(--bg-2); box-shadow: 1px 0 0 var(--line); overflow-y: auto;
  padding: calc(10px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  animation: slide .28s var(--ease) both;
}
@keyframes slide { from { transform: translateX(-100%); } }
.menu-h { display: flex; align-items: center; justify-content: space-between; margin: 0 -6px 6px 0; }
.menu-h .wordmark { font-size: 24px; }
.menu-h .wordmark i { font-style: normal; color: var(--accent); }
.sec { padding: 16px 0; border-top: 1px solid var(--line); }
.sec:first-of-type { border-top: 0; }
.sec-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sec h3 { font: 650 15px var(--display); letter-spacing: -0.01em; margin: 0; }
.sec p { margin: 0; color: var(--ink-2); font-size: 14px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li > button, .list li > div {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 8px; margin: 0 -8px; border: 0; border-radius: 10px; background: none; min-height: 48px;
}
.list li > button:hover { background: var(--surface); }
.list .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.list .t { flex: 1; min-width: 0; }
.list .t b { display: block; font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .t small { display: block; font-size: 12.5px; color: var(--ink-3); }
.list .w { font: 600 14px var(--display); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 999px; background: var(--bg); box-shadow: var(--shadow-hairline); }
.seg button { border: 0; background: none; color: var(--ink-2); padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack > * + * { margin-top: 8px; }
.okmsg { font-size: 13.5px; color: var(--ink-2); min-height: 20px; margin-top: 8px; }
.okmsg.bad { color: var(--danger); }

#notes {
  position: fixed; z-index: 41; top: calc(56px + var(--safe-t)); right: 10px; width: 340px; max-width: calc(100vw - 20px);
  max-height: 60vh; overflow-y: auto; padding: 12px 14px; border-radius: var(--r-card);
  background: var(--surface); box-shadow: var(--shadow-card); animation: rise .2s var(--ease) both;
}

.empty {
  position: absolute; z-index: 15; left: 50%; top: 46%; transform: translate(-50%, -50%);
  text-align: center; color: var(--ink-2);
}
.empty p { margin: 0 0 12px; font: 600 18px var(--display); color: var(--ink); }

#modal { position: fixed; z-index: 45; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }

#toast {
  position: fixed; z-index: 60; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%);
  padding: 9px 14px; border-radius: 999px; background: var(--surface-2); box-shadow: var(--shadow-card);
  font-size: 14px; animation: rise .2s var(--ease) both; max-width: calc(100vw - 24px);
}

/* ================================================================ PHONES */
@media (max-width: 640px) {
  #top .now { display: none; }
  #pop {
    left: 8px !important; right: 8px; top: auto !important; width: auto !important; max-width: none;
    bottom: calc(76px + var(--safe-b)); max-height: calc(100dvh - 190px); overflow-y: auto;
  }
  #ask { width: calc(100vw - 16px); bottom: calc(8px + var(--safe-b)); }
  #convo { max-height: 52dvh; }
  body.popping #convo { display: none; }
  #menu { width: 100vw; }
}

/* ==========================================================================
   CHAT COMPONENTS (kroven-ui.js) - ported from Beautiful UI, restyled here
   ========================================================================== */
.kui { animation: rise .26s var(--ease) both; font-size: 14px; }
.kui-ico { display: inline-flex; }
.kui-sm { min-height: 30px; padding: 0 12px; font-size: 13px; }
.kui-collapse { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .3s var(--ease), opacity .3s var(--ease); }
.kui-collapse > div { overflow: hidden; min-height: 0; }
.kui-collapse.open { grid-template-rows: 1fr; opacity: 1; }
.kui-card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-hairline); overflow: hidden; }
.kui-pad { padding: 14px 14px 10px; }
.kui-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 12px 14px; flex-wrap: wrap; }
.kui-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.kui-chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: var(--r-chip);
  background: var(--bg-2); box-shadow: var(--shadow-hairline); font-size: 12px; color: var(--ink-2);
  max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kui-pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: var(--bg-2); font-size: 11px; font-weight: 600; color: var(--ink-2); }

/* tool chips */
.kui-tc { align-self: stretch; }
.kui-tc-head {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--ink-3);
  font-size: 12.5px; font-weight: 600; padding: 4px 6px; margin: 0 -6px; border-radius: 8px;
}
.kui-tc-head:hover { background: var(--hover); color: var(--ink-2); }
.kui-tc-head .kui-ico { transition: transform .2s var(--ease); }
.kui-tc-head[aria-expanded="true"] .kui-ico { transform: rotate(90deg); }
.kui-tc-list { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.kui-tc-row {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; border: 0; background: none;
  padding: 0 6px; margin: 0 -6px; border-radius: 8px; text-align: left; color: var(--ink);
}
.kui-tc-row:hover { background: var(--hover); }
.kui-tc-ico { position: relative; width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.kui-tc-ico .kui-ico { position: absolute; inset: 0; align-items: center; justify-content: center; transition: opacity .12s, transform .15s; }
.kui-tc-ico .kui-ico + .kui-ico { opacity: 0; }
.kui-tc-row:hover .kui-tc-ico .kui-ico:first-child, .kui-tc-row.open .kui-tc-ico .kui-ico:first-child { opacity: 0; }
.kui-tc-row:hover .kui-tc-ico .kui-ico + .kui-ico, .kui-tc-row.open .kui-tc-ico .kui-ico + .kui-ico { opacity: 1; }
.kui-tc-row.open .kui-tc-ico .kui-ico + .kui-ico { transform: rotate(90deg); }
.kui-tc-row.done .kui-tc-ico { color: var(--accent); }
.kui-tc-row.bad .kui-tc-ico { color: var(--danger); }
.kui-tc-label { font-size: 13px; font-weight: 600; flex: none; }
.kui-tc-detail { margin: 2px 0 6px 8px; padding: 2px 0 2px 14px; border-left: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.kui-tc-detail.bad { color: var(--danger); }

/* insight cards */
.kui-ins { align-self: stretch; }
.kui-ins-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.kui-ins-title { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.kui-ins-count { margin-left: 4px; color: var(--ink-2); }
.kui-ins-pager { display: inline-flex; gap: 2px; }
.kui-ins-nav { width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; }
.kui-ins-nav:hover { background: var(--hover); color: var(--ink); }
.kui-ins-card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-hairline); padding: 12px; animation: rise .22s var(--ease) both; }
.kui-ins-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kui-ins-dev { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.kui-ins-dev i { width: 8px; height: 8px; border-radius: 50%; }
.kui-ins-fig { display: flex; align-items: baseline; gap: 6px; margin: 8px 0 6px; }
.kui-ins-big { font-size: 28px; font-weight: 600; line-height: 1; }
.kui-ins-unit { font-size: 12.5px; color: var(--ink-2); }
.kui-chart-stage { position: relative; height: 110px; border-radius: var(--r-control); background: var(--bg-2); box-shadow: var(--shadow-hairline); touch-action: pan-y; cursor: crosshair; }
.kui-chart { width: 100%; height: 100%; display: block; }
.kui-chart-cursor { position: absolute; top: 6px; bottom: 6px; width: 1px; background: var(--ink-3); opacity: 0; pointer-events: none; }
.kui-chart-tip {
  position: absolute; top: 6px; transform: translateX(-50%); padding: 3px 7px; border-radius: 6px; background: var(--surface-2);
  box-shadow: var(--shadow-hairline); font-size: 11.5px; white-space: nowrap; opacity: 0; pointer-events: none; font-variant-numeric: tabular-nums;
}
.kui-chart-stage.scrub .kui-chart-cursor, .kui-chart-stage.scrub .kui-chart-tip { opacity: 1; }
.kui-ins-foot { font-size: 12px; color: var(--ink-3); margin-top: 8px; }

/* recommendation card */
.kui-rc { align-self: stretch; }
.kui-rc-title { font-size: 15px; font-weight: 650; font-family: var(--display); letter-spacing: -0.01em; }
.kui-rc-body { margin: 5px 0 0; min-height: 20px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); animation: fade .18s ease-out both; }
.kui-rc-body .kui-chip { max-width: none; vertical-align: 1px; }
.kui-rc-body b { color: var(--ink); font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; }
.kui-rc-drawer { border-top: 1px solid var(--line); padding: 8px; }
.kui-rc-other { margin: 0; padding: 0 6px 4px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.kui-rc-alt { display: flex; width: 100%; align-items: center; gap: 10px; min-height: 36px; padding: 0 6px; border: 0; border-radius: 8px; background: none; text-align: left; }
.kui-rc-alt:hover { background: var(--hover); }
.kui-rc-alt-t { font-size: 13px; }
.kui-basis { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.kui-meter { display: inline-flex; align-items: flex-end; gap: 2px; }
.kui-meter span { width: 4px; height: 10px; border-radius: 2px; transition: background .3s; }
.kui-rc-status { padding: 0 14px 12px; font-size: 13.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.kui-rc-status.done { color: var(--ink); }
.kui-rc-status.error { color: var(--danger); padding-top: 0; }
.kui-okdot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* approval card */
.kui-ap { position: relative; width: min(380px, 100%); box-shadow: var(--shadow-card); }
.kui-ap-x { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; }
.kui-ap-warn { display: inline-flex; align-items: center; gap: 6px; color: var(--warn); font-size: 12.5px; font-weight: 700; padding: 3px 9px 3px 7px; border-radius: 999px; background: var(--warn-tint); }
.kui-ap-q { font: 650 17px/1.35 var(--display); letter-spacing: -0.015em; margin: 10px 30px 0 0; }
.kui-ap-detail { margin: 6px 0 0; color: var(--ink-2); font-size: 14px; }
.kui-ap-opts { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.kui-ap-opt { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 8px; margin: 0 -8px; border: 0; border-radius: 10px; background: none; text-align: left; font-size: 14px; color: var(--ink-2); }
.kui-ap-opt:hover { background: var(--hover); }
.kui-ap-opt[aria-checked="true"] { color: var(--ink); }
.kui-radio { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); display: inline-flex; align-items: center; justify-content: center; flex: none; transition: background .2s, box-shadow .2s; }
.kui-radio span { width: 7px; height: 7px; border-radius: 50%; background: var(--bg); transform: scale(0); transition: transform .2s; }
.kui-ap-opt[aria-checked="true"] .kui-radio { background: var(--ink); box-shadow: none; }
.kui-ap-opt.danger[aria-checked="true"] .kui-radio { background: var(--warn); }
.kui-ap-opt[aria-checked="true"] .kui-radio span { transform: scale(1); }

/* ==========================================================================
   VIEWS, ICONS, KROVEN'S POP-UPS, SETUP, STARTERS, QUICK REPLIES
   ========================================================================== */
.views {
  position: absolute; z-index: 19; left: 0; right: 0; top: calc(58px + var(--safe-t));
  display: flex; gap: 6px; padding: 2px 12px; overflow-x: auto; scrollbar-width: none;
}
.views::-webkit-scrollbar { display: none; }
.view {
  flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 13px;
  border: 0; border-radius: 999px; background: rgba(24, 23, 20, .9); box-shadow: var(--shadow-hairline);
  color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.view:hover { color: var(--ink); background: var(--surface-2); }
.view[aria-pressed="true"] { background: var(--ink); color: var(--bg); box-shadow: none; }
.view.locked { color: var(--ink-3); }
.view-loc { color: var(--accent); box-shadow: 0 0 0 1px rgba(214, 255, 61, .3); }
.home-pin.visit { border-radius: 50%; transform: none; box-shadow: 0 0 0 2px var(--you); }

.dev-ico { display: inline-flex; flex: none; }
.blip .tag { gap: 5px; }
.blip .tag .dev-ico { color: var(--c); align-self: center; }
.pop-ico {
  width: 30px; height: 30px; border-radius: 9px; flex: none; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 35%, transparent);
}
.pop-read:empty { display: none; }
.pop-read { margin: 2px 16px 0; font-size: 13px; color: var(--ink-2); }
.pop-read.warn { color: var(--warn); }
.pop-read.ok { color: var(--ink); }
.pop-wait.warn { background: var(--warn-tint); }
.pop-auto { padding: 4px 16px 0; margin-top: 10px; border-top: 1px solid var(--line); }
.pop-auto .switchrow { padding-top: 10px; }
.pop-auto .hint { margin-top: 0; }
.ico-dot { width: 28px; height: 28px; border-radius: 8px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c) 14%, transparent); }

.ilabel {
  --c: var(--you);
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border: 0; border-radius: 999px;
  background: rgba(18, 17, 15, .86); box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent);
  color: var(--ink); font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.ilabel .dev-ico { color: var(--c); }
.ilabel b { font-family: var(--display); color: var(--c); font-variant-numeric: tabular-nums; }
.ilabel.dim b { color: var(--ink-3); }

/* Kroven, the character: corner pop-ups */
#kroak {
  position: fixed; z-index: 55; right: 12px; top: calc(104px + var(--safe-t));
  width: min(320px, calc(100vw - 24px)); display: flex; flex-direction: column; align-items: flex-end;
  gap: 6px; pointer-events: none;
}
/* Glass over the map, so it reads on satellite imagery without a heavy slab. */
.kroak {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 6px 8px 8px; border-radius: 14px;
  background: rgba(24, 23, 20, .82); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 10px 28px rgba(0, 0, 0, .35);
  animation: kroak-in .26s var(--ease) both; transition: opacity .2s, transform .2s;
}
.kroak.hint { width: auto; max-width: 100%; padding: 6px 12px 6px 6px; border-radius: 999px; }
.kroak.hint .kroak-face { width: 24px; height: 24px; border-radius: 999px; }
.kroak.hint .kroak-dot { width: 8px; height: 8px; }
.kroak.hint .kroak-body p { font-size: 13px; }
.kroak.nudge { animation: kroak-nudge .35s ease-in-out; }
@keyframes kroak-nudge { 30% { transform: translateX(-5px); } 60% { transform: translateX(3px); } }
.kroak-link {
  border: 0; padding: 0; background: none; color: var(--accent); font: inherit; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.kroak.out { opacity: 0; transform: translateX(16px); }
.kroak.bad { box-shadow: 0 0 0 1px rgba(255, 107, 91, .45), 0 18px 40px rgba(0, 0, 0, .45); }
@keyframes kroak-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.kroak-face {
  flex: none; width: 28px; height: 28px; border-radius: 9px; background: var(--bg-2); box-shadow: var(--shadow-hairline);
  display: inline-flex; align-items: center; justify-content: center;
}
.kroak-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px 2px rgba(214, 255, 61, .45); animation: kroak-glow 1.6s ease-in-out 2;
}
.kroak.bad .kroak-dot { background: var(--danger); box-shadow: 0 0 10px 2px rgba(255, 107, 91, .45); }
@keyframes kroak-glow { 50% { box-shadow: 0 0 16px 5px rgba(214, 255, 61, .6); } }
.kroak-body { flex: 1; min-width: 0; }
.kroak-body p { margin: 0; font: 600 13.5px/1.4 var(--body); color: var(--ink); }
.kroak-acts { display: flex; gap: 6px; margin-top: 6px; }
.kroak-x { flex: none; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center; }
.kroak-x:hover { background: var(--hover); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .kroak, .kroak-dot { animation: none; } }

/* setup */
.setup-pill {
  min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--accent-tint);
  color: var(--accent); font: 700 12.5px var(--body); box-shadow: 0 0 0 1px rgba(214, 255, 61, .3);
}
#setup-card {
  position: fixed; z-index: 57; top: calc(56px + var(--safe-t)); right: 60px; width: 260px; padding: 12px;
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); animation: rise .2s var(--ease) both;
}
#setup-card h3 { margin: 0 0 6px; font: 650 15px var(--display); }
.setup-step { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 6px; margin: 0 -6px;
  border: 0; border-radius: 10px; background: none; text-align: left; font-size: 14px; color: var(--ink); }
.setup-step:hover { background: var(--hover); }
.setup-step .kui-okdot { background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.setup-step.done { color: var(--ink-3); }
.setup-step.done .kui-okdot { background: var(--accent); box-shadow: none; }

/* starters and quick replies */
.starters, .quick { display: flex; gap: 6px; flex-wrap: wrap; }
.starters { justify-content: center; }
.chip {
  min-height: 34px; padding: 0 13px; border: 0; border-radius: 999px; background: rgba(31, 29, 26, .94);
  box-shadow: var(--shadow-hairline); color: var(--ink-2); font-size: 13px; font-weight: 600; text-align: left;
}
.chip:hover { color: var(--ink); background: var(--surface-2); }
.chip.primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.quick { align-self: flex-start; animation: rise .26s var(--ease) both; }
.askbar .attach { background: transparent; }
.askbar:has(.attach) { padding-left: 4px; }

@media (max-width: 640px) {
  .views { top: calc(54px + var(--safe-t)); }
  #kroak { top: calc(100px + var(--safe-t)); left: 12px; right: 12px; width: auto; }
  #setup-card { right: 12px; left: 12px; width: auto; }
  .starters { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .starters .chip { flex: none; }
  body.popping .starters { display: none; }
}

/* ==========================================================================
   CALMER LAYOUT
   One view control, a quieter top bar, a simpler device panel.
   ========================================================================== */
/* view control */
.views { top: calc(60px + var(--safe-t)); overflow: visible; }
.view-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px 0 14px;
  border: 0; border-radius: 999px; background: rgba(24, 23, 20, .88); box-shadow: var(--shadow-hairline);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: var(--ink); font-size: 14px;
}
.view-btn:hover { background: var(--surface-2); }
.view-btn .view-k { color: var(--ink-3); font-weight: 600; font-size: 12.5px; }
.view-btn b { font-weight: 650; }
.view-btn .kui-ico { color: var(--ink-3); transition: transform .2s var(--ease); }
.view-btn[aria-expanded="true"] .kui-ico { transform: rotate(180deg); }
#view-menu {
  position: fixed; z-index: 58; left: 12px; top: calc(104px + var(--safe-t)); width: 240px; padding: 6px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-card); animation: rise .18s var(--ease) both;
}
.vm-item {
  display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 40px; padding: 0 10px;
  border: 0; border-radius: 9px; background: none; color: var(--ink); font-size: 14px; text-align: left;
}
.vm-item:hover:not([disabled]) { background: var(--hover); }
.vm-item[aria-checked="true"] { background: var(--surface-2); font-weight: 650; }
.vm-item[aria-checked="true"]::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.vm-item.locked { color: var(--ink-3); cursor: default; }
.vm-foot { border-top: 1px solid var(--line); margin-top: 6px; padding: 8px 10px 4px; }
.vm-foot p { margin: 0 0 6px; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }

/* top bar: setup is a quiet nudge, not a second accent */
.setup-pill { background: rgba(24, 23, 20, .82); color: var(--ink-2); box-shadow: var(--shadow-hairline); font-weight: 600; }
.setup-pill::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; }

/* the plain floor sits below the view control */
#plain .home-outline { top: 50%; }

/* device panel */
.pop-h { align-items: center; padding: 14px 8px 0 14px; }
.pop-title { flex: 1; min-width: 0; }
.pop-h h2 { font-size: 18px; }
.pop-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.pop-h .icon-btn { margin-top: 0; }
.pop-hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 2px; }
.pop-hero .pop-watts { padding: 0; }
.pop-read { margin: 6px 16px 0; }
.pop-read:empty { display: none; }
.pop-ctl { padding: 12px 16px 0; }
.presets { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.pop-note { margin: 10px 16px 0; }
.pop-wait { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pop-wait .row { margin-top: 0; }
.pop-more { margin: 12px 16px 0; }
.pop-more summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-3); padding: 4px 0;
}
.pop-more summary::-webkit-details-marker { display: none; }
.pop-more summary::before { content: ""; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform .2s; }
.pop-more[open] summary::before { transform: rotate(45deg); }
.pop-more summary:hover { color: var(--ink); }
.pop-more .pop-auto { padding: 0; margin-top: 4px; border-top: 0; }
.pop-more .pop-auto .switchrow { padding-top: 6px; }
.pop-chat { margin-top: 12px; }

/* starters float above the ask bar only while you're about to type */
.starters { animation: rise .2s var(--ease) both; }

@media (max-width: 640px) {
  .views { top: calc(56px + var(--safe-t)); }
  #view-menu { top: calc(100px + var(--safe-t)); }
}
