/* JARVIS Voice — r1 creation. 240×282 portrait, cyan-on-dark. */

/* One source of truth for the palette and rhythm. Before these existed the
   same cyan was written eleven different ways with slightly different
   alphas, so a tweak meant hunting every instance. */
:root {
  --cyan: #4fd6ff;
  --cyan-dim: #8fc9dd;
  --amber: #ffd166;
  --red: #ff6b6b;
  --green: #5fe3a1;

  --bg: #000;
  --surface: #0b1418;        /* cards, tabs, inputs */
  --surface-lift: #10262e;   /* active tab, pressed states */
  --line: rgba(79, 214, 255, .18);
  --line-strong: rgba(79, 214, 255, .45);

  --ink: #e8f6fb;
  --ink-soft: #9fb4bd;
  --ink-faint: #5d7078;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --gap: 6px;
}

html, body {
  margin: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#app { display: flex; flex-direction: column; height: 100vh; padding: 6px 10px 4px; box-sizing: border-box; }

header { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 6px; position: relative; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4fd6ff; position: relative; }
.dot::after { content: ""; position: absolute; inset: -3px; border-radius: 50%;
  background: rgba(79,214,255,.35); animation: glowpulse 2.4s ease-in-out infinite; }
.name { font-size: 16px; font-weight: 700; letter-spacing: 2px; color: #4fd6ff; }
#gear {
  width: 40px; height: 40px; font-size: 19px;
  background: none; border: none; color: #9fb4bd; padding: 0;
}

#main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.hidden { display: none !important; }

/* Six tabs across 240px leaves ~36px each. Letter-spacing was stealing the
   width the labels needed, so it goes; the active tab earns its emphasis
   from colour and a top rule instead of from spacing. */
#tabs { display: flex; gap: 3px; margin: 4px 0 2px; }
.tab {
  flex: 1; min-height: 28px; font-size: 10px; font-weight: 700; letter-spacing: 0;
  background: var(--surface); color: #7d939d; border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 0;
  position: relative;
  transition: background .15s, color .15s, border-color .15s;
}
.tab.on {
  background: var(--surface-lift); color: var(--cyan);
  border-color: var(--line-strong);
}
/* A lit top edge reads as "you are here" faster than colour alone at this
   size, and survives the r1's washed-out viewing angles. */
.tab.on::after {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 2px;
  background: var(--cyan); border-radius: 0 0 2px 2px;
  animation: glowpulse 2.4s ease-in-out infinite;
}
.tab:active { background: var(--surface-lift); }

#chatView { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* The status line carries a left-hand state lamp. Text alone at 20px was
   the only state signal; during a slow turn (TTS can run 20s+) a steady
   word reads as "frozen", while a pulsing lamp reads as "still working". */
.status {
  margin-top: 6px;
  font-size: 18px; font-weight: 700; text-align: center;
  min-height: 36px; display: flex; align-items: center; justify-content: center;
  gap: 8px;
  transition: color .2s;
}
.status::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
  background: var(--ink-faint); box-shadow: none;
  transition: background .2s, box-shadow .2s;
}
.status.listening { color: var(--cyan); }
.status.listening::before {
  background: var(--cyan); box-shadow: 0 0 10px var(--cyan);
  animation: lamp 1.1s ease-in-out infinite;
}
.status.thinking  { color: var(--amber); }
.status.thinking::before {
  background: var(--amber); box-shadow: 0 0 10px var(--amber);
  animation: lamp 1.6s ease-in-out infinite;
}
.status.speaking  { color: var(--cyan); }
.status.speaking::before {
  background: var(--cyan); box-shadow: 0 0 12px var(--cyan);
  animation: lamp .7s ease-in-out infinite;
}
.status.gated, .status.error { color: var(--red); }
.status.gated::before, .status.error::before {
  background: var(--red); box-shadow: 0 0 10px var(--red);
}
@keyframes pulse { 50% { opacity: .45; } }
@keyframes glowpulse { 50% { opacity: .5; } }
@keyframes lamp  { 50% { opacity: .25; transform: scale(.82); } }

