/* aki-remote — Cyberpunk 2077 HUD theme.
   Neon identities: Aki (assistant) = yellow, Kamil (user) = cyan.
   Design language lifted from the CP2077 HUD: angular chamfered panels,
   thin neon borders with bloom, hazard stripes, scanlines + vignette,
   glitch title, segmented gauges, key-prompt buttons, monospace readouts. */
:root {
  --bg: #04060c;
  --panel: #0a0e14;
  --panel2: #0e1319;
  --line: #26313c;
  --txt: #eef5fb;
  --dim: #6d7b89;

  /* the two neon identities */
  --aki: #ffe135;        /* Aki (assistant): yellow */
  --aki-bg: #221a05;     /* dark yellow / pane tint */
  --k: #4df0ff;          /* Kamil (user): cyan */
  --k-bg: #062331;       /* dark cyan / pane tint */

  /* status accents */
  --red: #ff3b5c;        /* warning / alert (CP2077 status red) */
  --ok: #4df0ff;
  --warn: #ffe135;
  --err: #ff3b5c;
  --caret: #4df0ff;

  --chamfer: 10px;       /* 45° corner cut size */
  /* Single source of truth for notch/inset clearance: whatever the OS reports,
     or the measured floor app.js installs when iOS lies and reports 0. */
  --safe-top: max(env(safe-area-inset-top, 0px), var(--sa-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--sa-bottom, 0px));
  --glow-aki: 0 0 7px rgba(255,225,53,0.7), 0 0 20px rgba(255,225,53,0.32);
  --glow-k: 0 0 7px rgba(77,240,255,0.65), 0 0 18px rgba(77,240,255,0.28);
  --glow-r: 0 0 7px rgba(255,59,92,0.7), 0 0 18px rgba(255,59,92,0.3);

  --ctxpct: 0;           /* set by app.js renderContext */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 14px;
  overscroll-behavior: none;
}

::selection { background: var(--aki); color: #000; }

.hidden { display: none !important; }

/* ---- canvas: HUD grid + scanlines + vignette + faint noise ---- */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(rgba(53,230,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(53,230,255,0.04) 1px, transparent 1px);
  background-size: 30px 30px;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 90;
  /* light scanline + a whisper of edge darkening — kept subtle because the
     app is used on a phone (a heavy vignette eats a small portrait viewport) */
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.07) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 78%, rgba(0,0,0,0.22) 100%);
  mix-blend-mode: multiply;
}
.chat, .gate { position: relative; z-index: 1; }

/* ---- fixed HUD corner brackets (decorative) ---- */
.hud {
  position: fixed;
  width: 22px; height: 22px;
  pointer-events: none;
  z-index: 80;
  border: 2px solid rgba(53,230,255,0.55);
  filter: drop-shadow(0 0 4px rgba(53,230,255,0.4));
}
.hud.tl { top: calc(var(--safe-top) + 8px); left: 10px; border-right: 0; border-bottom: 0; }
.hud.tr { top: calc(var(--safe-top) + 8px); right: 10px; border-left: 0; border-bottom: 0; }
.hud.bl { bottom: calc(var(--safe-bottom) + 8px); left: 10px; border-right: 0; border-top: 0; }
.hud.br { bottom: calc(var(--safe-bottom) + 8px); right: 10px; border-left: 0; border-top: 0; }

/* ---------- gate ---------- */
.gate { height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card {
  width: 100%; max-width: 400px;
  position: relative;
  isolation: isolate;
  background: var(--aki);
  padding: 30px;
  display: flex; flex-direction: column; gap: 14px;
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
  filter: drop-shadow(0 0 10px rgba(255,225,53,0.32));
}
.gate-card::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -1;
  background: var(--panel);
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
}
.gate-card h1 { margin: 0; font-size: 26px; letter-spacing: 8px; color: var(--aki); text-shadow: 0 0 10px rgba(255,214,10,0.6); }
.gate-card .dim { color: var(--k); }
.gate-hint { margin: 0; color: var(--dim); font-size: 12px; line-height: 1.5; }
.gate-hint code { color: var(--k); background: var(--k-bg); border: 1px solid rgba(53,230,255,0.35); padding: 1px 5px; }
.gate-error { color: var(--err); font-size: 11px; margin: 0; min-height: 14px; text-shadow: 0 0 6px rgba(255,46,77,0.5); }

