/* EDITH web HUD: a tactical display in the Halo Reactor palette (cyan core, amber attention,
   red limits) on dark glass, like the phone and desktop HUDs. */
@font-face { font-family: "Orbitron"; src: url("/fonts/Orbitron-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Rajdhani"; src: url("/fonts/Rajdhani-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }

:root {
  --bg: #03060b;
  --panel2: rgba(10, 26, 42, 0.55);
  --line: rgba(70, 160, 210, 0.20);
  --line-hi: rgba(45, 212, 255, 0.50);
  --text: #d6eaf4;
  --soft: #9dbccb;
  --dim: #6d8ea0;           /* 5:1 or better on the panels: fine for small text */
  --cyan: #2dd4ff;
  --amber: #ffb347;
  --red: #ff5c5c;
  --green: #46e39b;
  --ink: #00121b;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
  --display: "Orbitron", "Bahnschrift", system-ui, sans-serif;
  --body: "Rajdhani", "Bahnschrift", system-ui, sans-serif;
  --r: 14px;
  --chrome: 118px;          /* header + footer: what the two frames leave of the viewport */
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  padding: 0 max(18px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.muted { color: var(--soft); line-height: 1.45; }
code { font-family: var(--mono); font-size: 0.88em; color: var(--cyan); overflow-wrap: anywhere; }
b { color: var(--text); font-weight: inherit; }   /* Rajdhani ships one weight: no faux bold */
::selection { background: rgba(45, 212, 255, 0.3); }

/* --- the room: depth, a grid that fades out, a slow scan ---------------------------------- */
.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(900px 560px at 18% -10%, rgba(18, 96, 150, 0.32), transparent 62%),
    radial-gradient(760px 560px at 105% 112%, rgba(12, 74, 118, 0.26), transparent 60%),
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55)),
    var(--bg);
}
.backdrop .grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(45, 212, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 212, 255, 0.05) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 30%, #000 25%, transparent 78%);
          mask-image: radial-gradient(ellipse 85% 75% at 50% 30%, #000 25%, transparent 78%);
}
.backdrop::after {   /* faint scanlines */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
}
.backdrop .sweep {
  position: absolute; left: 0; right: 0; top: -45vh; height: 40vh;
  background: linear-gradient(to bottom, transparent, rgba(45, 212, 255, 0.035) 75%, rgba(45, 212, 255, 0.085) 99%, transparent);
  animation: sweep 12s linear infinite;
}
@keyframes sweep { to { transform: translateY(160vh); } }
.top, main, .foot { position: relative; z-index: 1; }

/* --- type and small parts ------------------------------------------------------------------ */
.wordmark {
  font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: 9px; color: var(--cyan);
  text-shadow: 0 0 18px rgba(45, 212, 255, 0.5), 0 0 2px rgba(45, 212, 255, 0.8);
}
.label { font-family: var(--display); font-size: 10px; letter-spacing: 3px; color: var(--soft); }
.label.center { text-align: center; color: var(--dim); }
.label.spaced { margin: 22px 0 8px; }
.label.spaced.first { margin-top: 2px; }
.dot {
  display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%;
  background: var(--dim); transition: background .3s, box-shadow .3s;
}
.dot.on { background: var(--cyan); box-shadow: 0 0 10px var(--cyan), 0 0 2px #fff inset; }
.dot.busy { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: blink 1s ease-in-out infinite; }
.dot.over { background: var(--red); box-shadow: 0 0 10px var(--red); }
@keyframes blink { 50% { opacity: .45; } }

/* --- header: brand, status ticker, telemetry, tabs ------------------------------------------ */
.top {
  max-width: 1320px; margin: 0 auto; padding: 16px 2px 12px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.tagline {
  font-family: var(--display); font-size: 9px; letter-spacing: 3px; color: var(--dim); text-transform: uppercase;
  padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap;
}
.status {
  justify-self: center; display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%;
  font-family: var(--display); font-size: 13px; letter-spacing: 4px; color: var(--cyan); white-space: nowrap;
  padding: 8px 18px; border: 1px solid rgba(45, 212, 255, 0.35); border-radius: 999px;
  background: linear-gradient(90deg, rgba(45, 212, 255, 0.02), rgba(45, 212, 255, 0.09), rgba(45, 212, 255, 0.02));
  text-shadow: 0 0 12px rgba(45, 212, 255, 0.55);
}
#status-label { overflow: hidden; text-overflow: ellipsis; }
.status.busy { color: var(--amber); border-color: rgba(255, 179, 71, 0.45); text-shadow: 0 0 12px rgba(255, 179, 71, 0.5);
  background: linear-gradient(90deg, rgba(255, 179, 71, 0.02), rgba(255, 179, 71, 0.1), rgba(255, 179, 71, 0.02)); }
.status.over { color: var(--red); border-color: rgba(255, 92, 92, 0.45); text-shadow: 0 0 12px rgba(255, 92, 92, 0.5);
  background: linear-gradient(90deg, rgba(255, 92, 92, 0.02), rgba(255, 92, 92, 0.1), rgba(255, 92, 92, 0.02)); }
.status.off { color: var(--dim); border-color: var(--line); text-shadow: none; background: transparent; }
.telemetry { display: flex; gap: 16px; font-family: var(--mono); font-size: 12px; color: var(--soft); white-space: nowrap; }
.tm .k { font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--soft); margin-right: 7px; }
.tabs { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(3, 10, 18, 0.65); }
.tab {
  background: transparent; border: 0; color: var(--soft); border-radius: 999px; padding: 7px 14px; cursor: pointer;
  font-family: var(--display); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; transition: color .2s, background .2s, box-shadow .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--ink); background: var(--cyan); box-shadow: 0 0 18px rgba(45, 212, 255, 0.45); }

/* --- layout -------------------------------------------------------------------------------- */
main > *, .top > * { min-width: 0; }   /* grid items may shrink below their content (phones) */
main {
  max-width: 1320px; margin: 0 auto; display: grid; grid-template-columns: minmax(340px, 500px) minmax(0, 1fr);
  gap: 18px; align-items: start;
}

/* --- frames: glass with corner brackets ----------------------------------------------------- */
.frame {
  position: relative; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 16px;
  background: linear-gradient(180deg, rgba(10, 25, 40, 0.84), rgba(4, 11, 20, 0.8));
  -webkit-backdrop-filter: blur(14px) saturate(125%); backdrop-filter: blur(14px) saturate(125%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(150, 228, 255, 0.07);
}
.frame::before, .frame::after {
  content: ""; position: absolute; width: 18px; height: 18px; pointer-events: none;
  border: 0 solid var(--cyan); opacity: .85; filter: drop-shadow(0 0 4px rgba(45, 212, 255, 0.7));
}
.frame::before { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; border-top-left-radius: var(--r); }
.frame::after { right: -1px; bottom: -1px; border-right-width: 2px; border-bottom-width: 2px; border-bottom-right-radius: var(--r); }
.frame-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 10px; margin-bottom: 12px; position: relative;
}
.frame-head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, var(--line-hi), rgba(45, 212, 255, 0.08) 60%, transparent);
}
.frame-head .label { flex: none; white-space: nowrap; }
.frame-head .label::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 9px; vertical-align: 1px;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan); transform: rotate(45deg);
}
.linkline, .meta-right { font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linkline { display: inline-flex; gap: 12px; }
.pip { color: var(--dim); }
.pip::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; border: 1px solid var(--dim); vertical-align: 0; }
.pip.on { color: var(--soft); }
.pip.on::before { background: var(--green); border-color: var(--green); box-shadow: 0 0 6px var(--green); }

