:root {
  --bg: #F7F7F3;
  --surface: #FFFFFF;
  --surface-2: #F0F1EC;
  --ink: #181B1E;
  --muted: #71767D;
  --line: #E7E6E0;
  --accent: #4E96BE;
  --accent-2: #86BCD8;
  --accent-soft: #E9F3F9;
  --danger: #BE5B51;
  --danger-soft: #FBEDEB;
  --warn: #A9824B;
  --warn-soft: #FAF3E7;
  --ok: #5C8A6E;
  --ok-soft: #EAF3EE;
  --shadow: 0 10px 30px rgba(24, 27, 30, .06);
  --radius: 18px;
  --tap: rgba(24, 27, 30, .045);
}

[data-theme="dark"] {
  --bg: #101215;
  --surface: #171A1E;
  --surface-2: #1F2328;
  --ink: #ECEEEA;
  --muted: #98A0A7;
  --line: #262B31;
  --accent: #7FB7D4;
  --accent-2: #5E9FC4;
  --accent-soft: #1B2A33;
  --danger: #D97A70;
  --danger-soft: #33201E;
  --warn: #D2A86B;
  --warn-soft: #2E2618;
  --ok: #7FB894;
  --ok-soft: #1C2A23;
  --shadow: 0 12px 32px rgba(0, 0, 0, .4);
  --tap: rgba(236, 238, 234, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', 'SF Pro Text', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }
h1, h2, h3 { line-height: 1.25; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- topo ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 12px 14px 8px;
  background: linear-gradient(var(--bg) 76%, transparent);
}
.brand {
  text-align: center;
  font-weight: 300;
  font-size: 14px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--ink);
}
.brand span { font-weight: 600; color: var(--accent); }
#home-btn { justify-self: start; }
#theme-btn { justify-self: end; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .18s, transform .15s;
}
.icon-btn:hover { background: var(--tap); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.subtle { color: var(--muted); width: 34px; height: 34px; }

/* ---------- estrutura ---------- */
.view {
  flex: 1;
  padding: 4px 18px 132px;
  animation: fadeUp .3s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hero { margin: 10px 0 20px; }
.hero-art {
  position: relative;
  margin: 2px 0 18px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 2.2;
  background: var(--surface-2);
}
.hero-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 45%;
}
.hero-art::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 30%;
  background: linear-gradient(to bottom, transparent, var(--bg));
  opacity: .5;
  pointer-events: none;
}
[data-theme="dark"] .hero-art img { filter: brightness(.82); }
.hero .eyebrow {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.hero h1 {
  font-size: 25px;
  font-weight: 300;
  margin: 8px 0 2px;
  letter-spacing: -.01em;
}
.hero .date { color: var(--muted); font-size: 13.5px; text-transform: capitalize; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card.pad-sm { padding: 6px 16px; }

.stat-card { padding: 14px 16px; }
.stat-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-value { font-size: 19px; font-weight: 500; letter-spacing: -.01em; }
.stat-card.primary { background: #1B1F23; border-color: #1B1F23; color: #F4F5F2; }
.stat-card.primary .stat-label { color: rgba(244, 245, 242, .55); }
[data-theme="dark"] .stat-card.primary {
  background: linear-gradient(140deg, #22333F, #1A2932);
  border-color: #2B3C48;
}
.home-card { cursor: pointer; transition: transform .16s; }
.home-card:active { transform: scale(.98); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 10px;
}
.section-head h2 {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

/* ---------- linhas e listas ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row-title {
  font-size: 14.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.row strong { font-weight: 500; font-size: 14px; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.is-done .row-title { text-decoration: line-through; color: var(--muted); }

.circle-check {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  color: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .15s;
}
.circle-check svg { width: 14px; height: 14px; }
.circle-check.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.circle-check:disabled { opacity: .35; cursor: default; }
.circle-check:active { transform: scale(.9); }

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
button.chip { border: none; cursor: pointer; }

/* ---------- segmentado / navegação de mês ---------- */
.seg {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 14px;
  margin: 12px 0 4px;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: .18s;
}
.seg button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .07);
}

.navline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 6px;
}
.navline .nav-label { font-size: 14.5px; font-weight: 500; text-transform: capitalize; }
.navline .icon-btn { color: var(--muted); }

/* ---------- botões / elementos ---------- */
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform .15s, background .18s;
}
.btn:active { transform: scale(.975); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn.small { padding: 8px 12px; font-size: 12.5px; border-radius: 11px; }
.btn.small svg { width: 15px; height: 15px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; }

.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 10px;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .35s ease;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  margin: 10px 0;
  font-weight: 500;
  line-height: 1.4;
}
.alert svg { flex: 0 0 auto; margin-top: 1px; width: 17px; height: 17px; }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.accent { background: var(--accent-soft); color: var(--accent); }

.catrow {
  display: grid;
  grid-template-columns: 104px 1fr 88px;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  font-size: 12.5px;
}
.catrow .name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catrow .track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.catrow .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.catrow strong { text-align: right; font-weight: 500; font-size: 12.5px; }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 22px 10px;
  line-height: 1.55;
}

