/* ============================================================
   RESUMEEASY · BIBABOBA — стили HUD
   Синий компьютер из «Железного человека»: чёрный фон, циан, оранж ошибок
   ============================================================ */

:root {
  --bg: #030810;
  --panel: rgba(8, 22, 38, 0.72);
  --line: rgba(25, 200, 255, 0.18);
  --cyan: #19c8ff;
  --cyan-soft: rgba(25, 200, 255, 0.35);
  --green: #2bffb0;
  --amber: #ffb54d;
  --red: #ff5f47;
  --text: #cfefff;
  --dim: #5f87a8;
  --font-head: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  letter-spacing: 0.02em;
}

/* ---------- фон ---------- */
#bg { position: fixed; inset: 0; z-index: 0; }

#scanlines {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* ---------- каркас ---------- */
#app {
  position: relative; z-index: 10;
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-rows: 54px 1fr 218px;
  gap: 10px; padding: 10px 12px;
}

main {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 10px; min-height: 0;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(3px);
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
}

/* уголки-скобки как у HUD */
.panel::before, .panel::after {
  content: ""; position: absolute; width: 14px; height: 14px;
  border: 2px solid var(--cyan-soft); pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.panel-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 8px 12px 6px;
  font-family: var(--font-head);
  font-size: 12px; font-weight: 700; letter-spacing: 0.22em;
  color: var(--cyan);
  border-bottom: 1px solid var(--line);
  text-shadow: 0 0 8px var(--cyan-soft);
  flex: 0 0 auto;
}
.panel-title .hint {
  font-family: var(--font-body); font-weight: 500; font-size: 11px;
  letter-spacing: 0.06em; color: var(--dim); text-shadow: none;
}

/* ---------- верхняя панель ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); padding: 0 14px;
  backdrop-filter: blur(3px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  color: var(--cyan); font-size: 22px;
  text-shadow: 0 0 12px var(--cyan);
  animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse { 50% { text-shadow: 0 0 22px var(--cyan); opacity: .85; } }
.brand-name {
  font-family: var(--font-head); font-weight: 900; font-size: 16px;
  letter-spacing: 0.28em; color: var(--text);
}
.brand-sub {
  font-family: var(--font-head); font-weight: 500; font-size: 11px;
  letter-spacing: 0.34em; color: var(--cyan);
  border-left: 1px solid var(--line); padding-left: 10px;
}
.top-status { display: flex; align-items: center; gap: 8px; }

.chip {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 0.14em;
  color: var(--cyan); background: rgba(25, 200, 255, 0.08);
  border: 1px solid var(--cyan-soft); border-radius: 4px;
  padding: 4px 8px; cursor: pointer; user-select: none;
  transition: background .2s, box-shadow .2s;
}
.chip:hover { background: rgba(25, 200, 255, 0.18); box-shadow: 0 0 10px var(--cyan-soft); }
.chip.warn { color: var(--amber); border-color: rgba(255, 181, 77, 0.4); background: rgba(255, 181, 77, 0.08); }
.chip.warn:hover { background: rgba(255, 181, 77, 0.16); }
.chip.ghost { color: var(--dim); border-color: rgba(95, 135, 168, 0.35); background: transparent; cursor: default; }

.conn { display: flex; align-items: center; gap: 6px; font-family: var(--font-head); font-size: 10px; letter-spacing: 0.14em; color: var(--dim); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.conn.on { color: var(--green); }
.conn.on i { background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 2s infinite; }
.conn.off { color: var(--red); }
.conn.off i { background: var(--red); animation: blink 0.8s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.clock { font-family: var(--font-head); font-size: 14px; color: var(--text); letter-spacing: 0.14em; text-shadow: 0 0 8px var(--cyan-soft); }

/* ---------- карта (SVG) ---------- */
#mapPanel { overflow: hidden; }
#mapWrap { flex: 1; min-height: 0; }
#map { width: 100%; height: 100%; display: block; }

