:root {
  --bg: #f6f5f2;
  --ink: #1b1a18;
  --muted: #8b8880;
  --faint: #b7b4ac;
  --line: rgba(27, 26, 24, 0.13);
  --line-strong: rgba(27, 26, 24, 0.28);
  --field: rgba(27, 26, 24, 0.03);
  --neg: #ab463d;
  --estudo: #4b7a63;
  --deveres: #a07c39;
  --lazer: #74659c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131211;
    --ink: #ecebe5;
    --muted: #837f78;
    --faint: #56534d;
    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.24);
    --field: rgba(255, 255, 255, 0.04);
    --neg: #d3867f;
    --estudo: #77a98d;
    --deveres: #c5a266;
    --lazer: #a493d0;
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  max-width: 440px;
  margin: 0 auto;
  padding: 0 22px calc(56px + env(safe-area-inset-bottom));
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Cabeçalho */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(26px + env(safe-area-inset-top)) 0 8px;
}
.wordmark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.sync {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.15s;
}
.sync:active {
  color: var(--ink);
}

/* Saldo */
.hero {
  text-align: center;
  padding: 44px 0 40px;
}
.hero-label {
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.hero-value {
  font-weight: 300;
  font-size: clamp(52px, 17vw, 82px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--ink);
}
.hero-value.neg {
  color: var(--neg);
}
.hero-hint {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin-top: 14px;
}

/* Ponto em andamento */
.active {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  padding: 15px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.active-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.active-text {
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.active .num {
  font-size: 15px;
  color: var(--muted);
}
.active-note {
  flex-basis: 100%;
  font-size: 12px;
  color: var(--muted);
}
.stop {
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}
.stop:active {
  background: var(--field);
}

/* Atividades */
.activities {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin: 28px 0 8px;
}
.activity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  border-right: 1px solid var(--line);
  padding: 22px 8px 20px;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.activity:last-child {
  border-right: none;
}
.activity:active {
  background: var(--field);
}
.activity[data-type="estudo"] { --ac: var(--estudo); }
.activity[data-type="deveres"] { --ac: var(--deveres); }
.activity[data-type="lazer"] { --ac: var(--lazer); }
.a-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ac);
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
}
.a-name {
  font-size: 15px;
  letter-spacing: 0.01em;
}
.a-rule {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.activity.on {
  background: var(--field);
}
.activity.on .a-dot {
  opacity: 1;
  transform: scale(1.35);
}
.activity.on .a-name {
  color: var(--ac);
}

/* Blocos */
.block {
  padding: 26px 0 4px;
  border-top: 1px solid var(--line);
  margin-top: 22px;
}
.block-label {
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

/* Ajuste manual */
.adjust {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 18px;
}
.uinput {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.uinput input {
  width: 56px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: inherit;
  font-size: 24px;
  font-weight: 300;
  text-align: center;
  padding: 4px 2px;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s;
}
.uinput input:focus {
  border-color: var(--ink);
}
.uinput label {
  font-size: 13px;
  color: var(--muted);
}
.note-input {
  flex: 1 1 130px;
  min-width: 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  padding: 8px 2px;
  outline: none;
  transition: border-color 0.15s;
}
.note-input::placeholder {
  color: var(--faint);
}
.note-input:focus {
  border-color: var(--ink);
}
.adjust-actions {
  flex-basis: 100%;
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.tbtn {
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.tbtn:active {
  background: var(--field);
}

/* Proporções */
.ratios-block {
  margin-top: 22px;
}
.ratios-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
}
.ratios-summary::-webkit-details-marker {
  display: none;
}
.ratios-summary::after {
  content: "+";
  font-size: 17px;
  color: var(--muted);
  font-weight: 400;
}
.ratios-block[open] .ratios-summary {
  margin-bottom: 22px;
}
.ratios-block[open] .ratios-summary::after {
  content: "−";
}
.ratios {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.ratio-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.ratio-row[data-type="estudo"] { --ac: var(--estudo); }
.ratio-row[data-type="deveres"] { --ac: var(--deveres); }
.ratio-row[data-type="lazer"] { --ac: var(--lazer); }
.r-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ac);
  flex: none;
}
.r-name {
  flex: 1;
  font-size: 15px;
}
.r-eq {
  font-size: 13px;
  color: var(--muted);
}
.r-sign {
  width: 10px;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}
.r-input {
  width: 62px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: inherit;
  font-size: 18px;
  font-weight: 300;
  text-align: center;
  padding: 4px 2px;
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}
.r-input:focus {
  border-color: var(--ink);
}
.r-unit {
  font-size: 13px;
  color: var(--muted);
  width: 12px;
}
.ratios-note {
  font-size: 12px;
  color: var(--muted);
  margin: 20px 0 0;
  line-height: 1.5;
}
.ratios-actions {
  margin-top: 16px;
}

/* Histórico */
.log {
  list-style: none;
  margin: 0;
  padding: 0;
}
.log li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.log li:first-child {
  border-top: none;
}
.l-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.l-main {
  flex: 1;
  min-width: 0;
}
.l-title {
  font-size: 14px;
  color: var(--ink);
}
.l-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.l-delta {
  font-size: 14px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.l-delta.neg {
  color: var(--neg);
}
.l-del {
  background: none;
  border: none;
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  flex: none;
  transition: color 0.15s;
}
.l-del:active {
  color: var(--neg);
}
.log-empty {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 8px;
  z-index: 50;
  max-width: 88vw;
  text-align: center;
}

.hidden {
  display: none !important;
}
