/* ═══════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════ */
:root {
  --bg0:        #03050a;
  --bg1:        #0b0e15;
  --bg2:        #10141f;
  --text:       #eef1fb;
  --muted:      #b3b9d4;
  --purple:     #9c54d6;
  --purple-dim: rgba(156,84,214,0.18);
  --green:      #8eb658;
  --green-dim:  rgba(142,182,88,0.15);
  --amber:      #d6a030;
  --amber-dim:  rgba(214,160,48,0.14);
  --red:        #d65454;
  --red-dim:    rgba(214,84,84,0.14);
  --bar:        rgba(243,247,255,0.95);
  --edge:       rgba(255,255,255,0.07);
  --r:          10px;
}

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

/* ═══════════════════════════════════════════
   A — BODY
═══════════════════════════════════════════ */
.App-Ax {
  font-family: "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #020307, #070913, #04060a);
  color: var(--text);
  min-height: 100vh;
}

/* ═══════════════════════════════════════════
   B — SHELL
═══════════════════════════════════════════ */
.Shell-Bx {
  padding: 10px;
  display: grid;
  gap: 8px;
}

/* ═══════════════════════════════════════════
   C — HERO
═══════════════════════════════════════════ */
.Hero-Cx {
  text-align: center;
  padding: 10px 8px 4px;
  display: grid;
  gap: 4px;
  justify-items: center;
}

.Logo-Do  { height: 32px; }
.Subtitle-Do {
  font-size: 10px;
  letter-spacing: .32em;
  color: #7c84b0;
}

/* ═══════════════════════════════════════════
   C — CONNECTION
═══════════════════════════════════════════ */
.Connection-Cx {
  padding: 6px 8px;
  display: grid;
  gap: 4px;
}

/* D — ROW */
.Row-Dx {
  display: grid;
  grid-template-columns: 1fr 70px 32px;
  gap: 5px;
  align-items: end;
}

