/* =====================================================================
   BRUTODO — sistema visual neo-brutalista
   Mobile-first. Bordas grossas, sombras duras, cores chapadas, zero blur.
   ===================================================================== */

/* ---------- 1. Tokens ---------- */

:root {
  color-scheme: light;

  --ink: #0b0b0b;
  --paper: #f2eee1;
  --paper-2: #fffdf5;
  --muted: #6d6a60;

  --yellow: #ffe500;
  --pink: #ff5fa2;
  --cyan: #3ee2f0;
  --lime: #b8ff3c;
  --orange: #ff7a2f;
  --violet: #b490ff;
  --red: #ff4d4d;
  --green: #16c172;

  --accent: var(--yellow);

  --bd: 3px;
  --bd-thick: 4px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-lg: 7px 7px 0 var(--ink);

  --gap: 12px;
  --pad: 16px;

  --font: 'Helvetica Neue', Helvetica, Arial, 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --tap: 48px;
  --bar-h: 60px;

  --sat-top: env(safe-area-inset-top, 0px);
  --sat-bottom: env(safe-area-inset-bottom, 0px);
  --sat-left: env(safe-area-inset-left, 0px);
  --sat-right: env(safe-area-inset-right, 0px);

  --dur: 140ms;

  /* altura do teclado virtual, publicada por js/ui.js enquanto o sheet está aberto */
  --kb: 0px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --ink: #f5f2e8;
  --paper: #12100c;
  --paper-2: #1c1a14;
  --muted: #a09b8c;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-lg: 7px 7px 0 var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --ink: #f5f2e8;
    --paper: #12100c;
    --paper-2: #1c1a14;
    --muted: #a09b8c;
  }
}

@media (min-width: 600px) {
  :root {
    --bd: 3px;
    --bd-thick: 5px;
    --shadow: 6px 6px 0 var(--ink);
    --shadow-lg: 9px 9px 0 var(--ink);
    --gap: 16px;
    --pad: 20px;
  }
}

/* ---------- 2. Reset ---------- */

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

* { margin: 0; padding: 0; }

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 23px, color-mix(in srgb, var(--ink) 7%, transparent) 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 23px, color-mix(in srgb, var(--ink) 7%, transparent) 23px 24px);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

img, svg { display: block; max-width: 100%; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
  border-radius: 0;
}

button { background: none; border: none; cursor: pointer; touch-action: manipulation; }

ul, ol { list-style: none; }

a { color: inherit; }

:focus { outline: none; }

:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: 3px;
  z-index: 3;
}

::selection { background: var(--pink); color: #000; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

/* ---------- 3. Tipografia ---------- */

h1, h2, h3, h4 {
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-transform: uppercase;
}

h1 { font-size: clamp(1.6rem, 7vw, 2.4rem); }
h2 { font-size: clamp(1.25rem, 5.4vw, 1.7rem); }
h3 { font-size: 1.05rem; letter-spacing: 0.01em; }

.label {
  display: block;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.hint {
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--muted);
  font-weight: 600;
}

.mono { font-family: var(--font-mono); font-size: 0.8rem; }

/* ---------- 4. Superfícies ---------- */

.box {
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow);
}

/* ---------- 5. Botões ---------- */

.btn {
  --btn-bg: var(--paper-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 16px;
  background: var(--btn-bg);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  transition: transform var(--dur) ease, box-shadow var(--dur) ease, background var(--dur) ease;
  user-select: none;
}

.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }

.btn:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: var(--shadow-sm); }

