/* ==========================================================================
   BoardGuard — Tema escuro estilo FamilyGuard
   ========================================================================== */

:root {
  --bg-0: #0b1220;
  --bg-1: #111a2c;
  --bg-2: #1a2640;
  --bg-3: #243355;
  --bg-hover: #2c3d63;
  --border: #2a3c64;
  --text-1: #e6ebf5;
  --text-2: #a9b6cf;
  --text-3: #6b7a96;
  --accent: #2bd576;        /* verde EcoClicke */
  --accent-2: #1a9a55;
  --warn: #ffb547;
  --danger: #ff5d6c;
  --info: #4cc9f0;
  --select: #ffd23f;
  --net-hi: #ff7eb6;
  --top-tint: #2bd576;
  --bot-tint: #ff7eb6;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --radius-sm: 5px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "JetBrains Mono", monospace;
}

[data-theme="light"] {
  --bg-0: #f4f6fb;
  --bg-1: #ffffff;
  --bg-2: #eef1f7;
  --bg-3: #dde3ee;
  --bg-hover: #d3dbe9;
  --border: #c8d1e0;
  --text-1: #1a2236;
  --text-2: #4a5773;
  --text-3: #7a8499;
  --shadow: 0 4px 20px rgba(20, 30, 50, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

/* ===== Topbar ============================================================= */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #052015;
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 12px rgba(43, 213, 118, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-tag { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar-status { display: flex; gap: 6px; }

.pill {
  padding: 5px 10px;
  background: var(--bg-3);
  border-radius: 999px;
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.muted { opacity: 0.6; }
#status-side { color: var(--top-tint); border-color: var(--top-tint); }
#status-side.bottom { color: var(--bot-tint); border-color: var(--bot-tint); }

.btn {
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #052015;
  border-color: transparent;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 4px 8px; font-size: 11.5px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.link-btn {
  background: none; border: none;
  color: var(--accent); font-size: 11.5px;
  cursor: pointer; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ===== Layout ============================================================= */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 0;
  overflow: hidden;
  min-height: 0;
}

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.sidebar.right { border-right: none; border-left: 1px solid var(--border); }

.panel {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}
.panel:last-child { border-bottom: none; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-2);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.panel-head input[type="search"] {
  flex: 1;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  outline: none;
}
.panel-head input[type="search"]:focus { border-color: var(--accent); }

/* Search panel */
.search-tabs {
  display: flex;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.search-tabs .tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  padding: 8px 4px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.search-tabs .tab:hover { color: var(--text-1); }
.search-tabs .tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  min-height: 0;
}
.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12.5px;
  border-left: 3px solid transparent;
  transition: all 0.1s;
}
.search-row:hover { background: var(--bg-2); }
.search-row.selected {
  background: var(--bg-2);
  border-left-color: var(--accent);
}
.search-row .meta {
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--mono);
}
.search-row .name { font-weight: 500; }
.search-row.side-bot .name::after {
  content: '·';
  color: var(--bot-tint);
  margin-left: 4px;
}

.results-counter {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  position: sticky;
  bottom: 0;
}

.vlist { width: 100%; }
.vlist-window { will-change: transform; }
.vlist-window .search-row { height: 28px; padding: 5px 12px; }

/* ===== Board area ========================================================= */
.board-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.board-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 6px 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}
.board-toolbar-left, .board-toolbar-right { display: flex; gap: 4px; }
.board-toolbar-center { text-align: center; }

.tool-btn {
  width: 30px; height: 30px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  display: grid; place-items: center;
  transition: all 0.15s;
}
.tool-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.tool-btn.active { background: var(--accent); color: #052015; border-color: var(--accent); }

.hover-info {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
}

.dropzone {
  flex: 1;
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.04) 1px, transparent 0),
    var(--bg-0);
  background-size: 24px 24px;
  overflow: hidden;
  min-height: 0;
}
.dropzone.dragover::after {
  content: 'Solte para abrir';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(43, 213, 118, 0.1);
  border: 3px dashed var(--accent);
  font-size: 24px;
  color: var(--accent);
  font-weight: 700;
  z-index: 5;
}

#board-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
}

.dropzone-hint {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
  pointer-events: none;
  color: var(--text-2);
}
.dropzone-hint > div, .dropzone-hint > h2, .dropzone-hint > p {
  pointer-events: auto;
}
.dropzone-hint .dropzone-icon {
  font-size: 80px;
  line-height: 1;
  opacity: 0.5;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(43, 213, 118, 0.3));
}
.dropzone-hint h2 {
  margin: 0 0 16px;
  font-size: 28px;
  color: var(--text-1);
  font-weight: 700;
}
.dropzone-hint p { margin: 8px 0; font-size: 14px; }
.dropzone-hint p.big { font-size: 16px; margin: 16px 0; }
.dropzone-hint p.small { font-size: 12px; margin-top: 24px; }
.dropzone-hint code {
  background: var(--bg-2);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  margin: 0 2px;
}
.dropzone-hint .big-btn {
  font-size: 15px;
  padding: 10px 24px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(43, 213, 118, 0.35);
}
.dropzone-hint .big-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}
.dropzone-hint.hidden { display: none; }

