:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --grid: #e5e7eb;
  --accent: #2563eb;
  --c0: #2563eb;
  --c1: #dc2626;
  --c2: #059669;
  --c3: #d97706;
  --event: #e11d48;
  --tip-bg: #1d2330;
  --tip-text: #f3f4f6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --card: #1b1f29;
    --text: #e6e8ee;
    --muted: #9aa3b2;
    --grid: #2b3140;
    --accent: #60a5fa;
    --c0: #60a5fa;
    --c1: #f87171;
    --c2: #34d399;
    --c3: #fbbf24;
    --event: #fb7185;
    --tip-bg: #2b3140;
    --tip-text: #e6e8ee;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 1100px;
  padding: 16px;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header { display: flex; flex-direction: column; align-items: center; gap: 12px; }
header .title { display: flex; align-items: center; gap: 12px; }

/* Logo sempre sobre fundo branco: o texto cinza dela some no tema escuro */
.logo {
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  line-height: 0;
}
.logo img { height: 140px; width: auto; max-width: 100%; }

/* ---------- Ícone "i" e tooltip ---------- */
.info {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 6px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  color: var(--muted);
  font: italic bold 12px/1 Georgia, serif;
  cursor: help;
  vertical-align: middle;
}
.info:hover, .info:focus { color: var(--accent); border-color: var(--accent); outline: none; }

.info .tip {
  position: absolute; z-index: 10;
  top: calc(100% + 8px); left: -10px;
  width: min(380px, 85vw);
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--tip-bg);
  color: var(--tip-text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  font: normal 13px/1.5 system-ui, sans-serif;
  text-align: left;
  visibility: hidden; opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.info:hover .tip, .info:focus .tip { visibility: visible; opacity: 1; }
.tip strong:first-child { display: block; margin-bottom: 4px; font-size: 14px; }
.tip ul { margin: 6px 0; padding-left: 18px; }
.tip code {
  display: block; margin: 6px 0; padding: 4px 6px;
  border-radius: 4px; background: rgba(255, 255, 255, .1);
  font-size: 12px;
}
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 8px; }
small { color: var(--muted); font-weight: normal; }

.status { font-size: .8rem; padding: 2px 10px; border-radius: 999px; color: #fff; }
.status.on  { background: #059669; }
.status.off { background: #dc2626; }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 16px 0; }
.controls input { width: 4em; padding: 4px; }
button {
  padding: 6px 14px; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer;
}

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stats div { background: var(--card); padding: 10px 14px; border-radius: 8px; }
.stats span { display: block; font-size: .8rem; color: var(--muted); }
.stats strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }

.card { background: var(--card); padding: 14px; border-radius: 8px; margin-bottom: 16px; }
canvas { width: 100%; height: 220px; display: block; }

.status.file { background: #7c3aed; }

.controls .spacer { flex: 1; }
button.secondary {
  background: var(--card); color: var(--text);
  border: 1px solid var(--grid);
}
button.secondary:hover { border-color: var(--accent); }

/* ---------- Modo arquivo ---------- */
.file-only { display: none; }
body.file-mode .file-only { display: block; }
body.file-mode .live-only { display: none; }

.filebar {
  background: var(--card); padding: 12px 14px; border-radius: 8px; margin-bottom: 16px;
  border-left: 4px solid #7c3aed;
}
.filebar-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.filebar-nav { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 10px; }
.filebar-nav select { padding: 4px; }
.filebar-nav input[type=range] { flex: 1; min-width: 160px; }
.range-label { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