.sub { text-align: center; font-size: 11px; color: var(--ink-soft); min-height: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.log {
  flex: 1; min-height: 0; overflow-y: auto;
  margin-top: 12px; padding: 8px 6px 10px;
  border: 1px solid rgba(79, 214, 255, .25); border-radius: 10px;
  -webkit-overflow-scrolling: touch;
  /* Without an explicit touch-action the WebView treats a vertical drag as a
     possible gesture and swallows it, so the panel reads as unscrollable. */
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.turn { margin-bottom: 8px; }
.turn .who { font-size: 10px; letter-spacing: 1px; color: #5d7078; }
.turn .who.you { color: #7d939d; }
.turn .txt { font-size: 14px; line-height: 1.35; white-space: pre-wrap; word-break: break-word; }
.turn.jarvis .txt { color: var(--ink); }
.turn .lat { font-size: 10px; color: #5d7078; margin-top: 2px; }
.turn.latest { border-left: 2px solid rgba(79,214,255,.6); padding-left: 6px; }
.turn .thumb {
  display: block; max-width: 120px; max-height: 90px; border-radius: 8px;
  border: 1px solid rgba(79,214,255,.35); margin: 4px 0 2px;
}

/* shared scroll container for the visual tabs */
.viewscroll { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 2px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;            /* see .log — drags are scrolls, not gestures */
  overscroll-behavior: contain; }

/* Text inside the scrollers stays selectable-free but DRAGGABLE: the global
   user-select:none is what makes a drag feel like it grabs nothing, while
   these panels still need the drag to move the content. */
.log, .viewscroll { -webkit-user-drag: none; }

/* A 240px screen hides most of a list, so a panel with more content shows a
   fade at that edge — the only affordance that fits. The element IS the
   scroller, so a ::after pinned with position:absolute would scroll away
   with the content; a sticky zero-height marker stays put instead, and
   background-attachment:local does the same job for the gradient. The
   .more-above / .more-below classes come from the scroll handler. */
.log, .viewscroll {
  background-repeat: no-repeat;
  background-attachment: local, local;
  background-size: 100% 20px, 100% 20px;
  background-position: top, bottom;
  background-image: none;
  transition: background-image .18s ease;
}
.log.more-above, .viewscroll.more-above {
  background-image: linear-gradient(to bottom, rgba(79,214,255,.16), rgba(0,0,0,0));
  background-position: top;
  background-attachment: scroll;
  background-size: 100% 16px;
}
.log.more-below, .viewscroll.more-below {
  background-image: linear-gradient(to top, rgba(79,214,255,.16), rgba(0,0,0,0));
  background-position: bottom;
  background-attachment: scroll;
  background-size: 100% 16px;
}
.log.more-above.more-below, .viewscroll.more-above.more-below {
  background-image:
    linear-gradient(to bottom, rgba(79,214,255,.16), rgba(0,0,0,0)),
    linear-gradient(to top, rgba(79,214,255,.16), rgba(0,0,0,0));
  background-position: top, bottom;
  background-size: 100% 16px, 100% 16px;
}

/* Every panel surface shares one recipe — the eight hand-rolled copies of
   this had drifted apart on border alpha and radius. The inset highlight is
   what stops a flat card disappearing into the black background. */
.qf, .stat, .spark, .act, .stage, .stream, .reccard, .timercard {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(79,214,255,.06);
}

/* agent view */
.qfstrip { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.qf { color: var(--ink); border-color: rgba(79,214,255,.25);
  border-radius: 999px; padding: 4px 10px; font-size: 11px; line-height: 1.3; }
.sectitle { font-size: 9px; letter-spacing: 1.6px; color: var(--ink-faint);
  margin: 9px 0 3px; text-transform: uppercase; }
.addr { font-size: 10px; color: #5d7078; word-break: break-all; }
.fleetcard { align-items: center; }

/* telemetry */
.statrow { display: flex; gap: 5px; margin: 4px 0; }
.stat { flex: 1; border-radius: var(--r-lg); padding: 6px 3px; text-align: center;
  min-width: 0; }
.stat .v { font-size: 15px; font-weight: 700; color: var(--cyan);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A number that has gone bad should read as bad without being read. */
.stat.warn .v { color: var(--amber); }
.stat.bad .v  { color: var(--red); }
.stat .k { font-size: 8px; letter-spacing: .8px; color: #7d939d;
  text-transform: uppercase; white-space: nowrap; overflow: hidden; }
.stat .s { font-size: 9px; color: var(--ink-faint); }
.spark { display: block; width: 100%; height: auto; margin: 4px 0;
  border-radius: var(--r-lg); }
.acts { display: flex; flex-direction: column; gap: 5px; margin-top: 5px; }
.act { border-radius: var(--r-lg); padding: 7px 9px; display: flex;
  align-items: center; justify-content: space-between; gap: 8px;
  /* A status stripe on the leading edge survives truncation; the pill on
     the right is the first thing to get squeezed out at 240px. */
  border-left-width: 2px; border-left-color: var(--line); }
.act.s-done { border-left-color: var(--cyan); }
.act.s-run  { border-left-color: var(--amber); }
.act.s-fail { border-left-color: var(--red); }
.act .t { font-size: 12px; color: var(--ink); line-height: 1.3; min-width: 0; }
.act .st { font-size: 9px; font-weight: 700; letter-spacing: .8px; padding: 2px 7px;
  border-radius: 999px; background: var(--surface-lift); color: #7d939d; flex-shrink: 0; }
.act .st.done { color: var(--cyan); } .act .st.run { color: var(--amber); }
.act .st.fail { color: var(--red); } .act .st.ok { color: var(--cyan); }

/* brain view */
.stages { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.stage { display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--r-lg); padding: 7px 9px; position: relative; overflow: hidden; }
.stage .n { font-size: 12px; font-weight: 700; color: var(--ink-soft); letter-spacing: .6px; }
.stage .ms { font-size: 12px; font-weight: 700; color: #7d939d; }
.stage.live .n, .stage.live .ms { color: var(--cyan); text-shadow: 0 0 6px rgba(79,214,255,.6); }
/* The live stage gets a sweep so a long brain call looks like progress
   rather than a frozen row. */
.stage.live::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 40%;
  background: linear-gradient(90deg, rgba(0,0,0,0), rgba(79,214,255,.12), rgba(0,0,0,0));
  animation: sweep 1.5s linear infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
.stage.done .n { color: var(--cyan); } .stage.done .ms { color: var(--ink); }
.stream { margin-top: 7px; font-size: 12px; line-height: 1.42; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; min-height: 56px;
  border-radius: var(--r-lg); padding: 8px; }
/* A caret while tokens arrive: the stream is the one place you can SEE the
   brain working, which is the whole point of this tab. */
.stream.streaming::after {
  content: "▌"; color: var(--cyan); animation: lamp 1s steps(2) infinite;
}

/* eyes view */
.eyeswrap { position: relative; flex: 1; min-height: 0; }
.eyes { display: block; width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--r-lg); border: 1px solid rgba(79,214,255,.35); background: var(--surface); }
.eyesrow { display: flex; gap: 5px; }
/* Three buttons across 240px: smaller type, and the labels stay on one line
   rather than wrapping into a second row that would steal camera height. */
.eyesrow .btn { flex: 1; min-height: 38px; font-size: 11px; padding: 0 2px;
  white-space: nowrap; overflow: hidden; }
/* Eye source chooser: r1 camera vs MacBook vs iPhone vs phone uplink. */
.srcrow { display: flex; gap: 5px; margin: 6px 0; }
.srcrow .btn { flex: 1; min-height: 26px; font-size: 10px; padding: 0 2px;
  white-space: nowrap; overflow: hidden; border-radius: 999px; position: relative;
  color: var(--cyan); border-color: rgba(79,214,255,.35); }
.srcrow .btn.on { background: #4fd6ff; color: #000; }
.srcrow .btn:disabled { opacity: .5; }

/* god's-eye world plate — SVG only, this WebView has no WebGL */
.world { position: absolute; inset: 0; border-radius: var(--r-lg);
  border: 1px solid rgba(79,214,255,.35); background:
    radial-gradient(circle at 50% 40%, #0c1c23 0%, #060c0f 70%);
  overflow: hidden; display: flex; flex-direction: column; }
.world svg { flex: 1; width: 100%; min-height: 0; }
.worldhere { font-size: 10px; color: var(--cyan); text-align: center;
  padding: 3px 6px 5px; line-height: 1.25;
  text-shadow: 0 0 8px rgba(79,214,255,.5); }
.wgrid { stroke: rgba(79,214,255,.10); stroke-width: .4; fill: none; }
.wland { fill: rgba(79,214,255,.085); stroke: rgba(79,214,255,.30); stroke-width: .45; }
.wpin  { fill: var(--cyan-dim); }
.wpin-label { fill: #80a4b2; font-size: 4.2px; font-family: system-ui, sans-serif; }
.whome { fill: var(--cyan); }
/* The current position pings so the eye finds it instantly among the pins. */
.whalo { fill: none; stroke: var(--cyan); stroke-width: .8; opacity: .9;
  transform-origin: center; animation: ping 2.1s ease-out infinite; }
@keyframes ping {
  0%   { r: 2.5; opacity: .85; }
  100% { r: 11;  opacity: 0; }
}

/* ── meeting recorder ───────────────────────────────────────────────────── */
.recmeter { position: relative; margin: 2px 0 6px; }
.recwave { display: block; width: 100%; height: 34px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); }
.recclock { position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  font-size: 12px; font-weight: 700; color: var(--cyan);
  text-shadow: 0 0 6px rgba(0,0,0,.9); font-variant-numeric: tabular-nums; }
.recclock.live { animation: lamp 1.6s ease-in-out infinite; }
/* The live transcript is the whole point — give it the room and let it
   scroll itself, newest text pinned to the bottom like a terminal. */
.reclive { font-size: 12px; line-height: 1.4; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 7px 8px; min-height: 96px; max-height: 150px;
  overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  white-space: pre-wrap; word-break: break-word; }
.reclive.empty { color: var(--ink-faint); }
.reclive .pending { color: var(--amber); }
.recresult { margin-top: 6px; font-size: 11px; line-height: 1.4;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); padding: 8px; }
.recresult h4 { margin: 0 0 3px; font-size: 12px; color: var(--cyan); }
.recresult .lbl { font-size: 8px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink-faint); margin-top: 6px; }
.recresult ul { margin: 2px 0 0; padding-left: 14px; }
.recresult li { margin-bottom: 2px; color: var(--ink); }
.recresult .own { color: var(--cyan-dim); }

/* record + timer cards */
.reccard { background: #0b1418; border: 1px solid rgba(79,214,255,.18); border-radius: 10px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.recstate { font-size: 12px; color: #9fb4bd; min-height: 16px; }
.recstate.on { color: #ff6b6b; animation: pulse 1.2s ease-in-out infinite; }
.timercard { background: #0b1418; border: 1px solid rgba(79,214,255,.18); border-radius: 10px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.timerdisp { font-size: 30px; font-weight: 700; color: #4fd6ff; text-align: center;
  min-height: 36px; letter-spacing: 1px; }
.timerdisp.run { color: #ffd166; }
.timerrow { display: flex; gap: 6px; }
.timerrow .btn { min-height: 38px; font-size: 13px; }
.timerrow input { min-width: 0; padding: 8px; font-size: 14px; }

/* pillbox mirror (status + fabric) */
#statusView, #teleView { flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 8px; padding-top: 8px; }
#statusView { overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#brainView, #eyesView, #agentView, #recView { flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 8px; padding-top: 8px; }
.pills { display: flex; flex-direction: column; gap: 8px; }
.pillrow { display: flex; align-items: center; justify-content: space-between;
  background: #0b1418; border: 1px solid rgba(79,214,255,.18); border-radius: 10px; padding: 10px 12px; }
.pillname { font-size: 13px; color: #cfeeff; font-weight: 600; }
.pill { font-size: 11px; font-weight: 700; letter-spacing: 1px; padding: 3px 10px; border-radius: 999px; }
.pill.up   { background: rgba(79,214,255,.15); color: #4fd6ff; border: 1px solid rgba(79,214,255,.5); }
.pill.down { background: rgba(255,107,107,.12); color: #ff6b6b; border: 1px solid rgba(255,107,107,.5); }
.pill.unknown { background: #10262e; color: #7d939d; border: 1px solid rgba(125,147,157,.4); }
.meta { font-size: 11px; color: #7d939d; line-height: 1.5; text-align: center; }
.btn.wide { width: 100%; }

/* camera overlay */
#camOverlay { z-index: 40; }
.camvideo { width: 100%; height: 180px; object-fit: cover; border-radius: 10px; background: #0b1418; }

/* typed chat: the room JARVIS answers in text without waking the speaker */
.typerow { display: flex; gap: 6px; margin-top: 6px; }
.typerow input { flex: 1; min-width: 0; min-height: 36px; padding: 7px 10px; font-size: 14px; }
/* Send is a small square on the LEFT of the field — out of the thumb's
   way at the bottom-left corner, per the standing layout. */
.typerow .btn { flex: 0 0 34px; min-height: 34px; width: 34px; font-size: 16px; border-radius: 9px;
  position: relative; }
/* 34px visual, ~46px touch: the hit area reaches past the border. */
.typerow .btn::before { content: ""; position: absolute; inset: -6px; }
/* A service that is off BY DESIGN should not read as a failure: amber,
   labelled OFF, with its note carried on the meta line. */
.pill.off { background: rgba(255, 209, 102, .12); color: #ffd166;
  border: 1px solid rgba(255, 209, 102, .5); }

footer { text-align: center; font-size: 11px; color: #5d7078; padding: 4px 0 2px; }

.settings {
  position: absolute; inset: 0; z-index: 30; background: #000;
  padding: 14px 12px; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 6px;
}
.settings.hidden { display: none; }
.s-title { font-size: 18px; font-weight: 700; color: #4fd6ff; margin-bottom: 4px; }
.s-label { font-size: 12px; color: #9fb4bd; }
input, select {
  width: 100%; box-sizing: border-box;
  background: #0b1418; color: #fff;
  border: 1px solid rgba(79, 214, 255, .35); border-radius: 8px;
  padding: 10px; font-size: 14px;
}
select { appearance: none; -webkit-appearance: none; }
.s-row { display: flex; gap: 8px; margin-top: 8px; }
.btn {
  flex: 1; min-height: 44px; font-size: 14px; font-weight: 600;
  background: #10262e; color: #fff; border: 1px solid rgba(79, 214, 255, .35);
  border-radius: 8px; padding: 0;
}
.btn.primary { background: #4fd6ff; color: #000; }
.btn.cam { margin-top: 6px; color: #4fd6ff; }
.s-msg { font-size: 12px; color: #ffd166; min-height: 30px; }
.s-hint { font-size: 11px; color: #5d7078; line-height: 1.4; }

/* hit-slop for the small source chips (26px visual → ~42px touch) */
.srcrow .btn::before { content: ""; position: absolute; inset: -8px 0; }
/* tab hit area: 28px visual, ~40px touch; the lit edge stays inside */
.tab::before { content: ""; position: absolute; inset: -6px -2px; }
/* long unbroken strings must wrap, not push the panel sideways */
.recresult { overflow-wrap: anywhere; }
.recresult li { overflow-wrap: anywhere; }