input[type="text"], textarea {
  width: 100%;
  background: #000;
  border: 1px solid #25303a;
  color: var(--txt);
  caret-color: var(--caret);
  padding: 12px;
  font: inherit;
  outline: none;
  border-radius: 0;
}
input::placeholder, textarea::placeholder { color: #3a4550; }
input:focus, textarea:focus { border-color: var(--k); box-shadow: 0 0 0 1px rgba(53,230,255,.25), var(--glow-k); }

/* iOS force-zooms the whole page when a focused text field renders text under
   16px — and it stays zoomed after the keyboard closes, which pushes the
   chamfered HUD chips past the right edge. Touch devices only; desktop keeps
   the compact 14px terminal density. */
@media (hover: none) {
  input[type="text"], input:not([type]), textarea { font-size: 16px; }
  .inputbar textarea { padding: 10px 12px; line-height: 1.4; }
  .cron-add input, .cron-add select, .cron-add textarea { font-size: 16px; }
}

/* key-prompt button (CP2077 "F EXECUTE" style) */
.btn {
  position: relative;
  background: var(--aki);
  color: #000;
  border: 1px solid var(--aki);
  border-radius: 0;
  font: inherit; font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 12px 16px;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  box-shadow: 0 0 12px rgba(255,214,10,0.35);
}
.btn:active { background: #000; color: var(--aki); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; height: calc(100% - var(--kb, 0px)); max-width: 780px; margin: 0 auto; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--k);
  background: linear-gradient(180deg, #05070a 0%, #020204 100%);
  padding-top: calc(14px + var(--safe-top));
  box-shadow: inset 0 -10px 18px -14px rgba(53,230,255,0.4);
}
/* hazard stripe along the topbar's lower edge */
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 3px;
  background: repeating-linear-gradient(45deg, var(--aki) 0 8px, transparent 8px 16px);
  opacity: 0.5;
  pointer-events: none;
}
.title { position: relative; font-weight: 700; letter-spacing: 5px; color: var(--aki); text-shadow: 0 0 10px rgba(255,214,10,0.6); }
/* glitch: two offset neon ghosts that jitter on hover/active */
.title::before, .title::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  opacity: 0.75;
  pointer-events: none;
}
.title::before { color: var(--red); transform: translate(-1px, 0); mix-blend-mode: screen; }
.title::after { color: var(--k); transform: translate(1px, 0); mix-blend-mode: screen; }
.title:hover::before, .title:hover::after { animation: glitch 0.28s steps(2) infinite; }
@keyframes glitch {
  0%   { transform: translate(-2px, 0); }
  50%  { transform: translate(2px, -1px); }
  100% { transform: translate(-1px, 1px); }
}
.meta { margin-left: auto; color: var(--dim); font-size: 10px; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.5px; }
.actbtn {
  background: transparent;
  color: var(--k);
  border: 1px solid rgba(53,230,255,0.45);
  border-radius: 0;
  font: inherit;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 8px;
  cursor: pointer;
}
.actbtn:disabled { color: #3a4550; border-color: #20262c; cursor: default; }
.actbtn:active:not(:disabled) { background: rgba(53,230,255,0.14); color: var(--aki); }
.pushbtn { display: inline-flex; align-items: center; justify-content: center; padding: 4px 7px; }
.pushicon { display: block; }
#psslash { display: none; }
.pushbtn.denied #psslash { display: block; }
.pushbtn.on { color: var(--aki); border-color: rgba(255,214,10,0.6); box-shadow: var(--glow-aki); }
.pushbtn.denied { color: #3a4550; border-color: #20262c; }

/* ---- top-bar ⋯ menu ---- */
.menuwrap { position: relative; margin-left: 10px; }
.menubtn { display: inline-flex; align-items: center; justify-content: center; padding: 4px 7px; }
.menubtn.on { color: var(--aki); border-color: rgba(53,230,255,0.6); background: rgba(53,230,255,0.08); }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 224px;
  background: rgba(77,240,255,0.55);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  filter: drop-shadow(0 0 6px rgba(77,240,255,0.28));
}
.menu::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  background: #04070a;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: transparent; border: none; border-bottom: 1px solid rgba(53,230,255,0.14);
  color: var(--k); font: inherit; font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  padding: 14px 15px; text-align: left; cursor: pointer;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:disabled { color: #3a4550; cursor: default; }
.menu-item:not(:disabled):active { background: rgba(53,230,255,0.14); color: var(--aki); }
.menu-item .mi-ic { flex: none; opacity: .85; }
.menu-item.on, .menu-item.listening { color: var(--aki); text-shadow: 0 0 6px rgba(255,214,10,0.5); }
.menu-sec { border-top: 1px dashed rgba(53,230,255,0.3); margin-top: 4px; padding-top: 4px; }
/* top-bar native voice/speaker buttons (Android only, shown when the native bridge is present) */
.topnative { display: inline-flex; align-items: center; gap: 6px; }
.topvoice, .topspeak { display: inline-flex; align-items: center; justify-content: center; padding: 6px 9px; }
.topvoice svg, .topspeak svg { display: block; }
.topvoice.listening { color: var(--aki); border-color: rgba(255,214,10,0.7); box-shadow: 0 0 10px rgba(255,214,10,0.45); animation: dotPulse 1.1s ease-in-out infinite; }
.topspeak.on { color: var(--aki); border-color: rgba(255,214,10,0.6); box-shadow: var(--glow-aki); }
#menu .pushbtn { width: 100%; justify-content: flex-start; }
#menu .pushbtn.on { color: var(--aki); }
#menu .pushbtn.denied .mi-label { color: #3a4550; }
/* status dot: neon beacon with a slow pulse */
.dot { width: 9px; height: 9px; border: 1px solid var(--warn); background: transparent; flex: none; }
.dot.connected { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 8px var(--ok), 0 0 16px rgba(53,230,255,0.4); animation: dotPulse 2.4s ease-in-out infinite; }
.dot.disconnected { background: var(--err); border-color: var(--err); box-shadow: 0 0 8px var(--err), 0 0 16px rgba(255,46,77,0.4); animation: dotPulse 1.1s ease-in-out infinite; }
@keyframes dotPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

.compactbusy {
  background: rgba(255, 214, 10, 0.08);
  border: 1px solid rgba(255, 214, 10, 0.5);
  color: var(--warn);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 5px 10px;
  margin: 0 10px 2px;
  text-shadow: 0 0 6px rgba(255,214,10,0.4);
}
@keyframes compactPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.compactbusy:not(.hidden) { animation: compactPulse 1.6s ease-in-out infinite; }

.messages {
  flex: 1; overflow-y: auto;
  padding: 16px 16px 6px;
  display: flex; flex-direction: column; gap: 14px;
}
/* scanlines over the thread */
.messages::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 3px);
  z-index: 0;
}
.messages > * { position: relative; z-index: 1; }