.nd { cursor: default; }
.nd .ring-o { fill: none; stroke: var(--cyan-soft); stroke-width: 1.4; stroke-dasharray: 4 7; opacity: .55; }
.nd .ring-i { fill: none; stroke: rgba(25, 200, 255, 0.14); stroke-width: 1; }
.nd .core { fill: rgba(6, 18, 30, 0.9); stroke: rgba(25, 200, 255, 0.35); stroke-width: 1.2; transition: stroke .3s; }
.nd .glyph { font-size: 19px; text-anchor: middle; dominant-baseline: central; }
.nd .nlabel {
  font-family: var(--font-head); font-weight: 700; font-size: 12px; letter-spacing: 0.18em;
  text-anchor: middle; fill: var(--text);
}
.nd .nsub {
  font-family: var(--font-body); font-weight: 500; font-size: 10.5px;
  text-anchor: middle; fill: var(--dim);
}
.nd .dot { fill: var(--dim); }

.nd .spin  { transform-box: fill-box; transform-origin: center; animation: rot 14s linear infinite; }
.nd .spinR { transform-box: fill-box; transform-origin: center; animation: rotR 22s linear infinite; }
@keyframes rot  { to { transform: rotate(360deg); } }
@keyframes rotR { to { transform: rotate(-360deg); } }

.nd.active .ring-o { stroke: var(--cyan); opacity: 1; animation-duration: 3.2s; }
.nd.active .core { stroke: var(--cyan); fill: rgba(12, 42, 66, 0.95); filter: drop-shadow(0 0 10px var(--cyan-soft)); }
.nd.active .nlabel { fill: var(--cyan); text-shadow: 0 0 10px var(--cyan-soft); }
.nd.active .dot { fill: var(--cyan); box-shadow: 0 0 6px var(--cyan); }

.nd.done .core { stroke: var(--green); }
.nd.done .nlabel { fill: var(--green); }
.nd.done .dot { fill: var(--green); }

.nd.err .core { stroke: var(--red); fill: rgba(60, 12, 10, 0.9); }
.nd.err .nlabel { fill: var(--red); }
.nd.err .dot { fill: var(--red); animation: blink .5s infinite; }
.nd.err { animation: shake .45s ease-in-out 2; }
@keyframes shake {
  25% { transform: translateX(-2.5px); } 75% { transform: translateX(2.5px); }
}

.nd.planned .ring-o, .nd.planned .core { stroke: rgba(95, 135, 168, 0.35); stroke-dasharray: 2 5; opacity: .5; }
.nd.planned .nlabel { fill: var(--dim); }
.nd.planned .glyph { opacity: .45; }

/* активный узел светится РОВНО; вспышка (мигание) — только на событие */
.nd.active .glowring { display: block; animation: none; opacity: .32; transform: scale(1.3); }
.nd.burst .glowring { display: block; animation: breathe .55s ease-out 3; }
.glowring { display: none; fill: none; stroke: var(--cyan); stroke-width: 1; opacity: .6; transform-box: fill-box; transform-origin: center; animation: breathe 1.6s ease-out infinite; }
@keyframes breathe { 0% { transform: scale(1); opacity: .6; } 100% { transform: scale(1.7); opacity: 0; } }

/* связи */
.lk { fill: none; stroke: rgba(25, 200, 255, 0.16); stroke-width: 1.6; stroke-dasharray: 5 7; }
.lk.flow { animation: dashflow 1.1s linear infinite; }
@keyframes dashflow { to { stroke-dashoffset: -24; } }
.lk.on {
  stroke: var(--cyan); opacity: 1;
  filter: drop-shadow(0 0 5px var(--cyan-soft));
  stroke-dasharray: 5 7; animation: dashflow .45s linear infinite;
}
.lk.err { stroke: var(--red); }

/* ярлыки связей */
.lklabel {
  font-family: var(--font-body); font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-anchor: middle; fill: var(--dim); opacity: .8;
}