/* --- the core: canvas and telemetry tiles --------------------------------------------------- */
.stage { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 64vh; margin: 0 auto; }
#orb { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.tile {
  position: relative; min-width: 0; padding: 10px 10px 9px; border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(180deg, rgba(45, 212, 255, 0.07), rgba(45, 212, 255, 0.012));
  overflow: hidden;
}
.tile::before { content: ""; position: absolute; left: 10px; right: 10px; top: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(45, 212, 255, 0.5), transparent); }
.tile .k { font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--soft); }
.tile .v {
  font-family: var(--display); font-size: 21px; color: var(--text); margin-top: 7px; line-height: 1;
  text-shadow: 0 0 14px rgba(45, 212, 255, 0.3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .s { font-size: 13px; color: var(--dim); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.5px; }
.tile.spend { display: flex; align-items: center; gap: 9px; }
.spend-text { min-width: 0; }
.gauge { width: 40px; height: 40px; flex: none; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 4; }
.gauge .track { stroke: rgba(255, 255, 255, 0.07); }
.gauge .fill {
  stroke: var(--cyan); stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 113.1;
  transition: stroke-dashoffset .7s ease, stroke .4s; filter: drop-shadow(0 0 3px rgba(45, 212, 255, 0.8));
}
.usage.warn .gauge .fill { stroke: var(--amber); filter: drop-shadow(0 0 3px rgba(255, 179, 71, 0.8)); }
.usage.over .gauge .fill { stroke: var(--red); filter: drop-shadow(0 0 3px rgba(255, 92, 92, 0.8)); }
.usage.over .v { color: var(--red); }

/* --- comms ---------------------------------------------------------------------------------- */
.comms { display: flex; flex-direction: column; }
.live { display: inline-flex; align-items: center; gap: 7px; font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--dim); }
.live .dot { width: 7px; height: 7px; }
.live.on { color: var(--green); }
.live.on .dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 2s ease-in-out infinite; }
.transcript {
  flex: 1; min-height: 160px; overflow-y: auto; padding-right: 6px; outline: none;
  display: flex; flex-direction: column;   /* the conversation sits on the command line */
  font-family: var(--mono); font-size: 14px; line-height: 1.55;
  scrollbar-width: thin; scrollbar-color: rgba(45, 212, 255, 0.3) transparent;
}
.transcript > :first-child { margin-top: auto; }
.transcript > .empty:only-child { margin-bottom: auto; }
.transcript:focus-visible { box-shadow: inset 0 0 0 1px var(--line-hi); border-radius: 8px; }
.transcript::-webkit-scrollbar { width: 6px; }
.transcript::-webkit-scrollbar-thumb { background: rgba(45, 212, 255, 0.25); border-radius: 3px; }
.line {
  display: grid; grid-template-columns: 42px 58px minmax(0, 1fr); gap: 10px; align-items: start; flex: none;
  padding: 8px 0; border-bottom: 1px dashed rgba(70, 160, 210, 0.09); animation: rise .28s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }
