/* =============================================================================
   SiriNEO Things Compiler — Temas escuros
   -----------------------------------------------------------------------------
   Todas as cores vêm de variáveis definidas por tema (bloco abaixo, gerado por
   tools/temas.py, que também verifica o contraste WCAG de cada combinação).
   O tema ativo é o atributo data-tema do <html> (padrao, rosa, roxo, preto,
   verde, laranja, amarelo). Para mudar uma cor, edite tools/temas.py e
   regere o bloco: python tools/temas.py --css
   ============================================================================= */
/* ===== Temas (gerado por tools/temas.py — contraste WCAG verificado) ===== */
:root, [data-tema="padrao"] {
  --bg: #07102a;
  --bg-deep: #050b1f;
  --bg-head: #0b1a45;
  --panel: #0c1736;
  --panel-2: #12204a;
  --menu: #0e1a3c;
  --term-bg: #040919;
  --border: #1d3270;
  --text: #e8eefc;
  --muted: #8fa0c8;
  --dim: #6b7ba3;
  --comment: #7d8db5;
  --code-text: #d6deeb;
  --term-text: #b9c4da;
  --link: #6fb8ff;
  --brand: #5fe01e;
  --brand-hi: #a6f04a;
  --brand-2: #1e8bff;
  --accent: #f6d32b;
  --on-brand: #04131a;
  --ok: #5fe01e;
  --warn: #f5a524;
  --err: #ff6b86;
}
[data-tema="rosa"] {
  --bg: #1a0812;
  --bg-deep: #120509;
  --bg-head: #3a0f2a;
  --panel: #220a18;
  --panel-2: #331027;
  --menu: #2c0d20;
  --term-bg: #10040b;
  --border: #5a1d45;
  --text: #fde8f3;
  --muted: #d79bbd;
  --dim: #b0789a;
  --comment: #c48aac;
  --code-text: #f7dcea;
  --term-text: #ecc6db;
  --link: #f9a8d4;
  --brand: #ff5fa8;
  --brand-hi: #ff9dcc;
  --brand-2: #c084fc;
  --accent: #ffd166;
  --on-brand: #2a0516;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #ff7a7a;
}
[data-tema="roxo"] {
  --bg: #0f0a1f;
  --bg-deep: #090614;
  --bg-head: #25164f;
  --panel: #150e2b;
  --panel-2: #221842;
  --menu: #1d1438;
  --term-bg: #080512;
  --border: #3d2c70;
  --text: #efe9ff;
  --muted: #b3a3e0;
  --dim: #8f7fc0;
  --comment: #a393d4;
  --code-text: #e4dcff;
  --term-text: #cfc4f2;
  --link: #c4b5fd;
  --brand: #b48cff;
  --brand-hi: #d8c2ff;
  --brand-2: #60a5fa;
  --accent: #fcd34d;
  --on-brand: #1a0b38;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #ff7a8a;
}
[data-tema="preto"] {
  --bg: #000000;
  --bg-deep: #000000;
  --bg-head: #141414;
  --panel: #0b0b0b;
  --panel-2: #1a1a1a;
  --menu: #141414;
  --term-bg: #000000;
  --border: #333333;
  --text: #f2f2f2;
  --muted: #a8a8a8;
  --dim: #8a8a8a;
  --comment: #9a9a9a;
  --code-text: #e8e8e8;
  --term-text: #d0d0d0;
  --link: #93c5fd;
  --brand: #f5f5f5;
  --brand-hi: #bdbdbd;
  --brand-2: #9ca3af;
  --accent: #facc15;
  --on-brand: #000000;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
}
[data-tema="verde"] {
  --bg: #03140c;
  --bg-deep: #020d08;
  --bg-head: #0a3322;
  --panel: #061c12;
  --panel-2: #0b2e1d;
  --menu: #0a2619;
  --term-bg: #010a06;
  --border: #175238;
  --text: #e6fff2;
  --muted: #93cdb0;
  --dim: #6fae8f;
  --comment: #82bfa1;
  --code-text: #d7f7e6;
  --term-text: #bfe8d2;
  --link: #67e8f9;
  --brand: #34d399;
  --brand-hi: #86efac;
  --brand-2: #22d3ee;
  --accent: #fde047;
  --on-brand: #022c1c;
  --ok: #86efac;
  --warn: #fbbf24;
  --err: #ff7a7a;
}
[data-tema="laranja"] {
  --bg: #170b02;
  --bg-deep: #0f0701;
  --bg-head: #3d1d06;
  --panel: #1f0f03;
  --panel-2: #331a07;
  --menu: #2a1506;
  --term-bg: #0d0601;
  --border: #5c3110;
  --text: #fff1e6;
  --muted: #e0b08a;
  --dim: #b98d6b;
  --comment: #cc9f7c;
  --code-text: #fde6d3;
  --term-text: #f1d0b5;
  --link: #93c5fd;
  --brand: #ff9f43;
  --brand-hi: #ffc58a;
  --brand-2: #60a5fa;
  --accent: #fde047;
  --on-brand: #2b1300;
  --ok: #4ade80;
  --warn: #fde047;
  --err: #ff7a7a;
}
[data-tema="amarelo"] {
  --bg: #141102;
  --bg-deep: #0c0a01;
  --bg-head: #3a3006;
  --panel: #1b1703;
  --panel-2: #2b2506;
  --menu: #262005;
  --term-bg: #0b0901;
  --border: #554a10;
  --text: #fffbe6;
  --muted: #d9cd8c;
  --dim: #b0a565;
  --comment: #c4b977;
  --code-text: #fbf3cf;
  --term-text: #efe4ad;
  --link: #93c5fd;
  --brand: #ffd60a;
  --brand-hi: #fff07a;
  --brand-2: #60a5fa;
  --accent: #fb923c;
  --on-brand: #231d00;
  --ok: #4ade80;
  --warn: #fb923c;
  --err: #ff7a7a;
}

:root {
  --radius: 10px;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}


* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }
code { font-family: var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* ---------------- Cabeçalho ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px;
  background: linear-gradient(90deg, var(--bg-deep), var(--bg-head));
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 52px; height: 52px; object-fit: contain;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--brand-2) 45%, transparent));
}
.brand .neo { color: var(--brand); }
.brand strong { display: block; font-size: 16px; letter-spacing: .3px; }
.brand small  { color: var(--muted); font-size: 12px; }