/* Borda animada na zona vazia para sinalizar que é drop target */
.dropzone:not(.has-board) {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.04) 1px, transparent 0),
    linear-gradient(135deg, rgba(43, 213, 118, 0.04), transparent 50%);
  background-size: 24px 24px, 100% 100%;
}
.dropzone:not(.has-board)::before {
  content: '';
  position: absolute;
  inset: 16px;
  border: 2px dashed rgba(43, 213, 118, 0.4);
  border-radius: 12px;
  pointer-events: none;
  animation: pulseBorder 2.5s ease-in-out infinite;
}
@keyframes pulseBorder {
  0%, 100% { border-color: rgba(43, 213, 118, 0.25); }
  50%      { border-color: rgba(43, 213, 118, 0.6); }
}

.board-statusbar {
  display: flex;
  gap: 16px;
  padding: 5px 12px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--text-3);
}

/* ===== Inspector ========================================================== */
.inspector { flex: 0 0 auto; }
.inspector-body {
  padding: 12px;
  font-size: 12.5px;
  max-height: 240px;
  overflow-y: auto;
}
.inspector-empty {
  color: var(--text-3);
  font-style: italic;
  text-align: center;
  padding: 20px 0;
}
.inspector-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}
.inspector-row:last-child { border-bottom: none; }
.inspector-row .k { color: var(--text-3); font-size: 11.5px; }
.inspector-row .v {
  font-family: var(--mono);
  color: var(--text-1);
  word-break: break-all;
}
.inspector-row .v.accent { color: var(--accent); }

.pinout { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pinout-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 11.5px;
  min-height: 0;
}
.pinout-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  padding: 4px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.pinout-row:hover { background: var(--bg-2); }
.pinout-row.selected {
  background: var(--bg-2);
  border-left-color: var(--select);
}
.pinout-row .pin-num {
  color: var(--text-3);
  text-align: right;
}
.pinout-row .pin-net { color: var(--text-1); }
.pinout-row .pin-net.gnd { color: var(--text-3); }
.pinout-row .pin-net.power { color: var(--warn); }
.pinout-row .pin-net.signal { color: var(--info); }

/* Notes */
.notes { flex: 0 0 auto; }
.notes textarea {
  width: 100%;
  min-height: 90px;
  background: var(--bg-0);
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-1);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  resize: vertical;
}

/* ===== Schematic panel ==================================================== */
.schematic-panel {
  position: fixed;
  right: 0;
  top: 60px;
  bottom: 0;
  width: 50vw;
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}
.schematic-panel.hidden { transform: translateX(100%); pointer-events: none; }

.schematic-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
}
.schematic-controls { display: flex; gap: 6px; align-items: center; }
.schematic-controls input[type="search"] {
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  width: 160px;
  outline: none;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}