.line .t { color: var(--dim); font-size: 11px; padding-top: 3px; }
.line .who {
  font-family: var(--display); font-size: 9px; letter-spacing: 1px; text-align: center;
  padding: 4px 0 3px; border-radius: 5px; margin-top: 1px; border: 1px solid transparent;
}
.line.you .who { color: var(--cyan); border-color: rgba(45, 212, 255, 0.45); }
.line.edith .who { color: var(--ink); background: var(--cyan); box-shadow: 0 0 12px rgba(45, 212, 255, 0.45); }
.line.system .who { color: var(--soft); border-color: var(--line); }
.line .text { word-break: break-word; white-space: pre-wrap; }
.line.you .text { color: #a9ecff; }
.line.edith .text { color: var(--text); }
.line.system .text { color: var(--dim); font-style: italic; }
.line.auto .who { color: var(--amber); border-color: rgba(255, 179, 71, 0.5); }
.line.auto .text { color: #ffd9a3; }
.line.local { opacity: .65; }
.line.hist { animation: none; }   /* sent, not yet confirmed by the brain */
.line .tag {
  display: inline-block; margin-right: 7px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--display); font-size: 8px; letter-spacing: 1px; color: var(--soft); vertical-align: 2px; font-style: normal;
}
.more { align-self: center; flex: none; margin: 2px 0 6px; font-size: 13px; }
.conv { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 7px; justify-content: center; }
.conv-pick {
  min-width: 0; max-width: 100%; background: rgba(3, 12, 20, 0.85); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 8px; font-family: var(--display); font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
}
.conv-pick:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.conv-pick option { background: #06121c; text-transform: none; letter-spacing: 0; font-family: var(--body); font-size: 14px; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); flex: none; }
.thinking .text i {
  display: inline-block; width: 6px; height: 6px; margin: 0 3px 0 0; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: think 1.1s ease-in-out infinite;
}
.thinking .text i:nth-child(2) { animation-delay: .15s; }
.thinking .text i:nth-child(3) { animation-delay: .3s; }
@keyframes think { 0%, 80%, 100% { opacity: .2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.empty { color: var(--dim); text-align: center; padding: 44px 0; font-family: var(--mono); font-size: 13px; letter-spacing: 1px; }

/* --- approvals: an alert, not a chat line ---------------------------------------------------- */
.card {
  position: relative; margin: 12px 0 2px; padding: 16px 14px 13px; overflow: hidden;
  border: 1px solid rgba(255, 179, 71, 0.6); border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 179, 71, 0.1), rgba(255, 179, 71, 0.03));
  animation: alert 1.6s ease-in-out infinite alternate, rise .28s ease-out;
}
.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; opacity: .75;
  background: repeating-linear-gradient(-45deg, var(--amber) 0 8px, transparent 8px 16px);
}
.card .label { color: var(--amber); margin-bottom: 7px; text-shadow: 0 0 10px rgba(255, 179, 71, 0.45); }
.card .what { color: var(--text); line-height: 1.45; font-size: 16px; overflow-wrap: anywhere; }
.card .row { margin-top: 12px; }
@keyframes alert { from { box-shadow: 0 0 8px rgba(255, 179, 71, 0.07); } to { box-shadow: 0 0 30px rgba(255, 179, 71, 0.24); } }

/* --- the command line ---------------------------------------------------------------------- */
.say {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 5px 5px 5px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(2, 8, 15, 0.75);
  transition: border-color .2s, box-shadow .2s;
}
.say:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(45, 212, 255, 0.12), 0 0 26px rgba(45, 212, 255, 0.16); }
.say .prompt { font-family: var(--mono); color: var(--cyan); font-size: 20px; line-height: 1; text-shadow: 0 0 10px var(--cyan); }
input[type=text], input[type=password] {
  flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 12px 14px; font: inherit; font-size: 16px; outline: none;
}
input:focus { border-color: var(--cyan); }
.say input[type=text] { border: 0; background: transparent; padding: 10px 2px; font-family: var(--mono); font-size: 16px; }   /* 16px: no zoom on iPhone */
.say input:disabled { opacity: .5; }
input::placeholder { color: var(--dim); }