.btn--primary { --btn-bg: var(--accent); color: #0b0b0b; }
.btn--danger { --btn-bg: var(--red); color: #0b0b0b; }

/* Compacto no visual, mas nunca abaixo do alvo mínimo de toque. */
.btn--sm { min-height: 44px; padding: 6px 12px; font-size: 0.75rem; box-shadow: 2px 2px 0 var(--ink); }

.btn--icon {
  min-height: var(--tap);
  width: var(--tap);
  padding: 0;
  flex: 0 0 auto;
}

.btn--icon.btn--sm { width: 44px; min-height: 44px; }

.btn__ico { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.6; fill: none; stroke-linecap: square; stroke-linejoin: miter; pointer-events: none; }
.btn--sm .btn__ico { width: 17px; height: 17px; }

/* ---------- 6. Formulários ---------- */

.field { margin-bottom: var(--gap); }

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  font-size: 16px; /* impede o zoom automático do iOS */
  font-weight: 700;
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  box-shadow: inset 2px 2px 0 color-mix(in srgb, var(--ink) 12%, transparent);
  appearance: none;
}

.textarea { min-height: 96px; resize: vertical; line-height: 1.4; font-weight: 600; }

.select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
                    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: right 18px center, right 12px center;
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.input::placeholder, .textarea::placeholder { color: var(--muted); font-weight: 600; }

.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  background: var(--accent);
  color: #0b0b0b;
}

/* Em foco o fundo vira amarelo: o cinza de `--muted` sumiria nele. */
.input:focus-visible::placeholder,
.textarea:focus-visible::placeholder { color: rgba(0, 0, 0, 0.55); }

.input[aria-invalid='true'] { background: color-mix(in srgb, var(--red) 35%, var(--paper-2)); }

.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group > .input { flex: 1 1 auto; min-width: 0; }

.error-text {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--red);
  color: #0b0b0b;
  border: var(--bd) solid var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

/* medidor de força de senha */
.meter { display: flex; gap: 4px; margin-top: 8px; }
.meter__seg {
  flex: 1;
  height: 10px;
  border: 2px solid var(--ink);
  background: var(--paper-2);
}
.meter__seg.on { background: var(--accent); }
.meter[data-score='0'] .meter__seg.on { background: var(--red); }
.meter[data-score='1'] .meter__seg.on { background: var(--orange); }
.meter[data-score='2'] .meter__seg.on { background: var(--yellow); }
.meter[data-score='3'] .meter__seg.on { background: var(--lime); }
.meter[data-score='4'] .meter__seg.on { background: var(--green); }

/* seletor de cor */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 44px; height: 44px;
  border: var(--bd) solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  position: relative;
  transition: transform var(--dur) ease;
}
.swatch[aria-checked='true'] { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.swatch[aria-checked='true']::after {
  content: '';
  position: absolute; inset: 4px;
  border: 3px solid var(--ink);
}

/* ---------- 7. Barra superior ---------- */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--bar-h);
  padding: 8px calc(var(--pad) + var(--sat-right)) 8px calc(var(--pad) + var(--sat-left));
  padding-top: calc(8px + var(--sat-top));
  background: var(--accent);
  border-bottom: var(--bd-thick) solid var(--ink);
}

.app-bar__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  color: #0b0b0b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-bar__sub {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  font-weight: 800;
  opacity: 0.7;
}

.app-bar .btn { background: var(--paper-2); color: var(--ink); }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  color: #0b0b0b;
}

.logo__mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  background: #0b0b0b;
  color: var(--accent);
  border: 3px solid #0b0b0b;
  transform: rotate(-4deg);
  flex: 0 0 auto;
}
.logo__mark svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 3.4; fill: none; stroke-linecap: square; }

/* ---------- 8. Layout ---------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.view {
  flex: 1 1 auto;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding:
    var(--pad)
    calc(var(--pad) + var(--sat-right))
    calc(120px + var(--sat-bottom))
    calc(var(--pad) + var(--sat-left));
}

.view[hidden] { display: none; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: var(--gap);
}

.count-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border: 2px solid var(--ink);
  background: var(--paper-2);
  white-space: nowrap;
}

/* ---------- 9. Cartão de workspace ---------- */

.ws-grid { display: grid; gap: var(--gap); }

@media (min-width: 560px) {
  .ws-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ws-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  text-align: left;
  background: var(--ws-color, var(--paper-2));
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow);
  color: #0b0b0b;
  transition: transform var(--dur) ease, box-shadow var(--dur) ease;
  overflow: hidden;
}

