/* ========== Temas ========== */
:root,
[data-theme="light"] {
  --bg: #f6f4fb;
  --surface: #ffffff;
  --surface-2: #efecf7;
  --text: #1d1a2b;
  --muted: #6e6a80;
  --border: #e4e0ef;
  --primary: #7c5cff;
  --primary-soft: #ece7ff;
  --on-primary: #ffffff;
  --shadow: 0 4px 18px rgba(40, 20, 90, 0.08);
  --danger: #e5484d;

  --cat-trabalho: #3b82f6;
  --cat-casa: #f59e0b;
  --cat-pessoal: #10b981;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f0e17;
  --surface: #1a1825;
  --surface-2: #252233;
  --text: #f2f0fa;
  --muted: #9a96ad;
  --border: #2e2a3f;
  --primary: #9b82ff;
  --primary-soft: #2a2347;
  --on-primary: #ffffff;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  --danger: #ff6b6f;

  --cat-trabalho: #60a5fa;
  --cat-casa: #fbbf24;
  --cat-pessoal: #34d399;
  color-scheme: dark;
}

/* ========== Base ========== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background .25s, color .25s;
}

body {
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }

/* ========== Topo ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 10px;
}
.greeting { margin: 0; color: var(--muted); font-size: .9rem; }
.topbar h1 { font-size: 1.7rem; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.streak {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .9rem;
}

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.1rem;
  display: grid; place-items: center;
}
.icon-btn.small { width: 34px; height: 34px; font-size: 1.3rem; }

main { padding: 0 16px; }
.screen { display: none; }
.screen.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ========== Hoje ========== */
.day-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.day-label {
  background: none; border: none; font-weight: 600; font-size: 1rem;
  padding: 6px 12px; border-radius: 10px;
}

.progress-card {
  background: linear-gradient(135deg, var(--primary), #c56cff);
  color: #fff;
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.progress-text { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 10px; }
.progress-text strong { font-size: 1.2rem; }
.progress-text span { opacity: .9; font-size: .9rem; text-align: right; }
.progress-bar { height: 10px; background: rgba(255,255,255,.3); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: #fff; border-radius: 999px; transition: width .4s ease; }

.period { margin-bottom: 18px; }
.period h3 {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 4px 8px;
}

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--cat, var(--primary));
  border-radius: 14px;
  padding: 12px 12px 12px 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  transition: opacity .2s, transform .1s;
}
.item:active { transform: scale(.99); }
.item.done { opacity: .55; }
.item.done .item-title { text-decoration: line-through; }

.check {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--cat, var(--primary));
  background: transparent;
  display: grid; place-items: center;
  color: #fff; font-size: .9rem;
  transition: background .2s, transform .2s;
}
.item.done .check { background: var(--cat, var(--primary)); animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }

.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 500; word-break: break-word; }
.item-meta { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.item-del {
  background: none; border: none; color: var(--muted);
  font-size: 1.1rem; padding: 4px 6px; border-radius: 8px;
}

/* Urgente: tarefas que ficaram pra trás */
.period.urgent {
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 18px;
  padding: 12px 10px 4px;
}
.period.urgent h3 { color: var(--danger); font-weight: 800; }
.item.is-urgent { --cat: var(--danger); }
.item.is-urgent:not(.done) { animation: nudge 2.5s ease-in-out 1; }
.late { color: var(--danger); font-weight: 600; }
@keyframes nudge {
  0%, 100% { transform: none; }
  10%, 30% { transform: translateX(-3px); }
  20%, 40% { transform: translateX(3px); }
  50% { transform: none; }
}

.empty {
  text-align: center; color: var(--muted);
  padding: 40px 20px;
}
.empty .big { font-size: 2.5rem; display: block; margin-bottom: 8px; }

/* Categorias */
.cat-trabalho { --cat: var(--cat-trabalho); }
.cat-casa     { --cat: var(--cat-casa); }
.cat-pessoal  { --cat: var(--cat-pessoal); }

/* ========== Metas de vídeo ========== */
.goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.goal-card.complete { border-color: var(--pc); }
.goal-head { display: flex; align-items: center; gap: 10px; }
.goal-badge {
  flex: none; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.3rem;
  background: color-mix(in srgb, var(--pc) 18%, transparent);
}
.goal-info { flex: 1; min-width: 0; }
.goal-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-num { font-size: .9rem; color: var(--muted); }
.goal-num b { font-size: 1.25rem; color: var(--text); }
.goal-bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 12px 0; }
.goal-bar div { height: 100%; background: var(--pc); border-radius: 999px; transition: width .3s ease; }
.vchecks { display: flex; flex-wrap: wrap; gap: 7px; }
.vcheck {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--pc) 55%, var(--border));
  background: transparent; color: var(--muted);
  font-size: .78rem; font-weight: 600;
  display: grid; place-items: center;
  transition: background .2s, transform .15s;
}
.vcheck:active { transform: scale(.88); }
.vcheck.on { background: var(--pc); border-color: var(--pc); color: #fff; font-size: 1rem; animation: pop .3s ease; }
.vcheck.extra.on { border-style: dashed; }
.vcheck.plus { border-style: dashed; font-size: 1.2rem; }
.goal-pace { margin-top: 10px; font-size: .85rem; color: var(--muted); }
.goal-pace b { color: var(--text); }

/* ========== Ajustes ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 12px; font-size: 1rem; }

.segmented {
  display: flex; background: var(--surface-2);
  border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 8px;
}
.segmented button {
  flex: 1; border: none; background: transparent;
  padding: 10px 4px; border-radius: 9px; font-size: .88rem;
}
.segmented button.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

/* Grupos por rede social */
.platform-group { margin-bottom: 18px; }
.platform-title {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--pc); margin: 0 4px 8px; font-weight: 800;
}
.platform-count { color: var(--muted); font-weight: 600; letter-spacing: 0; }

