/* TwineKnot — tema escuro. Superfícies em camadas (fundo < cartão < campo), um único acento. */
:root {
  --bg: #0f1113;
  --surface: #181b1e;
  --raised: #21252a;
  --line: #2a2f35;
  --text: #eceef0;
  --muted: #98a1aa;
  --accent: #e58a6b;
  --accent-ink: #1a0f0a;
  --ok: #6cc08b;
  --danger: #e57878;
  --radius: 14px;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1.15;
}
h1 em {
  font-style: normal;
  color: var(--accent);
}
h2 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.2px;
}
h3 {
  font-size: 16px;
  font-weight: 500;
}
.muted {
  color: var(--muted);
  font-size: 14px;
}
.fine {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ---------- Estrutura ---------- */
.topbar {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 20px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.6px;
}
.brand-dot {
  color: var(--accent);
}
.connection {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--raised);
  font-size: 14px;
  font-weight: 650;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 20px calc(110px + env(safe-area-inset-bottom));
}
.page-head {
  margin: 10px 0 18px;
}
.page-head .muted {
  margin-top: 4px;
}
.block {
  margin-top: 26px;
}
.block-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ---------- Botões e campos ---------- */
.primary,
.secondary {
  border: 0;
  border-radius: 12px;
  min-height: 48px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 650;
}
.primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.secondary {
  background: var(--raised);
  border: 1px solid var(--line);
}
.wide {
  width: 100%;
}
.square {
  width: 48px;
  padding: 0;
  font-size: 20px;
  flex: 0 0 48px;
}
.link {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  padding: 10px 4px;
  min-height: 40px;
  text-decoration: none;
}
.link.danger,
.menu-item.danger {
  color: var(--danger);
}
.icon-button {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 26px;
  width: 40px;
  height: 40px;
  line-height: 1;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
}
input::placeholder {
  color: #6f7881;
}
textarea {
  resize: vertical;
}
.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  font-size: 14px;
  color: var(--text);
}
.check input {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent);
  flex: 0 0 20px;
}
.form-error {
  color: var(--danger);
  font-size: 14px;
}
.fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.grid-2:empty {
  display: none;
}
.grid-2 label {
  justify-content: space-between;
}

/* ---------- Login ---------- */
.login {
  padding-top: 12vh;
}
.login h1 {
  font-size: 40px;
  margin-bottom: 10px;
}
.login form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 28px 0 14px;
}

/* ---------- Cartões e painéis ---------- */
.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card {
  margin-top: 10px;
}
.card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.card-head h3 {
  font-weight: 650;
  flex: 1;
}
.card-head .link {
  padding: 0 2px;
  min-height: 0;
  font-size: 13px;
}
.card .status {
  margin: 4px 0 14px;
  font-size: 14px;
  color: var(--muted);
}
.card .status.ok {
  color: var(--ok);
}
.card .status.warn {
  color: var(--accent);
}
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 14px;
}
.week span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}
.dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
}
.dot.taken {
  background: var(--ok);
  border-color: var(--ok);
}
.dot.missed {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 25%, transparent);
}
.dot.pause {
  border-style: dashed;
  border-color: #4a525b;
}
.dot.pending {
  border-color: var(--accent);
}

/* ---------- Linhas (listas) ---------- */
.rows {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.rows:empty {
  display: none;
}
.row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 4px;
  min-height: 56px;
}
.row + .row {
  border-top: 1px solid var(--line);
}
.row-main {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  text-align: left;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row-main h3 {
  overflow-wrap: anywhere;
}
.row.is-done h3 {
  color: var(--muted);
  text-decoration: line-through;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 13px;
  color: var(--muted);
}
.meta:empty {
  display: none;
}
.meta .flag {
  color: var(--accent);
}
.row-notes {
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.toggle {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
}
.toggle::before {
  content: '';
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #4a525b;
}
.toggle[aria-pressed='true']::before {
  content: '✓';
  display: grid;
  place-items: center;
  background: var(--ok);
  border-color: var(--ok);
  color: #0c1a11;
  font-size: 13px;
  font-weight: 800;
}
.row-action {
  flex: 0 0 40px;
  width: 40px;
  height: 44px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 17px;
}
.row-action[aria-pressed='true'] {
  color: var(--accent);
}
.row-link {
  color: var(--accent);
  font-size: 13px;
}
.row.linked {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
progress {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--raised);
  margin-top: 6px;
}
progress::-webkit-progress-bar {
  background: var(--raised);
}
progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 6px;
}
progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 6px;
}
.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.nav-row {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  min-height: 56px;
}
.nav-row + .nav-row {
  border-top: 1px solid var(--line);
}
.nav-row .grow {
  flex: 1;
  min-width: 0;
}
.nav-row .grow span {
  display: block;
  font-size: 13px;
  color: var(--muted);
}
.nav-row .chev {
  color: var(--muted);
}
.pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
}

