*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #090a0f;
  --surface: #11131c;
  --surface2: #191c28;
  --border: #222636;
  --accent: #5880ff;
  --accent-hover: #7ba0ff;
  --green: #4cdf8d;
  --red: #ff6b6b;
  --text: #f0f4ff;
  --text-muted: #9ab0d9;
  --font-mono: "Fira Mono", "Cascadia Code", "Consolas", "Courier New", monospace;
  --font-ui: system-ui, -apple-system, sans-serif;
  --header-h: 56px;
  --bar-h: 48px;
  --radius: 8px;
}

/* ── Tema claro ──────────────────────────────── */
body.light {
  --bg: #f0f4ff;
  --surface: #ffffff;
  --surface2: #e4eaf8;
  --border: #c8d2ec;
  --accent: #3a5fd9;
  --accent-hover: #2a4fc9;
  --green: #16a34a;
  --red: #dc2626;
  --text: #111827;
  --text-muted: #374151;
}

body.light .hl-keyword  { color: #7c3aed; }
body.light .hl-operator { color: #0284c7; }
body.light .hl-io       { color: #1d4ed8; }
body.light .hl-boolean  { color: #c2410c; }
body.light .hl-string   { color: #15803d; }
body.light .hl-comment  { color: #6b7280; }
body.light .hl-number   { color: #c2410c; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────── */
header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 24px;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}


#btn-tema {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

#btn-tema:hover {
  border-color: var(--accent);
}

.logo-header {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-ui);
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.logo-code {
  color: var(--accent);
  font-family: var(--font-mono);
}

.logo-separator {
  color: var(--text-muted);
  font-weight: 300;
  margin: 0 2px;
}

.logo-plus {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.footer-logo {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  opacity: 0.45;
  flex-shrink: 0;
  order: 2;
  margin-left: auto;
}


.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex: 1;
}

/* ── Main split ──────────────────────────────── */
main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#resizer {
  width: 5px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
}

#resizer:hover,
#resizer.dragging {
  background: var(--accent);
}

/* ── Pane shared ─────────────────────────────── */
.editor-pane,
.output-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-pane {
  min-width: 200px;
  overflow: hidden;
}

.output-pane {
  min-width: 200px;
  flex: 1;
}

.pane-header {
  height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}


button {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  transition: background 0.15s;
}

#btn-executar {
  background: var(--accent);
  color: #fff;
}

#btn-executar:hover {
  background: var(--accent-hover);
}

#btn-executar:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ── Inputs panel ────────────────────────────── */
.inputs-panel {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.inputs-label {
  font-size: 0.75rem;
  color: var(--text);
  white-space: nowrap;
  padding-top: 5px;
}

.inputs-hint {
  color: var(--text-muted);
  opacity: 0.95;
  font-size: 0.7rem;
}

.inputs-hint code {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
}

#entradas {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 4px 8px;
  resize: vertical;
  min-height: 28px;
  max-height: 120px;
  outline: none;
}

#entradas:focus {
  border-color: var(--accent);
}

/* ── Editor ──────────────────────────────────── */
.editor-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.line-numbers {
  padding: 14px 10px 14px 14px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  white-space: pre;
  min-width: 42px;
  overflow: hidden;
}

.code-area-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

#highlight-layer {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 4;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  scrollbar-width: none;
  pointer-events: none;
  color: var(--text);
  background: transparent;
}

#highlight-layer::-webkit-scrollbar {
  display: none;
}

#editor {
  position: absolute;
  inset: 0;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 14px 16px;
  tab-size: 4;
  overflow-y: auto;
  z-index: 1;
  white-space: pre-wrap;
  word-break: break-word;
}

#editor::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Modo toggle ─────────────────────────────── */
.modo-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.modo-btn {
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  transition: background 0.15s, color 0.15s;
}

.modo-btn.active {
  background: var(--accent);
  color: #fff;
}

.modo-btn:hover:not(.active):not(.modo-btn-soon) {
  color: var(--text);
}

.modo-btn-soon {
  color: var(--text-muted);
  opacity: 0.5;
  cursor: default;
}

/* ── Toast ───────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  padding: 7px 18px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Ligatures por modo ──────────────────────── */
.modo-pytugues #highlight-layer,
.modo-pytugues #editor {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

/* ── Token colors ─────────────────────────────── */
.hl-keyword  { color: #d6a0ff; }
.hl-operator { color: #7ee8ff; }
.hl-io       { color: #79c0ff; }
.hl-boolean  { color: #ffb347; }
.hl-string   { color: #a8e878; }
.hl-comment  { color: #7d8fa8; font-style: italic; }
.hl-number   { color: #ffb347; }

/* ── Tabs ────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  background: transparent;
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

/* ── Status ──────────────────────────────────── */
#status {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

#status.ok   { color: var(--green); }
#status.erro { color: var(--red);   }

/* ── Output ──────────────────────────────────── */
.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

.output-area {
  flex: 1;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  background: var(--bg);
}

.output-area.erro-text {
  color: var(--red);
}

.code-area {
  color: #a9b7d6;
}

body.light .code-area {
  color: #374151;
}

/* ── Exemplos bar ────────────────────────────── */
#exemplos-bar {
  height: var(--bar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
  overflow-x: auto;
}

.exemplos-titulo {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.exemplos-grupo {
  display: contents;
}

.exemplo-btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.exemplo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   RESPONSIVO — MOBILE (≤ 768 px)
   ============================================================ */
@media (max-width: 768px) {

  /* --- Header: compacto, sem tagline -------------------- */
  .tagline { display: none; }
  header { padding: 0 12px; }

  /* --- Main: cada pane ocupa a tela inteira, alternando - */
  main { flex-direction: column; position: relative; }

  #resizer { display: none; }

  /* Panes ocupam 100% e se sobrepõem; JS controla display */
  .editor-pane,
  .output-pane {
    flex: none !important;
    width: 100%;
    min-width: unset;
    height: 100%;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
  }

  /* Pane oculto no mobile */
  .editor-pane.mobile-hidden,
  .output-pane.mobile-hidden { display: none; }

  /* --- Pane header compacto ----------------------------- */
  .pane-header {
    height: auto;
    flex-wrap: wrap;
    padding: 6px 10px;
  }

  /* Executar/Limpar ficam na barra de rodapé */
  .editor-actions { display: none; }

  /* --- Barra fixa no rodapé ----------------------------- */
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 2px solid var(--border);
    flex-shrink: 0;
  }

  /* Abas móveis: Código / Terminal */
  .mobile-tabs {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
  }

  .mobile-tab {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 0;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 8px 14px;
    transition: background 0.15s, color 0.15s;
  }

  .mobile-tab.active {
    background: var(--accent);
    color: #fff;
  }

  .mobile-bar #btn-executar-mobile {
    flex: 1;
    height: 42px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 8px;
  }

  .mobile-bar #btn-limpar-mobile {
    height: 42px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 0.78rem;
  }

  /* --- Inputs panel compacto ---------------------------- */
  .inputs-hint { display: none; }
  #entradas { min-height: 32px; max-height: 72px; }

  /* --- Barra de exemplos -------------------------------- */
  #exemplos-bar { height: auto; padding: 6px 12px; flex-wrap: nowrap; }
  .footer-logo { display: none; }

  /* --- Touch targets maiores ---------------------------- */
  .exemplo-btn { font-size: 0.82rem; padding: 6px 14px; }
  .modo-btn    { font-size: 0.82rem; }
}

/* Em telas grandes a mobile-bar não aparece */
@media (min-width: 769px) {
  .mobile-bar { display: none; }
}

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Spinner ─────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}