/* D — HOST / PORT */
.Host-Dx,
.Port-Dx {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.Label-Eo {
  font-size: 9px;
  letter-spacing: .15em;
  color: #7c84b0;
}

.Input-Eo {
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid var(--edge);
  background: var(--bg2);
  color: var(--text);
  font-size: 12px;
}

.Save-Do {
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--edge);
  background: var(--purple-dim);
  color: var(--purple);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.Save-Do:hover { background: rgba(156,84,214,0.32); }

/* O — STATUS */
/* D — STATUS ROW */
.StatusRow-Dx {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.Status-Do {
  font-size: 9px;
  color: var(--muted);
  flex: 1;
}
.Refresh-Eo {
  font-size: 14px;
  line-height: 1;
  padding: 1px 5px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.Refresh-Eo:hover { color: var(--green); background: var(--green-dim); }
.Refresh-Eo.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── UPDATE FLASH ── */
@keyframes badge-pop {
  0%   { transform: scale(1);    background: radial-gradient(circle,#c387ff,#672a96); }
  40%  { transform: scale(1.35); background: radial-gradient(circle,#fff,#9c54d6); }
  100% { transform: scale(1);    background: radial-gradient(circle,#c387ff,#672a96); }
}
@keyframes bar-flash {
  0%   { opacity: 0.82; }
  50%  { opacity: 1; filter: brightness(1.8); }
  100% { opacity: 0.82; filter: brightness(1); }
}
.badge-updated {
  animation: badge-pop 0.4s ease-out forwards;
}
.bars-updated .monitor-bar-el {
  animation: bar-flash 0.5s ease-out forwards;
}

.Name-Eo {
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.AiRef-Eo {
  font-size: 9px;
  letter-spacing: .08em;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  text-align: right;
  text-decoration: underline;
  text-decoration-color: rgba(179,185,212,0.3);
  text-underline-offset: 2px;
  transition: color 0.15s;
  align-self: end;
}
.AiRef-Eo:hover { color: var(--purple); text-decoration-color: var(--purple); }

/* ═══════════════════════════════════════════
   C — MONITOR
═══════════════════════════════════════════ */
.Monitor-Cx {
  padding: 8px 10px;
  border-radius: var(--r);
  border: 1px solid var(--edge);
  display: grid;
  gap: 6px;
}

/* D — HEAD */
.Head-Dx {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--muted);
}

/* D — INDICATOR */
.Indicator-Dx {
  display: flex;
  align-items: center;
  gap: 5px;
}

.Dot-Eo {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.Dot-Eo.sending {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
  animation: pulse 0.6s ease-in-out infinite alternate;
}

.State-Eo { font-size: 10px; letter-spacing: .12em; }
.State-Eo.sending { color: var(--amber); }

@keyframes pulse { to { opacity: 0.4; } }

/* D — BARS */
.Bars-Dx {
  display: flex;
  gap: 3px;
  height: 36px;
  align-items: flex-end;
}

/* individual bars built by JS */
.monitor-bar-el {
  flex: 1;
  background: linear-gradient(180deg, var(--bar), var(--purple));
  border-radius: 2px 2px 0 0;
  transition: height 0.15s ease, opacity 0.15s ease;
}

/* ═══════════════════════════════════════════
   C — TRANSPORT
═══════════════════════════════════════════ */
.Transport-Cx {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 48px;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--edge);
  background: var(--bg2);
}

.Transport-Cx button {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  transition: background 0.15s;
}
.Transport-Cx button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.Transport-Cx button:hover     { background: rgba(255,255,255,0.06); }
.Eject-Do:hover                { background: rgba(214,84,84,0.18) !important; }

/* ═══════════════════════════════════════════
   C — CHANGES
═══════════════════════════════════════════ */
.Changes-Cx {
  padding: 10px;
  border-radius: var(--r);
  border: 1px solid var(--edge);
  display: grid;
  gap: 8px;
}

/* D — TOP */
.Top-Dx {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.Title-Eo {
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--muted);
}

.Badge-Eo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, #c387ff, #672a96);
  font-size: 11px;
  font-weight: 700;
}

.Empty-Do {
  text-align: center;
  color: #5a6080;
  padding: 12px 0;
  font-size: 12px;
}

/* D — READY */
.Ready-Dx {
  display: grid;
  gap: 4px;
}

/* D — INCOMPLETE */
.Incomplete-Dx {
  display: grid;
  gap: 4px;
}

/* E — TOGGLE / HEADER rows */
.Toggle-Ex,
.Header-Ex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--edge);
  transition: background 0.15s;
}
.Toggle-Ex:hover,
.Header-Ex:hover { background: rgba(255,255,255,0.06); }

/* F — labels inside toggle/header */
.Toggle-Ex .Label-Fo {
  font-size: 9px;
  letter-spacing: .2em;
  font-weight: 700;
  color: var(--green);
}
.Header-Ex .Label-Fo {
  font-size: 9px;
  letter-spacing: .2em;
  font-weight: 700;
  color: var(--amber);
}
.Count-Fo {
  font-size: 10px;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  border-radius: 20px;
  padding: 1px 7px;
}

/* D — CARDS containers */
.Cards-Dx {
  display: grid;
  gap: 6px;
}
.Cards-Dx.collapsed { display: none; }

/* O — SEND between sections */
.Send-Do {
  width: 100%;
  border: none;
  background: transparent;
  padding: 2px 0;
  cursor: pointer;
}
.Send-Do img {
  width: 100%;
  display: block;
  height: 40px;
  object-fit: contain;
}

/* ═══════════════════════════════════════════
   CARDS — built by JS, use simple selectors
   Depth: card=C, internals=D/E
═══════════════════════════════════════════ */
.card {
  border-radius: 8px;
  border: 1px solid var(--edge);
  background: var(--bg2);
  padding: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.card.selected  { border-color: var(--purple); background: rgba(156,84,214,0.08); }
.card:hover     { border-color: rgba(255,255,255,0.14); }

/* ready card — compact row */
.card-ready {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
}
.card-ready .title {
  flex: 1;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-ready .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* unready card — expanded grid */
.card-unready { display: grid; gap: 7px; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
}
.card-title  { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.35; }
.card-meta   { font-size: 9px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .1em; }

.pill {
  font-size: 9px; letter-spacing: .1em;
  padding: 2px 7px; border-radius: 20px;
  border: 1px solid rgba(156,84,214,0.4);
  color: var(--purple); background: var(--purple-dim);
  white-space: nowrap; flex-shrink: 0;
}
.pill.unassigned { border-color: rgba(214,160,48,0.4); color: var(--amber); background: var(--amber-dim); }

.flag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9px; padding: 2px 7px; border-radius: 10px;
  border: 1px solid rgba(214,84,84,0.4);
  color: var(--red); background: var(--red-dim); letter-spacing: .08em;
  white-space: nowrap; flex-shrink: 0;
}

/* missing button */
.missing {
  display: flex; align-items: center; gap: 6px;
  background: var(--red-dim);
  border: 1px solid rgba(214,84,84,0.35);
  border-radius: 6px; padding: 5px 8px;
  cursor: pointer; width: 100%; text-align: left;
  color: var(--red); font-size: 10px; letter-spacing: .1em;
  transition: background 0.15s;
}
.missing:hover { background: rgba(214,84,84,0.25); }
.missing .icon { font-size: 14px; }
.missing-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.missing-tag {
  font-size: 9px; padding: 1px 5px; border-radius: 10px;
  border: 1px solid rgba(214,84,84,0.4);
  color: var(--red); text-transform: uppercase; letter-spacing: .1em;
}

/* phrase context */
.phrase {
  background: rgba(214,160,48,0.07);
  border: 1px solid rgba(214,160,48,0.2);
  border-radius: 6px; padding: 7px 9px;
  font-size: 11px; color: #d4c08a; line-height: 1.5;
}
.phrase .label {
  font-size: 9px; letter-spacing: .15em; color: var(--amber);
  margin-bottom: 4px; display: block;
}
.phrase-pair { display: grid; gap: 4px; margin-top: 4px; }
.phrase-item {
  background: rgba(255,255,255,0.04); border-radius: 4px;
  padding: 4px 7px; font-size: 10px; color: var(--muted);
}
.phrase-item strong { color: var(--text); }

/* filepath section */
.section-label {
  font-size: 9px; letter-spacing: .15em; color: var(--muted); margin-bottom: 3px;
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: 10px; padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--edge); background: rgba(255,255,255,0.04);
  color: var(--muted); cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.chip.active  { border-color: var(--green); color: var(--green); background: var(--green-dim); }
.chip:hover   { border-color: rgba(255,255,255,0.2); color: var(--text); }

/* file autocomplete */
.autocomplete { position: relative; }
.file-input {
  width: 100%; padding: 4px 7px; border-radius: 5px;
  border: 1px solid var(--edge); background: rgba(255,255,255,0.03);
  color: var(--muted); font-size: 11px;
}
.file-input::placeholder { color: #40465e; }
.file-input:focus { outline: none; border-color: rgba(156,84,214,0.4); color: var(--text); }

.ac-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg1);
  border: 1px solid rgba(156,84,214,0.3);
  border-radius: 6px; max-height: 140px; overflow-y: auto;
  z-index: 50; display: none;
}
.ac-list.open { display: block; }
.ac-item {
  padding: 5px 9px; font-size: 10px; color: var(--muted);
  cursor: pointer; font-family: "Consolas", monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-item:hover, .ac-item.focus { background: var(--purple-dim); color: var(--text); }
.ac-item .hi { color: var(--purple); font-weight: 700; }

/* assign controls */
.assign { display: grid; gap: 5px; }
.action-select {
  width: 100%; padding: 4px 6px; border-radius: 5px;
  border: 1px solid rgba(214,160,48,0.3);
  background: var(--bg2); color: var(--text); font-size: 11px;
}
.radio-row { display: flex; gap: 5px; }
.radio {
  flex: 1; padding: 3px 0; border-radius: 5px;
  border: 1px solid var(--edge); background: rgba(255,255,255,0.03);
  color: var(--muted); font-size: 10px; cursor: pointer; transition: background 0.12s;
}
.radio.active { border-color: var(--purple); color: var(--purple); background: var(--purple-dim); }

/* manifest preview */
.preview-label {
  font-size: 9px; letter-spacing: .15em; color: var(--muted); margin-bottom: 2px;
}
.preview {
  background: rgba(0,0,0,0.35); border-radius: 6px; padding: 6px 8px;
  font-size: 10px; font-family: "Consolas", "Cascadia Code", monospace;
  color: #9aa8cc; white-space: pre-wrap; word-break: break-all;
  max-height: 120px; overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.05); line-height: 1.5;
}

/* ═══════════════════════════════════════════
   B — OVERLAY
═══════════════════════════════════════════ */
.Overlay-Bx {
  position: fixed; inset: 0;
  background: rgba(2,3,8,0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.Overlay-Bx.hidden { display: none !important; }

/* C — MODAL */
.Modal-Cx {
  background: var(--bg1);
  border: 1px solid rgba(156,84,214,0.3);
  border-radius: 12px;
  width: 100%; max-height: 70vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}

/* D — HEAD (reused) */
.Modal-Cx .Head-Dx {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--edge);
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--purple);
}

/* E — CLOSE */
.Close-Eo {
  border: none; background: none;
  color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 2px 6px; border-radius: 4px;
}
.Close-Eo:hover { background: rgba(255,255,255,0.07); color: var(--text); }

/* D — BODY (reused) */
.Modal-Cx .Body-Dx {
  padding: 12px 14px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

/* evidence sentences */
.evidence {
  padding: 5px 8px; border-radius: 5px;
  border-left: 2px solid rgba(156,84,214,0.4);
  background: rgba(255,255,255,0.02);
}
.evidence .hl {
  color: var(--green); font-weight: 600;
  background: var(--green-dim); border-radius: 3px; padding: 0 3px;
}

/* ai ref modal body items */
.Desc-Eo   { font-size: 11px; color: var(--muted); }
.Option-Eo {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text); cursor: pointer;
}
.Option-Eo input { accent-color: var(--purple); cursor: pointer; }
.Copy-Eo {
  width: 100%; padding: 8px; border-radius: 6px;
  border: 1px solid rgba(156,84,214,0.4);
  background: var(--purple-dim); color: var(--purple);
  font-size: 12px; letter-spacing: .1em; cursor: pointer;
  transition: background 0.15s;
}
.Copy-Eo:hover { background: rgba(156,84,214,0.32); }
.Confirm-Eo { text-align: center; color: var(--green); font-size: 12px; padding: 4px 0; }

/* ═══════════════════════════════════════════
   C — FOOTER
═══════════════════════════════════════════ */
.Footer-Cx {
  display: flex;
  justify-content: center;
  padding: 4px 0 2px;
}
.Banner-Do { height: 32px; opacity: 0.8; }

/* ═══════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════ */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(156,84,214,0.3); border-radius: 4px; }