/* jump-to-latest affordance */
.tobottom {
  position: fixed;
  right: 14px;
  bottom: calc(var(--kb, 0px) + 96px);
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font: 20px/1 'Share Tech Mono', monospace;
  color: var(--aki);
  border: 1px solid rgba(255,214,10,0.5);
  background: rgba(0,0,0,0.82);
  cursor: pointer; user-select: none;
  z-index: 70;
  box-shadow: 0 0 14px rgba(0,0,0,0.6), var(--glow-aki);
}
.tobottom:active { background: rgba(255,214,10,0.24); }

/* message bubbles: chamfered HUD chips. The bright color is the element bg and
   a ::before (inset by the border width) repaints the dark content tint on top,
   so the neon edge follows the chamfer instead of being clipped away (the old
   clip-path-on-border trick left the diagonal looking black on low-contrast phones). */
.msg { max-width: 88%; padding: 11px 13px; border-radius: 0; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; position: relative; isolation: isolate; }
.msg.user {
  align-self: flex-end;
  background: var(--k);
  color: var(--k);
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
  filter: drop-shadow(0 0 5px rgba(77,240,255,0.5));
}
.msg.assistant {
  align-self: flex-start;
  background: var(--aki);
  color: var(--aki);
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
  filter: drop-shadow(0 0 5px rgba(255,225,53,0.5));
}
.msg.user::before, .msg.assistant::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -1;
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, var(--chamfer) 100%, 0 calc(100% - var(--chamfer)));
}
.msg.user::before { background: var(--k-bg); }
.msg.assistant::before { background: var(--aki-bg); }
.msg.streaming::after { content: "▌"; color: var(--aki); animation: blink 1s steps(2) infinite; }
/* live voice transcript (interim STT) — dashed + italic so it reads as "in progress" */
.msg.user.live { opacity: 0.9; border: 1px dashed rgba(255,214,10,0.55); font-style: italic; }
/* busy "Aki is thinking…" placeholder for the dead-air window */
.msg.assistant.thinking { color: var(--dim); font-style: italic; }
.msg.assistant.thinking .thdots { display: inline-flex; gap: 1px; margin-left: 3px; }
.msg.assistant.thinking .thdots span { animation: blink 1.2s steps(2) infinite; }
.msg.assistant.thinking .thdots span:nth-child(2) { animation-delay: .2s; }
.msg.assistant.thinking .thdots span:nth-child(3) { animation-delay: .4s; }