.btn {
  border: 1px solid var(--cyan); background: transparent; color: var(--cyan); border-radius: 10px; cursor: pointer;
  padding: 11px 18px; font-family: var(--display); font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  transition: background .2s, box-shadow .2s, color .2s, opacity .2s;
}
.btn:hover:not(:disabled) { box-shadow: 0 0 18px rgba(45, 212, 255, 0.4); }
.btn.primary { background: var(--cyan); color: var(--ink); font-weight: 700; }
.btn.go { border-color: var(--amber); background: var(--amber); color: #1c1000; font-weight: 700; }
.btn.go:hover { box-shadow: 0 0 20px rgba(255, 179, 71, 0.5); }
.btn.no { border-color: rgba(157, 188, 203, 0.55); color: var(--soft); }
.btn:disabled { opacity: .35; cursor: default; }
.btn:focus-visible, .tab:focus-visible, .linklike:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.linklike { background: none; border: none; color: var(--soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; font-size: 14px; padding: 4px 0; }
.linklike:hover { color: var(--cyan); }
.error { color: var(--red); min-height: 1.2em; margin: 0; }

/* --- bodies --------------------------------------------------------------------------------- */
.bodies { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.bcard {
  position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 14px; padding: 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); animation: rise .28s ease-out;
}
.bcard .ico svg { width: 50px; height: 50px; fill: none; stroke: var(--cyan); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 7px rgba(45, 212, 255, 0.55)); }
.bcard.phone .ico svg { stroke: var(--green); filter: drop-shadow(0 0 7px rgba(70, 227, 155, 0.5)); }
.bcard .kind { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--soft); }
.bcard .kind .dot { width: 7px; height: 7px; }
.bcard.phone .kind .dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.bcard .name { font-size: 20px; font-weight: 500; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard .stats { display: flex; gap: 18px; margin-top: 8px; }
.stat .k { display: block; font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--soft); }
.stat .v { font-family: var(--mono); font-size: 14px; color: var(--text); }
.bcard .id { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard details { margin-top: 8px; }
.bcard summary { cursor: pointer; color: var(--soft); font-size: 14px; letter-spacing: .5px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; max-height: 180px; overflow-y: auto; }
.chips span { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--soft); }
.bcard.missing { border-style: dashed; background: transparent; }
.bcard.missing .ico svg { stroke: var(--dim); filter: none; opacity: .8; }
.bcard.missing .name { color: var(--soft); }
.bcard.missing .hint { color: var(--dim); font-size: 14px; margin-top: 4px; line-height: 1.4; }
.howto { margin-top: 6px; }
.pcs { display: grid; gap: 10px; }
.pcrow {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); animation: rise .28s ease-out;
}
.pcrow .kind { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--soft); }
.pcrow .kind .dot { width: 7px; height: 7px; }
.pcrow .name { font-size: 18px; font-weight: 500; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcrow .id { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-backup { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pc-backup .k { font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--soft); margin-right: 2px; }
.chip { font: inherit; font-size: 14px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--soft); cursor: pointer; transition: border-color .15s, color .15s, box-shadow .15s; }
.chip[aria-pressed="true"] { border-color: var(--green); color: var(--green); background: rgba(70, 227, 155, 0.08); box-shadow: 0 0 12px rgba(70, 227, 155, 0.18); }
.chip:hover:not(:disabled) { border-color: var(--cyan); color: var(--text); }
.chip:disabled { opacity: .5; cursor: default; }
.chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.pcs-note { font-size: 14px; margin: 8px 0 0; }
.pcrow .mode { display: inline-block; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; font-family: var(--display); font-size: 9px; letter-spacing: 1px; color: var(--soft); }
.pcrow .mode.admin { border-color: var(--amber); color: var(--amber); }
.pcrow .pc-main { grid-row: span 2; }
.pc-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-self: end; }
.pc-acts:empty { display: none; }
@media (max-width: 760px) { .pcrow { grid-template-columns: minmax(0, 1fr); gap: 10px; } .pcrow .pc-main { grid-row: auto; } .pcrow .pc-acts { justify-self: start; } }