/* Data de hoje embaixo do mês */
.day-label small { display: block; font-weight: 500; font-size: .78rem; color: var(--muted); margin-top: 1px; }

/* Dias de postar no cartão do perfil */
.post-days { display: flex; gap: 4px; margin-top: 10px; }
.post-days span {
  flex: 1; text-align: center; font-size: .7rem; padding: 4px 0;
  border-radius: 7px; background: var(--surface-2); color: var(--muted);
}
.post-days span.on { background: color-mix(in srgb, var(--pc) 20%, transparent); color: var(--text); font-weight: 700; }
.post-days span.today { outline: 2px solid var(--pc); outline-offset: -2px; }
.post-days span b { display: block; font-size: .85rem; margin-top: 1px; }
.post-days span.past { opacity: .55; }
.today-post {
  margin-top: 10px; padding: 8px 12px; border-radius: 10px;
  background: var(--pc); color: #fff; font-weight: 700; font-size: .85rem;
}

/* Tirar perfil */
.remove-who { margin: -4px 0 16px; font-size: 1rem; }
.btn.choice { text-align: left; padding: 14px 16px; }
.btn.choice small { display: block; font-weight: 400; font-size: .8rem; opacity: .85; margin-top: 3px; }
.goal-head .item-del { padding: 4px; }

/* Backup */
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.backup-last { font-size: .82rem; color: var(--muted); text-align: center; margin: 12px 0 4px; }
.backup-last.warn { color: var(--cat-casa); font-weight: 600; }
.howto { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.howto summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--primary); padding: 4px 0; }

/* Tutorial de instalação */
.steps { list-style: none; padding: 0; margin: 14px 0 0; }
.steps li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: .92rem; line-height: 1.45;
}
.steps li:last-child { border-bottom: none; }
.step-n {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.key {
  display: inline-block; padding: 0 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.tip { margin: 10px 0 0; }
.installed-msg {
  background: color-mix(in srgb, var(--cat-pessoal) 18%, transparent);
  color: var(--text); border-radius: 12px; padding: 10px 12px;
  font-weight: 600; font-size: .9rem; margin-bottom: 12px;
}
#install-now { margin-bottom: 12px; }
[hidden] { display: none !important; }

.btn {
  border: none; border-radius: 12px; padding: 12px 16px;
  font-weight: 600; width: 100%;
  background: var(--primary); color: var(--on-primary);
}
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

/* ========== Barra de abas ========== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tab {
  flex: 1; background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; color: var(--muted);
  padding: 6px 0; border-radius: 12px;
}
.tab span { font-size: 1.25rem; filter: grayscale(1); opacity: .6; transition: .2s; }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active span { filter: none; opacity: 1; }

.fab {
  position: fixed;
  right: max(18px, calc(50% - 280px + 18px));
  bottom: calc(80px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 18px;
  border: none;
  background: var(--primary); color: #fff;
  font-size: 2rem; line-height: 1;
  box-shadow: 0 8px 24px rgba(124, 92, 255, .45);
  z-index: 11;
  transition: transform .15s;
}
.fab:active { transform: scale(.92); }
.fab.hidden { display: none; }

/* ========== Folha (modal de baixo) ========== */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%; max-width: 560px;
  max-height: 88dvh; overflow-y: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  transition: transform .25s ease;
  z-index: 21;
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-handle { width: 40px; height: 5px; border-radius: 9px; background: var(--border); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet h2 { font-size: 1.25rem; margin: 0; }
.sheet-close {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: none; background: var(--surface-2); color: var(--text);
  font-size: 1.05rem; font-weight: 700;
  display: grid; place-items: center;
  transition: transform .15s, background .15s;
}
.sheet-close:active { transform: scale(.9); background: var(--border); }

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input[type="text"], .field input[type="date"], .field input[type="number"], .field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 1rem;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .9rem;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.round { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }

.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet-actions .btn.secondary { background: var(--surface-2); color: var(--text); }

/* ========== Toast ========== */
.toast {
  position: fixed; left: 50%; top: calc(20px + env(safe-area-inset-top));
  /* Escondido: sobe bem pra fora da tela e fica invisível */
  transform: translate(-50%, calc(-100% - 60px));
  opacity: 0; visibility: hidden; pointer-events: none;
  background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: 14px;
  font-weight: 600; box-shadow: var(--shadow);
  transition: transform .3s ease, opacity .3s ease, visibility 0s linear .3s;
  z-index: 30;
  max-width: 90%; text-align: center;
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1; visibility: visible;
  transition: transform .3s ease, opacity .3s ease, visibility 0s;
}