/* бегущий импульс */
.pulse { fill: #bff2ff; filter: drop-shadow(0 0 6px var(--cyan)); }
.pulse.err { fill: #ffb3a6; filter: drop-shadow(0 0 6px var(--red)); }

/* ---------- правая колонка ---------- */
#side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
#nowPanel { flex: 1.25; }
#tbotPanel { flex: 1; }

.idle-note, .tbot-run.idle {
  color: var(--dim); font-size: 13px; text-align: center; margin: auto 0; padding: 18px 10px;
  letter-spacing: 0.1em;
}

.now-stage {
  font-family: var(--font-head); font-weight: 700; font-size: 21px;
  color: var(--cyan); text-align: center; letter-spacing: 0.1em;
  text-shadow: 0 0 14px var(--cyan-soft);
  margin: 10px 12px 2px; text-transform: uppercase;
}
.now-stage.ok { color: var(--green); text-shadow: 0 0 14px rgba(43, 255, 176, .4); }
.now-stage.bad { color: var(--red); text-shadow: 0 0 14px rgba(255, 95, 71, .4); }

.now-row {
  display: flex; justify-content: center; gap: 8px; margin: 2px 12px 6px;
  font-family: var(--font-head); font-size: 10px; letter-spacing: 0.2em; color: var(--dim);
}
.now-row #nowStepNo { color: var(--text); }

.typebox {
  margin: 2px 14px 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-left: 2px solid var(--cyan);
  background: rgba(3, 10, 18, 0.6); border-radius: 4px;
  font-size: 13.5px; font-weight: 500; min-height: 40px; line-height: 1.35;
  color: #e3f6ff;
}
.caret { color: var(--cyan); animation: blink 0.9s steps(1) infinite; }

.steps {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 2px; padding: 0 10px 8px;
}
.step { display: flex; align-items: center; gap: 2px; }
.step i {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid var(--dim); background: transparent; display: block;
}
.step.active i { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.step.done i { background: var(--green); border-color: var(--green); }
.step.err i { background: var(--red); border-color: var(--red); box-shadow: 0 0 6px var(--red); }
.step span {
  font-size: 10px; color: var(--dim); margin: 0 5px 0 3px;
  font-weight: 600; letter-spacing: 0.05em;
}
.step.active span { color: var(--cyan); }
.step.done span { color: var(--green); }
.step.err span { color: var(--red); }
.step-arrow { color: rgba(95, 135, 168, 0.5); font-size: 9px; margin-right: 5px; }

.now-result {
  margin: 0 14px 10px; padding: 7px 10px; border-radius: 4px; font-size: 12.5px;
  border: 1px solid rgba(43, 255, 176, 0.35); color: var(--green);
  background: rgba(43, 255, 176, 0.06);
}
.now-result.bad {
  border-color: rgba(255, 95, 71, 0.4); color: var(--red); background: rgba(255, 95, 71, 0.06);
}

/* ---------- TBOT ---------- */
.tbot-run {
  padding: 7px 14px 4px; font-size: 13px; font-weight: 600; color: var(--text);
}
.tbot-run .rlabel { color: var(--cyan); font-family: var(--font-head); font-size: 11px; letter-spacing: 0.16em; }
.tbot-run.idle { color: var(--dim); }

.chips {
  display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 10px 4px; align-content: flex-start;
  flex: 1; overflow-y: auto; min-height: 0;
}
.chipA {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid rgba(95, 135, 168, 0.35); border-radius: 20px;
  padding: 2px 9px 2px 6px; font-size: 11px; font-weight: 600; color: var(--dim);
  background: rgba(8, 22, 38, 0.6); transition: all .25s;
  white-space: nowrap;
}
.chipA i { width: 6px; height: 6px; border-radius: 50%; background: rgba(95, 135, 168, 0.4); }
.chipA.active {
  color: #dff6ff; border-color: var(--cyan);
  background: rgba(25, 200, 255, 0.12);
  box-shadow: 0 0 12px rgba(25, 200, 255, 0.25);
}
.chipA.active i { background: var(--cyan); box-shadow: 0 0 7px var(--cyan); }
.chipA.done { color: var(--green); border-color: rgba(43, 255, 176, 0.35); }
.chipA.done i { background: var(--green); }
.chipA.err { color: var(--red); border-color: rgba(255, 95, 71, 0.4); }
.chipA.err i { background: var(--red); }
.chipA.planned { opacity: .45; border-style: dashed; }

.tbot-note { display: none; padding: 4px 14px 9px; font-size: 10.5px; color: var(--dim); line-height: 1.35; }

/* ---------- чат с BIBABOBA ---------- */
#chatPanel { flex: 1.05; }
.chat-log {
  flex: 1; overflow-y: auto; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px; min-height: 0;
  scrollbar-width: thin; scrollbar-color: var(--cyan-soft) transparent;
}
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--cyan-soft); border-radius: 3px; }
.chat-empty { color: var(--dim); font-size: 12px; text-align: center; padding: 12px 8px; letter-spacing: .05em; margin: auto 0; }
.bub {
  max-width: 88%; padding: 6px 10px 7px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.35; white-space: pre-wrap; word-break: break-word;
  animation: evIn .25s ease-out;
}
.bub.me {
  align-self: flex-end; border-bottom-right-radius: 3px;
  background: rgba(25, 200, 255, 0.13); border: 1px solid var(--cyan-soft); color: #e3f6ff;
}
.bub.bot {
  align-self: flex-start; border-bottom-left-radius: 3px;
  background: rgba(43, 255, 176, 0.06); border: 1px solid rgba(43, 255, 176, 0.3); color: #dcf8ee;
}
.bub .who {
  display: block; font-family: var(--font-head); font-size: 8.5px;
  letter-spacing: .18em; color: var(--dim); margin-bottom: 2px;
}
.bub.me .who { color: var(--cyan); }
.bub.bot .who { color: var(--green); }
.chat-input { display: flex; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--line); flex: 0 0 auto; }
.chat-input input, .chat-keyrow input {
  flex: 1; min-width: 0; background: rgba(3, 10, 18, 0.8);
  border: 1px solid var(--line); border-radius: 6px; color: var(--text);
  padding: 7px 10px; font-family: var(--font-body); font-size: 13px; outline: none;
}
.chat-input input:focus, .chat-keyrow input:focus { border-color: var(--cyan); box-shadow: 0 0 8px var(--cyan-soft); }
.chat-input button, .chat-keyrow button {
  font-family: var(--font-head); font-size: 11px; letter-spacing: .1em;
  color: #04121e; background: var(--cyan); border: 0; border-radius: 6px;
  padding: 0 12px; cursor: pointer; box-shadow: 0 0 10px var(--cyan-soft);
}
.chat-input button:hover, .chat-keyrow button:hover { box-shadow: 0 0 18px var(--cyan); }
.chat-keyrow { display: flex; gap: 6px; padding: 0 10px 10px; flex: 0 0 auto; }
.chat-keyrow[hidden] { display: none; }
.linkkey {
  background: none; border: 1px solid var(--line); border-radius: 4px;
  color: var(--dim); cursor: pointer; font-size: 10px; padding: 1px 7px;
}
.linkkey:hover { color: var(--cyan); border-color: var(--cyan-soft); }

