:root {
  --brick: #A5311F;
  --brick-dark: #8A2819;
  --brick-soft: #FDF1EF;
  --brick-soft-hover: #F6DDD9;
  --white: #FFFFFF;
  --bg: #FFFFFF;
  --surface: #F7F7F7;
  --placeholder: #EAEAEA;
  --text: #1F1F1F;
  --text-2: #6B6B6B;
  --text-faint: #B9B9B9;
  --text-placeholder: #A7A7A7;
  --border: #E3E3E3;
  --error: #C0392B;
  --error-bg: #FCEDEB;
  --error-border: #E5A8A0;
  --warn-bg: #FEF6E7;
  --warn-border: #E8C87A;
  --warn-text: #7A5A12;
  --success: #1E7B44;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { max-width: 100%; overflow-x: hidden; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

/* Texto base: 1rem (16px). Tudo herda daqui; só os desvios declaram font-size. */
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a { color: var(--brick); }
a:hover { color: var(--brick-dark); }

/* ---------- Controlos partilhados (branco com borda) ---------- */
.chip, .rank-arrow, .cal-nav, .time-card {
  font: inherit;
  background: var(--white);
  border: 1.5px solid var(--border);
  cursor: pointer;
}
.chip:hover, .time-card:hover,
.rank-arrow:hover:not(:disabled), .cal-nav:hover:not(:disabled) {
  border-color: var(--brick);
  color: var(--brick);
}

/* ---------- Escala tipográfica ---------- */
/* pequeno (labels, hints, texto secundário) */
.p-dot, .p-label, .field label, .hint, .err-msg, .chip,
.project-info p, .rank-num, .review-row dt, .banner, .submit-err,
.success-card .s-note, .footer-col h3, .footer-links a {
  font-size: .875rem;
}
/* mínimo (badges e ordinais) */
.chip .ord, .cal-dow, .review-slot .badge, .pref-badge {
  font-size: .75rem;
}

/* ---------- Header ---------- */
header.site {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
}
.wordmark {
  font-weight: 800;
  font-size: clamp(1.125rem, 3vw, 1.375rem);
  letter-spacing: 2px;
}
.wordmark .sub { color: var(--brick); }

/* ---------- Layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(24px, 5.5vw, 40px) clamp(14px, 2.8vw, 20px) clamp(48px, 10vw, 72px);
}
.page-title {
  font-size: clamp(1.5rem, 4.2vw, 1.875rem);
  font-weight: 800;
  letter-spacing: 0.5px;
}
.title-bar {
  width: 56px;
  height: 5px;
  background: var(--brick);
  border-radius: 3px;
  margin: 10px 0 8px;
}
.page-lead {
  color: var(--text-2);
  margin-bottom: clamp(22px, 4.4vw, 32px);
}

/* ---------- Progress ---------- */
.progress {
  display: flex;
  align-items: center;
  margin-bottom: clamp(22px, 4.4vw, 32px);
}
.p-step {
  display: flex;
  align-items: center;
  gap: 10px;
}
.p-dot {
  width: clamp(28px, 4.7vw, 34px);
  height: clamp(28px, 4.7vw, 34px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--placeholder);
  color: var(--text-2);
  flex: none;
  transition: background .2s, color .2s;
}
.p-step.active .p-dot, .p-step.done .p-dot { background: var(--brick); color: var(--white); }
.p-label { font-weight: 600; color: var(--text-2); white-space: nowrap; }
.p-step.active .p-label { color: var(--text); }
.p-line { flex: 1; height: 2px; background: var(--placeholder); margin: 0 10px; min-width: 14px; }
.p-line.done { background: var(--brick); }
@media (max-width: 560px) {
  .p-label { display: none; }
}

/* ---------- Cards & steps ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  padding: clamp(20px, 4.4vw, 32px) clamp(16px, 4.4vw, 32px);
}
.step { display: none; }
.step.visible { display: block; }
.step-title { font-size: 1.25rem; font-weight: 700; }
.step-bar {
  width: 40px;
  height: 4px;
  background: var(--brick);
  border-radius: 2px;
  margin: 8px 0 24px;
}

/* ---------- Welcome / projects ---------- */
.projects {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.project-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.project-thumb {
  flex: none;
  width: clamp(60px, 11.7vw, 84px);
  height: clamp(60px, 11.7vw, 84px);
  border-radius: 10px;
  object-fit: cover;
  background: var(--placeholder);
}
.project-thumb.ph {
  display: grid;
  place-items: center;
  color: var(--white);
  font-weight: 800;
  font-size: 1.5rem;
  background: var(--brick);
}
.project-info h3 { font-weight: 700; margin-bottom: 3px; }
.project-info p { color: var(--text-2); }

.project-row-btn {
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.project-row-btn:hover, .project-row-btn:focus-visible {
  border-color: var(--brick);
  background: var(--brick-soft);
  outline: none;
}

/* ---------- Project details dialog ---------- */
.project-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  margin: auto;
  width: min(560px, 92vw);
  max-height: 88vh;
  max-height: 88dvh;
  overflow: hidden;
  background: var(--white);
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.project-dialog::backdrop {
  background: rgba(31,31,31,0.55);
}
.dialog-scroll {
  max-height: inherit;
  height: 100%;
  overflow-y: auto;
}
.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 1;
}
.dialog-close:hover { background: var(--white); color: var(--brick); }
.dialog-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--placeholder);
}
.dialog-body {
  padding: clamp(18px, 4.4vw, 28px);
}
.dialog-body h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.dialog-body p {
  color: var(--text-2);
  margin-bottom: 10px;
}
.dialog-body p:last-child { margin-bottom: 0; }