.schematic-controls #sch-page {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  padding: 0 4px;
}

.schematic-body {
  flex: 1;
  overflow: auto;
  background: #2b2b2b;
  padding: 16px;
  text-align: center;
  position: relative;
}
#sch-canvas-wrap {
  display: inline-block;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
#sch-canvas-wrap canvas { display: block; }
.sch-highlight {
  position: absolute;
  background: rgba(255, 210, 63, 0.4);
  border: 2px solid var(--select);
  pointer-events: none;
  border-radius: 2px;
  animation: pulse 1.2s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { box-shadow: 0 0 0 0 rgba(255, 210, 63, 0.6); }
  to { box-shadow: 0 0 0 8px rgba(255, 210, 63, 0); }
}

.floating-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #052015;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(43, 213, 118, 0.4);
  z-index: 40;
  transition: transform 0.15s;
}
.floating-btn:hover { transform: scale(1.08); }
.floating-btn.hidden { display: none; }

/* ===== Dialog & Toast ===================================================== */
.dialog {
  background: var(--bg-1);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  min-width: 400px;
  max-width: 95vw;
}

/* Modal de abrir arquivo (com paste/URL) ================================== */
.open-dialog { width: 520px; }
.open-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 16px;
}
.open-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--text-1);
  transition: all 0.15s;
}
.open-opt:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.open-opt.highlight {
  background: linear-gradient(135deg, rgba(43, 213, 118, 0.15), rgba(26, 154, 85, 0.08));
  border-color: var(--accent);
}
.open-opt.highlight:hover {
  background: linear-gradient(135deg, rgba(43, 213, 118, 0.25), rgba(26, 154, 85, 0.15));
}
.open-opt.highlight .open-opt-text strong { color: var(--accent); }
.open-opt-icon { font-size: 28px; }
.open-opt-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.open-opt-text small { color: var(--text-3); font-size: 12px; }

.paste-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 12px;
}
.paste-area textarea {
  width: 100%;
  min-height: 200px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
  outline: none;
}
.paste-area textarea:focus { border-color: var(--accent); }
.paste-area input[type="url"] {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}
.paste-area input[type="url"]:focus { border-color: var(--accent); }
.paste-actions { display: flex; gap: 8px; justify-content: flex-end; }

.open-tip {
  background: rgba(43, 213, 118, 0.08);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 4px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
  margin-bottom: 12px;
}
.open-tip strong { color: var(--accent); }
.open-tip code {
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
}
.open-tip ol {
  margin: 8px 0 0;
  padding-left: 20px;
}
.open-tip ol li {
  margin: 4px 0;
}
.open-tip p { margin: 0; }

/* Error dialog ============================================================ */
.error-dialog { width: 600px; }
.error-content {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-1);
  max-height: 50vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

@media (max-width: 600px) {
  .dialog { min-width: 0; padding: 16px; }
  .open-dialog { width: 100%; }
  .open-opt { padding: 12px; }
  .open-opt-icon { font-size: 24px; }
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog h3 { margin: 0 0 16px; }
.dialog table { width: 100%; border-collapse: collapse; }
.dialog table td { padding: 6px 8px; font-size: 13px; }
.dialog table td:first-child { text-align: right; width: 130px; }
.dialog kbd {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 11px;
}
.dialog-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-3);
  color: var(--text-1);
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  z-index: 100;
  transition: transform 0.25s ease, opacity 0.25s;
  opacity: 0;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--accent); color: var(--accent); }
.toast.hidden { display: none; }

/* ===== Scrollbars ========================================================= */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ===== Responsivo ========================================================= */
.mobile-only { display: none; }
.icon-btn {
  width: 38px;
  padding: 7px 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px 1fr 280px; }
}

/* Tablet em paisagem ou desktop pequeno: comprime mas mantém 3 colunas */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 220px 1fr 260px; }
  .topbar { gap: 12px; padding: 8px 12px; }
  .brand-tag { display: none; }
  .topbar-status { display: none; }
}

