/* ===========================================================
   Cheff Cake — rodízio de bolos da Garten
   Mobile-first. Sem dependências.
   =========================================================== */

:root {
  --pink:      #FF6B8A;
  --pink-dark: #E8446A;
  --cream:     #FFF6EC;
  --butter:    #FFC94D;
  --mint:      #4ECDA4;
  --choco:     #4A3128;
  --grape:     #8B5CF6;

  --bg:        #FFF6EC;
  --bg-2:      #FFE9DC;
  --card:      #FFFFFF;
  --card-2:    #FFF9F4;
  --text:      #3D2B23;
  --text-soft: #8C776C;
  --line:      #F0E0D4;
  --shadow:    0 6px 20px rgba(122, 74, 52, .10);
  --shadow-lg: 0 14px 38px rgba(122, 74, 52, .18);
  --radius:    22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #201612;
    --bg-2:      #2A1D18;
    --card:      #2C1F1A;
    --card-2:    #35251F;
    --text:      #F7E9E0;
    --text-soft: #B79C8F;
    --line:      #442F27;
    --cream:     #2C1F1A;
    --shadow:    0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 14px 38px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* precisa vencer os `display` das classes abaixo */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 0%, rgba(255,107,138,.16), transparent 42%),
    radial-gradient(circle at 92% 8%, rgba(255,201,77,.20), transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.45;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-cake { font-size: 30px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.15)); }
.brand h1 { font-size: 20px; font-weight: 800; letter-spacing: -.4px; }
.brand p { font-size: 11.5px; color: var(--text-soft); }

.sync-pill {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--text-soft);
  border-radius: 999px; padding: 6px 11px;
  font-size: 11px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
}
.sync-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-soft); }
.sync-pill.ok    .dot { background: var(--mint); }
.sync-pill.local .dot { background: var(--butter); }
.sync-pill.err   .dot { background: var(--pink-dark); }

/* ---------- views ---------- */
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(155deg, var(--pink) 0%, #FF8F6B 55%, var(--butter) 130%);
  border-radius: 28px;
  padding: 24px 20px 22px;
  text-align: center;
  color: #fff;
  box-shadow: var(--shadow-lg);
  margin-bottom: 14px;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 82% 12%, rgba(255,255,255,.30), transparent 45%);
  pointer-events: none;
}
.hero.late { background: linear-gradient(155deg, #E8446A 0%, #C0295C 60%, #8B5CF6 130%); }

.hero-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.6px; opacity: .85; font-weight: 700; }
.hero-avatar {
  width: 74px; height: 74px; margin: 10px auto 8px;
  border-radius: 50%; background: rgba(255,255,255,.22);
  border: 2.5px solid rgba(255,255,255,.5);
  display: grid; place-items: center; font-size: 36px;
  backdrop-filter: blur(4px);
}
.hero-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.hero-name { font-size: 27px; font-weight: 800; letter-spacing: -.6px; line-height: 1.15; }
.hero-date { font-size: 14px; opacity: .92; margin-top: 4px; }
.hero-countdown {
  display: inline-block; margin-top: 12px;
  background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.32);
  border-radius: 999px; padding: 6px 14px;
  font-size: 13px; font-weight: 700;
}

.btn-primary {
  display: block; width: 100%; margin-top: 18px;
  background: #fff; color: var(--pink-dark);
  border: none; border-radius: 16px;
  padding: 15px; font-size: 16px; font-weight: 800; font-family: inherit;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.14);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary:active { transform: scale(.975); box-shadow: 0 2px 8px rgba(0,0,0,.14); }

/* ---------- stats ---------- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 16px; }
.stat {
  background: var(--card); border-radius: 16px; padding: 12px 8px;
  text-align: center; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.stat strong { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.stat span { font-size: 10.5px; color: var(--text-soft); line-height: 1.25; display: block; margin-top: 2px; }

/* ---------- blocos ---------- */
.block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.block-head h3 { font-size: 15.5px; font-weight: 800; letter-spacing: -.2px; }
.hint { font-size: 11px; color: var(--text-soft); }
.empty { font-size: 13.5px; color: var(--text-soft); text-align: center; padding: 18px 0; }

/* ---------- fila ---------- */
.queue { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.queue li {
  display: flex; align-items: center; gap: 11px;
  padding: 10px; border-radius: 15px; background: var(--card-2);
  border: 1px solid transparent;
}
.queue li.is-next { border-color: var(--pink); background: rgba(255,107,138,.10); }
.q-pos {
  width: 20px; text-align: center; font-size: 11px; font-weight: 800;
  color: var(--text-soft); flex-shrink: 0;
}
.q-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 19px;
  background: linear-gradient(140deg, var(--bg-2), var(--cream));
  border: 1px solid var(--line);
}
.q-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.q-avatar:has(img) { padding: 0; overflow: hidden; }
.q-info { flex: 1; min-width: 0; }
.q-name { display: block; font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.q-sub { display: block; font-size: 11.5px; color: var(--text-soft); }
.q-badge {
  display: inline-block; vertical-align: 2px; margin-left: 6px; white-space: nowrap;
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  background: var(--pink); color: #fff; padding: 2px 7px; border-radius: 999px;
}
.q-count {
  font-size: 11px; font-weight: 800; color: var(--text-soft);
  background: var(--bg-2); border-radius: 999px; padding: 4px 9px; flex-shrink: 0;
}

/* ---------- último bolo ---------- */
.last-cake { display: flex; align-items: center; gap: 12px; }
.last-cake .lc-emoji { font-size: 30px; flex-shrink: 0; }
.last-cake .lc-title { display: block; font-size: 14.5px; font-weight: 700; }
.last-cake .lc-sub { display: block; font-size: 12px; color: var(--text-soft); }

/* ---------- timeline ---------- */
.timeline { list-style: none; position: relative; padding-left: 26px; }
.timeline::before {
  content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--line); border-radius: 2px;
}
.timeline li { position: relative; padding: 0 0 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -22px; top: 7px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--pink); border: 2px solid var(--card);
}
.tl-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tl-name { font-size: 14.5px; font-weight: 700; }
.tl-date { font-size: 11.5px; color: var(--text-soft); white-space: nowrap; }
.tl-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; align-items: center; }
.tag {
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 9px;
  background: var(--bg-2); color: var(--text-soft);
}
.tag.reason { background: rgba(255,107,138,.14); color: var(--pink-dark); }
.tl-edit {
  background: none; border: none; font-family: inherit; font-size: 11.5px;
  color: var(--text-soft); text-decoration: underline; cursor: pointer; padding: 4px 0 0;
}