/* ---------- Espaço (Nosso / Meu) ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -20px;
  padding: 2px 20px 14px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar {
  display: none;
}
.chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font-size: 14px;
}
.chip[aria-current='page'] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 650;
}
.section-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.section-bar .link {
  margin-left: auto;
  padding: 0 2px;
  min-height: 32px;
}
.count {
  font-size: 13px;
  color: var(--muted);
}
.quick-add {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.quick-add input {
  flex: 1;
}
#add {
  margin-bottom: 12px;
}
.list-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.list-controls label {
  flex: 0 1 auto;
}
.list-controls .search {
  flex: 1;
}
.list-controls input,
.list-controls select {
  min-height: 40px;
  padding: 7px 11px;
  font-size: 14px;
  background: transparent;
}
.planner {
  margin-bottom: 12px;
  padding: 0 16px;
}
.planner summary {
  padding: 14px 0;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.planner form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
}
.suggestion {
  border-top: 1px solid var(--line);
  padding: 14px 0 16px;
}
.suggestion h3 {
  font-weight: 650;
  margin: 2px 0;
}
.suggestion .actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.suggestion .actions button {
  flex: 1;
  min-height: 42px;
  font-size: 14px;
}
#trackers-panel:not(:empty) {
  margin-bottom: 22px;
}

/* ---------- Barra inferior ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1;
  max-width: 160px;
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  font-size: 11px;
  font-weight: 600;
}
.tabbar svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar button[aria-current='page'] {
  color: var(--accent);
}

/* ---------- Aviso ---------- */
.notice {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 6;
  width: min(600px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #f1f2f3;
  color: #14171a;
  font-size: 14px;
  box-shadow: 0 8px 30px #0008;
  cursor: pointer;
}
.notice.error {
  background: #f3c4c4;
}
.notice-action {
  border: 0;
  background: none;
  color: #9a4426;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 2px;
}

/* ---------- Diálogos ---------- */
dialog {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop {
  background: #000a;
  backdrop-filter: blur(2px);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
#item-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
dialog .link.danger {
  align-self: center;
}
.optional summary {
  color: var(--muted);
  font-size: 14px;
  padding: 6px 0;
  cursor: pointer;
}
.optional .fields {
  margin-top: 12px;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}
legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0;
}
.menu-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
}
.menu-item {
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
  padding: 15px 2px;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.menu-list .menu-item:first-child {
  border-top: 0;
}
#menu .panel {
  background: var(--raised);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#install-guide p + p {
  margin-top: 10px;
}

/* ---------- Calendário ---------- */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 8px;
}
.calendar-nav strong::first-letter {
  text-transform: uppercase;
}
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar .weekday {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding-bottom: 4px;
}
.day {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px solid transparent;
  background: none;
  color: var(--text);
  font-size: 14px;
  display: grid;
  place-items: center;
  padding: 0;
}
.day:disabled {
  opacity: 1;
}
.day.before,
.day.future {
  color: #5d666f;
}
.day.taken {
  background: var(--ok);
  color: #0c1a11;
  font-weight: 700;
}
.day.missed {
  border-color: var(--danger);
  color: var(--danger);
}
.day.pause {
  border-style: dashed;
  border-color: #4a525b;
  color: var(--muted);
}
.day.pending {
  border-color: var(--accent);
  color: var(--accent);
}
.day.is-today {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 3.5px var(--text);
}
.legend {
  display: flex;
  gap: 16px;
  margin: 14px 0 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
#tracker-detail .secondary {
  margin-top: 14px;
}