/* Tablet em retrato e mobile: layout single-column com sidebars off-canvas */
@media (max-width: 900px) {
  .mobile-only { display: inline-grid; }
  .layout { grid-template-columns: 1fr; position: relative; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(85vw, 340px);
    z-index: 80;
    background: var(--bg-1);
    box-shadow: 0 0 32px rgba(0,0,0,0.5);
    transition: transform 0.25s ease;
  }
  .sidebar.left  { left: 0;  border-right: 1px solid var(--border); transform: translateX(-105%); }
  .sidebar.right { right: 0; border-left: 1px solid var(--border); display: flex; transform: translateX(105%); }
  .sidebar.left.open  { transform: translateX(0); }
  .sidebar.right.open { transform: translateX(0); }

  /* Backdrop quando sidebar está aberta */
  body.sidebar-open::after {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 70;
    animation: fadeIn 0.2s;
  }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

  /* Topbar: só os essenciais */
  .topbar { grid-template-columns: auto auto auto 1fr; padding: 6px 8px; gap: 6px; }
  .brand .logo { width: 32px; height: 32px; font-size: 13px; }
  .brand-text { display: none; }
  .topbar-actions { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .topbar-actions .btn { font-size: 11.5px; padding: 6px 8px; }

  /* Esconde botões de toolbar redundantes em mobile */
  #btn-flip, #btn-fit, #btn-mirror, #btn-rotate, #btn-theme, #btn-help { display: none; }

  /* Toolbar do canvas: maior pra dedo */
  .tool-btn { width: 40px; height: 40px; font-size: 18px; }
  .board-toolbar-center .hover-info { display: none; }

  /* Schematic panel: tela inteira em mobile */
  .schematic-panel { width: 100vw; top: 0; }

  /* Recents menu: largura total */
  .recent-menu { width: calc(100vw - 24px); top: 50px; }

  /* Drop hint em mobile */
  .dropzone-hint .dropzone-icon { font-size: 64px; }
  .dropzone-hint h2 { font-size: 22px; }
  .dropzone-hint p.big { font-size: 14px; }
  .dropzone-hint .big-btn { padding: 14px 28px; font-size: 16px; }
}

@media (max-width: 480px) {
  /* Smartphone: mais agressivo */
  .topbar-actions .btn:not(.primary) { display: none; }
  .schematic-controls input[type="search"] { width: 100px; }
}

/* Touch: aumenta hit-targets */
@media (pointer: coarse) {
  .btn { min-height: 38px; }
  .search-row { padding: 10px 12px; }
  .pinout-row { padding: 8px 12px; }
  .recent-row { padding: 10px 14px; }
  .tool-btn { min-width: 40px; min-height: 40px; }
}
.muted { color: var(--text-3); }
.hidden { display: none !important; }

/* ===== Update bar (PWA) ================================================== */
.update-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-1);
  color: var(--text-1);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translate(-50%, 60px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ===== Recent files menu ================================================ */
.recent-menu {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 60;
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.recent-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.recent-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  border-left: 3px solid transparent;
}
.recent-row:hover {
  background: var(--bg-2);
  border-left-color: var(--accent);
}
.recent-row .ic { color: var(--accent); font-size: 14px; }
.recent-row .name { font-weight: 500; }
.recent-row .meta {
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--mono);
}
.recent-row .del {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
}
.recent-row .del:hover { color: var(--danger); }
.recent-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ===== Highlight de matches na busca ===================================== */
.search-row mark, .recent-row mark {
  background: rgba(43, 213, 118, 0.25);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 600;
}

/* ===== Window controls overlay (PWA standalone) ========================= */
@media (display-mode: window-controls-overlay) {
  .topbar {
    padding-top: env(titlebar-area-y, 10px);
    padding-left: env(titlebar-area-x, 16px);
    -webkit-app-region: drag;
  }
  .topbar .btn, .topbar input, .topbar button {
    -webkit-app-region: no-drag;
  }
}

/* ===== Safe area para iOS notch ========================================= */
@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}
