/* ─── Engine diagnostics — drafting-style readout ────────────── */
.ff-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
#ffmpeg-status { white-space: nowrap; transition: color .2s ease; }
.ff-status.failed #ffmpeg-status { color: var(--bad); }
.ff-status.ready  #ffmpeg-status { color: var(--good); }
.ff-status.loading #ffmpeg-status {
  color: var(--rust);
  animation: ff-pulse 1.1s ease-in-out infinite;
}
[data-theme="light"] .ff-status.loading #ffmpeg-status { color: var(--rust-lo); }
@keyframes ff-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.ff-diag-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px; height: 17px;
  padding: 0;
  flex-shrink: 0;
  color: var(--ink-soft);
  background: var(--panel-hi);
  border: 1px solid var(--border-strong);
  border-radius: 1px;
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .08s;
}
.ff-diag-toggle:hover { color: var(--blueprint); border-color: var(--blueprint); }
[data-theme="light"] .ff-diag-toggle:hover { color: var(--blueprint-lo); border-color: var(--blueprint-lo); }
.ff-diag-toggle:active { transform: translate(1px, 1px); }
.ff-diag-toggle svg {
  width: 9px; height: 9px;
  transition: transform .2s ease;
}
.ff-diag-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.ff-diag-toggle:focus-visible { outline: 2px solid var(--blueprint); outline-offset: 2px; }

.ff-status.failed .ff-diag-toggle {
  color: var(--bad);
  border-color: var(--bad);
  animation: diagNudge 2.4s ease-in-out 1s 3;
}
@keyframes diagNudge {
  0%, 88%, 100% { box-shadow: none; }
  92%           { box-shadow: 0 0 6px var(--bad); }
}

.ff-diag-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 90;
  width: min(360px, 78vw);
  max-height: 60vh;
  overflow-y: auto;
  padding: 13px 15px 14px;
  background: var(--panel-hi);
  border: 1.5px solid var(--border-strong);
  border-radius: 1px;
  box-shadow:
    0 2px 0 var(--panel-lo),
    0 10px 22px rgba(0,0,0,.34);
  text-transform: none;
  letter-spacing: normal;
  cursor: default;
}
[data-theme="light"] .ff-diag-panel {
  box-shadow:
    0 2px 0 var(--panel-lo),
    0 10px 22px rgba(60,40,20,0.20);
}
.ff-diag-panel[hidden] { display: none; }
.ff-diag-panel::before {
  content: '';
  position: absolute;
  top: -6px; right: 5px;
  width: 10px; height: 10px;
  background: var(--panel-hi);
  border-left: 1.5px solid var(--border-strong);
  border-top: 1.5px solid var(--border-strong);
  transform: rotate(45deg);
}
.ff-diag-title {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--rust);
  padding-bottom: 8px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--rule);
}
[data-theme="light"] .ff-diag-title { color: var(--rust-lo); }
.ff-diag-row {
  display: flex;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  padding: 3px 0;
  border-bottom: 1px dotted var(--border);
}
.ff-diag-row:last-of-type { border-bottom: 0; }
.ff-diag-row .k {
  flex: 0 0 96px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ff-diag-row .v {
  flex: 1;
  color: var(--ink);
  word-break: break-word;
}
.ff-diag-row .v.ok   { color: var(--good); }
.ff-diag-row .v.warn { color: var(--rust); }
.ff-diag-row .v.bad  { color: var(--bad); }
[data-theme="light"] .ff-diag-row .v.warn { color: var(--rust-lo); }

.ff-diag-note {
  margin-top: 10px;
  padding: 9px 11px;
  font-family: var(--body);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--panel-lo);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--rust);
  border-radius: 0;
}
[data-theme="light"] .ff-diag-note { border-left-color: var(--rust-lo); }
.ff-diag-note.bad { border-left-color: var(--bad); }
.ff-diag-note b { color: var(--rust); }
[data-theme="light"] .ff-diag-note b { color: var(--rust-lo); }
.ff-diag-log {
  margin-top: 9px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  color: var(--ink-soft);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 1px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 140px;
  overflow-y: auto;
}
.ff-diag-actions {
  display: flex;
  gap: 8px;
  margin-top: 11px;
}
.ff-diag-actions .btn { font-size: 10px; padding: 6px 11px; }

@media (max-width: 720px) {
  .ff-diag-panel { right: auto; left: 0; }
  .ff-diag-panel::before { right: auto; left: 7px; }
}