/* ---------- Form fields ---------- */
.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.field .req { color: var(--brick); }
.field input, .field select {
  width: 100%;
  font: inherit; /* 1rem = 16px: evita o auto-zoom do iOS ao focar */
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  min-height: 46px;
}
.field input::placeholder { color: var(--text-placeholder); }
.field input:focus, .field select:focus,
button:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--brick);
  outline-offset: 2px;
  border-color: var(--brick);
}
.field.invalid input, .field.invalid select { border-color: var(--error); }
.err-msg { display: none; color: var(--error); margin-top: 6px; font-weight: 500; }
.field.invalid .err-msg { display: block; }
.hint { color: var(--text-2); margin-top: 6px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font-weight: 600;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 999px;
  color: var(--text-2);
  transition: all .15s;
}
.chip[aria-pressed="true"] {
  background: var(--brick);
  border-color: var(--brick);
  color: var(--white);
}
.chip .ord {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  color: var(--brick);
  font-weight: 800;
  margin-right: 8px;
  vertical-align: -4px;
}

/* ranking list */
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px 8px 14px;
  min-height: 52px;
  transition: border-color .15s, box-shadow .15s;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* iOS: sem menu de contexto no long-press */
  touch-action: pan-y; /* scroll vertical livre; o JS bloqueia-o só durante o arrasto */
}
.rank-list.drag-active .rank-item { transition: transform .15s ease; }
.rank-item.dragging {
  transition: none; /* segue o dedo sem atraso */
  position: relative;
  z-index: 10;
  border-color: var(--brick);
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
  cursor: grabbing;
}
.rank-num {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brick);
  color: var(--white);
  font-weight: 800;
}
.rank-label { flex: 1; font-weight: 600; }
.rank-handle {
  color: var(--text-faint);
  cursor: grab;
  padding: 0 4px;
  flex: none;
  font-size: 1.125rem;
  letter-spacing: 2px;
  user-select: none;
}
.rank-arrows { display: flex; gap: 4px; flex: none; }
.rank-arrow {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--text-2);
  display: grid;
  place-items: center;
}
.rank-arrow:disabled { opacity: .3; cursor: not-allowed; }

/* honeypot — humans never see this */
.hp-field {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Buttons ---------- */
.nav-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
.nav-row:has(> :only-child) { justify-content: flex-end; }
.btn {
  font: inherit;
  font-weight: 700;
  padding: 13px clamp(18px, 3.9vw, 28px);
  min-height: 48px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--brick); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--brick-dark); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1.5px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