/* ---------- хроника ---------- */
#chron {
  flex: 1; overflow-y: auto; padding: 6px 10px; min-height: 0;
  scrollbar-width: thin; scrollbar-color: var(--cyan-soft) transparent;
}
.ev {
  display: flex; align-items: baseline; gap: 8px;
  padding: 3.5px 8px; border-radius: 4px; font-size: 12.5px;
  border-left: 2px solid transparent;
  animation: evIn .3s ease-out;
}
@keyframes evIn { from { opacity: 0; transform: translateY(-6px); } }
.ev:nth-child(odd) { background: rgba(25, 200, 255, 0.03); }
.ev .t { color: var(--dim); font-family: var(--font-head); font-size: 10px; letter-spacing: 0.06em; flex: 0 0 auto; }
.ev .badge {
  font-family: var(--font-head); font-size: 9px; letter-spacing: 0.12em; flex: 0 0 auto;
  border: 1px solid; border-radius: 3px; padding: 1px 6px; opacity: .9;
}
.ev .who { flex: 0 0 auto; font-weight: 700; color: var(--text); }
.ev .tx { color: #a8cde4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev .tx.long { white-space: normal; }

.ev.c-task   { border-left-color: var(--cyan); }  .ev.c-task .badge   { color: var(--cyan); border-color: var(--cyan); }
.ev.c-start  { border-left-color: var(--cyan); }  .ev.c-start .badge  { color: var(--cyan); border-color: var(--cyan); }
.ev.c-think  { border-left-color: #3fa9d9; }      .ev.c-think .badge  { color: #3fa9d9; border-color: #3fa9d9; }
.ev.c-move   { border-left-color: #8f7bff; }      .ev.c-move .badge   { color: #8f7bff; border-color: #8f7bff; }
.ev.c-ok     { border-left-color: var(--green); } .ev.c-ok .badge     { color: var(--green); border-color: var(--green); }
.ev.c-out    { border-left-color: var(--green); } .ev.c-out .badge    { color: var(--green); border-color: var(--green); }
.ev.c-err    { border-left-color: var(--red); background: rgba(255, 95, 71, 0.05); }
.ev.c-err .badge    { color: var(--red); border-color: var(--red); }
.ev.c-tool   { border-left-color: var(--amber); } .ev.c-tool .badge   { color: var(--amber); border-color: var(--amber); }
.ev.c-tool .who { color: var(--amber); }

#chron::-webkit-scrollbar { width: 6px; }
#chron::-webkit-scrollbar-thumb { background: var(--cyan-soft); border-radius: 3px; }

/* ---------- настройка ---------- */
#setup[hidden] { display: none; }
#setup {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2, 6, 12, 0.88); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.setup-card {
  width: min(420px, 92vw); text-align: center;
  border: 1px solid var(--cyan-soft); border-radius: 12px;
  background: rgba(8, 22, 38, 0.9); padding: 30px 28px;
  box-shadow: 0 0 40px rgba(25, 200, 255, 0.12);
}
.setup-logo { font-size: 42px; color: var(--cyan); text-shadow: 0 0 24px var(--cyan); animation: logoPulse 3s infinite; }
.setup-card h1 { font-family: var(--font-head); font-size: 15px; letter-spacing: 0.24em; margin: 10px 0 4px; color: var(--text); }
.setup-card p { color: var(--dim); font-size: 13px; margin-bottom: 16px; }
.setup-card label { display: block; text-align: left; font-size: 11px; letter-spacing: 0.14em; color: var(--dim); font-family: var(--font-head); margin: 12px 0 4px; }
.setup-card input {
  width: 100%; padding: 9px 12px; border-radius: 6px; font-size: 14px;
  border: 1px solid var(--line); background: rgba(3, 10, 18, 0.8); color: var(--text);
  font-family: var(--font-body); outline: none;
}
.setup-card input:focus { border-color: var(--cyan); box-shadow: 0 0 10px var(--cyan-soft); }
#goBtn {
  margin-top: 18px; width: 100%; padding: 11px;
  font-family: var(--font-head); font-weight: 700; font-size: 12px; letter-spacing: 0.24em;
  color: #04121e; background: var(--cyan); border: 0; border-radius: 6px; cursor: pointer;
  box-shadow: 0 0 18px var(--cyan-soft);
}
#goBtn:hover { box-shadow: 0 0 26px var(--cyan); }
.setup-err { color: var(--red); font-size: 12px; min-height: 16px; margin-top: 10px; }

/* ---------- мобильная версия ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100dvh; grid-template-rows: 50px auto auto; }
  main { grid-template-columns: 1fr; }
  #mapWrap { height: 300px; }
  #nowPanel, #tbotPanel, #chatPanel { min-height: 200px; }
  #chatPanel { min-height: 240px; }
  #chronPanel { height: 240px; }
  #chron { max-height: 190px; }
  .brand-name { display: none; }
  .chip.ghost { display: none; }
  .now-stage { font-size: 17px; }
}

@media (max-width: 520px) {
  #app { padding: 8px; gap: 8px; }
  .clock { font-size: 12px; }
  .brand-sub { display: none; }
  #mapWrap { height: 260px; }
}

/* сокращение анимаций для доступности */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
