/* ---------- Rodape ---------- */
.link-btn{
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background:none; border:none; cursor:pointer;
  padding: 12px 10px;
  min-height: var(--tap);
  border-radius: 8px;
  text-align:left;
  flex: 1 1 auto;
}
.link-btn:active{ color: var(--accent-glow); background: rgba(91,141,255,0.08); }

.save-pill{
  font-family: var(--font-mono);
  font-size: 11px;
  line-height:1.4;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  display:flex; gap:8px; align-items:center;
  background: rgba(255,255,255,0.02);
}
.save-pill .sp-dot{ width:7px; height:7px; border-radius:50%; background: var(--muted); flex-shrink:0; }
.save-pill.ok{ color: var(--green); border-color: rgba(79,220,142,0.3); }
.save-pill.ok .sp-dot{ background: var(--green); box-shadow: 0 0 7px var(--green); }
.save-pill.saving{ color: var(--accent-glow); border-color: rgba(91,141,255,0.35); }
.save-pill.saving .sp-dot{ background: var(--accent); animation: pulse 1s infinite; }
.save-pill.warn{ color: var(--gold); border-color: rgba(240,185,84,0.3); }
.save-pill.warn .sp-dot{ background: var(--gold); }
.save-pill.err{ color: var(--red); border-color: rgba(255,107,107,0.35); }
.save-pill.err .sp-dot{ background: var(--red); }

/* ---------- Avisos ---------- */
#toast-stack{
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(10px + var(--safe-b));
  display:flex; flex-direction:column; gap:8px;
  z-index: 60;
  pointer-events:none;
}
.toast{
  background: var(--panel2);
  border: 1px solid var(--accent);
  box-shadow: 0 0 24px rgba(91,141,255,0.35);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  animation: toast-in .3s ease, toast-out .4s ease 3.6s forwards;
}
.toast b{ color: var(--gold); }
@keyframes toast-in{ from{ opacity:0; transform: translateY(16px);} to{opacity:1; transform:translateY(0);} }
@keyframes toast-out{ to{ opacity:0; transform: translateY(16px);} }

/* ---------- Level up ---------- */
#levelup-overlay{
  position: fixed; inset:0;
  background: rgba(4,6,12,0.9);
  display:none;
  align-items:center; justify-content:center;
  z-index: 100;
  flex-direction:column;
  text-align:center;
  cursor:pointer;
  padding: 20px;
}
#levelup-overlay.show{ display:flex; }
.lu-flare{
  font-family: var(--font-display);
  font-size: clamp(30px, 11vw, 48px);
  font-weight:900;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(240,185,84,0.8), 0 0 60px rgba(240,185,84,0.4);
  letter-spacing: 2px;
  animation: lu-pop .5s cubic-bezier(.2,1.6,.4,1);
}
@keyframes lu-pop{ 0%{ transform: scale(.3); opacity:0;} 60%{ transform: scale(1.15);} 100%{ transform: scale(1); opacity:1;} }
.lu-sub{
  font-family: var(--font-mono);
  color: var(--accent-glow);
  margin-top: 10px; font-size: 13px;
}
.lu-hint{
  margin-top: 22px; color: var(--muted); font-size: 11px; font-family: var(--font-mono);
}

/* ---------- Modais ---------- */
#journal-overlay, .modal-overlay{
  position:fixed; inset:0; background: rgba(4,6,12,0.85);
  display:none; align-items:flex-start; justify-content:center;
  z-index: 90;
  padding: 12px 10px calc(12px + var(--safe-b));
  overflow-y:auto;
  -webkit-overflow-scrolling: touch;
}
#journal-overlay.show, .modal-overlay.show{ display:flex; }
.journal-panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 620px; width:100%;
  padding: 16px 14px;
}
.journal-head{
  display:flex; justify-content:space-between; align-items:center;
  gap: 10px;
  margin-bottom: 12px;
}
.journal-head h2{
  font-family: var(--font-display); font-size:15px; margin:0; color:#fff;
}
.journal-head .link-btn{ flex: 0 0 auto; text-align:right; }
.journal-entry{
  border-left: 2px solid var(--accent);
  padding: 8px 0 8px 12px;
  margin-bottom: 12px;
}
.journal-entry .je-top{
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  display:flex; justify-content:space-between; gap:8px; flex-wrap:wrap;
}
.journal-entry .je-text{ font-size: 13px; margin-top:5px; line-height:1.5; overflow-wrap: anywhere; }
.empty-note{ color: var(--muted); font-size: 13px; text-align:center; padding: 22px 10px; line-height:1.5; }