.health { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok   { background: var(--ok);  box-shadow: 0 0 8px var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err  { background: var(--err); }

.banner {
  margin: 10px 20px 0; padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent);
  border-radius: var(--radius); color: var(--text); font-size: 13px;
}

/* ---------------- Barra de ferramentas ---------------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px;
  padding: 12px 20px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 210px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
select {
  appearance: none;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238c9ab5'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 34px 9px 12px; font: inherit; cursor: pointer;
}
select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.board-info { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-bottom: 6px; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}
.chip.mono  { font-family: var(--mono); color: var(--text); background: var(--panel-2); border-color: var(--border); }
.chip.ghost { color: var(--muted); background: transparent; border-color: var(--border); }
.chip.py    { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

.actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 16px; font: 600 13px var(--sans); cursor: pointer;
  color: var(--text); background: var(--panel-2);
  transition: transform .05s, filter .15s, background .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary   { border: 0; color: var(--on-brand); background: linear-gradient(135deg, var(--brand), var(--brand-hi)); }
.btn.secondary { border-color: var(--brand-2); color: var(--link); background: color-mix(in srgb, var(--brand-2) 10%, transparent); }
.btn.ghost     { background: transparent; }
.btn.tiny      { padding: 3px 10px; font-size: 11px; }
.btn.busy      { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px;
  border: 2px solid currentColor; border-color: var(--text) transparent var(--text) transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Barra de menus (estilo Arduino IDE) ---------------- */
.menubar {
  display: flex; gap: 2px; padding: 2px 12px;
  background: var(--bg-deep); border-bottom: 1px solid var(--border);
  font-size: 13px; position: relative; z-index: 50; user-select: none;
}
/* Com um menu aberto, a barra de menus sobe acima da janela flutuante */
.menubar.aberto { z-index: 1100;
}
.menu { position: relative; }
.menu > button {
  background: none; border: 0; color: var(--text); font: inherit;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
}
.menu > button:hover, .menu.open > button { background: var(--panel-2); }
.menu-list {
  display: none; position: absolute; top: 100%; left: 0; min-width: 260px; width: max-content; max-width: 560px;
  margin: 2px 0 0; padding: 6px 0; list-style: none;
  background: var(--menu); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.menu.open > .menu-list { display: block; }
.menu-list li { position: relative; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 14px; background: none; border: 0; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; white-space: nowrap;
}
.menu-item:hover:not(:disabled), .has-sub:hover > .menu-item { background: color-mix(in srgb, var(--brand-2) 22%, transparent); }
.menu-item:disabled { color: var(--dim); opacity: .7; cursor: default; }
.menu-item .check { width: 14px; color: var(--brand); }
.menu-item .label { flex: 1; }
.menu-item .key { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.menu-item .arrow { color: var(--muted); }
.menu-sep { height: 1px; margin: 5px 0; background: var(--border); }
.menu-list .menu-list { top: -7px; left: 100%; margin-left: 2px; max-height: 70vh; overflow: auto; }
.has-sub:hover > .menu-list { display: block; }

/* ---------------- Botões rápidos (✓ ➜ 💾) ---------------- */
.quick { display: flex; gap: 6px; padding-bottom: 1px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font-size: 17px; font-weight: 800; cursor: pointer; transition: filter .15s, transform .05s;
}
.icon-btn:hover:not(:disabled) { filter: brightness(1.25); }
.icon-btn:active:not(:disabled) { transform: scale(.95); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn.verify { border-color: var(--brand-2); color: var(--link); }
.icon-btn.upload { border: 0; color: var(--on-brand); background: linear-gradient(135deg, var(--brand), var(--brand-hi)); }

.mini { display: flex; align-items: center; gap: 4px; white-space: nowrap; font: 11px var(--sans); color: var(--muted); }
.mini select { padding: 2px 22px 2px 6px; font-size: 11px; background-position: right 6px center; }
.pane-title .mini:first-of-type { margin-left: auto; }
.pane-title .mini ~ .btn { margin-left: 0; }
.draft { margin-left: auto; font-size: 11px; color: var(--dim); }

/* ---------------- Diálogo ---------------- */
dialog {
  max-width: 560px; width: calc(100% - 40px);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; padding: 22px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.65); }
dialog h3 { margin: 0 0 12px; font-size: 17px; }
dialog p { margin: 6px 0; color: var(--text); }
dialog table { width: 100%; border-collapse: collapse; font-size: 13px; }
dialog td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
dialog td:first-child { font-family: var(--mono); color: var(--brand); white-space: nowrap; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.about { display: flex; gap: 18px; align-items: center; }
.about img { width: 110px; height: 110px; }

/* Barra de busca do CodeMirror (Ctrl+F) no tema escuro */
.CodeMirror-dialog { background: var(--panel-2); color: var(--text); border-color: var(--border) !important; font: 12.5px var(--sans); }
.CodeMirror-dialog input { color: var(--text); font: 12.5px var(--mono); }
.CodeMirror-search-hint { color: var(--muted); }
.CodeMirror-activeline-background { background: color-mix(in srgb, var(--brand-2) 8%, transparent); }
.cm-searching { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------------- Conexão serial ---------------- */
.toolbar.conn { padding-top: 0; }
.row { display: flex; gap: 6px; }
.row select { min-width: 230px; }
.field.small { min-width: 140px; }
.btn.monitor-on { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }

.serial-send {
  display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); background: var(--bg-deep);
}
.serial-send input {
  flex: 1; min-width: 0; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font: 12.5px var(--mono);
}
.serial-send input:disabled { opacity: .5; }
.serial-send select { padding: 4px 28px 4px 8px; font-size: 12px; }
.terminal .serial { color: var(--text); }
.terminal .tx { color: var(--accent); }

/* ---------------- Área de trabalho (painéis redimensionáveis) ---------------- */
/* --a / --b: proporção editor/terminal em "fr" (ajustadas pelo splitter no JS) */
.workspace {
  --a: 62fr; --b: 38fr;
  flex: 1; min-height: 0;
  display: grid; padding: 0 20px 12px;
}
.workspace.lado      { grid-template-columns: minmax(0, var(--a)) 10px minmax(0, var(--b)); }
.workspace.empilhado { grid-template-rows: minmax(0, var(--a)) 10px minmax(0, var(--b)); }
.splitter { position: relative; touch-action: none; }
.splitter::after {
  content: ""; position: absolute; border-radius: 3px; background: var(--border); transition: background .15s;
}
.workspace.lado .splitter { cursor: col-resize; }
.workspace.lado .splitter::after { top: 40%; bottom: 40%; left: 3px; width: 4px; }
.workspace.empilhado .splitter { cursor: row-resize; }
.workspace.empilhado .splitter::after { left: 45%; right: 45%; top: 3px; height: 4px; }
.splitter:hover::after, .splitter.arrastando::after { background: var(--brand-2); }
.workspace.arrastando { user-select: none; }
.workspace.arrastando .CodeMirror, .workspace.arrastando .terminal { pointer-events: none; }
/* Painel minimizado (largura/altura ~0): esconde o conteúdo */
.pane-oculto { visibility: hidden; }

.editor-pane, .terminal-pane {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.pane-title {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  font: 12px var(--mono); color: var(--muted);
}
.pane-title .btn { margin-left: auto; }
.dirty { color: var(--warn); font-size: 14px; }

/* CodeMirror ocupando todo o painel */
.CodeMirror {
  flex: 1; height: auto; min-height: 0;
  font: var(--editor-font, 13.5px)/1.55 var(--mono);
  background: var(--panel); color: var(--code-text);
}
.CodeMirror-gutters { background: var(--panel); border-right: 1px solid var(--border); }
.CodeMirror-linenumber { color: var(--dim); }
.CodeMirror-cursor { border-left: 2px solid var(--brand); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: color-mix(in srgb, var(--brand) 22%, transparent) !important; }
.CodeMirror-matchingbracket { color: var(--ok) !important; text-decoration: underline; }
/* Realce de sintaxe (paleta própria, legível no escuro) */
.cm-s-default .cm-keyword  { color: #c792ea; }
.cm-s-default .cm-def      { color: #82aaff; }
.cm-s-default .cm-variable-2, .cm-s-default .cm-variable-3, .cm-s-default .cm-type { color: #8be36a; }
.cm-s-default .cm-string   { color: #f6d32b; }
.cm-s-default .cm-number   { color: #f78c6c; }
.cm-s-default .cm-comment  { color: var(--comment); font-style: italic; }
.cm-s-default .cm-meta     { color: #89ddff; }
.cm-s-default .cm-builtin  { color: #82aaff; }
.cm-s-default .cm-atom     { color: #f78c6c; }
.cm-s-default .cm-operator { color: #89ddff; }

/* ---------------- Terminal ---------------- */
.terminal {
  flex: 1; margin: 0; padding: 12px 14px; overflow: auto;
  font: 12.5px/1.5 var(--mono); color: var(--term-text); background: var(--term-bg);
  white-space: pre-wrap; word-break: break-word;
}
.terminal .ok   { color: var(--ok); }
.terminal .err  { color: var(--err); }
.terminal .warn { color: var(--warn); }
.terminal .info { color: var(--link); }
.terminal .dim  { color: var(--dim); }

/* ---------------- Rodapé ---------------- */
.statusbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 6px 20px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--bg-deep);
}

/* ---------------- Progresso (rodapé do terminal) ---------------- */
.sb-progress {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-top: 1px solid var(--border); background: var(--bg-deep);
}
.sb-progress .track {
  flex: 1; height: 12px; border-radius: 999px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--border);
}
.sb-progress .bar {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  box-shadow: 0 0 10px color-mix(in srgb, var(--brand) 50%, transparent); transition: width .25s;
}
.sb-progress span { min-width: 260px; color: var(--text); font: 600 12px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-progress.ok .bar  { background: var(--ok); }
.sb-progress.err .bar { background: var(--err); box-shadow: none; }

/* ---------------- Botão de tema ---------------- */
.top-right { display: flex; align-items: center; gap: 16px; }
.theme-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px 6px 8px; font: 600 12px var(--sans); cursor: pointer;
}
.theme-btn:hover { border-color: var(--brand); }
.theme-btn .swatch { width: 16px; height: 16px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--brand); }
.menu-item .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
/* Modo indeterminado (conectando/etapas sem % conhecido) */
.sb-progress.indet .bar { width: 35% !important; animation: vaivem 1.2s ease-in-out infinite alternate; }
@keyframes vaivem { from { margin-left: 0; } to { margin-left: 65%; } }

/* ---------------- Abas do terminal ---------------- */
.tabs { display: flex; gap: 2px; }
.tab {
  position: relative; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font: 600 12px var(--sans); padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--brand); }
.tab-dot {
  display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 6px var(--brand); vertical-align: middle;
}
#btnFloat, #btnPip { font-size: 13px; padding: 2px 8px; }
#btnFloat.ativo, #btnPip.ativo { color: var(--brand); border-color: var(--brand); }

/* ---------------- Terminal flutuante (por cima de TUDO na página) ---------------- */
.terminal-pane.flutuante {
  position: fixed; z-index: 1000;
  min-width: 360px; min-height: 180px; max-width: 96vw; max-height: 94vh;
  resize: both;                       /* canto inferior direito redimensiona */
  box-shadow: 0 18px 50px rgba(0,0,0,.65), 0 0 0 1px var(--brand-2);
}
.terminal-pane.flutuante .pane-title { cursor: move; background: var(--menu); }
.terminal-pane.flutuante .pane-title :is(button, select, input, label) { cursor: pointer; }
/* Sem o terminal no fluxo: o editor ocupa tudo */
.workspace.sem-terminal { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: minmax(0, 1fr) !important; }
.workspace.sem-terminal .splitter { display: none; }

/* ---------------- Janela separada (Picture-in-Picture de documento) ---------------- */
body.pip-body { display: block; height: 100vh; overflow: hidden; }
body.pip-body .terminal-pane { height: 100vh; border-radius: 0; border: 0; }

/* ---------------- Barra de atividades + painel lateral ---------------- */
.main-row { flex: 1; min-height: 0; display: flex; }
.main-row > .workspace { flex: 1; min-width: 0; padding-left: 12px; }
.activitybar {
  display: flex; flex-direction: column; gap: 6px; padding: 4px 6px 12px 12px;
}
.act-btn {
  width: 40px; height: 40px; border-radius: 10px; font-size: 18px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
}
.act-btn:hover { border-color: var(--brand); }
.act-btn.ativo { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 16%, var(--panel)); box-shadow: 0 0 0 1px var(--brand); }

.sidebar {
  width: 360px; flex: 0 0 360px; margin-bottom: 12px; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.painel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.painel-titulo {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  font: 700 11px var(--sans); letter-spacing: .8px; color: var(--muted);
}
.lib-busca { display: flex; gap: 6px; padding: 10px 12px 6px; }
.lib-busca input {
  flex: 1; min-width: 0; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: 13px var(--sans);
}
.lib-busca input:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.lib-filtros { display: flex; gap: 6px; align-items: center; padding: 0 12px 6px; }
.lib-filtros select { flex: 1; padding: 5px 28px 5px 8px; font-size: 12px; }
.lib-pasta { padding: 0 12px 8px; font: 11px var(--mono); color: var(--dim); word-break: break-all; }
.lib-lista { flex: 1; overflow: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.lib-vazio { color: var(--muted); font-size: 13px; padding: 16px 4px; text-align: center; }

.lib-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--panel-2); display: flex; flex-direction: column; gap: 6px;
}
.lib-card.instalada { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.lib-nome { font-weight: 700; color: var(--text); word-break: break-word; }
.lib-autor { font-size: 12px; color: var(--muted); }
.lib-desc { font-size: 12.5px; color: var(--text); margin: 0; opacity: .92; }
.lib-includes { font: 11px var(--mono); color: var(--link); word-break: break-all; }
.lib-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-tag { font: 600 10.5px var(--sans); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.lib-tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.lib-tag.upd { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.lib-acoes { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lib-acoes select { padding: 4px 26px 4px 8px; font-size: 12px; background-position: right 8px center; }
.lib-acoes a { font-size: 12px; color: var(--link); margin-left: auto; }
.btn.danger { border-color: color-mix(in srgb, var(--err) 60%, transparent); color: var(--err); background: transparent; }

.exemplo-item { text-align: left; width: 100%; }
.exemplo-item small { display: block; color: var(--muted); font: 11px var(--mono); margin-top: 2px; }

/* Botão de ação dentro do terminal (ex.: "Instalar biblioteca") */
.term-acao {
  margin: 2px 6px 2px 0; padding: 2px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent);
  color: var(--text); font: 600 12px var(--sans);
}
.term-acao:hover { background: color-mix(in srgb, var(--brand) 28%, transparent); }
.term-acao:disabled { opacity: .5; cursor: default; }

@media (max-width: 1100px) { .sidebar { width: 300px; flex-basis: 300px; } }

/* ---------------- Autocompletar (show-hint do CodeMirror) ---------------- */
.CodeMirror-hints {
  z-index: 1200; max-height: 300px; min-width: 300px; max-width: 640px; padding: 4px 0;
  background: var(--menu); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.55); font: 12.5px var(--mono);
}
.CodeMirror-hint {
  display: flex; gap: 14px; align-items: baseline; justify-content: space-between;
  padding: 4px 10px; color: var(--text); border-radius: 0; white-space: nowrap;
}
li.CodeMirror-hint-active { background: color-mix(in srgb, var(--brand-2) 30%, transparent); color: var(--text); }
.ac-nome { overflow: hidden; text-overflow: ellipsis; }
.ac-info { color: var(--muted); font: 11.5px var(--sans); overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.ac-funcao .ac-nome, .ac-membro .ac-nome { color: #82aaff; }
.ac-const .ac-nome { color: #f78c6c; }
.ac-classe .ac-nome { color: #8be36a; }
.ac-palavra .ac-nome { color: #c792ea; }
.ac-snippet .ac-nome { color: var(--accent); }
.ac-codigo .ac-nome { color: var(--code-text); }

/* ---------------- Abas do editor (vários arquivos) ---------------- */
.abas-barra { padding: 0 8px 0 0; gap: 4px; }
.abas { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.aba {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px 7px 12px; cursor: pointer;
  border-right: 1px solid var(--border); border-bottom: 2px solid transparent;
  color: var(--muted); font: 12px var(--mono); white-space: nowrap; user-select: none;
}
.aba:hover { color: var(--text); background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.aba.ativa { color: var(--text); background: var(--panel-2); border-bottom-color: var(--brand); }
.aba-icone { font: 700 10px var(--sans); color: var(--brand-2); min-width: 14px; text-align: center; }
.aba-ponto { color: var(--warn); font-size: 11px; }
.aba-fechar {
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1;
  padding: 0 2px; border-radius: 4px; visibility: hidden;
}
.aba:hover .aba-fechar, .aba.ativa .aba-fechar { visibility: visible; }
.aba-fechar:hover { color: var(--err); background: color-mix(in srgb, var(--err) 15%, transparent); }
.aba-nova {
  background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer;
  font-size: 16px; padding: 2px 8px; border-radius: 6px;
}
.aba-nova:hover { color: var(--brand); border-color: var(--border); }
.abas-barra .draft { margin-left: 6px; white-space: nowrap; }

/* ---------------- Árvore do projeto ---------------- */
.arq-acoes { flex-wrap: wrap; padding-top: 10px; }
.arvore { flex: 1; overflow: auto; padding: 4px 8px 12px; font: 12.5px var(--mono); }
.arv-pasta { color: var(--muted); padding: 6px 6px 2px; }
.arv-arquivo {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; color: var(--text);
}
.arv-arquivo:hover { background: var(--panel-2); }
.arv-arquivo.ativo { background: color-mix(in srgb, var(--brand-2) 22%, transparent); }
.arv-arquivo.dentro { padding-left: 18px; }
.arv-seta { width: 12px; color: var(--muted); }
.arv-nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arv-simbolo {
  display: flex; align-items: center; gap: 6px; padding: 2px 6px 2px 32px; border-radius: 4px;
  cursor: pointer; color: var(--muted); white-space: nowrap; overflow: hidden;
}
.arv-simbolo.dentro { padding-left: 44px; }
.arv-simbolo:hover { background: var(--panel-2); color: var(--text); }
.arv-icone { width: 16px; text-align: center; }
.arv-linha { margin-left: auto; color: var(--dim); font-size: 11px; }
.arv-classe .arv-icone { color: #8be36a; }
.arv-funcao .arv-icone, .arv-metodo .arv-icone { color: #82aaff; }
.arv-define .arv-icone { color: #f78c6c; }
.arv-classe { color: var(--text); }

/* Erro clicável no terminal (arquivo:linha) e linha destacada ao pular */
.erro-link { text-decoration: underline dotted; cursor: pointer; color: var(--link); }
.erro-link:hover { text-decoration: underline; }
.linha-destaque { background: color-mix(in srgb, var(--warn) 22%, transparent); transition: background .4s; }

/* ---------------- Divisória do painel lateral ---------------- */
.sidebar-splitter { width: 8px; flex: 0 0 8px; cursor: col-resize; position: relative; margin-bottom: 12px; }
.sidebar-splitter::after { content: ""; position: absolute; top: 45%; bottom: 45%; left: 2px; width: 4px; border-radius: 3px; background: var(--border); }
.sidebar-splitter:hover::after, .sidebar-splitter.arrastando::after { background: var(--brand-2); }
.sidebar.hidden + .sidebar-splitter { display: none; }
.main-row > .workspace { padding-left: 4px; }
body.redimensionando { user-select: none; cursor: col-resize; }
body.redimensionando .CodeMirror { pointer-events: none; }

/* ---------------- Janela "Abrir sketch" ---------------- */
dialog.explorador { max-width: 760px; width: calc(100% - 40px); }
.exp-dica { font-size: 13px; color: var(--muted) !important; margin: 0 0 10px; }
.exp-linha { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.exp-caminho {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 6px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  font: 12px var(--mono); color: var(--text); word-break: break-all;
}
.exp-lista {
  height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 8px;
  background: var(--term-bg); padding: 4px;
}
.exp-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: 13px var(--sans);
}
.exp-item:hover:not(:disabled) { background: color-mix(in srgb, var(--brand-2) 22%, transparent); }
.exp-item:disabled { color: var(--dim); cursor: default; }
.exp-icone { width: 20px; text-align: center; color: var(--brand-2); font-weight: 700; font-size: 12px; }
.exp-ino { font-weight: 700; }
.exp-ino .exp-icone { color: var(--brand); font-size: 14px; }
.exp-salvar { display: flex; gap: 10px; align-items: end; margin-top: 10px; }
.exp-salvar label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.exp-salvar input {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: 13px var(--mono);
}
.dialog-actions { gap: 8px; }

/* =============================================================================
   Modo celular (body.celular, ligado pelo script.js em telas estreitas/toque)
   No PC nada disto se aplica: só .so-celular fica escondido.
   ============================================================================= */
.so-celular { display: none !important; }
.banner-fechar { display: none; }

body.celular .so-celular { display: revert !important; }
body.celular .so-pc { display: none !important; }
body.celular { height: 100dvh; overflow: hidden; font-size: 14px; }

/* Cabeçalho compacto: logo pequena, nome curto, bolinha de status */
body.celular .topbar { padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); gap: 8px; }
body.celular .brand { gap: 8px; min-width: 0; }
body.celular .brand-logo { width: 34px; height: 34px; }
body.celular .brand strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.celular .brand small { display: none; }
body.celular .top-right { gap: 8px; flex-shrink: 0; }
body.celular .theme-btn { padding: 6px; }
body.celular .theme-btn > span:last-child { display: none; }
body.celular #healthText { display: none; }
body.celular .health { padding: 6px; }

/* Menus: rolam na horizontal; listas abrem em largura total e submenus abrem embaixo */
body.celular .menubar { padding: 2px 6px; overflow-x: auto; scrollbar-width: none; position: static; }
body.celular .menubar::-webkit-scrollbar { display: none; }
body.celular .menu { position: static; }
body.celular .menu > button { white-space: nowrap; padding: 8px 10px; }
body.celular .menubar .menu-list {
  position: fixed; left: 8px; right: 8px; top: auto; width: auto; max-width: none; min-width: 0;
  max-height: 70dvh; overflow-y: auto; z-index: 1300;
}
body.celular .menu-item { padding: 11px 14px; white-space: normal; }
body.celular .menu-item .key { display: none; }
body.celular .menu-list .menu-list {
  position: static; display: none; margin: 0; max-height: none; box-shadow: none;
  border: 0; border-left: 2px solid var(--brand-2); border-radius: 0; background: var(--panel-2);
}
body.celular .has-sub:hover > .menu-list { display: none; }
body.celular .has-sub.sub-aberto > .menu-list { display: block; }
body.celular .has-sub.sub-aberto > .menu-item .arrow { transform: rotate(90deg); }

/* Aviso de Web Serial: uma linha, com botão de fechar */
body.celular .banner { margin: 6px 8px 0; padding: 8px 34px 8px 10px; font-size: 12.5px; position: relative; }
body.celular .banner-fechar {
  display: block; position: absolute; top: 4px; right: 4px; width: 28px; height: 28px;
  background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer;
}

/* Barra de ferramentas: só ✓ ➜ 💾 e o botão ⚙️; o resto abre ao tocar no ⚙️ */
body.celular .toolbar { padding: 8px 10px; gap: 10px; }
body.celular .quick { width: 100%; align-items: center; }
body.celular .icon-btn { width: 42px; height: 42px; flex-shrink: 0; }
body.celular .config-btn {
  display: flex !important; align-items: center; gap: 6px; flex: 1; min-width: 0; height: 42px;
  padding: 0 12px; border-radius: 999px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); font: 600 13px var(--sans);
}
body.celular .config-placa { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.celular .config-seta { color: var(--muted); transition: transform .15s; }
body.celular .toolbar.config-aberta .config-btn { border-color: var(--brand); }
body.celular .toolbar.config-aberta .config-seta { transform: rotate(180deg); }
body.celular .toolbar > :not(.quick) { display: none; }
body.celular .toolbar.config-aberta > :not(.quick):not(.hidden) { display: flex; }
body.celular .toolbar.config-aberta { max-height: 60dvh; overflow-y: auto; }
body.celular .field, body.celular .field.small { min-width: 0; width: 100%; }
body.celular .row { width: 100%; }
body.celular .row select { min-width: 0; flex: 1; }
body.celular .actions { margin-left: 0; width: 100%; }
body.celular .actions .btn { flex: 1; }

/* Área principal: o editor ocupa tudo */
body.celular .main-row { position: relative; }
body.celular .activitybar, body.celular .sidebar-splitter, body.celular .splitter, body.celular .statusbar { display: none !important; }
body.celular .main-row > .workspace { padding: 0 6px 6px; }
body.celular .workspace { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: minmax(0, 1fr) !important; }
body.celular .editor-pane { border-radius: 10px; }
body.celular .CodeMirror { font-size: var(--editor-font, 13px); }
body.celular .aba { padding: 9px 10px; }
body.celular .aba-fechar { visibility: visible; }
body.celular .aba-nova { font-size: 20px; padding: 4px 12px; }
body.celular .abas-barra .draft { display: none; }

/* Painel lateral vira tela cheia por cima do editor */
body.celular .sidebar {
  position: absolute; inset: 0 6px 6px; z-index: 40; width: auto !important; flex-basis: auto !important; margin: 0;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
body.celular .lib-busca input { font-size: 16px; }   /* 16px: o celular não dá zoom ao digitar */
body.celular .btn.tiny { padding: 7px 12px; font-size: 12px; }
body.celular .arv-arquivo, body.celular .arv-simbolo { padding-top: 8px; padding-bottom: 8px; }

/* Terminal: folha que sobe de baixo, por cima do editor, ao compilar ou tocar em "Saída" */
body.celular .terminal-pane {
  position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important;
  bottom: calc(58px + env(safe-area-inset-bottom)) !important;
  width: auto !important; height: 58dvh !important; z-index: 900; resize: none;
  border-radius: 14px 14px 0 0; border-bottom: 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.55);
  transform: translateY(110%); transition: transform .22s ease; visibility: hidden !important;
}
body.celular.terminal-aberto .terminal-pane { transform: none; visibility: visible !important; }
body.celular .terminal-pane .pane-title { flex-wrap: wrap; row-gap: 6px; padding: 8px 10px; cursor: default; }
body.celular .terminal-pane .pane-title::before {
  content: ""; position: absolute; top: 4px; left: 50%; width: 40px; height: 4px; margin-left: -20px;
  border-radius: 3px; background: var(--border);
}
body.celular .terminal-pane .pane-title label.mini:not(:first-of-type),
body.celular #btnFloat, body.celular #btnPip { display: none !important; }
body.celular #btnFecharTerminal { font-size: 14px; }
body.celular .tab { padding: 8px 10px; font-size: 13px; }
body.celular .terminal { font-size: 12px; padding: 10px; }
body.celular .serial-send input { font-size: 16px; }
body.celular .sb-progress span { min-width: 0; flex: 0 1 auto; }

/* Barra de navegação inferior */
body.celular .navcel {
  display: flex !important; flex-shrink: 0; height: calc(58px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-deep); border-top: 1px solid var(--border); position: relative; z-index: 950;
}
.navcel button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; color: var(--muted); font: 600 10.5px var(--sans); cursor: pointer; position: relative;
  -webkit-tap-highlight-color: transparent;
}
.navcel button span { font-size: 19px; line-height: 1; filter: grayscale(.6); }
.navcel button.ativo { color: var(--brand); }
.navcel button.ativo span { filter: none; }
.navcel button.ativo::before {
  content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand);
}
.nav-ponto {
  position: absolute; top: 8px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 6px var(--brand);
}
.nav-ponto.err { background: var(--err); box-shadow: 0 0 6px var(--err); }

/* Autocompletar e diálogos cabem na tela */
body.celular .CodeMirror-hints { min-width: 0; max-width: 92vw; }
body.celular .ac-info { display: none; }
body.celular dialog { width: calc(100% - 20px); padding: 16px; max-height: 88dvh; }
body.celular .exp-lista { height: 46dvh; }
body.celular .exp-item { padding: 10px; }
body.celular .about { flex-direction: column; text-align: center; }
body.celular .terminal-pane .pane-title { position: relative; padding-top: 14px; }
body.celular .pane-oculto { visibility: visible; }
body.celular .terminal-pane .pane-title { flex-wrap: nowrap; gap: 6px; }
body.celular .terminal-pane .pane-title .mini { font-size: 0; gap: 0; }   /* esconde a palavra "Baud", fica só a caixa */
body.celular .terminal-pane .tab { padding: 8px 6px; }

/* ---------------- Orientação DFU (Black Pill) ---------------- */
dialog.dfu-dialog { max-width: 440px; text-align: center; }
.dfu-dialog h3 { font-size: 19px; }
.dfu-chip { color: var(--muted) !important; font-size: 13px; }
.dfu-passos { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.dfu-passos li {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; font-size: 15px;
}
.dfu-n {
  flex: 0 0 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font: 800 15px var(--sans); color: var(--on-brand); background: linear-gradient(135deg, var(--brand), var(--brand-hi));
}
.dfu-dica { font-size: 12.5px; color: var(--muted) !important; }
.dfu-dialog .dialog-actions { justify-content: center; }

/* ================= Terminal AT (módulos pelo adaptador USB-serial) ================= */
dialog.tat {
  width: min(1240px, 97vw); max-width: none; height: min(860px, 94vh); padding: 0;
  display: none; flex-direction: column; overflow: hidden;
}
dialog.tat[open] { display: flex; }
.tat-topo { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg-head); }
.tat-topo h3 { margin: 0; font-size: 16px; }
.tat-adaptador { color: var(--muted); font-size: 13px; }
.tat-estado { margin-left: auto; font: 600 12px var(--mono); color: var(--muted); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); }
.tat-estado.on { color: var(--ok); border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.tat-conexao {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg-deep); font-size: 12px; color: var(--muted);
}
.tat-conexao label { display: flex; align-items: center; gap: 6px; }
.tat-conexao select { padding: 5px 28px 5px 8px; font-size: 12.5px; background-position: right 8px center; }
#tatPorta { max-width: 300px; }
.tat-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.tat-sinal.ativo { color: var(--ok); border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tat-corpo { flex: 1; min-height: 0; display: flex; }
.tat-lado {
  width: 330px; flex: 0 0 330px; overflow: auto; padding: 10px 12px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; background: var(--panel);
}
.tat-modulo { display: flex; flex-direction: column; gap: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.tat-modulo select { text-transform: none; letter-spacing: 0; font-size: 13px; }
.tat-dica { margin: 0; font-size: 12px; color: var(--muted) !important; line-height: 1.45; }
.tat-roteiros { display: flex; flex-wrap: wrap; gap: 6px; }
.tat-roteiro { text-align: left; }
.tat-grupo { border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.tat-grupo summary { cursor: pointer; padding: 7px 10px; font: 700 12px var(--sans); color: var(--text); }
.tat-grupo[open] summary { border-bottom: 1px solid var(--border); }
.tat-cmd { display: flex; align-items: stretch; }
.tat-cmd > button:first-child {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; text-align: left; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  padding: 6px 10px; color: var(--text);
}
.tat-cmd > button:first-child:hover { background: color-mix(in srgb, var(--brand-2) 18%, transparent); }
.tat-cmd code { background: none; padding: 0; font: 600 12.5px var(--mono); color: var(--link); word-break: break-all; }
.tat-cmd small { color: var(--muted); font-size: 11.5px; }
.tat-remover { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 10px; font-size: 16px; }
.tat-remover:hover { color: var(--err); }
.tat-principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tat-barra { display: flex; align-items: center; gap: 12px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.tat-espaco { flex: 1; }
.tat-vista { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tat-vista button { background: none; border: 0; color: var(--muted); font: 600 12px var(--sans); padding: 4px 12px; cursor: pointer; }
.tat-vista button + button { border-left: 1px solid var(--border); }
.tat-vista button.ativo { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--text); }
.tat-console {
  flex: 1; overflow: auto; padding: 8px 12px; background: var(--term-bg);
  font: 12.5px/1.5 var(--mono); color: var(--term-text);
}
.tat-linha { display: flex; gap: 10px; align-items: baseline; padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.tat-t { color: var(--dim); flex: 0 0 auto; font-size: 11px; }
.tat-seta { flex: 0 0 auto; font-weight: 700; }
.tat-txt { flex: 1; min-width: 0; }
.tat-hex { display: block; color: var(--dim); font-size: 11.5px; }
.tat-linha.tx .tat-seta, .tat-linha.tx .tat-txt { color: var(--accent); }
.tat-linha.rx .tat-seta { color: var(--link); }
.tat-linha.rx .tat-txt { color: var(--text); }
.tat-linha.evt .tat-txt { color: var(--warn); }
.tat-linha.info .tat-txt { color: var(--link); }
.tat-linha.ok .tat-txt { color: var(--ok); }
.tat-linha.err .tat-txt { color: var(--err); }
.tat-linha.dim .tat-txt { color: var(--dim); }
.tat-res { flex: 0 0 auto; font: 600 11px var(--sans); padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.tat-res.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.tat-res.erro { color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, transparent); }
.tat-res.timeout { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.tat-envio { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--bg-deep); }
.tat-envio input:not([type]) , #tatEntrada {
  flex: 1; min-width: 0; background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font: 13px var(--mono);
}
#tatEntrada:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.tat-envio select { padding: 6px 28px 6px 8px; font-size: 12px; background-position: right 8px center; }
body.celular dialog.tat { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; }
body.celular .tat-corpo { flex-direction: column; }
body.celular .tat-lado { width: auto; flex: 0 0 auto; max-height: 34dvh; border-right: 0; border-bottom: 1px solid var(--border); }
.tat-linha.warn .tat-txt { color: var(--warn); }
/* Terminal AT: janela móvel e redimensionável */
dialog.tat { resize: both; min-width: 620px; min-height: 360px; max-width: 100vw; max-height: 100vh; }
dialog.tat .tat-topo { cursor: move; user-select: none; }
dialog.tat .tat-topo :is(button, select) { cursor: pointer; }
dialog.tat.max { inset: 0; margin: 0; width: 100vw !important; height: 100vh !important; border-radius: 0; resize: none; }
dialog.tat.max .tat-topo { cursor: default; }
.tat-divisor { flex: 0 0 6px; cursor: col-resize; background: var(--border); opacity: .5; transition: opacity .15s, background .15s; touch-action: none; }
.tat-divisor:hover, .tat-divisor.ativo { opacity: 1; background: var(--brand-2); }
.tat-lado { border-right: 0; }
body.celular dialog.tat { resize: none; min-width: 0; min-height: 0; }
body.celular .tat-divisor { display: none; }
body.celular .tat-topo { cursor: default; }
/* Terminal AT v2: duas portas (A/B), ponte e espião */
.tat-modos { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tat-modos button { background: none; border: 0; color: var(--muted); font: 600 12px var(--sans); padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.tat-modos button + button { border-left: 1px solid var(--border); }
.tat-modos button.ativo { background: color-mix(in srgb, var(--brand) 20%, transparent); color: var(--text); }
.tat-dica-modo { flex: 1 1 260px; font-size: 11.5px; color: var(--muted); }
#tatPausa.pausado { color: var(--warn); border-color: var(--warn); }
.tat-canal { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; width: 100%; padding: 4px 0; border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent); }
.tat-canal select[id^="tatPorta"] { max-width: 280px; }
.tat-tag { font: 800 12px var(--mono); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; color: #10131c; }
.tat-tag.canal-A { background: #ff8a65; }
.tat-tag.canal-B { background: #4dd0b0; }
.tat-nome {
  width: 110px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font: 600 12px var(--sans);
}
.tat-canal.on .tat-nome { border-color: var(--ok); }
.tat-destino select { padding: 4px 26px 4px 8px; font-size: 12px; background-position: right 8px center; }
.tat-linha.canal-A .tat-seta { color: #ff8a65; }
.tat-linha.canal-B .tat-seta { color: #4dd0b0; }
.tat-linha.rx.canal-A .tat-txt { color: color-mix(in srgb, #ff8a65 35%, var(--text)); }
.tat-linha.rx.canal-B .tat-txt { color: color-mix(in srgb, #4dd0b0 35%, var(--text)); }
dialog.tat[data-modo="uma"] .tat-seta { min-width: 0; }
dialog.tat:not([data-modo="uma"]) .tat-seta { min-width: 150px; font-size: 11.5px; }

/* ================= Tela de abertura / Sobre ================= */
.splash {
  position: fixed; inset: 0; z-index: 3000; display: none; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg-deep) 82%, transparent); backdrop-filter: blur(6px);
}
.splash.aberto { display: grid; animation: splashEntra .35s ease; }
.splash.saindo { animation: splashSai .35s ease forwards; }
@keyframes splashEntra { from { opacity: 0; } to { opacity: 1; } }
@keyframes splashSai { to { opacity: 0; } }
.splash-card {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 28px 30px 18px; text-align: center; border-radius: 18px;
  background: linear-gradient(160deg, var(--panel), var(--bg-head)); border: 1px solid var(--border);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px color-mix(in srgb, var(--brand-2) 40%, transparent);
  animation: splashSobe .5s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes splashSobe { from { transform: translateY(24px) scale(.96); opacity: 0; } }
.splash-ondas { position: absolute; top: 34px; left: 50%; width: 0; height: 0; pointer-events: none; }
.splash-ondas span {
  position: absolute; left: -70px; top: 0; width: 140px; height: 140px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); opacity: 0;
  animation: splashOnda 2.6s ease-out infinite;
}
.splash-ondas span:nth-child(2) { animation-delay: .85s; }
.splash-ondas span:nth-child(3) { animation-delay: 1.7s; }
@keyframes splashOnda { 0% { transform: scale(.7); opacity: .8; } 100% { transform: scale(1.9); opacity: 0; } }
.splash-logo {
  position: relative; width: 140px; height: 140px; object-fit: contain;
  filter: drop-shadow(0 0 22px color-mix(in srgb, var(--brand-2) 60%, transparent));
  animation: splashGira 1s cubic-bezier(.2,.9,.3,1.3) both, splashFlutua 4s ease-in-out 1s infinite;
}
@keyframes splashGira { from { transform: scale(.3) rotate(-160deg); opacity: 0; } }
@keyframes splashFlutua { 50% { transform: translateY(-6px); } }
.splash-titulo { margin: 10px 0 4px; font-size: 26px; letter-spacing: .3px; }
.splash-titulo span { color: var(--brand); }
.splash-sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.splash-versao { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.splash-chip {
  font: 700 12px var(--mono); padding: 4px 12px; border-radius: 999px;
  color: var(--on-brand); background: linear-gradient(135deg, var(--brand), var(--brand-hi));
}
.splash-chip.ghost { color: var(--text); background: var(--panel-2); border: 1px solid var(--border); }
.splash-autor { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; text-align: left; }
.splash-autor > div { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); }
.splash-autor small { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.splash-autor b { font-size: 14px; color: var(--text); }
.splash-carga { height: 4px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin-bottom: 14px; }
.splash-carga div {
  height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand));
  animation: splashCarga 6.8s linear forwards;
}
.splash.sobre .splash-carga { display: none; }
@keyframes splashCarga { to { width: 100%; } }
.splash-historico { text-align: left; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); }
.splash-historico summary { cursor: pointer; padding: 9px 12px; font: 600 13px var(--sans); color: var(--text); }
.splash-lista { max-height: 260px; overflow: auto; padding: 0 12px 10px; }
.splash-ver + .splash-ver { border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 8px; }
.splash-ver-cab { display: flex; justify-content: space-between; font-size: 13px; }
.splash-ver-cab b { color: var(--brand); font-family: var(--mono); }
.splash-ver-cab span { color: var(--dim); font-size: 12px; }
.splash-ver ul { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text); line-height: 1.5; }
.splash-acoes { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.splash-check { margin-right: auto; display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.splash-rodape { margin: 14px 0 0; font-size: 11px; color: var(--dim); }
@media (prefers-reduced-motion: reduce) { .splash *, .splash { animation: none !important; } }
body.celular .splash-autor { grid-template-columns: 1fr; }
body.celular .splash-logo { width: 110px; height: 110px; }
.splash-carga.parada div { animation: none; width: 100%; opacity: .35; }
.splash-dica-som { margin: -6px 0 12px; font-size: 12px; color: var(--muted) !important; }
#splashEntrar.pulsando { animation: splashPulso 1.2s ease-in-out infinite; }
@keyframes splashPulso { 50% { transform: scale(1.06); box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 25%, transparent); } }

/* ================= Redes sociais no topo ================= */
.redes { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rede {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px;
  color: var(--brand); background: color-mix(in srgb, var(--panel-2) 80%, transparent);
  border: 2px solid color-mix(in srgb, var(--border) 85%, var(--muted));
  transition: transform .12s, border-color .12s, background .12s;
}
.rede:hover { transform: translateY(-2px); border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, var(--panel-2)); }
.rede:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
body.celular .redes { display: none; }

/* ================= Seletor de placas com prévia (foto) ================= */
.nativo-oculto { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; }
.placa-seletor { position: relative; }
.placa-botao {
  width: 100%; min-width: 300px; text-align: left; cursor: pointer;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238c9ab5'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 34px 9px 12px; font: inherit;
}
.placa-botao span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.placa-botao:focus-visible, .placa-botao[aria-expanded="true"] { outline: 2px solid var(--brand); outline-offset: 1px; }
.placa-painel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 1200; min-width: 100%; max-width: 520px;
  max-height: min(70vh, 560px); overflow: auto; padding: 4px 0;
  background: var(--menu); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.placa-grupo { padding: 8px 12px 4px; font: 700 11px var(--sans); text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.placa-item { padding: 7px 14px 7px 18px; cursor: pointer; white-space: nowrap; color: var(--text); font-size: 13.5px; }
.placa-item.foco { background: color-mix(in srgb, var(--brand-2) 28%, transparent); }
.placa-item.atual { font-weight: 700; }
.placa-item.atual::before { content: "✓ "; color: var(--brand); margin-left: -12px; }
.placa-previa {
  position: fixed; z-index: 1300; width: 240px; padding: 10px; border-radius: 12px; pointer-events: auto;
  background: var(--panel); border: 1px solid var(--border); box-shadow: 0 18px 44px rgba(0,0,0,.55);
  animation: previaEntra .12s ease;
}
@keyframes previaEntra { from { opacity: 0; transform: scale(.97); } }
.placa-foto {
  height: 170px; display: grid; place-items: center; border-radius: 8px; overflow: hidden;
  background: repeating-conic-gradient(color-mix(in srgb, var(--panel-2) 90%, #fff) 0 25%, var(--panel-2) 0 50%) 0 0 / 16px 16px;
}
.placa-foto img { max-width: 100%; max-height: 100%; object-fit: contain; }
.placa-sem-foto { padding: 12px; text-align: center; font-size: 12px; color: var(--muted); }
.placa-legenda { margin-top: 8px; font-size: 12.5px; text-align: center; color: var(--text); word-break: break-all; }
.placa-legenda b { font-family: var(--mono); color: var(--brand); }
.placa-legenda a { color: var(--link); }
.placa-sem-link { color: var(--dim); }
body.celular .placa-botao { min-width: 0; }

/* Terminal AT e Monitor serial na barra do terminal (no espaço livre entre as abas e o Baud) */
.pane-acoes { display: flex; gap: 6px; margin-left: 14px; }
.pane-title .pane-acoes .btn { margin-left: 0; white-space: nowrap; }
body.celular .pane-acoes { display: none; }
.terminal-pane .pane-title { flex-wrap: wrap; row-gap: 6px; }

/* Bandeira do Brasil no cantinho do topo */
.bandeira { height: 22px; width: auto; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.25), 0 2px 6px rgba(0,0,0,.4); }
body.celular .bandeira { height: 16px; }

/* ================= Tutorial (Ajuda → Tutorial · F1) ================= */
dialog.tutorial { width: min(900px, 96vw); max-width: none; height: min(620px, 92vh); padding: 0; display: none; flex-direction: column; overflow: hidden; }
dialog.tutorial[open] { display: flex; }
.tut-topo { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--bg-head); }
.tut-topo h3 { margin: 0; font-size: 16px; }
.tut-corpo { flex: 1; min-height: 0; display: flex; }
.tut-indice { width: 210px; flex: 0 0 210px; overflow: auto; padding: 10px 8px; border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; gap: 2px; }
.tut-indice button { text-align: left; background: none; border: 0; color: var(--muted); font: 500 13px var(--sans); padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.tut-indice button:hover { color: var(--text); background: var(--panel-2); }
.tut-indice button.ativo { color: var(--text); background: color-mix(in srgb, var(--brand) 18%, transparent); font-weight: 700; }
.tut-pagina { flex: 1; overflow: auto; padding: 18px 26px; }
.tut-pagina h2 { margin: 0 0 12px; font-size: 20px; color: var(--brand); }
.tut-texto { font-size: 14px; line-height: 1.65; color: var(--text); }
.tut-texto li { margin-bottom: 6px; }
.tut-texto code { font-family: var(--mono); font-size: 12.5px; padding: 1px 5px; border-radius: 4px; background: var(--panel-2); }
.tut-obs { color: var(--muted) !important; font-size: 13px; }
.tut-cartoes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.tut-cartoes div { padding: 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); text-align: center; }
.tut-cartoes b { display: block; color: var(--brand); font-size: 15px; }
.tut-cartoes span { font-size: 12px; color: var(--muted); }
.tut-atalhos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin-bottom: 12px; font-size: 13px; }
kbd { font: 600 11.5px var(--mono); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); border-bottom-width: 2px; background: var(--panel-2); color: var(--text); }
.tut-rodape { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-top: 1px solid var(--border); background: var(--bg-deep); }
.tut-conta { margin-right: auto; font-size: 12px; color: var(--muted); }
body.celular .tut-corpo { flex-direction: column; }
body.celular .tut-indice { width: auto; flex: 0 0 auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
body.celular .tut-indice button { white-space: nowrap; }
body.celular .tut-cartoes { grid-template-columns: 1fr 1fr; }