/* --- activity timeline ----------------------------------------------------------------------- */
.activity { position: relative; padding-left: 20px; }
.activity::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: linear-gradient(var(--line-hi), transparent); }
.activity .empty { margin-left: -20px; }
.activity .item {
  position: relative; display: grid; grid-template-columns: 60px minmax(0, 1fr) 66px 70px; gap: 10px; align-items: baseline;
  padding: 8px 0; font-family: var(--mono); font-size: 13px; border-bottom: 1px dashed rgba(70, 160, 210, 0.1); animation: rise .28s ease-out;
}
.activity .item::before { content: ""; position: absolute; left: -18px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.activity .item.bad::before { background: var(--red); box-shadow: 0 0 8px var(--red); }
.activity .item > :last-child { justify-self: end; }
.activity .t, .activity .ms { color: var(--dim); }
.activity .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity .where { justify-self: center; font-family: var(--display); font-size: 9px; letter-spacing: 1px; color: var(--soft); padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; }
.activity .ok { color: var(--green); }
.activity span.bad, .activity .bad .name { color: var(--red); }

/* --- vault ----------------------------------------------------------------------------------- */
.vault-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); overflow: hidden; margin: -2px 0 14px; }
#vault-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--green)); box-shadow: 0 0 10px rgba(45, 212, 255, 0.6); transition: width .6s; }
.vault-sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.vsrc { text-align: left; cursor: pointer; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); color: var(--text); font: inherit; transition: border-color .2s, box-shadow .2s; }
.vsrc:hover, .vsrc.on { border-color: var(--cyan); box-shadow: 0 0 18px rgba(45, 212, 255, 0.18); }
.vsrc .n { font-size: 18px; }
.vsrc .pc { font-family: var(--mono); font-size: 11px; color: var(--cyan); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vsrc .m { font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--soft); margin-top: 4px; }
.vsrc .w { font-size: 13px; color: var(--dim); margin-top: 2px; }
.vault-browser { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.vault-nav { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.vault-nav select { background: rgba(255, 255, 255, 0.04); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 15px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; font-family: var(--mono); font-size: 13px; color: var(--soft); }
.crumbs button { background: none; border: 0; color: var(--cyan); cursor: pointer; font: inherit; padding: 2px 4px; }
.vault-list { max-height: 50vh; overflow-y: auto; }
.vrow { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 8px 6px; background: none; border: 0; border-bottom: 1px dashed rgba(70, 160, 210, 0.1); color: var(--text); font-family: var(--mono); font-size: 13px; cursor: pointer; }
.vrow:hover { background: rgba(45, 212, 255, 0.05); }
.vrow .i { color: var(--cyan); }
.vrow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow .sz { color: var(--dim); }
.vault-note { margin-top: 14px; font-size: 14px; }

/* --- settings -------------------------------------------------------------------------------- */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0 0 16px; }
.facts dt { color: var(--soft); font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; padding-top: 3px; }
.facts dd { margin: 0; font-family: var(--mono); font-size: 14px; word-break: break-all; }
input.code { font-family: var(--mono); font-size: 24px; letter-spacing: 8px; text-align: center; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: fit-content; margin: 8px 0; box-shadow: 0 0 30px rgba(45, 212, 255, 0.25); }
.qr svg { display: block; width: 180px; height: 180px; }
#totp-setup { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
#totp-setup input[type=password] { width: 100%; }
#tab-settings .row { margin-top: 6px; }
.backup-row input[type=password] { flex: 1 1 220px; }

/* --- sign-in --------------------------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  overflow-y: auto; overscroll-behavior: contain;   /* a card taller than the screen scrolls */
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(640px 440px at 50% 42%, rgba(18, 84, 128, 0.42), rgba(2, 5, 9, 0.97) 72%);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.login { --tone: var(--cyan); --tone-a: rgba(45, 212, 255, 0.3); width: 100%; max-width: 420px; margin: auto; padding: 28px 26px 16px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login.denied { --tone: var(--red); --tone-a: rgba(255, 92, 92, 0.3); }
.login.granted { --tone: var(--green); --tone-a: rgba(70, 227, 155, 0.3); }
.login input { width: 100%; }
.login .wordmark { font-size: 30px; letter-spacing: 14px; margin-right: -14px; }
.login .muted { margin: 0; }
.login .muted.small { font-size: 14px; }
.login label.label { display: block; margin-bottom: 10px; }
.login-link { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: -4px;
  font-family: var(--display); font-size: 9px; letter-spacing: 2.5px; color: var(--soft); text-transform: uppercase; overflow-wrap: anywhere; }

/* the core: a tick ring, two counter-rotating arcs and a breathing light; faster while checking,
   red on a wrong code, green when let in */
.login-core { position: relative; width: 136px; height: 136px; margin: 0 auto 2px; flex: none; }
.login-core i { position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, var(--tone) 0 1.2deg, transparent 1.2deg 10deg);
  -webkit-mask: radial-gradient(circle, transparent 63px, #000 64px 67px, transparent 68px);
          mask: radial-gradient(circle, transparent 63px, #000 64px 67px, transparent 68px);
  opacity: .55; animation: spin 40s linear infinite; }
.login-core span { position: absolute; inset: 12px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--tone); border-left-color: var(--tone-a);
  animation: spin 2.6s linear infinite; filter: drop-shadow(0 0 6px var(--tone)); transition: border-color .3s; }
.login-core span:nth-child(3) { inset: 28px; border-top-color: transparent; border-bottom-color: var(--tone); border-left-color: transparent; border-right-color: var(--tone-a); animation-duration: 3.8s; animation-direction: reverse; }
.login-core span:nth-child(4) { inset: 50px; border: 0; background: radial-gradient(circle, #fff 0%, var(--tone) 38%, transparent 72%); animation: breathe 2.4s ease-in-out infinite; filter: none; }
.login.busy .login-core span { animation-duration: .7s; }
.login.busy .login-core span:nth-child(3) { animation-duration: 1s; }
.login.busy .login-core span:nth-child(4) { animation-duration: .8s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.18); opacity: .82; } }

/* six boxes over one real input: typing, paste and one-time-code autofill all land in it */
.code-boxes { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 12px repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 336px; margin: 0 auto; }
.code-boxes input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; padding: 0; border: 0; background: transparent;
  color: transparent; caret-color: transparent; font-size: 16px; cursor: text; }
.code-boxes input::selection { background: transparent; }
.code-boxes input:focus-visible { outline: none; }
.code-boxes span { height: 58px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(3, 12, 20, 0.75); font-family: var(--mono); font-size: 26px; color: var(--text);
  transition: border-color .15s, box-shadow .15s; }
.code-boxes b { align-self: center; height: 2px; background: var(--line-hi); border-radius: 1px; }
.code-boxes span.on { border-color: var(--tone); box-shadow: 0 0 14px var(--tone-a), inset 0 0 10px var(--tone-a); }
.code-boxes span.on:empty::after { content: ""; width: 2px; height: 26px; background: var(--tone); animation: blink 1s steps(2) infinite; }
.code-boxes span.full { border-color: var(--line-hi); color: var(--tone); text-shadow: 0 0 10px var(--tone-a); }
.login.denied .code-boxes { animation: shake .42s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.code-timer { height: 3px; max-width: 336px; margin: 12px auto 8px; background: rgba(70, 160, 210, 0.15); border-radius: 2px; overflow: hidden; }
.code-timer div { height: 100%; width: 100%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); transform-origin: left; transition: transform .25s linear; }
.code-timer div.low { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.login-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line);
  font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--dim); text-transform: uppercase; }