/* ---------- Tela inicial / configuracoes ---------- */
.setup-wrap{
  min-height: 100vh;
  min-height: 100dvh;
  display: none;
  align-items: flex-start; justify-content: center;
  padding: 16px 12px calc(24px + var(--safe-b));
}
.setup-wrap.show{ display:flex; }
.setup-card{
  width: 100%; max-width: 540px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border-radius: 12px;
  padding: 20px 16px 18px;
  box-shadow: 0 0 0 1px rgba(91,141,255,0.05), 0 30px 80px -40px rgba(91,141,255,0.5);
  position: relative; overflow: hidden;
}
.setup-card::before{
  content:''; position:absolute; inset:0; pointer-events:none;
  background: linear-gradient(120deg, transparent 0%, rgba(91,141,255,0.06) 45%, transparent 55%);
  background-size: 250% 250%;
  animation: sheen 7s ease-in-out infinite;
}
.setup-title{
  font-family: var(--font-display); font-weight:900;
  font-size: clamp(18px, 5.4vw, 22px);
  line-height:1.25;
  letter-spacing:.5px; color:#fff;
  margin: 10px 0 8px;
}

.field{ margin-bottom: 14px; }
.field label{
  display:block;
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="date"]{
  width:100%;
  background:#05070f;
  border:1px solid var(--border);
  border-radius:8px;
  padding:12px;
  min-height: var(--tap);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  /* 16px impede o zoom automatico do iOS ao focar o campo */
}
.field input[type="date"]{ font-family: var(--font-mono); }
.field input:focus{ outline:none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,141,255,0.12); }
.grid-2{ display:grid; grid-template-columns: 1fr; gap: 0; }

.check-row{
  display:flex; gap:10px; align-items:flex-start;
  cursor: pointer;
  padding: 4px 0;
}
.field label.check-row{
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  font-size: inherit;
  margin-bottom: 0;
}
.check-row input[type="checkbox"]{
  width:22px; height:22px; margin:0; margin-top:1px;
  accent-color: var(--accent); flex-shrink:0; cursor:pointer;
}
.check-row span{ font-size: 13px; line-height:1.45; color: var(--text); }

.hint{ font-size: 12.5px; color: var(--muted); line-height:1.55; margin: 0 0 18px; }
.hint-sm{ font-size: 11.5px; color: var(--muted); line-height:1.5; margin-top:10px; }
.err{ color: var(--red); font-size: 12px; min-height: 18px; font-family: var(--font-mono); line-height:1.4; }

.btn-primary{
  width:100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-glow));
  color:#05070d; border:none;
  padding: 15px; border-radius:10px;
  min-height: 52px;
  font-family: var(--font-display); font-weight:700; letter-spacing:1.2px;
  font-size: 13px; cursor:pointer;
  box-shadow: 0 0 18px -4px rgba(91,141,255,0.7);
}
.setup-foot{
  display:flex; flex-direction:column; gap:2px;
  margin-top: 10px;
}


/* ============================================================
   Escolha da metrica (aulas x modulos)
   ============================================================ */
.segmented{
  display:flex; gap:8px;
}
.segmented label{
  flex:1;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:3px;
  border:1px solid var(--border);
  background:#05070f;
  border-radius:10px;
  padding:12px 8px;
  min-height: var(--tap);
  cursor:pointer;
  text-transform:none;
  letter-spacing:0;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--muted);
  margin:0;
}
.segmented label small{
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height:1.35;
  text-align:center;
  color: var(--muted);
}
.segmented input{ position:absolute; opacity:0; pointer-events:none; }
.segmented input:checked + span{ color:#fff; }
.segmented label:has(input:checked){
  border-color: var(--accent);
  background: rgba(91,141,255,0.1);
  box-shadow: 0 0 0 1px rgba(91,141,255,0.25);
  color:#fff;
}

/* Tres opcoes de metrica nao cabem lado a lado no celular:
   viram linhas, com a descricao a direita. */
.segmented{ flex-direction: column; }
.segmented label{
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px;
  min-height: 52px;
  text-align: left;
}
.segmented label small{ text-align: right; margin-left: auto; }

/* "Carregar checkpoint" e o segundo caminho da tela inicial, nao uma nota de
   rodape: separador claro e botao com a mesma presenca do primario. */
.setup-ou{ margin-top: 16px; }
.ou-linha{
  display:flex; align-items:center; gap:10px;
  font-family: var(--font-mono);
  font-size: 9.5px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.ou-linha::before, .ou-linha::after{
  content:''; flex:1; height:1px; background: var(--border-soft);
}
.btn-secundario{
  width:100%;
  display:flex; align-items:center; gap:12px;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
  min-height: 58px;
  color: var(--text);
  text-align:left;
  cursor:pointer;
}
.btn-secundario:active{ border-color: var(--accent); background: rgba(91,141,255,0.14); }
.bs-ico{ font-size: 18px; line-height:1; color: var(--accent-glow); flex-shrink:0; }
.bs-txt{
  font-size: 13.5px; font-weight:600; color:#fff; line-height:1.3;
}
.bs-txt small{
  display:block;
  font-family: var(--font-mono);
  font-size: 9.5px; font-weight:400; color: var(--muted);
  margin-top: 4px; line-height:1.4;
}