.ws-card::before {
  content: '';
  position: absolute;
  top: -18px; right: -18px;
  width: 56px; height: 56px;
  background: #0b0b0b;
  transform: rotate(45deg);
  opacity: 0.12;
}

.ws-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); }
.ws-card:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.ws-card__top { display: flex; align-items: flex-start; gap: 10px; }

.ws-card__name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.15rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.ws-card__open {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}

/* área de toque estendida: o cartão inteiro abre o workspace */
.ws-card__open::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.ws-card__open:focus-visible { outline: none; }
.ws-card__open:focus-visible::after { outline: 3px dashed #0b0b0b; outline-offset: -6px; }

.ws-card__state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 4px 8px;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  border: 2px solid #0b0b0b;
  background: #0b0b0b;
  /* Fixo, e não `--paper-2`: o fundo do selo também é fixo, e no tema escuro os
     dois viravam quase a mesma cor (contraste 1,13:1). */
  color: #fffdf5;
}
.ws-card__state svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.6; }
.ws-card__state--open { background: var(--green); color: #0b0b0b; }

.ws-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

.ws-card__actions {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.ws-card__actions .btn {
  background: rgba(255, 255, 255, 0.65);
  border-color: #0b0b0b;
  color: #0b0b0b;
  box-shadow: 2px 2px 0 #0b0b0b;
}

/* ---------- 10. Abas de listas ---------- */

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 4px 2px 10px;
  margin: 0 calc(var(--pad) * -1) 0;
  padding-left: var(--pad);
  padding-right: var(--pad);
  scroll-snap-type: x proximity;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 13px;
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  max-width: 62vw;
  transition: transform var(--dur) ease, box-shadow var(--dur) ease;
}

.tab__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tab__badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 1px 5px;
  border: 2px solid currentColor;
}

.tab[aria-current='true'] {
  background: var(--tab-color, var(--accent));
  color: #0b0b0b;
  border-color: #0b0b0b;
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--ink);
}

.tab--add { padding: 8px 12px; }

/* ---------- 11. Progresso ---------- */

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 var(--gap);
  padding: 10px 12px;
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-sm);
}

.progress__bar {
  position: relative;
  flex: 1 1 auto;
  height: 16px;
  background: var(--paper);
  border: 2px solid var(--ink);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,0.22) 0 5px, transparent 5px 10px);
  transition: width 220ms ease;
}

.progress__num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

/* ---------- 12. Compositor de tarefa ---------- */

.composer {
  display: flex;
  gap: 8px;
  margin-bottom: var(--gap);
}
.composer .input { flex: 1 1 auto; min-width: 0; box-shadow: var(--shadow-sm); }

/* ---------- 13. Filtros ---------- */

.filters {
  display: flex;
  gap: 6px;
  margin-bottom: var(--gap);
  flex-wrap: wrap;
}

.filter {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 6px 10px;
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 var(--ink);
}
.filter[aria-pressed='true'] { background: var(--ink); color: var(--paper); }

/* ---------- 14. Tarefas ---------- */

.tasks { display: flex; flex-direction: column; gap: 10px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px;
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) ease, box-shadow var(--dur) ease, opacity var(--dur) ease;
}

.task--done { background: var(--paper); background: color-mix(in srgb, var(--ink) 6%, var(--paper-2)); }
.task--done .task__text { text-decoration: line-through; opacity: 0.55; }

.task--dragging { opacity: 0.4; }