/* ---------- v3: hábitos, compras, fotos ---------- */
/* Campos de data e hora no iPhone: sem isso eles estouram a largura do diálogo. */
input[type='date'],
input[type='time'],
input[type='datetime-local'] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  display: block;
}
input::-webkit-date-and-time-value {
  text-align: left;
}
dialog {
  overflow-x: hidden;
}
.grid-2.single {
  grid-template-columns: 1fr;
}
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.emoji-choices,
.weekday-choices {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.weekday-choices {
  grid-template-columns: repeat(7, 1fr);
}
.choice {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--raised);
  font-size: 20px;
  padding: 0;
}
.weekday-choices .choice {
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
}
.choice[aria-pressed='true'] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--raised));
  color: var(--text);
}

/* Barra com cinco abas */
.tabbar {
  gap: 0;
  padding-left: 4px;
  padding-right: 4px;
}
.tabbar button {
  max-width: 110px;
  font-size: 10.5px;
}

/* Fotos */
.face {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  background: var(--raised);
}
.face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar {
  padding: 0;
  overflow: hidden;
}
.face.large {
  width: 64px;
  height: 64px;
  font-size: 24px;
  border: 2px solid var(--line);
}
.face-button {
  border: 0;
  background: none;
  padding: 0;
  border-radius: 50%;
}
.crop-stage {
  margin: 14px auto;
  width: min(280px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--line);
  background: var(--raised);
}
#crop-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#avatar-editor .wide {
  margin-top: 12px;
}
input[type='range'] {
  padding: 0;
  min-height: 32px;
  border: 0;
  background: none;
  accent-color: var(--accent);
}

/* Placar */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  font-size: 13px;
  min-width: 0;
}
.score strong {
  font-size: 15px;
  margin-top: 6px;
}
.score .points {
  color: var(--accent);
  font-weight: 650;
}
.score + .score {
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

/* Linhas de hábito */
span.toggle,
.toggle.is-off {
  opacity: 0.45;
}
.row > .chev {
  color: var(--muted);
  padding: 0 10px 0 4px;
}
.meta .tag {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 8px;
  font-size: 12px;
}
.row-link {
  display: grid;
  place-items: center;
  text-decoration: none;
}
.chips.flush {
  margin: 0 0 12px;
  padding: 0;
}

/* Mapa de calor (um quadrado por dia; colunas são semanas) */
.heatmap-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
}
.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
}
.heat {
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 3px;
  background: var(--raised);
}
.heat.future {
  visibility: hidden;
}
.heat.none {
  background: var(--raised);
  opacity: 0.45;
}
.heat.l1 {
  background: color-mix(in srgb, var(--danger) 45%, var(--raised));
}
.heat.l2 {
  background: color-mix(in srgb, var(--ok) 30%, var(--raised));
}
.heat.l3 {
  background: color-mix(in srgb, var(--ok) 60%, var(--raised));
}
.heat.l4 {
  background: var(--ok);
}
.heat.is-today {
  outline: 1.5px solid var(--text);
  outline-offset: 1px;
}
.bars {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px;
}
.bar-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 10px 0;
  font-size: 14px;
}
.bar-line + .bar-line {
  border-top: 1px solid var(--line);
}
.bar-line progress {
  grid-column: 1 / -1;
  margin-top: 4px;
}
.bar-value {
  color: var(--muted);
}
.list-controls .link {
  padding: 0 4px;
}
#add {
  margin-bottom: 12px;
}

/* Hábito feito continua legível: é conquista, não item riscado. */
.row.habit.is-done h3 {
  text-decoration: none;
  color: var(--text);
}

