@font-face {
  font-family: 'Atkinson Next';
  src: url('fonts/atkinson-next.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}

/* Gazur, anão guerreiro: aço da armadura como base, ouro para as
   essenciais (incrustação dos martelos), ciano para o que foi concluído
   (runas acesas) e castanho-avermelhado da barba nos pontos. */
:root {
  --paper: #e5e8eb;
  --paper-2: #f2f4f5;
  --rule: #c9d0d6;
  --ink: #1c2731;
  --ink-soft: #4f5d69;
  --ink-faint: #85929d;
  --hl: #f0bf4c;
  --hl-ink: #1c2731;
  --gold: #a87814;
  --cyan: #0b8396;
  --on-cyan: #ffffff;
  --auburn: #9a3f1f;
  --danger: #a12a2a;
  --strike: rgba(28, 39, 49, .55);
  --row: 3.25rem;
  --shadow: 0 -1px 0 var(--rule), 0 -12px 24px -18px rgba(28, 39, 49, .35);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #13181d;
    --paper-2: #1b2229;
    --rule: #29323a;
    --ink: #e3e8ec;
    --ink-soft: #9aa6b0;
    --ink-faint: #66727c;
    --hl: rgba(232, 176, 56, .30);
    --hl-ink: #ffe3a3;
    --gold: #e8b038;
    --cyan: #3fd0e0;
    --on-cyan: #0c1a1f;
    --auburn: #e07a4f;
    --danger: #ff8a7a;
    --strike: rgba(227, 232, 236, .55);
    --shadow: 0 -1px 0 var(--rule), 0 -12px 24px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #13181d; --paper-2: #1b2229; --rule: #29323a; --ink: #e3e8ec; --ink-soft: #9aa6b0;
  --ink-faint: #66727c; --hl: rgba(232, 176, 56, .30); --hl-ink: #ffe3a3; --gold: #e8b038;
  --cyan: #3fd0e0; --on-cyan: #0c1a1f; --auburn: #e07a4f; --danger: #ff8a7a; --strike: rgba(227, 232, 236, .55);
  --shadow: 0 -1px 0 var(--rule), 0 -12px 24px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.4 'Atkinson Next', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  max-width: 36rem;
  margin-inline: auto;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink);
  touch-action: manipulation;
}
.icon-btn:active { background: var(--rule); }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: .25rem;
  padding: max(.5rem, env(safe-area-inset-top)) .5rem .25rem;
  background: var(--paper);
}
.nav { display: flex; align-items: center; min-width: 0; }
.tools { display: flex; }
.today-btn {
  margin-left: auto;
  min-height: 2.25rem; padding: 0 .875rem;
  border: 2px solid var(--ink); border-radius: 2rem;
  background: var(--hl); color: var(--hl-ink);
  font-weight: 800; font-size: .9375rem;
  touch-action: manipulation;
}

h1 {
  margin: 0; min-width: 0;
  display: flex; flex-direction: column;
  line-height: 1.05;
  text-align: center;
}
#day-name { font-size: 1.75rem; font-weight: 800; letter-spacing: -.01em; }
#day-date { font-size: .875rem; font-weight: 500; color: var(--ink-soft); }

.badge {
  position: absolute; top: .3rem; right: .2rem;
  min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem;
  border-radius: .55rem;
  background: var(--ink); color: var(--paper);
  font-size: .6875rem; font-weight: 700; line-height: 1.1rem; text-align: center;
}

.score {
  display: flex; align-items: center; flex-wrap: wrap; gap: .25rem 1rem;
  min-height: 2.5rem;
  margin: 0; padding: 0 1rem .5rem;
  color: var(--ink-soft); font-size: .875rem;
}
.score b { color: var(--auburn); font-weight: 800; font-variant-numeric: tabular-nums; }

.plan-banner {
  display: flex; align-items: flex-start; gap: .75rem;
  margin: 0 1rem .75rem; padding: .75rem .875rem;
  background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: .5rem;
}
.plan-banner p { margin: 0; flex: 1; font-size: .9375rem; }

/* ---------- lista ---------- */
main {
  padding-top: .25rem;
  /* ocupa a tela toda para o arraste funcionar mesmo em dia vazio */
  min-height: calc(100dvh - 6rem);
  padding: 0 0 calc(8.5rem + env(safe-area-inset-bottom));
  touch-action: pan-y;
  transition: transform .18s ease-out;
}
main.slide-l { animation: in-l .22s ease-out; }
main.slide-r { animation: in-r .22s ease-out; }
@keyframes in-l { from { transform: translateX(2.5rem); opacity: .3; } }
@keyframes in-r { from { transform: translateX(-2.5rem); opacity: .3; } }

h2 { margin: 0; font-size: 1rem; font-weight: 700; }
h3 { margin: 1.25rem 0 .25rem; font-size: 1rem; font-weight: 700; }


.tasks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }

