#firmware-editor-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

#firmware-editor-panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  width: min(90vw, 960px);
  height: 80vh;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}

.fe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fe-title {
  color: var(--white);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.fe-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.fe-kbd-hint {
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  color: var(--text-dim);
}

.fe-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 17px;
  padding: 2px 7px;
  line-height: 1;
  border-radius: 6px;
}
.fe-close-btn:hover { color: #ffffff; background: rgba(255,255,255,0.08); }

#fe-cm-container {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* CodeMirror fills the container (código → monospace) */
#fe-cm-container .CodeMirror {
  position: absolute;
  inset: 0;
  height: 100%;
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
}

/* Fallback plain textarea */
#fe-plain-textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  border: none;
  outline: none;
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  padding: 10px;
  box-sizing: border-box;
  resize: none;
  line-height: 1.6;
}

.fe-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}

/* ── Help button ─────────────────────────────────────────────────────── */

.fe-help-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Roboto', sans-serif;
  width: 26px;
  height: 26px;
  line-height: 1;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.fe-help-btn:hover { background: rgba(var(--accent-rgb),0.15); border-color: var(--accent); }

/* ── Checker status bar ──────────────────────────────────────────────── */

.fe-checker {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.fe-checker-dot {
  font-size: 13px;
  color: var(--text-dim);
  flex-shrink: 0;
  line-height: 1;
}

.fe-checker-msg {
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fe-save-btn {
  background: var(--accent);
  border: none;
  color: #04222e;
  padding: 8px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  flex-shrink: 0;
  transition: filter 0.15s;
}
.fe-save-btn:hover { filter: brightness(1.1); }

/* ── Help Modal ──────────────────────────────────────────────────────── */

#fe-help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}

#fe-help-panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  width: min(92vw, 820px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}

.fe-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fe-help-title {
  color: var(--white);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.fe-help-body {
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.fe-help-body::-webkit-scrollbar { width: 6px; }
.fe-help-body::-webkit-scrollbar-track { background: transparent; }
.fe-help-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.fh-section {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.fh-section-title {
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.fh-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 560px) { .fh-cols { grid-template-columns: 1fr; } }

/* Tabela de referência da API → conteúdo é código (monospace) */
.fh-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
}
.fh-table tr { border-bottom: 1px solid var(--border); }
.fh-table tr:last-child { border-bottom: none; }
.fh-table td { padding: 6px 7px; color: var(--text); vertical-align: top; }
.fh-table td:first-child { white-space: nowrap; padding-right: 12px; }
.fh-fn {
  color: var(--accent);
  font-weight: bold;
}
.fh-table code {
  color: #ffcc66;
  font-family: inherit;
}

.fh-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: #b8d0e8;
  line-height: 1.65;
  margin: 0;
  white-space: pre;
  overflow-x: auto;
}

.fh-note {
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
  padding: 8px 12px;
  background: rgba(var(--accent-rgb),0.06);
  border-left: 2px solid rgba(var(--accent-rgb),0.5);
  border-radius: var(--radius-sm);
}
.fh-note code { color: var(--accent); font-family: 'Share Tech Mono', monospace; }

.fh-examples-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) { .fh-examples-grid { grid-template-columns: 1fr; } }

.fh-example {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fh-example-label {
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  color: var(--text-dim);
}

/* ── Button type in prop extra ───────────────────────────────────────── */

.prop-fw-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--accent);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: 'Roboto', sans-serif;
  margin-top: 8px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.prop-fw-btn:hover { background: rgba(var(--accent-rgb),0.12); border-color: var(--accent); }