/* ---------- v4: agenda, listas, links ---------- */
.tabbar button {
  font-size: 10px;
}
.segments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.segment {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.segment[aria-current='page'] {
  background: var(--raised);
  color: var(--text);
}
.calendar-panel .calendar-nav {
  margin-top: 0;
}
.agenda-day {
  position: relative;
}
.agenda-day.is-past {
  color: #5d666f;
}
.agenda-day.has-events::after {
  content: '';
  position: absolute;
  bottom: 14%;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--accent);
}
.agenda-day.is-selected {
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
}
.agenda-day.is-selected.has-events::after {
  background: var(--bg);
}
.day-heading {
  padding: 12px 16px 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.row + .day-heading {
  border-top: 1px solid var(--line);
}
.day-heading + .row {
  border-top: 0;
}
.event-time {
  flex: 0 0 58px;
  padding-left: 12px;
  font-size: 14px;
  font-weight: 650;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
#view-agenda > .primary {
  margin-bottom: 4px;
}
.hook-panel {
  background: var(--raised);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#hook-url,
#calendar-url {
  font-size: 12px;
  min-height: 40px;
  color: var(--muted);
}
#calendar-sync .fine {
  margin: 10px 0;
}
#calendar-url {
  margin-top: 12px;
}

/* "Fiz junto" */
.row-action.pair[aria-pressed='true'] {
  color: var(--accent);
}
.together-line {
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.day.together {
  box-shadow: inset 0 0 0 2.5px var(--accent);
}
/* Folga pedida. Fica diferente do dia de pausa da cartela, que ninguém escolheu. */
.day.skip {
  border-style: solid;
  border-color: #4a525b;
  background: repeating-linear-gradient(
    135deg,
    transparent,
    transparent 4px,
    #2b3137 4px,
    #2b3137 8px
  );
}
select:disabled {
  opacity: 0.45;
}

/* ---------- v5: disputa, quantidade, casa ---------- */
.amount {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--raised);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}
span.amount {
  color: var(--muted);
  background: none;
}
.card .actions {
  display: flex;
  gap: 8px;
}
.card .actions button {
  flex: 1;
}
.card .points {
  color: var(--accent);
  font-weight: 650;
  font-size: 14px;
}
.card .history {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.card .history + .history {
  margin-top: 4px;
  padding-top: 0;
  border-top: 0;
}
.goal {
  padding: 14px 16px;
}
.goal + .goal,
.goal + .nav-row {
  border-top: 1px solid var(--line);
}
.goal .link {
  font-size: 18px;
}
.medal-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.medal-line strong {
  flex: 0 0 52px;
  font-size: 14px;
}
.medal-line + .medal-line {
  margin-top: 10px;
}
.medal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--raised);
  font-size: 17px;
  padding: 0;
}
.medal.locked {
  filter: grayscale(1);
  opacity: 0.3;
}
.chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
}
.chart .line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart .mine {
  stroke: var(--accent);
  fill: var(--accent);
}
.chart .theirs {
  stroke: #6fa8dc;
  fill: #6fa8dc;
}
.chart .line.mine,
.chart .line.theirs {
  fill: none;
}
.swatch {
  display: inline-block;
  width: 12px;
  height: 4px;
  border-radius: 2px;
}
.swatch.mine {
  background: var(--accent);
}
.swatch.theirs {
  background: #6fa8dc;
}
.total {
  margin: -4px 0 12px;
  font-size: 14px;
  color: var(--accent);
  font-weight: 650;
}
#view-agenda .quick-add {
  margin-bottom: 8px;
}
#view-agenda > .secondary {
  margin-bottom: 4px;
}

.medal-line strong {
  flex: 0 0 100%;
  margin-bottom: 2px;
}

/* ---------- v6: ajustes de uso ---------- */
.segments.three {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
}
.repeat-mark {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
  opacity: 1;
}
.repeat-mark::before {
  content: none;
}
.row.event .event-time {
  flex: 0 0 auto;
  padding: 0 12px 0 6px;
  text-align: right;
}
.goal .icon-button {
  width: 40px;
  height: 40px;
  margin: -8px -8px 0 0;
  font-size: 22px;
}

