/* Preto e branco, tipografia Karla (referência: unum.la). */
:root {
  --paper: #ffffff;
  --card: #ffffff;
  --ink: #09090b;
  --mute: #6b6b74;
  --line: #e5e5e8;
  --mark: #7c6cf2;   /* lilás do UNUM, só no "já postei" */
  --danger: #c93426;
  --font: "Karla", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ratio: 3 / 4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #09090b;
    --card: #151518;
    --ink: #ffffff;
    --mute: #a0a0aa;
    --line: #27272b;
    --mark: #9d90ff;
    --danger: #ff6a5a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
h1, h2, h3 { text-wrap: balance; }
html {
  color-scheme: light dark;
  scroll-padding-bottom: 96px; /* a barra fixa não cobre o que está em foco */
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
}
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
input, textarea { font-size: 16px; }
button {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.app {
  max-width: 540px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

/* Topo */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px;
  height: 44px;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-content: center;
  gap: 4px;
  font: 800 12.5px/1 var(--font);
}
/* Cada letra numa coluna de 10px (mesmo espaçamento nas duas linhas); NA centralizado sobre RRA */
.logo span { display: grid; grid-auto-flow: column; grid-auto-columns: 10px; justify-content: center; }
.logo i { font-style: normal; text-align: center; }
.wordmark { font: 700 20px/1 var(--font); letter-spacing: -.02em; }
.wordmark span { color: var(--mute); }

/* Botões */
.btn, .btn-ghost {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  min-height: 48px;
  padding: 0 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 120ms var(--ease-out), border-color 120ms, opacity 120ms;
}
.btn:active, .btn-ghost:active { transform: scale(.97); }
.btn:disabled { opacity: .35; }
.btn-ghost {
  border-color: transparent;
  background: none;
  min-height: 44px;
  padding: 0 10px;
  color: var(--mute);
  font-weight: 500;
}
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-danger { color: var(--danger); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: var(--ink); }
  .btn-ghost:hover { color: var(--ink); }
  .btn-primary:hover { opacity: .86; }
}

/* Perfil */
.profile {
  display: flex;
  gap: 16px;
  padding: 6px 16px 18px;
  align-items: flex-start;
}
.avatar {
  flex: none;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 1px dashed var(--mute);
  background: var(--card);
  color: var(--mute);
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.avatar:has(img:not([hidden])) { border: 1px solid var(--line); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar img[hidden] { display: none; }
.who { flex: 1; min-width: 0; display: grid; gap: 2px; }
.who input, .who textarea {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: none;
  padding: 3px 4px;
  margin-left: -4px;
  resize: none;
}
.who input { font-weight: 700; }
.who textarea { line-height: 1.35; font-size: 16px; }
.who ::placeholder { color: var(--mute); opacity: 1; }
.stats { font-size: 13px; color: var(--mute); padding-top: 4px; font-variant-numeric: tabular-nums; }
.stats:empty { display: none; }

/* Grade */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.cell { aspect-ratio: var(--ratio); position: relative; }
.cell button {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: var(--line);
  overflow: hidden;
  -webkit-touch-callout: none;
  transition: transform 140ms var(--ease-out);
}
.cell button:focus-visible { outline-offset: -4px; outline-color: #fff; box-shadow: inset 0 0 0 6px #09090b; }
.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.cell.slot button {
  background: none;
  border: 1px dashed var(--mute);
  color: var(--mute);
  font-size: 13px;
  font-weight: 500;
}
.tag {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 11px;
  background: rgba(9, 9, 11, .74);
  color: #fff;
  font: 700 11px/21px var(--font);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tag.done { background: var(--mark); color: #fff; }
.grid.clean .tag { display: none; }
.sortable-ghost { opacity: .25; }
.sortable-chosen button { transform: scale(.94); }
.sortable-drag button { transform: scale(1.04); box-shadow: 0 12px 30px rgba(0, 0, 0, .3); }

/* Grade vazia */
.empty { padding: 0 16px 32px; text-align: center; }
.empty[hidden] { display: none; }
.ghosts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 0 -16px 28px; }
.ghosts i { aspect-ratio: var(--ratio); border: 1px dashed var(--line); }
.ghosts i:nth-child(n+4) { opacity: .45; }
.empty h2 { font: 500 28px/1.15 var(--font); letter-spacing: -.02em; }
.empty p { color: var(--mute); max-width: 30ch; margin: 10px auto 0; }

/* Barra de ações */
.bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

/* Folhas (dialog nativo) */
.sheet {
  width: 100%;
  max-width: 540px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet[open] { animation: rise 240ms var(--ease-out); }
.sheet::backdrop { background: rgba(0, 0, 0, .5); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet-body {
  display: grid;
  gap: 16px;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font: 500 24px/1.1 var(--font); letter-spacing: -.02em; }
.sheet-head .btn-ghost { margin-right: -10px; }
.sheet-main { display: grid; grid-template-columns: 104px 1fr; gap: 14px; align-items: start; }
.sheet-main.no-photo { grid-template-columns: 1fr; }
.preview { aspect-ratio: var(--ratio); background: var(--line); overflow: hidden; border-radius: 6px; }
.preview:empty { display: none; }
.preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fields { display: grid; gap: 8px; min-width: 0; }
.fields label, .seg legend, .group h3 { font: 600 13px/1.4 var(--font); color: var(--mute); padding: 0; }
.fields textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 10px 12px;
  resize: vertical;
}
.fields ::placeholder { color: var(--mute); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; flex-wrap: wrap; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.check small { color: var(--mute); font-weight: 400; font-size: 14px; flex-basis: 100%; padding-left: 30px; margin-top: -8px; }
.seg { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg legend { margin-bottom: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-weight: 600;
  text-align: center;
}
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.group { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; }
.group p { color: var(--mute); font-size: 15px; }

/* Aviso */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms, transform 180ms var(--ease-out);
  z-index: 10;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

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