.task {
  display: flex; align-items: center;
  min-height: var(--row);
  border-bottom: 1px solid var(--rule);
  padding-left: .25rem;
}
.task.step { padding-left: 2rem; }
.task.step .text { font-size: 1rem; }

.check {
  flex: none;
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;
  border: 0; background: transparent; padding: 0;
  touch-action: manipulation;
}
.check svg {
  width: 1.375rem; height: 1.375rem;
  border: 2px solid var(--ink); border-radius: .3rem;
  stroke-width: 2.6; stroke: transparent;
  transition: background-color .15s, stroke .15s;
}
.task.ess .check svg { border-radius: 50%; }
.task.done .check svg { background: var(--cyan); border-color: var(--cyan); stroke: var(--on-cyan); }

.body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  padding: .55rem .25rem .55rem .25rem;
  border: 0; background: transparent; text-align: left;
}

/* risco de caneta que atravessa o texto ao concluir */
.text {
  max-width: 100%;
  overflow-wrap: anywhere;
  background-image: linear-gradient(var(--strike), var(--strike));
  background-repeat: no-repeat;
  background-position: 0 58%;
  background-size: 0 1.5px;
  transition: background-size .28s ease-out, color .28s;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.task.done .text { background-size: 100% 1.5px; color: var(--ink-soft); }
.task.done .text, .task.done .meta { text-decoration-color: var(--ink-faint); }

/* marca-texto das essenciais */
.task.ess .text {
  font-weight: 700;
  color: var(--hl-ink);
  background-image:
    linear-gradient(var(--strike), var(--strike)),
    linear-gradient(transparent 22%, var(--hl) 22%, var(--hl) 92%, transparent 92%);
  background-size: 0 1.5px, 100% 100%;
  background-position: 0 58%, 0 0;
  padding: 0 .2em; margin-left: -.2em;
  border-radius: .15em;
}
.task.ess.done .text { background-size: 100% 1.5px, 100% 100%; color: var(--hl-ink); opacity: .8; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .6rem; font-size: .8125rem; color: var(--ink-soft); }
.meta svg { width: .9rem; height: .9rem; margin-right: .15rem; vertical-align: -.1rem; }
.imp { font-weight: 800; color: var(--ink); }
.imp::before { content: '! '; }
.cat::before { content: '#'; opacity: .6; }
.task.done .meta { opacity: .75; }

.grip {
  flex: none;
  display: grid; place-items: center;
  width: 2.5rem; height: 2.75rem; margin-right: .25rem;
  border: 0; background: transparent; color: var(--ink-faint);
  touch-action: none; cursor: grab;
}
.grip svg { width: 1.25rem; height: 1.25rem; }
.tasks.sorting { user-select: none; -webkit-user-select: none; }
.task.lifting {
  position: relative; z-index: 3;
  background: var(--paper-2);
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .45);
}
.task.lifting .grip { cursor: grabbing; color: var(--ink); }

.star {
  flex: none;
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;
  border: 0; background: transparent; color: var(--ink-faint);
  touch-action: manipulation;
}
.star svg { width: 1.25rem; height: 1.25rem; }
.star[aria-pressed="true"] { color: var(--ink); }
.star[aria-pressed="true"] svg { fill: var(--hl); stroke: var(--gold); }

.empty { padding: 1rem; margin: 0; color: var(--ink-soft); }

.float-pts {
  position: fixed; z-index: 30;
  transform: translate(-50%, -100%);
  font-weight: 800; font-size: 1rem; color: var(--auburn);
  pointer-events: none;
  animation: rise .9s ease-out forwards;
}
.float-pts.big {
  font-size: 1.5rem;
  padding: 0 .25em;
  background: linear-gradient(transparent 25%, var(--hl) 25%, var(--hl) 90%, transparent 90%);
}
@keyframes rise {
  0% { opacity: 0; translate: 0 .5rem; }
  20% { opacity: 1; }
  100% { opacity: 0; translate: 0 -2.25rem; }
}

/* ---------- adicionar ---------- */
.add {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  max-width: 36rem; margin-inline: auto;
  padding: .5rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  background: var(--paper);
  box-shadow: var(--shadow);
}
.add input {
  width: 100%;
  height: 3.25rem;
  padding: 0 .875rem;
  border: 2px solid var(--ink); border-radius: .5rem;
  background: var(--paper-2);
  font-size: 1.0625rem;
}
.add input::placeholder { color: var(--ink-faint); }
.add input:focus-visible { outline-offset: 1px; }
.hint { margin: .4rem .125rem 0; font-size: .8125rem; color: var(--ink-faint); word-spacing: .2em; white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: .375rem; }
.chips:not(:empty) { margin-bottom: .5rem; }
.chip {
  padding: .15rem .55rem;
  border: 1.5px solid var(--ink); border-radius: 1rem;
  font-size: .8125rem; font-weight: 600;
}
.chip-essential { background: var(--hl); color: var(--hl-ink); }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 40;
  left: 1rem; right: 1rem; bottom: calc(7.25rem + env(safe-area-inset-bottom));
  max-width: 34rem; margin-inline: auto;
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1rem;
  background: var(--ink); color: var(--paper);
  border-radius: .5rem;
  font-size: .9375rem;
}
.toast span { flex: 1; }
.toast .link-btn { color: var(--paper); }