/* ---------- v7: cor e movimento ---------- */
/* Curvas no espírito das do iOS: uma mola suave para entrar e um leve ressalto para confirmar. */
:root {
  --accent: #f0876a;
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ok: #5fd08f;
  --surface: #171a1e;
  --raised: #20242a;
}
body {
  background:
    radial-gradient(
        120% 55% at 50% -18%,
        color-mix(in srgb, var(--accent) 20%, transparent),
        transparent 70%
      )
      no-repeat fixed,
    var(--bg);
}
.brand-dot,
h1 em {
  color: var(--accent);
}
.page-head h1 {
  background: linear-gradient(
    100deg,
    var(--text) 40%,
    color-mix(in srgb, var(--accent) 75%, var(--text))
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card,
.panel,
.rows,
.bars,
.heatmap-wrap {
  background: linear-gradient(180deg, #1b1f24, #16191d);
  border-color: #2b3138;
  box-shadow:
    0 1px 0 #ffffff08 inset,
    0 10px 30px -18px #000c;
}
.block-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.block-title::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.primary {
  background: linear-gradient(
    135deg,
    var(--accent),
    color-mix(in srgb, var(--accent) 70%, #f2b04c)
  );
  box-shadow: 0 8px 22px -10px var(--accent);
}
button,
.chip,
.segment,
.nav-row,
.row-main {
  transition:
    transform 0.18s var(--spring),
    background-color 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease,
    opacity 0.2s ease;
}
button:active:not(:disabled) {
  transform: scale(0.96);
}
.nav-row:active,
.row-main:active {
  transform: scale(0.985);
  background-color: #ffffff08;
}
.chip[aria-current='page'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.segment[aria-current='page'] {
  background: color-mix(in srgb, var(--accent) 22%, var(--raised));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent) inset;
}
progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), #f2b04c);
}
progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent), #f2b04c);
}

/* Cada hábito com a sua cor. */
.habit.c0 {
  --hue: #f0876a;
}
.habit.c1 {
  --hue: #5fb4f0;
}
.habit.c2 {
  --hue: #5fd08f;
}
.habit.c3 {
  --hue: #f2b04c;
}
.habit.c4 {
  --hue: #a58cf5;
}
.habit.c5 {
  --hue: #f078a8;
}
.habit .toggle::before {
  border-color: color-mix(in srgb, var(--hue) 70%, transparent);
  transition:
    background-color 0.25s ease,
    border-color 0.25s ease,
    transform 0.4s var(--bounce);
}
.habit .toggle[aria-pressed='true']::before {
  background: var(--hue);
  border-color: var(--hue);
  box-shadow: 0 0 14px -2px var(--hue);
}
.habit {
  border-left: 3px solid transparent;
}
.habit.is-done {
  border-left-color: var(--hue);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--hue) 12%, transparent),
    transparent 60%
  );
}
.row.pop .toggle::before {
  animation: pop 0.55s var(--bounce);
}
@keyframes pop {
  0% {
    transform: scale(0.5);
  }
  60% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}
.toggle[aria-pressed='true']::before {
  transition: transform 0.4s var(--bounce);
}

/* Anel de progresso em volta da foto. */
.face-button.ring {
  padding: 4px;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), #2b3138 0);
  transition: background 0.6s var(--spring);
}
.face-button.ring .face.large {
  border-color: var(--bg);
}
.score .points {
  color: var(--accent);
}

/* Bolinhas de pendência na barra. */
.tabbar button {
  position: relative;
}
.tabbar button[data-badge]::after {
  content: attr(data-badge);
  position: absolute;
  top: 2px;
  left: calc(50% + 6px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
  animation: pop 0.5s var(--bounce);
}
.tabbar button[aria-current='page'] {
  color: var(--accent);
}
.tabbar button[aria-current='page'] svg {
  animation: pop 0.45s var(--bounce);
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 70%, transparent));
}