#login-clock { font-family: var(--mono); font-size: 11px; letter-spacing: 1px; }
@media (max-width: 380px) {
  .login { padding: 22px 16px 14px; }
  .code-boxes { gap: 6px; grid-template-columns: repeat(3, minmax(0, 1fr)) 8px repeat(3, minmax(0, 1fr)); }
  .code-boxes span { height: 50px; font-size: 22px; }
}

/* --- footer ---------------------------------------------------------------------------------- */
.foot {
  max-width: 1320px; margin: 14px auto 0; display: flex; justify-content: space-between; gap: 12px;
  font-family: var(--display); font-size: 9px; letter-spacing: 1.5px; color: var(--dim); text-transform: uppercase;
}

/* --- desktop: the two frames share one height that fits the screen -------------------------- */
@media (min-width: 861px) {
  main { align-items: stretch; }
  .core, .comms { height: clamp(520px, calc(100vh - var(--chrome)), 920px); }
  .core { display: flex; flex-direction: column; }
  .core .stage { flex: 1 1 0; min-height: 0; max-height: none; aspect-ratio: auto; }
  #tab-bodies, #tab-activity, #tab-settings { min-height: clamp(520px, calc(100vh - var(--chrome)), 920px); }
}
/* the status gets a row of its own before it would be cut */
@media (max-width: 1300px) {
  :root { --chrome: 168px; }
  .tagline { display: none; }
  .top { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 10px; }
  .telemetry { justify-self: end; }
  .status { grid-row: 2; grid-column: 1 / -1; justify-self: center; }
}
@media (max-width: 1120px) {
  main { grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); }
}
/* big screens use more of themselves */
@media (min-width: 1600px) {
  .top, main, .foot { max-width: 1520px; }
  main { grid-template-columns: minmax(340px, 620px) minmax(0, 1fr); }
}
@media (min-width: 1800px) and (min-height: 1100px) {
  .top, main, .foot { max-width: 1760px; }
  main { grid-template-columns: minmax(340px, 680px) minmax(0, 1fr); }
  .core, .comms { height: calc(100vh - var(--chrome)); }
  #tab-bodies, #tab-activity, #tab-settings { min-height: calc(100vh - var(--chrome)); }
}