/* ---------- ranking ---------- */
.ranking { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.ranking li { display: flex; align-items: center; gap: 10px; }
.rk-name { font-size: 12.5px; font-weight: 700; width: 152px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-bar { display: block; flex: 1; height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.rk-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--pink), var(--butter)); transition: width .5s ease; }
.rk-val { display: block; font-size: 12px; font-weight: 800; color: var(--text-soft); width: 20px; flex-shrink: 0; text-align: right; }
.rk-name { display: block; }

/* ---------- pessoas ---------- */
.people { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.people li {
  display: flex; align-items: center; gap: 8px;
  background: var(--card-2); border-radius: 15px; padding: 8px;
}
.p-emoji {
  width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); font-size: 20px; text-align: center;
  font-family: inherit; cursor: pointer; overflow: hidden; padding: 0;
}
.p-emoji img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* avatar miniatura usado no histórico e no ranking */
.mini-avatar {
  display: inline-block; vertical-align: -4px;
  width: 20px; height: 20px; margin-right: 6px;
  border-radius: 50%; overflow: hidden;
  font-size: 15px; line-height: 20px; text-align: center;
}
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-name {
  flex: 1; min-width: 0; border: 1px solid transparent; background: transparent;
  font-family: inherit; font-size: 14.5px; font-weight: 700; color: var(--text);
  padding: 8px; border-radius: 10px;
}
.p-name:focus { outline: none; background: var(--card); border-color: var(--pink); }
.icon-btn {
  width: 30px; height: 34px; flex-shrink: 0; border: none; background: transparent;
  color: var(--text-soft); font-size: 15px; cursor: pointer; border-radius: 9px; font-family: inherit;
}
.icon-btn:active { background: var(--bg-2); }
.icon-btn:disabled { opacity: .25; }
.icon-btn.del { color: var(--pink-dark); }

/* ---------- form ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }
.field em { font-style: normal; font-weight: 500; opacity: .8; }
.field input, .field select {
  width: 100%; font-family: inherit; font-size: 16px; color: var(--text);
  background: var(--card-2); border: 1.5px solid var(--line);
  border-radius: 13px; padding: 12px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--pink); }

.mini-select {
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--text);
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 10px; max-width: 150px;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--card-2); border: 1.5px solid var(--line);
  border-radius: 999px; padding: 8px 13px; cursor: pointer;
}
.chip.active { background: var(--pink); border-color: var(--pink); color: #fff; }

.btn-ghost {
  font-family: inherit; font-size: 14px; font-weight: 700;
  color: var(--text-soft); background: var(--card-2);
  border: 1.5px solid var(--line); border-radius: 13px;
  padding: 12px 16px; cursor: pointer; width: 100%;
}
.btn-ghost.danger { color: var(--pink-dark); border-color: rgba(232,68,106,.35); background: rgba(232,68,106,.07); }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* ---------- bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(40, 20, 14, .5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
.sheet {
  width: 100%; max-width: 520px;
  background: var(--card); color: var(--text);
  border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow-y: auto;
  animation: slideUp .28s cubic-bezier(.2,.9,.3,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 4px auto 14px; }
.sheet h3 { font-size: 19px; font-weight: 800; margin-bottom: 16px; }
.sheet-actions { display: flex; gap: 9px; margin-top: 20px; }
.sheet-actions .btn-primary { margin-top: 0; background: var(--pink); color: #fff; }
.sheet-actions .btn-ghost { width: auto; flex-shrink: 0; }
.sheet-actions .btn-primary { flex: 1; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 160px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; font-family: inherit;
  font-size: 10.5px; font-weight: 700; color: var(--text-soft);
  padding: 6px 4px; border-radius: 13px; cursor: pointer;
}
.tab span { font-size: 19px; line-height: 1.1; filter: grayscale(1) opacity(.6); transition: filter .2s; }
.tab.active { color: var(--pink-dark); }
.tab.active span { filter: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 80;
  background: var(--choco); color: #fff;
  font-size: 13.5px; font-weight: 600;
  padding: 11px 18px; border-radius: 999px;
  box-shadow: var(--shadow-lg); animation: fade .2s ease;
  max-width: 88vw; text-align: center;
}

/* ---------- confete ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105dvh) rotate(720deg); opacity: .1; }
}

.footnote { font-size: 11px; color: var(--text-soft); text-align: center; padding: 4px 8px 12px; line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
