:root {
  /* base NEUTRA (cinza escuro); o azul fica só nos detalhes (--accent / barras) */
  --bg: #121316; --surface: #1a1c20; --surface2: #24262b; --line: #31343a;
  --text: #e9eaed; --muted: #a0a3ab; --accent: #4f8df7; --accent-d: #1b2740;
  --danger: #ef5350; --ok: #54c98a; --track: #31343a;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100dvh;
}
.topbar {
  display: flex; align-items: baseline; gap: 10px; padding: 14px 18px;
  background: linear-gradient(180deg, #131a29, #0f1420); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--muted); }

#app { flex: 1; overflow-y: auto; }
.screen { max-width: 720px; margin: 0 auto; padding: 16px 16px 90px; }
h1 { font-size: 22px; margin: 4px 0 6px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.accent { color: var(--accent); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.empty { margin-top: 24px; padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* botões */
.btn { border: 1px solid var(--line); background: var(--surface2); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 14px; cursor: pointer; }
.btn:hover { border-color: #41444b; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.iconbtn { background: transparent; border: none; color: var(--muted); font-size: 20px; width: 38px; height: 38px; border-radius: 9px; cursor: pointer; }
.iconbtn:hover { background: var(--surface2); color: var(--text); }
.rowbtns { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* cards */
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card.concurso { display: flex; align-items: center; gap: 12px; }
.card.concurso.ativo { background: var(--accent-d); border-color: var(--accent); }
.titulo { font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.sm { width: 9px; height: 9px; display: inline-block; vertical-align: middle; margin-right: 6px; }

/* ring */
.ring { flex: none; }
.ring-t { fill: var(--text); font-size: 11px; font-weight: 600; }

/* progresso */
.resumo { display: flex; align-items: center; gap: 14px; margin: 12px 0; }
.bloco { padding: 0; overflow: hidden; margin-top: 10px; }
.bloco-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.bloco-h:hover { background: var(--surface2); }
.chev { color: var(--muted); }
.tag { font-size: 10px; background: var(--surface2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.disc { padding: 6px 14px 12px; border-top: 1px solid var(--line); }
.disc-h { margin: 8px 0 6px; }
.topico { display: flex; align-items: center; gap: 10px; background: var(--surface2); border-radius: 10px; padding: 9px 11px; margin: 5px 0; }
.tt { font-size: 14px; }
.status { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 7px; display: inline-block; margin-top: 3px; }
.st-none { color: var(--muted); background: #ffffff10; }
.st-prog { color: #d7b36b; background: #d7b36b22; }
.st-done { color: var(--ok); background: #54c98a22; }
.acts { display: flex; gap: 6px; flex: none; }
.mini { font-size: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 5px 9px; cursor: pointer; }
.mini.ghost { background: transparent; color: var(--muted); }

/* semana */
.semana-h { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.dia { display: flex; align-items: center; gap: 10px; margin-top: 8px; border-left: 3px solid transparent; }
.dia.tem { border-left-color: var(--accent); }
.dia.hoje { background: var(--accent-d); }
.step { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font-size: 20px; cursor: pointer; }
.step:hover { border-color: var(--accent); }

/* inputs */
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.inp { width: 100%; background: var(--surface2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; }
.ta { min-height: 150px; resize: vertical; }
.tree { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 280px; overflow: auto; }
.tb { margin-top: 8px; }
.tb:first-child { margin-top: 0; }
.td { color: var(--muted); font-size: 13px; padding-left: 12px; }

/* modal / sheet */
.overlay { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; }
.sheet { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.sheet-item { text-align: left; background: transparent; border: none; color: var(--text); padding: 13px 10px; border-radius: 9px; font-size: 15px; cursor: pointer; }
.sheet-item:hover { background: var(--surface2); }
.sheet-item.danger { color: var(--danger); }

/* tabbar */
.tabbar {
  position: sticky; bottom: 0; display: flex; background: #121826; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbtn {
  flex: 1; background: transparent; border: none; color: var(--muted); padding: 10px 4px 12px;
  font-size: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbtn .ic { font-size: 20px; filter: grayscale(.4) opacity(.8); }
.tabbtn.active { color: var(--accent); }
.tabbtn.active .ic { filter: none; }

/* editor de estrutura */
body.editing .tabbar { display: none; }
.editbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; background: var(--bg); padding: 8px 0 10px; z-index: 4; margin-bottom: 2px; border-bottom: 1px solid var(--line); }
.ebloco { margin-top: 12px; }
.erow { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.edisc { background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 8px; }
.etop { margin: 4px 0; }
.chip { background: var(--surface2); border: 1px solid var(--line); color: var(--muted); border-radius: 20px; padding: 6px 12px; font-size: 13px; cursor: pointer; margin: 6px 0; }
.chip.on { background: #d7b36b22; border-color: #d7b36b66; color: #d7b36b; }
.sel { background: var(--surface2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px; font-size: 13px; font-family: inherit; min-width: 0; }
.step.sm { width: 32px; height: 32px; font-size: 12px; flex: none; }
.ta2 { min-height: 44px; resize: vertical; padding: 8px 10px; line-height: 1.35; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%) translateY(20px);
  background: #16181c; border: 1px solid var(--line); color: var(--text); padding: 10px 16px;
  border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90%;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Barra de sincronização (Firebase) */
.cloudbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin: 10px 0; font-size: 13px; color: var(--muted); }
.cloudbar.ok { border-color: var(--ok); }
.cloudbar span { flex: 1; min-width: 160px; }
.btn.small { padding: 6px 10px; font-size: 13px; }

/* editor: campos com legenda flutuante (igual ao app) */
.field { position: relative; margin-top: 12px; }
.field > label {
  position: absolute; top: -7px; left: 10px; padding: 0 6px;
  font-size: 11px; color: var(--muted); pointer-events: none; background: var(--bg);
}
.ebloco > .field > label { background: var(--surface); }
.edisc .field > label { background: var(--surface2); }
.field .inp { margin: 0; background: transparent; }

/* switch (Prioritário) igual ao app */
.switchrow { display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; font-size: 14px; }
.switch { flex: none; width: 44px; height: 26px; border-radius: 13px; border: none;
  background: var(--line); position: relative; cursor: pointer; padding: 0; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on .knob { left: 21px; }

/* seletor de bloco compacto (igual ao app: "Bloco: N ▾") */
.blocosel { background: transparent; border: none; color: var(--accent);
  font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px 2px; }
.blocosel:hover { text-decoration: underline; }