/* --- phones and tablets: one column, the active pane first ---------------------------------- */
@media (max-width: 860px) {
  body { padding: 0 max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .top { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; padding-top: 12px; }
  .status { grid-row: auto; grid-column: 1 / -1; order: 3; justify-self: stretch; justify-content: center; font-size: 12px; letter-spacing: 3px; }
  .tabs { grid-column: 1 / -1; order: 4; }
  .tab { flex: 1 1 0; min-width: 0; padding: 9px 2px; letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis; }
  .telemetry { gap: 12px; font-size: 11px; }
  main { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  main > .tabpane { order: -1; }   /* what a tab tap shows (and an approval) is on the first screen */
  .stage { max-width: 440px; max-height: 52vh; }
  .comms { height: auto; }
  .transcript { max-height: 40vh; max-height: 40dvh; }
  .line { grid-template-columns: 50px minmax(0, 1fr); }
  .line .t { display: none; }
}
@media (max-width: 420px) {
  .wordmark { font-size: 19px; letter-spacing: 7px; }
  .telemetry .tm:first-child { display: none; }
  .tile .v { font-size: 18px; }
  .tile .s { white-space: normal; line-height: 1.25; }
  .bodies { grid-template-columns: minmax(0, 1fr); }
  .activity .item { grid-template-columns: 48px minmax(0, 1fr) 70px; }
  .activity .where { display: none; }
}
/* touch devices: no full-screen sweep and no live blur behind the (nearly opaque) frames */
@media (pointer: coarse) {
  .backdrop .sweep { display: none; }
  .frame { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition: none !important; }
  .backdrop .sweep { display: none; }
}
/* --- device names: the pencil and the editor in place ------------------------------------------ */
.bcard .name, .pcrow .name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bcard .name .nm, .pcrow .name .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--soft); opacity: .7;
  transition: opacity .15s, color .15s, border-color .15s, box-shadow .15s;
}
.icon-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover, .icon-btn:focus-visible { opacity: 1; color: var(--cyan); border-color: var(--line-hi); box-shadow: 0 0 10px rgba(45, 212, 255, 0.25); }
.icon-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
@media (hover: none) { .icon-btn { opacity: 1; } }
form.rename { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 6px; align-items: center; margin-top: 5px; max-width: 420px; }
form.rename .rename-input { grid-column: 1 / -1; width: 100%; }
form.rename .rename-input { padding: 7px 10px; border-color: var(--line-hi); background: rgba(3, 12, 20, 0.85); box-shadow: 0 0 12px rgba(45, 212, 255, 0.12); }
.btn.sm { padding: 8px 12px; font-size: 9px; letter-spacing: 1.5px; border-radius: 8px; }
.rename-note { grid-column: 1 / -1; font-size: 13px; color: var(--dim); }
.bcard.seen, .pcrow.seen { animation: none; }   /* only a new card fades in, not every live update */
.rename-note.error { color: var(--red); }