/* live reasoning unit */
.aunit {
  align-self: flex-start;
  max-width: 92%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.aunit .msg { align-self: stretch; max-width: 100%; }
.msg.user.queued { opacity: 0.7; }
.msg.user.queued::before { background: repeating-linear-gradient(135deg, var(--k-bg) 0 6px, rgba(0,0,0,0.35) 6px 12px); }
.qbar { display: flex; gap: 10px; align-items: center; margin-top: 7px; font-size: 10px; }
.qtag { color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.qbtn { background: none; border: 1px solid var(--dim); color: var(--dim); padding: 1px 7px; font: inherit; font-size: 10px; cursor: pointer; }
.qbtn:hover { color: var(--k); border-color: var(--k); }
.thinking {
  background: #020204;
  border: 1px solid #232b31;
  border-left: 3px solid var(--k);
  border-radius: 0;
  font-size: 11px;
  color: var(--dim);
  overflow: hidden;
}
.thinking-head {
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  color: var(--k);
  display: flex;
  align-items: center;
  gap: 6px;
}
.thinking-head::before { content: "◆"; font-size: 10px; color: var(--k); text-shadow: 0 0 5px rgba(53,230,255,0.5); }
.thinking-head::after { content: "▾"; margin-left: auto; }
.thinking.collapsed .thinking-body { display: none; }
.thinking.collapsed .thinking-head::after { content: "▸"; }
.thinking-body {
  padding: 0 10px 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.4;
}

/* tool-call cards (live, inside the assistant turn) */
.tc {
  align-self: stretch;
  max-width: 100%;
  position: relative;
  isolation: isolate;
  background: rgba(255,225,53,0.5);
  font-size: 11px;
  color: var(--dim);
  overflow: hidden;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  filter: drop-shadow(0 0 4px rgba(255,225,53,0.3));
}
.tc::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  background: #0a0701;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.tc-head {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 9px;
  cursor: pointer; user-select: none;
  color: var(--aki);
  min-height: 22px;
}
.tc-icon { flex: none; }
.tc-name { font-weight: 700; letter-spacing: 1px; flex: none; }
.tc-args {
  color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1 1 auto; min-width: 0;
}
.tc-state { flex: none; font-size: 10px; color: var(--dim); }
.tc-head::after { content: "▾"; margin-left: 2px; color: var(--dim); font-size: 10px; }
.tc.collapsed .tc-head::after { content: "▸"; }
.tc.collapsed .tc-body { display: none; }
.tc-body {
  padding: 0 9px 9px;
  white-space: pre-wrap; word-break: break-word;
  max-height: 220px; overflow-y: auto;
  color: #9fb0b8; line-height: 1.45;
}
.tc.done { background: rgba(255,225,53,0.35); }
.tc.done .tc-state { display: none; }
.tc.error { background: rgba(255,59,92,0.62); filter: drop-shadow(0 0 5px rgba(255,59,92,0.5)); }
.tc.error .tc-head { color: var(--err); }
.tc.error .tc-state { color: var(--err); }
.tc.error .tc-body { border-top: 1px dashed rgba(255,59,92,0.4); }
.tc.interrupted { background: #3a434c; }
.tc.interrupted .tc-head { color: var(--dim); }
.tc.interrupted .tc-state { color: var(--dim); }
.tc-shot {
  display: block;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  margin: 6px auto 0;
  border: 1px solid rgba(255,214,10,0.3);
  background: #000;
  cursor: zoom-in;
}

/* full-screen image viewer */
.lb {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.97);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.lb.open { opacity: 1; pointer-events: auto; }
.lb img {
  max-width: 98vw;
  max-height: 94vh;
  object-fit: contain;
  border: 1px solid rgba(255,214,10,0.4);
  box-shadow: 0 0 40px rgba(255,214,10,0.15);
}
.lb-c {
  position: fixed;
  top: 12px;
  right: 16px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font: 26px/1 'Rajdhani', 'Share Tech Mono', monospace;
  color: var(--aki);
  border: 1px solid rgba(255,214,10,0.55);
  background: rgba(0,0,0,0.6);
  cursor: pointer;
  user-select: none;
}
.lb-c:active { background: rgba(255,214,10,0.22); }
.lb-hint {
  position: fixed;
  bottom: 10px;
  left: 0; right: 0;
  text-align: center;
  font: 10px 'Share Tech Mono', monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #8a7b2f;
  pointer-events: none;
}
.msg.error { align-self: center; color: var(--err); background: transparent; border: 1px dashed var(--err); font-size: 12px; text-shadow: 0 0 6px rgba(255,46,77,0.4); }
.msg.system { align-self: center; background: #080602; border: 1px dashed rgba(255,214,10,0.5); color: var(--dim); font-size: 10px; max-width: 95%; }

.msg code { background: #000; border: 1px solid rgba(53,230,255,0.4); padding: 1px 4px; color: var(--k); }
.msg pre { background: #000; border: 1px solid #232b31; padding: 10px; overflow-x: auto; margin: 6px 0; }
.msg pre code { background: none; border: none; padding: 0; color: var(--aki); }
.msg strong { color: #fff; }
.msg a { color: var(--k); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg a::after { content: "↗"; font-size: .7em; opacity: .55; margin-left: 2px; }
.msg ul, .msg ol { margin: 4px 0; padding-left: 20px; }
.msg p { margin: 4px 0; }

/* ---- code blocks: lang label + copy button (shareable snippet) ---- */
.codeblock { position: relative; margin: 6px 0; }
.codeblock pre { margin: 0; }
.code-lang { position: absolute; top: 4px; right: 52px; font-size: 10px; color: var(--dim); letter-spacing: 1px; text-transform: uppercase; }
.codecopy { position: absolute; top: 3px; right: 4px; font-size: 10px; line-height: 1; color: var(--k); background: rgba(77,240,255,0.08); border: 1px solid rgba(77,240,255,0.35); padding: 3px 7px; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; font-family: inherit; }
.codecopy:hover { background: rgba(77,240,255,0.22); }
.codecopy.copied { color: var(--ok); border-color: rgba(77,240,255,0.6); }

/* syntax-highlight token colors (cyberpunk palette) */
.hl-kw { color: var(--aki); }
.hl-st { color: var(--k); }
.hl-cm { color: var(--dim); font-style: italic; }
.hl-nu { color: #ff9f43; }
.hl-fn { color: #c3a6ff; }

/* ---- tables ---- */
.msg table { border-collapse: collapse; margin: 6px 0; max-width: 100%; width: 100%; font-size: 12px; table-layout: fixed; }
.msg th, .msg td { border: 1px solid var(--line); padding: 4px 7px; text-align: left; white-space: normal; overflow-wrap: break-word; word-break: break-word; }
.msg th:first-child, .msg td:first-child { width: 30%; }
.msg th { background: var(--panel2); color: var(--aki); font-weight: 700; }
.msg td { color: var(--txt); }
.msg tbody tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* ---- blockquotes ---- */
.msg blockquote { margin: 6px 0; padding: 4px 10px; border-left: 3px solid var(--k); background: var(--k-bg); color: var(--txt); }
.msg blockquote p { margin: 2px 0; }

/* ---- copy button on assistant messages ---- */
.msg-copy { position: absolute; top: 5px; right: 5px; font-size: 9px; line-height: 1; color: var(--dim); background: transparent; border: 1px solid transparent; padding: 3px 6px; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; font-family: inherit; opacity: 0.5; transition: opacity .15s; }
.msg.assistant:hover .msg-copy, .msg-copy:focus { opacity: 1; }
.msg-copy:hover { color: var(--k); border-color: rgba(77,240,255,0.35); }

.pending { align-self: flex-end; color: var(--dim); font-style: italic; font-size: 12px; border: 1px dashed rgba(53,230,255,0.5); border-radius: 0; }

@keyframes blink { 50% { opacity: 0; } }


.inputbar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--k);
  background: #020204;
  padding-bottom: calc(8px + var(--safe-bottom));
  box-shadow: inset 0 10px 18px -14px rgba(53,230,255,0.4);
}
.inputbar textarea {
  resize: none;
  height: 46px;
  max-height: 46px;
  overflow-y: auto;
  line-height: 1.4;
  color: var(--k);
}
.send { width: 50px; padding: 0; height: 46px; border-radius: 0; }
.mode {
  flex: none;
  width: 46px; padding: 0; height: 46px;
  border-radius: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  border: 1px solid var(--dim);
  background: transparent;
  clip-path: none;   /* outline button: don't inherit the .btn chamfer (leaves a black notch) */
}
.mode.steer { color: var(--warn); border-color: var(--warn); box-shadow: var(--glow-aki); }
.stop {
  width: 46px; padding: 0; height: 46px;
  background: transparent;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 0;
  font-size: 16px;
  clip-path: none;   /* outline button: don't inherit the .btn chamfer (leaves a black notch) */
}
.stop:active { background: rgba(255,214,10,0.14); }

/* reserved status line above the input: activity left, context gauge right */
.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  min-height: 20px;
  border-top: 1px solid #10151a;
  background: #020204;
  font-size: 10px;
  color: var(--dim);
}
.sbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbr { flex: none; color: var(--k); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* context gauge: segmented HUD bar, width driven by --ctxpct */
.ctxwrap { display: inline-flex; align-items: center; gap: 7px; flex: none; }
.ctxgauge {
  width: 58px; height: 6px;
  background: #0a0f13;
  border: 1px solid rgba(53,230,255,0.35);
  position: relative;
  overflow: hidden;
}
.ctxgauge::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 4px, #020204 4px 6px);
  pointer-events: none;
}
.ctxgauge-fill {
  display: block; height: 100%;
  width: calc(var(--ctxpct, 0) * 1%);
  background: linear-gradient(90deg, rgba(53,230,255,0.6), var(--k));
  box-shadow: 0 0 8px rgba(53,230,255,0.6);
  transition: width 0.4s ease;
}
/* over 80% the gauge warns (approaching compaction) */
.ctxgauge-fill.warn { background: linear-gradient(90deg, rgba(255,214,10,0.6), var(--warn)); box-shadow: 0 0 8px rgba(255,214,10,0.6); }

/* thin HUD scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: #232b31; border: 1px solid #000; }
::-webkit-scrollbar-thumb:hover { background: rgba(53,230,255,0.4); }

/* ---- image attachments (phone → Aki) ---- */
.attach { width: 46px; padding: 0; height: 46px; border-radius: 0; font-size: 20px; }
.hidden { display: none !important; }
#attachbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  border-top: 1px solid var(--k);
  background: #020204;
}
#attachbar img {
  height: 52px; max-width: 120px; object-fit: cover;
  border: 1px solid var(--aki);
  image-rendering: auto;
  box-shadow: var(--glow-aki);
}
#attach-x {
  background: transparent; border: 1px solid var(--warn); color: var(--warn);
  width: 28px; height: 28px; font-size: 16px; line-height: 1;
  border-radius: 0; cursor: pointer;
}
.msg .user-shot {
  display: block; margin-top: 6px;
  max-width: min(240px, 60vw); max-height: 240px;
  border: 1px solid var(--aki); border-radius: 2px;
  cursor: zoom-in;
  box-shadow: var(--glow-aki);
}
.img-chip {
  display: inline-block; margin-left: 8px; padding: 0 6px;
  font-size: 11px; color: var(--aki); border: 1px solid var(--aki);
  border-radius: 8px; vertical-align: middle;
}
.icon { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.12em; }

/* ---- rich tool cards: terminal + diff (monochrome) ---- */
.tc-term { font-family: ui-monospace, Menlo, Consolas, monospace; }
.tc-cmdline { display: flex; gap: 6px; }
.tc-ps1 { color: var(--aki); flex: none; }
.tc-cmd { color: #e8edf2; white-space: pre-wrap; word-break: break-word; }
.tc-out {
  color: #8a97a2; white-space: pre-wrap; word-break: break-word;
  border-top: 1px solid rgba(255,214,10,0.12);
  margin-top: 4px; padding-top: 4px;
}

/* diff rows: additions bright, removals dimmed, context quiet — no color,
   hierarchy comes from brightness + glyphs (monochrome aesthetic) */
.tc-diff { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 10.5px; }
.tc-dmeta { color: var(--dim); padding: 2px 0 4px; }
.tc-dl { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.tc-add { color: #f2f6fa; }
.tc-del { color: #4d5660; text-decoration: line-through; text-decoration-thickness: 1px; }
.tc-ctx { color: #6f7c87; }
.tc-argsbody { white-space: pre-wrap; }

/* streaming state: pulsing name while the model is still writing the call */
.tc.streaming .tc-name { animation: tcPulse 1.1s ease-in-out infinite; }
@keyframes tcPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* history tool cards are direct flex children of #messages; overflow:hidden
   zeroes their automatic flex min-height → 2px slivers. Never shrink. */
.tc { flex: 0 0 auto; }

/* ---------------- cron jobs panel ---------------- */
.cron { position: fixed; inset: 0; background: rgba(0,0,0,0.78); display: flex; align-items: center; justify-content: center; z-index: 60; }
.cron-card { width: min(92vw, 420px); max-height: 82vh; overflow: auto; background: #0b1014; border: 1px solid #1f2a33; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 0 24px rgba(0,0,0,0.8), var(--glow-k); }
.cron-head { display: flex; align-items: center; justify-content: space-between; color: var(--aki); letter-spacing: 1px; font-size: 15px; }
.cron-list { display: flex; flex-direction: column; gap: 8px; }
.cron-row { background: #12181e; border: 1px solid #1c2731; border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.cron-t { display: flex; flex-direction: column; gap: 2px; }
.cron-t small { color: #6b7a86; font-size: 11px; }
.cron-a { display: flex; gap: 6px; flex-wrap: wrap; }
.cron-a button, .cron-add button#cron-add { background: #1c2731; color: #cfe3f2; border: 1px solid #2a3640; border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; }
.cron-a button:hover, .cron-add button#cron-add:hover { background: #243340; }
.cron-add { border-top: 1px solid #1c2731; padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.cron-add input, .cron-add select, .cron-add textarea { background: #0b1014; color: #e6eef5; border: 1px solid #2a3640; border-radius: 6px; padding: 6px 8px; font-size: 13px; width: 100%; }
.cron-add textarea { resize: vertical; }
.cron-wake { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #cfe3f2; }
.cron-wake input { width: auto; }
.cron-add button#cron-add { margin-left: auto; }