.task__check {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  margin-top: 1px;
  background: var(--paper);
  border: var(--bd) solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  transition: background var(--dur) ease, transform var(--dur) ease;
}
.task__check svg { width: 20px; height: 20px; stroke: #0b0b0b; stroke-width: 4; fill: none; stroke-linecap: square; stroke-dasharray: 40; stroke-dashoffset: 40; }
.task__check[aria-checked='true'] { background: var(--green); }
.task__check[aria-checked='true'] svg { stroke-dashoffset: 0; transition: stroke-dashoffset 200ms ease; }
.task__check:active { transform: translate(2px, 2px); box-shadow: none; }

/* Área de toque de 46px sem inchar o quadrado desenhado. */
.task__check::before {
  content: '';
  position: absolute;
  inset: -7px;
}

.task__body {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  padding: 2px 0;
}

.task__text {
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.task__note {
  margin-top: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.task__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 2px solid var(--ink);
  background: var(--paper);
}
.tag--high { background: var(--red); color: #0b0b0b; }
.tag--low { background: var(--cyan); color: #0b0b0b; }
.tag--due { background: var(--violet); color: #0b0b0b; }
.tag--late { background: var(--orange); color: #0b0b0b; }

.task__side { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }

.task__grip {
  width: 40px; height: 44px;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  color: var(--muted);
}
.task__grip svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.6; fill: none; }

/* ---------- 15. Estado vazio ---------- */

.empty {
  padding: 26px 18px;
  text-align: center;
  background: var(--paper-2);
  border: var(--bd) dashed var(--ink);
}
.empty__art {
  display: inline-grid;
  place-items: center;
  width: 62px; height: 62px;
  margin-bottom: 12px;
  background: var(--accent);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-sm);
  transform: rotate(-6deg);
}
.empty__art svg { width: 30px; height: 30px; stroke: #0b0b0b; stroke-width: 2.8; fill: none; }
.empty h3 { margin-bottom: 6px; }
.empty p { font-size: 0.85rem; font-weight: 600; color: var(--muted); max-width: 34ch; margin: 0 auto; }

/* ---------- 16. FAB ---------- */

.fab-dock {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding:
    12px
    calc(var(--pad) + var(--sat-right))
    calc(12px + var(--sat-bottom))
    calc(var(--pad) + var(--sat-left));
  background: linear-gradient(to top, var(--paper) 55%, transparent);
  pointer-events: none;
}

.fab-dock > * { pointer-events: auto; }

.fab {
  width: 100%;
  max-width: 420px;
  min-height: 54px;
  font-size: 1rem;
  box-shadow: var(--shadow);
}

/* ---------- 17. Bottom sheets ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55); /* fallback: sem color-mix o fundo não pode sumir */
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  opacity: 0;
  transition: opacity var(--dur) ease;
}
.backdrop[hidden] { display: none !important; }
.backdrop.is-open { opacity: 1; }

.sheet {
  position: fixed;
  z-index: 50;
  left: 0; right: 0;
  bottom: var(--kb, 0px);
  max-height: 92vh;
  max-height: calc(92dvh - var(--kb, 0px));
  display: flex;
  flex-direction: column;
  background: var(--paper-2);
  border-top: var(--bd-thick) solid var(--ink);
  border-left: var(--bd-thick) solid var(--ink);
  border-right: var(--bd-thick) solid var(--ink);
  box-shadow: 0 -6px 0 0 var(--ink);
  transform: translateY(102%);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet[hidden] { display: none !important; }
.sheet.is-open { transform: translateY(0); }

@media (min-width: 640px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(520px, 92vw);
    max-height: 88vh;
    max-height: 88dvh;
    border: var(--bd-thick) solid var(--ink);
    box-shadow: var(--shadow-lg);
    transform: translate(-50%, -46%) scale(0.96);
    opacity: 0;
    transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease;
  }
  .sheet.is-open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#sheet-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.sheet__grab {
  width: 60px; height: 6px;
  margin: 10px auto 0;
  background: var(--ink);
  flex: 0 0 auto;
}
@media (min-width: 640px) { .sheet__grab { display: none; } }

.sheet__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px var(--pad) 10px;
  border-bottom: var(--bd) solid var(--ink);
  flex: 0 0 auto;
}
.sheet__title { flex: 1 1 auto; font-size: 1.15rem; }

.sheet__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + var(--sat-bottom));
}

.sheet__foot {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 12px var(--pad);
  padding-bottom: calc(12px + var(--sat-bottom));
  border-top: var(--bd) solid var(--ink);
  background: var(--paper);
}
.sheet__foot .btn { flex: 1 1 0; }

/* Trava a página atrás do sheet. `position: fixed` é o único jeito que segura o
   iOS; o deslocamento do scroll é reposto pelo JS ao fechar. */
.body-lock {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

/* menu em lista dentro do sheet */
.menu { display: flex; flex-direction: column; gap: 10px; }
.menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  text-align: left;
  background: var(--paper-2);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 900;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: transform var(--dur) ease, box-shadow var(--dur) ease;
}
.menu__item:active { transform: translate(3px, 3px); box-shadow: none; }
.menu__item svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.5; fill: none; flex: 0 0 auto; }
.menu__item small { display: block; font-size: 0.68rem; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--muted); margin-top: 2px; }
.menu__item--danger { background: var(--red); color: #0b0b0b; }
.menu__item--danger small { color: rgba(0,0,0,0.65); }

/* ---------- 18. Toasts ---------- */

.toasts {
  position: fixed;
  z-index: 70;
  left: 0; right: 0;
  bottom: calc(78px + var(--sat-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 var(--pad);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 420px;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--paper);
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  font-weight: 800;
  pointer-events: auto;
  animation: toast-in 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
.toast--ok { background: var(--green); color: #0b0b0b; }
.toast--err { background: var(--red); color: #0b0b0b; }
.toast--out { animation: toast-out 160ms ease forwards; }
.toast__btn {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  border: 2px solid currentColor;
}

@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(10px); opacity: 0; } }

/* ---------- 19. Banner de alerta ---------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: var(--gap);
  padding: 12px;
  background: var(--orange);
  color: #0b0b0b;
  border: var(--bd) solid var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: 0.82rem;
  font-weight: 700;
}
.banner strong { display: block; font-size: 0.9rem; text-transform: uppercase; margin-bottom: 3px; }
.banner svg { width: 22px; height: 22px; flex: 0 0 auto; stroke: currentColor; stroke-width: 2.6; fill: none; }
.banner code { font-family: var(--font-mono); background: rgba(0,0,0,0.14); padding: 1px 4px; }

/* ---------- 20. Splash / carregando ---------- */

.busy {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
}
.busy[hidden] { display: none !important; }

.busy__box {
  padding: 22px 26px;
  background: var(--accent);
  border: var(--bd-thick) solid var(--ink);
  box-shadow: var(--shadow-lg);
  text-align: center;
  color: #0b0b0b;
}
.busy__bars { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.busy__bars i {
  display: block;
  width: 12px; height: 30px;
  background: #0b0b0b;
  animation: pump 720ms ease-in-out infinite;
}
.busy__bars i:nth-child(2) { animation-delay: 120ms; }
.busy__bars i:nth-child(3) { animation-delay: 240ms; }
.busy__label { font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem; }

@keyframes pump { 0%, 100% { transform: scaleY(0.45); } 50% { transform: scaleY(1); } }

/* ---------- 21. Animações utilitárias ---------- */

.shake { animation: shake 320ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* No desktop o sheet já é centralizado por transform: um shake com translateX
   puro o jogaria para o canto. Estes quadros preservam a centralização. */
@media (min-width: 640px) {
  .sheet.shake { animation-name: shake-centered; }
}
@keyframes shake-centered {
  10%, 90% { transform: translate(-50%, -50%) translateX(-2px); }
  20%, 80% { transform: translate(-50%, -50%) translateX(4px); }
  30%, 50%, 70% { transform: translate(-50%, -50%) translateX(-7px); }
  40%, 60% { transform: translate(-50%, -50%) translateX(7px); }
  100% { transform: translate(-50%, -50%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .sheet { transition: none; }
}

/* ---------- 22. Rodapé ---------- */

.foot-note {
  margin-top: 22px;
  padding-top: 14px;
  border-top: var(--bd) dashed var(--ink);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