/* Telas e linhas entram com um deslize curto. */
section.enter {
  animation: rise 0.42s var(--spring) both;
}
section.enter .block,
section.enter .rows > *,
section.enter .card {
  animation: rise 0.5s var(--spring) both;
}
section.enter .block:nth-of-type(2) {
  animation-delay: 0.04s;
}
section.enter .block:nth-of-type(3) {
  animation-delay: 0.08s;
}
section.enter .block:nth-of-type(4) {
  animation-delay: 0.12s;
}
section.enter .rows > :nth-child(2) {
  animation-delay: 0.03s;
}
section.enter .rows > :nth-child(3) {
  animation-delay: 0.06s;
}
section.enter .rows > :nth-child(4) {
  animation-delay: 0.09s;
}
section.enter .rows > :nth-child(n + 5) {
  animation-delay: 0.12s;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
.notice:not([hidden]) {
  animation: toast 0.45s var(--spring) both;
}
@keyframes toast {
  from {
    opacity: 0;
    transform: translate(-50%, 16px) scale(0.96);
  }
}

/* Janelas sobem como folhas, no celular coladas embaixo. */
dialog[open] {
  animation: sheet 0.42s var(--spring) both;
}
dialog[open]::backdrop {
  animation: fade 0.3s ease both;
}
@keyframes sheet {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.98);
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@media (max-width: 560px) {
  dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    max-height: 92dvh;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  dialog::before {
    content: '';
    display: block;
    width: 38px;
    height: 5px;
    border-radius: 3px;
    background: #3a4149;
    margin: -8px auto 12px;
  }
  @keyframes sheet {
    from {
      transform: translateY(100%);
    }
  }
}

/* Medalhas conquistadas brilham; mapa de calor e gráfico ganham a cor do app. */
.medal:not(.locked) {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 14px -4px var(--accent);
}
.chart .mine {
  stroke: var(--accent);
  fill: var(--accent);
}
.event-time,
.total,
.card .points {
  color: var(--accent);
}
.pill {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
}
.amount {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

/* Comemoração de dia completo. */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: fall var(--d) cubic-bezier(0.2, 0.6, 0.4, 1) var(--w) both;
}
@keyframes fall {
  to {
    transform: translateY(105vh) rotate(var(--r));
    opacity: 0.2;
  }
}

/* Personalizar */
.swatch-row {
  display: flex;
  gap: 12px;
  margin: 2px 0 18px;
}
.swatch-pick {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  padding: 0;
}
.swatch-pick[aria-pressed='true'] {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg) inset;
}
#customize .fine {
  margin-top: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0 14px;
}
#calendar-sync h3 {
  font-weight: 650;
  margin-bottom: 4px;
}
#calendar-sync form {
  margin: 12px 0 8px;
}
.linked-event .repeat-mark {
  color: var(--accent);
}

/* ---------- v8: arrastar linhas, conquistas ---------- */
.row {
  touch-action: pan-y;
  position: relative;
}
.row.dragging {
  transition: none;
  z-index: 1;
}
.row:not(.dragging) {
  transition: transform 0.35s var(--spring);
}
.row[data-swipe='done'] {
  box-shadow: -200px 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent);
}
.row[data-swipe='open'] {
  box-shadow: 200px 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
}
.goal .wide {
  margin-top: 12px;
  min-height: 44px;
}
#goal-hint {
  margin-top: -8px;
}

/* ---------- v9: janelas ---------- */
/* Com uma janela aberta, o fundo não rola; a rolagem fica só dentro dela. */
html:has(dialog[open]),
html:has(dialog[open]) body {
  overflow: hidden;
  overscroll-behavior: none;
}
dialog {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
dialog::backdrop {
  touch-action: none;
}

/* ---------- v10: gaveta ---------- */
/* A parte de cima da janela é a alça: dá para puxar para baixo e fechar. */
@media (max-width: 560px) {
  dialog::before {
    width: 44px;
    margin: -10px auto 14px;
    background: #4a525b;
  }
  .dialog-head {
    touch-action: none;
  }
}

/* Link do convite: endereço comprido não pode estourar a tela do celular. */
.invite-link {
  margin: 0.75rem 0;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
  user-select: all;
}

/* Termômetro do relacionamento: a escala do dia e o rastro das últimas duas semanas. */
.mood-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.mood-row .chip {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 6px;
  font-size: 13px;
  text-align: center;
}
.mood-trail {
  display: flex;
  gap: 3px;
  margin-top: 12px;
}
.mood-trail i {
  flex: 1 1 0;
  height: 16px;
  border-radius: 3px;
  background: var(--line);
}
.mood-trail i[data-level='1'] {
  background: var(--danger);
}
.mood-trail i[data-level='2'] {
  background: var(--danger);
  opacity: 0.5;
}
.mood-trail i[data-level='3'] {
  background: var(--muted);
}
.mood-trail i[data-level='4'] {
  background: var(--ok);
  opacity: 0.6;
}
.mood-trail i[data-level='5'] {
  background: var(--ok);
}

/* Carta do baralho: é o texto que puxa a conversa, então tem de ter peso na tela. */
.deck-card {
  margin: 0.9rem 0 0.5rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.05);
  border-left: 3px solid var(--accent, var(--ok));
  font-size: 1.05rem;
  line-height: 1.45;
}