.tip {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.tip:last-child { border-bottom: none; }
.tip strong { display: block; color: var(--ink); font-weight: 500; font-size: 13.5px; margin-bottom: 2px; }

.prio { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.prio.danger { background: var(--danger); }
.prio.warn { background: var(--warn); }
.prio.baixa { background: var(--muted); }
.streak { color: var(--warn); font-weight: 500; }

.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 500;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.link-row svg { width: 15px; height: 15px; }

/* ---------- formulários / sheet ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(14, 16, 19, .42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .2s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  animation: slideUp .28s cubic-bezier(.3, .7, .2, 1) both;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: .4; }
  to { transform: none; opacity: 1; }
}
.sheet h3 { margin: 2px 0 16px; font-size: 17px; font-weight: 500; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
  appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { min-height: 88px; resize: vertical; }
.fields2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 13px; }
.fields2 .field { margin-bottom: 0; }

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--ink);
  margin: 2px 0 14px;
  cursor: pointer;
}
.checkline input { width: 18px; height: 18px; accent-color: var(--accent); }

.days-picker { display: flex; gap: 6px; }
.day-opt { flex: 1; position: relative; }
.day-opt input { position: absolute; opacity: 0; pointer-events: none; }
.day-opt span {
  display: grid;
  place-items: center;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: .18s;
}
.day-opt input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.limit-input {
  width: 96px;
  text-align: right;
  font: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
}
.limit-input:focus { border-color: var(--accent); }

/* ---------- tarefas: calendário ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 6px; }
.cal .dow {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 6px 0;
  letter-spacing: .05em;
}
.cal button {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  border-radius: 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s;
}
.cal button:hover { background: var(--tap); }
.cal button.today { border: 1.5px solid var(--accent); font-weight: 600; color: var(--accent); }
.cal .cal-empty { visibility: hidden; }
.cal .dots { display: flex; gap: 2px; height: 5px; }
.cal .dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: .9; }
.cal .dots i.done { opacity: .3; }

.day-block { padding: 12px 0; border-bottom: 1px solid var(--line); }
.day-block:last-child { border-bottom: none; }
.day-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; cursor: pointer; }
.day-head .dn {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.day-head .dd { font-size: 13px; font-weight: 500; }
.day-head.today .dd { color: var(--accent); }
.day-head .cnt { margin-left: auto; }
.mini-empty { font-size: 12px; color: var(--muted); padding: 8px 0; }

/* ---------- ideias ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  margin: 12px 0 14px;
  color: var(--muted);
}
.search input {
  border: none;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  flex: 1;
  padding: 0;
}
.search svg { width: 17px; height: 17px; }

.idea-card { padding: 15px 16px; margin-bottom: 12px; }
.idea-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.idea-top .chip { flex: 0 0 auto; }
.fav {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  display: grid;
  place-items: center;
  transition: transform .15s;
}
.fav svg { width: 18px; height: 18px; }
.fav.active { color: var(--accent); }
.fav.active svg { fill: currentColor; }
.fav:active { transform: scale(.88); }
.idea-title { font-size: 15px; font-weight: 500; margin: 0 0 3px; }
.idea-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}
.idea-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.idea-foot .small { color: var(--muted); font-size: 11.5px; margin-right: auto; }

/* ---------- barra inferior ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  padding: 9px 8px calc(9px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  padding: 4px 0 0;
  transition: color .18s;
}
.tab .tab-ic { display: grid; place-items: center; transition: transform .15s; }
.tab .tab-ic svg { width: 23px; height: 23px; }
.tab .tab-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  margin-top: 1px;
  transition: background .18s;
}
.tab.active { color: var(--accent); }
.tab.active .tab-dot { background: var(--accent); }
.tab:active .tab-ic { transform: scale(.9); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%) translateY(8px);
  z-index: 80;
  background: #1B1F23;
  color: #F4F5F2;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  max-width: calc(100vw - 48px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

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