.link-btn {
  border: 0; background: none; padding: .25rem 0;
  font-weight: 700; text-decoration: underline; text-underline-offset: .2em;
  color: var(--ink);
}

/* ---------- folhas (dialog) ---------- */
dialog.sheet {
  width: 100%; max-width: 36rem;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom));
  border: 0; border-top: 2px solid var(--ink);
  border-radius: .875rem .875rem 0 0;
  background: var(--paper-2); color: var(--ink);
  overflow: auto;
}
dialog.sheet[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(1.5rem); opacity: 0; } }
dialog::backdrop { background: rgba(18, 23, 42, .45); }
@media (min-width: 40rem) {
  dialog.sheet { margin: auto; border-radius: .875rem; border: 2px solid var(--ink); }
}
dialog h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: .75rem; }

.field { display: flex; flex-direction: column; gap: .3rem; margin: 0 0 .875rem; padding: 0; border: 0; min-width: 0; }
.field > span, .field legend { font-size: .875rem; font-weight: 600; color: var(--ink-soft); padding: 0; }
.field input, .field textarea {
  width: 100%; min-height: 2.875rem;
  padding: .55rem .75rem;
  border: 1.5px solid var(--ink-soft); border-radius: .4rem;
  background: var(--paper);
}
.field textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.seg { flex-direction: row; flex-wrap: wrap; gap: .375rem; }
.seg legend { width: 100%; margin-bottom: .3rem; }
.seg label {
  position: relative;
  padding: .45rem .8rem;
  border: 1.5px solid var(--ink-soft); border-radius: 2rem;
  font-size: .9375rem;
}
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg label:has(input:focus-visible) { outline: 2.5px solid var(--ink); outline-offset: 2px; }

label.toggle { display: flex; align-items: center; gap: .6rem; margin: 0 0 .875rem; }
label.toggle input { width: 1.25rem; height: 1.25rem; accent-color: var(--ink); }

.actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.actions.left { justify-content: flex-start; margin-top: .5rem; }
#edit-delete { margin-right: auto; }

.btn {
  min-height: 2.75rem; padding: 0 1.1rem;
  border: 2px solid var(--ink); border-radius: .5rem;
  background: var(--ink); color: var(--paper);
  font-weight: 700;
  touch-action: manipulation;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { color: var(--danger); border-color: currentColor; }
.btn.sm { min-height: 2.25rem; padding: 0 .7rem; font-size: .875rem; border-width: 1.5px; }

.muted { color: var(--ink-soft); margin: 0 0 .75rem; font-size: .9375rem; }


.tip { margin-top: 1rem; font-size: .9375rem; }
.tip summary { font-weight: 600; cursor: pointer; min-height: 2.75rem; display: flex; align-items: center; }
.tip ol { margin: .25rem 0 0; padding-left: 1.25rem; color: var(--ink-soft); }

/* calendário */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.cal-head h2 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem; text-align: center; }
.dow { font-size: .8125rem; font-weight: 700; color: var(--ink-soft); text-decoration: none; padding: .25rem 0; }
.day {
  position: relative;
  aspect-ratio: 1; min-height: 2.75rem;
  border: 0; border-radius: 50%;
  background: transparent;
  font-variant-numeric: tabular-nums; font-weight: 500;
}
.day.today { box-shadow: inset 0 0 0 2px var(--ink); font-weight: 800; }
.day[aria-current="date"] { background: var(--ink); color: var(--paper); }
.day.has::after, .day.all-done::after {
  content: ''; position: absolute; left: 50%; bottom: 14%;
  width: .4rem; height: .4rem; margin-left: -.2rem; border-radius: 50%;
  border: 1.5px solid currentColor;
}
.day.all-done::after { background: currentColor; }

/* pendentes */
.pend-day { color: var(--ink-soft); font-size: .875rem; margin: 1rem 0 .25rem; }
.pend { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.pend li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.pend .text { flex: 1 1 10rem; }
.pend-actions { display: flex; gap: .375rem; }

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

/* revisão de interface: arraste, folhas, hover */
dialog.sheet { overscroll-behavior: contain; }
main.dragging { user-select: none; -webkit-user-select: none; transition: none; }
h1, h2, h3 { text-wrap: balance; }
@media (hover: hover) {
  .icon-btn:hover, .star:hover, .check:hover { background: var(--rule); border-radius: 50%; }
  .btn:hover { filter: brightness(1.12); }
  .btn.ghost:hover, .body:hover { background: color-mix(in srgb, var(--rule) 55%, transparent); }
  .link-btn:hover { text-decoration-thickness: 2px; }
  .day:hover:not([aria-current]) { background: var(--rule); }
}