.btn.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Calendar ---------- */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cal-month { font-weight: 700; text-transform: capitalize; }
.cal-nav {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  font-size: 1.125rem;
  color: var(--text);
}
.cal-nav:disabled { opacity: .35; cursor: not-allowed; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  text-align: center;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  padding: 6px 0;
}
.cal-day {
  aspect-ratio: 1;
  min-height: 44px;
  display: grid;
  place-items: center;
  font: inherit;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-faint);
  position: relative;
}
.cal-day.avail {
  background: var(--brick-soft);
  color: var(--brick);
  font-weight: 700;
  cursor: pointer;
}
.cal-day.avail::after {
  content: "";
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brick);
}
.cal-day.avail:hover { background: var(--brick-soft-hover); }
.cal-day.selected { background: var(--brick); color: var(--white); }
.cal-day.selected::after { background: var(--white); }

/* time cards */
.times-title { font-weight: 700; margin: 24px 0 12px; }
.times-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.time-card {
  font-weight: 700;
  padding: 14px 10px;
  min-height: 52px;
  border-radius: 10px;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: all .15s;
}
.time-card[aria-pressed="true"] {
  background: var(--brick);
  border-color: var(--brick);
  color: var(--white);
}

/* skeleton / empty */
.skeleton { display: grid; gap: 10px; }
.sk-row { height: 44px; border-radius: 8px; background: var(--placeholder); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.empty-state {
  text-align: center;
  padding: 36px 20px;
  background: var(--surface);
  border-radius: 10px;
  color: var(--text-2);
}
.empty-state strong { color: var(--text); display: block; margin-bottom: 6px; }

/* ---------- Review ---------- */
.review-list { display: grid; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.review-row {
  display: grid;
  grid-template-columns: clamp(140px, 26vw, 190px) 1fr;
  gap: 12px;
  padding: 13px 16px;
  background: var(--white);
}
.review-row:nth-child(even) { background: var(--surface); }
.review-row dt { color: var(--text-2); font-weight: 600; }
.review-row dd { font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 560px) { .review-row { grid-template-columns: 1fr; gap: 2px; } }
.review-slot {
  margin-top: 16px;
  background: var(--brick-soft);
  border: 1.5px solid var(--brick);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.review-slot .badge {
  background: var(--brick);
  color: var(--white);
  font-weight: 700;
  letter-spacing: .5px;
  padding: 5px 14px;
  border-radius: 999px;
  text-transform: uppercase;
  flex: none;
}
.review-slot .slot-text { font-weight: 700; color: var(--brick-dark); }
.pref-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.pref-badge {
  background: var(--brick);
  color: var(--white);
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}

/* ---------- Messages ---------- */
.banner {
  display: none;
  border-radius: 10px;
  padding: 13px 16px;
  font-weight: 500;
  margin-bottom: 18px;
}
.banner.show { display: block; }
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); }
.banner.error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error); }
.submit-err { display: none; color: var(--error); font-weight: 600; margin-top: 12px; }
.submit-err.show { display: block; }

/* ---------- Success ---------- */
.success-card { text-align: center; padding: clamp(32px, 6.7vw, 48px) clamp(18px, 4.4vw, 32px); }
.success-icon {
  width: clamp(60px, 10.5vw, 76px);
  height: clamp(60px, 10.5vw, 76px);
  border-radius: 50%;
  background: var(--brick);
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
}
.success-icon svg { width: 50%; height: 50%; }
.success-card h2 { font-size: clamp(1.3rem, 3.6vw, 1.625rem); font-weight: 800; margin-bottom: 8px; }
.success-card .s-slot {
  display: inline-block;
  background: var(--brick-soft);
  color: var(--brick-dark);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 999px;
  margin: 16px 0 8px;
}
.success-card p { color: var(--text-2); }
.success-card .s-note { margin-top: 20px; }

/* ---------- Footer ---------- */
footer.site {
  background: var(--brick);
  color: var(--white);
  padding: clamp(24px, 5.5vw, 40px) clamp(16px, 3.3vw, 24px);
  margin-top: auto;
}
.footer-inner {
  max-width: 960px;
  margin: 0 auto;
}
.footer-col h3 {
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 28px;
}
.footer-links a { color: rgba(255,255,255,.85); text-decoration: none; }
.footer-links a:hover { color: var(--white); text-decoration: underline; }
@media (max-width: 560px) {
  .footer-links { flex-direction: column; }
}