/* Divisão de tarefas: duas faixas lado a lado, proporcionais. Nenhuma das duas é vermelha —
   a barra mostra tendência do casal, não quem está perdendo. */
.chore-bar {
  display: flex;
  height: 10px;
  margin-top: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--line);
}
.chore-bar i[data-who='me'] {
  background: var(--accent, var(--ok));
}
.chore-bar i[data-who='them'] {
  background: var(--muted);
}

/* Retrospectiva: número grande, frase pequena. Uma linha por fato. */
.retro-line {
  margin: 10px 0;
  line-height: 1.5;
}
.retro-line strong {
  font-size: 26px;
  color: var(--accent);
  margin-right: 6px;
}

/* Imprimir a retrospectiva. O navegador gera o PDF; não há biblioteca nenhuma no caminho.
   Some tudo que é de navegar e de tocar, porque no papel não serve para nada. */
@media print {
  #tabbar,
  #menu-button,
  .no-print,
  .chips,
  .page-head .link,
  dialog,
  #toast {
    display: none !important;
  }
  body,
  .card,
  .retro {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
  }
  .card {
    border: none !important;
    padding: 0 !important;
  }
  .retro-line {
    break-inside: avoid;
    font-size: 15pt;
    line-height: 1.7;
  }
  .retro-line strong {
    font-size: 22pt;
  }
  .page-head h1 {
    font-size: 26pt;
  }
  a[href]::after {
    content: '';
  }
}

/* "O resto da semana": o que não é de todo dia fica recolhido no fim da tela de Hoje. */
.weekly {
  margin-top: 8px;
}
.weekly > summary {
  cursor: pointer;
  padding: 14px 4px;
  color: var(--muted);
  font-size: 14px;
}
.weekly[open] > summary {
  color: var(--text);
}

/* ---------- Página de entrada ---------- */
/* Quem chega de anúncio cai aqui, não no formulário de login. Rola de cima a baixo num
   telefone: título, o que é, preço, três fotos do app de verdade, e o que ele faz. */
.landing {
  padding: 6vh 0 48px;
}
.landing h1 {
  font-size: 40px;
  line-height: 1.05;
  margin-bottom: 14px;
}
.landing .lede {
  font-size: 17px;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 24px;
}
.landing h2 {
  font-size: 22px;
  margin: 36px 0 10px;
}
.landing .fine.center {
  text-align: center;
  margin-top: 10px;
}
.landing .plain {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}
.landing .plain li {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  line-height: 1.5;
}
.landing .plain li strong {
  display: block;
}
/* As fotos rolam de lado: três telas de 375px não cabem lado a lado num telefone, e
   encolhê-las até caber tornaria ilegível justamente o que elas deveriam provar. */
.shots {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin: 28px -20px 0;
  padding: 0 20px 8px;
  scrollbar-width: none;
}
.shots::-webkit-scrollbar {
  display: none;
}
.shots figure {
  flex: 0 0 auto;
  width: 220px;
  margin: 0;
  scroll-snap-align: center;
}
.shots img {
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  display: block;
  background: var(--surface);
}
.shots figcaption {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.4;
}
.landing-end {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.landing-end .primary {
  margin-bottom: 8px;
}
@media (min-width: 720px) {
  .landing h1 {
    font-size: 56px;
  }
  .landing .lede {
    font-size: 19px;
    max-width: 34em;
  }
}

/* ---------- O contador do topo ---------- */
/* É o ponto focal da tela de hoje: uma coisa grande, antes da pilha de cartões. */
.card.hero {
  text-align: center;
  padding: 22px 16px;
  cursor: pointer;
  margin-bottom: 4px;
}
.hero-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.hero-number {
  display: block;
  font-size: 26px;
  line-height: 1.2;
  color: var(--accent);
}
.hero-names {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 0;
}

/* O código de recuperação: grande, monoespaçado e selecionável, porque é para copiar. */
.recovery-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 26px;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 16px 8px;
  margin: 12px 0;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  user-select: all;
}