/* --- pictures in the chat: a thumbnail under the words, full size in a viewer ------------------ */
.shots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.shot {
  padding: 0; border: 1px solid var(--line-hi); border-radius: 10px; background: rgba(3, 12, 20, 0.8); cursor: zoom-in;
  overflow: hidden; max-width: min(100%, 420px); box-shadow: 0 0 14px rgba(45, 212, 255, 0.15);
}
.shot img { display: block; max-width: 100%; max-height: 220px; object-fit: contain; }
.shot.missing { padding: 10px 12px; color: var(--dim); font-size: 13px; cursor: default; box-shadow: none; }
.shot:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.lightbox {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; background: rgba(2, 5, 9, 0.92); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); border: 1px solid var(--line-hi); border-radius: 10px; box-shadow: 0 0 40px rgba(45, 212, 255, 0.2); cursor: default; }
.shot img:not([src]) { width: 200px; height: 112px; }
/* a screen video plays in place, with its own controls (full screen from there) */
video.shot.clip { display: block; max-height: 260px; width: auto; cursor: default; }
/* a sound clip: the browser's player, as wide as a thumbnail */
/* a LIVE card (listen_mic): play/stop, a pulsing LIVE tag while it plays, the time listened */
.shot.live { display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; cursor: default; min-width: 240px; }
.live-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--cyan); color: #04060a; font-size: 16px; cursor: pointer; flex: none; }
.live-btn:disabled { opacity: 0.35; cursor: default; }
.live-tag { display: inline-flex; align-items: center; gap: 6px; font: 600 10px/1 "Orbitron", sans-serif; letter-spacing: 0.15em; color: var(--dim); }
.live-tag i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.shot[data-state="on"] .live-tag { color: #ff5468; }
.shot[data-state="on"] .live-tag i { background: #ff5468; animation: live-pulse 1.2s ease-in-out infinite; }
.shot.live[data-state="ended"], .shot.livecam[data-state="ended"] { opacity: 0.6; }
/* a LIVE webcam card (watch_camera): the picture 16:9, play over it, the LIVE bar below */
.shot.livecam { display: block; width: min(100%, 420px); padding: 0; cursor: default; overflow: hidden; }
.cam-view { position: relative; aspect-ratio: 16 / 9; background: #000; display: flex; align-items: center; justify-content: center; }
.cam-view img { width: 100%; height: 100%; object-fit: contain; display: block; cursor: zoom-in; }
.cam-view img:not([src]) { display: none; }
.cam-play { position: absolute; width: 56px; height: 56px; font-size: 22px; box-shadow: 0 0 24px rgba(45, 212, 255, 0.35); }
.cam-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.cam-stop { border: 1px solid #ff5468; color: #ff5468; background: transparent; border-radius: 14px; padding: 4px 12px; font-size: 12px; cursor: pointer; }
.live-what { color: var(--text); font-size: 13px; }
.live-time { margin-left: auto; color: var(--dim); font: 12px/1 ui-monospace, monospace; }
@keyframes live-pulse { 50% { opacity: 0.25; } }
audio.shot.sound { display: block; width: min(100%, 360px); height: 40px; cursor: default; background: transparent; border: none; box-shadow: none; color-scheme: dark; border-radius: 20px; }
