:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --card-border: #e5e8ee;
  --text: #1b2333;
  --text-muted: #647085;
  --accent: #16a34a;
  --accent-dark: #15803d;
  --accent-soft: rgba(22, 163, 74, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.07);
  --radius: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px 64px;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
}

.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------- Perfil ---------- */
.profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
}

.profile-goal {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-metrics {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-metrics:empty {
  display: none;
}

.profile-meta {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge .icon {
  width: 13px;
  height: 13px;
}

.badge-streak {
  background: var(--warn-soft);
  color: var(--warn);
}

/* ---------- Botões ---------- */
.register {
  text-align: center;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.25);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.btn-primary:disabled {
  background: var(--card);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  box-shadow: none;
  cursor: default;
}

.btn-small {
  width: auto;
  padding: 10px 20px;
  font-size: 14px;
}

.btn-ghost {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-ghost .icon {
  width: 18px;
  height: 18px;
}

.register-hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}

/* ---------- Dashboard ---------- */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dashboard-header h2,
.calendar h2 {
  font-size: 16px;
  font-weight: 700;
}

.week-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-dark);
}

.week-score {
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-circle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background:
    radial-gradient(closest-side, var(--card) 82%, transparent 83%),
    conic-gradient(var(--accent) calc(var(--pct, 0) * 1%), var(--card-border) 0);
}

.score-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.score-max {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Resumo das 4 semanas */
.weeks-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.week-chip {
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--card-border);
}

.week-chip.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.week-chip .chip-label {
  font-size: 11px;
  color: var(--text-muted);
}

.week-chip .chip-score {
  font-size: 18px;
  font-weight: 800;
  margin-top: 2px;
}

.dashboard-footer {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Grade dos 28 dias ---------- */
.calendar h2 {
  margin-bottom: 14px;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.day-cell {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.day-cell .icon {
  width: 15px;
  height: 15px;
}

.day-cell.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.day-cell.partial {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
}

.day-cell.zero {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.day-cell.missed {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.day-cell.today {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.day-cell.future {
  opacity: 0.5;
}

/* ---------- Quiz ---------- */
.quiz {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.quiz[hidden] {
  display: none;
}

.quiz-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.quiz-progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--card-border);
  overflow: hidden;
}

.quiz-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  transition: width 0.3s ease;
}

.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 48px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Centraliza verticalmente sem cortar quando o conteúdo é maior que a tela
   (margens automáticas permitem rolagem; justify-content: center não) */
.quiz-body > :first-child {
  margin-top: auto;
}

.quiz-body > :last-child {
  margin-bottom: auto;
}

.quiz-step {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.quiz-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.quiz-icon .icon {
  width: 36px;
  height: 36px;
}

.quiz-theme {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-dark);
  margin-bottom: 8px;
}

.quiz-question {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 16px;
}

.quiz-details {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 32px;
}

.quiz-details li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.quiz-details li::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
}

.quiz-answers {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-answer:hover {
  transform: translateY(-1px);
}

.btn-yes {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.25);
}

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

.btn-no:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-answer:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.quiz-top-spacer {
  width: 34px;
  flex-shrink: 0;
}

/* ---------- Cadastro (onboarding) ---------- */
.quiz-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 17px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  margin-bottom: 28px;
}

.quiz-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}

.photo-slot {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 180px;
  border: 2px dashed var(--card-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  background: var(--card);
  overflow: hidden;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.photo-slot:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.photo-slot.filled {
  border-style: solid;
  border-color: var(--accent);
}

.photo-slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-slot .icon {
  width: 24px;
  height: 24px;
}

.photo-slot .slot-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(15, 23, 42, 0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  z-index: 1;
}

/* Fotos iniciais (página principal) */
.photos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.photos-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.photos-hint[hidden] {
  display: none;
}

.photos-grid .photo-slot {
  max-height: none;
  font-size: 12px;
}

.quiz-skip {
  align-self: center;
  font-weight: 600;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.photos-grid figure {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.photos-grid img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--card-border);
}

.photos-grid figcaption {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 420px) {
  .photos-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Resumo do quiz */
.quiz-summary-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.quiz-summary-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.quiz-summary-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.quiz-summary-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

.quiz-summary-list li .icon {
  color: var(--text-muted);
}

.quiz-summary-list li .points {
  margin-left: auto;
  font-weight: 800;
}

.quiz-summary-list li.yes .points {
  color: var(--accent-dark);
}

.quiz-summary-list li.no .points {
  color: var(--danger);
}

.quiz-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 24px;
}

.quiz-total .total-value {
  font-size: 40px;
  font-weight: 800;
  color: var(--accent-dark);
}

.quiz-total .total-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* ---------- Login ---------- */
body.locked {
  overflow: hidden;
}

.auth {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  padding: 24px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.auth[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: auto;
}

.auth-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.3);
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
}

.auth-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 20px;
}

.auth-accounts {
  width: 100%;
  margin-bottom: 18px;
}

.auth-accounts-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-align: left;
}

.auth-accounts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.account-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form label[hidden] {
  display: none;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
}

.auth-form input {
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

.auth-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

#auth-pin,
#auth-pin2 {
  letter-spacing: 8px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

.auth-error {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
}

.auth-error[hidden] {
  display: none;
}

.auth-form .btn-primary {
  margin-top: 4px;
  font-size: 16px;
}

.auth-toggle {
  margin-top: 16px;
  font-weight: 600;
  color: var(--accent-dark);
}

/* ---------- Perfil: ações ---------- */
.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: flex-start;
}

/* ---------- Instruções de fotos ---------- */
.btn-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: flex-start;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease;
}

.btn-help:hover {
  border-color: var(--accent);
  filter: brightness(0.98);
}

.dialog-photos {
  width: min(92vw, 440px);
}

.photos-help-img-link {
  display: block;
  line-height: 0;
}

.photos-help-img-link[hidden] {
  display: none;
}

.photos-help-img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.photos-help-zoom {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: -6px;
}

.photos-help-zoom[hidden] {
  display: none;
}

.photos-help-list[hidden] {
  display: none;
}

.photos-help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.photos-help-list li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.photos-help-list li::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
}

/* ---------- Dialog ---------- */
.dialog {
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  padding: 0;
  width: min(92vw, 400px);
  box-shadow: 0 20px 60px rgba(16, 24, 40, 0.2);
}

.dialog::backdrop {
  background: rgba(20, 26, 40, 0.45);
}

.dialog-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog-form h3 {
  font-size: 18px;
}

.dialog-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.dialog-form input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* ≥16px evita zoom automático no iOS ao focar */
}

.dialog-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.dialog-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 420px) {
  .quiz-question {
    font-size: 20px;
  }
}
