/* Aflito — layout: cabeçalho fixo no topo (marca + ferramentas, depois abas + adicionar) e uma coluna central de leitura.
   Cor: âmbar de ampulheta (o tempo passando); vermelho só para o que está muito perto. */
:root {
  --bg: #ffffff;
  --surface: #faf8f5;
  --fg: #1f1d1a;
  --muted: #6b665f;
  --faint: #a19b92;
  --line: #ece8e1;
  --hover: #f4f1ec;
  --accent: #b45309;
  --accent-hover: #9a4708;
  --accent-soft: #fdf2e2;
  --on-accent: #ffffff;
  --urgent: #c8372d;
  --urgent-soft: #fbeae8;
  --ok: #2f7d4a;
  --ok-soft: #e7f2ea;
  --shadow: 0 8px 28px rgb(40 25 5 / .12);
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a18; --surface: #23211e; --fg: #ece8e2; --muted: #a7a097; --faint: #736d65; --line: #34312c; --hover: #2c2a26;
    --accent: #f2a541; --accent-hover: #f7b85f; --accent-soft: #3b2c16; --on-accent: #1b1206;
    --urgent: #ff7a6b; --urgent-soft: #3d2220; --ok: #73c592; --ok-soft: #1e3326; --shadow: 0 8px 28px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a18; --surface: #23211e; --fg: #ece8e2; --muted: #a7a097; --faint: #736d65; --line: #34312c; --hover: #2c2a26;
  --accent: #f2a541; --accent-hover: #f7b85f; --accent-soft: #3b2c16; --on-accent: #1b1206;
  --urgent: #ff7a6b; --urgent-soft: #3d2220; --ok: #73c592; --ok-soft: #1e3326; --shadow: 0 8px 28px rgb(0 0 0 / .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

/* ---------- Cabeçalho ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in, .tabs-in, .wrap { max-width: 820px; margin: 0 auto; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px 6px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand b { font-size: 18px; letter-spacing: -.3px; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.logo svg { width: 18px; height: 18px; stroke-width: 1.9; }
.tools { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; background: var(--hover); border-radius: 8px; padding: 2px; }
.seg button { padding: 4px 8px; border-radius: 6px; color: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 600; min-width: 30px; }
.seg button svg { width: 15px; height: 15px; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / .14); }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #8a6d5a; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 12px; min-width: 220px; display: flex; flex-direction: column; gap: 2px; z-index: 6; }
.pop small { color: var(--muted); margin-bottom: 8px; overflow-wrap: anywhere; }
.pop button { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; margin: 0 -4px; }
.pop button:hover { background: var(--hover); }

.tabs-in { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; padding-block: 4px 0; }
.tabs-in::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 9px 10px 11px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tab svg { width: 17px; height: 17px; }
.tab:hover { color: var(--fg); }
.tab[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.tab[aria-current="page"] svg { color: var(--accent); }
.tab em { font-style: normal; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tab em.alert { color: var(--on-accent); background: var(--accent); border-radius: 99px; padding: 0 6px; font-weight: 700; }
.tabs-in .add { margin-left: auto; flex: none; }
.demo { background: var(--accent-soft); color: var(--accent); text-align: center; font-size: 12px; padding: 4px 16px; }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; background: var(--hover); white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { filter: brightness(.97); }
.btn.pri { background: var(--accent); color: var(--on-accent); }
.btn.pri:hover { background: var(--accent-hover); filter: none; }
.btn.pri:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: none; border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--hover); }
.btn.done { background: var(--ok-soft); color: var(--ok); cursor: default; }
.ib { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.ib:hover { background: var(--hover); color: var(--fg); }
.ib.del:hover { color: var(--urgent); }
.pill { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 6px; display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.pill svg { width: 14px; height: 14px; }
.pill.add { color: var(--accent); }
.pill.add:hover { background: var(--accent-soft); }
.pill.done { color: var(--muted); cursor: default; }
.pill.ok { color: var(--ok); }
.pill.ok:hover { background: var(--ok-soft); }
.pill.no { color: var(--muted); }
.pill.no:hover { background: var(--hover); color: var(--urgent); }
.pill.danger { color: var(--urgent); background: var(--urgent-soft); }

/* ---------- Conteúdo ---------- */
.wrap { padding-block: 32px 96px; }
.head h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.3px; text-wrap: balance; }
.head p { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }
.head p b { color: var(--fg); font-weight: 600; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 500; margin: -8px 0 16px -4px; padding: 4px; border-radius: 6px; }
.back:hover { color: var(--fg); background: var(--hover); }
.back svg { width: 16px; height: 16px; }

.section { margin-top: 28px; }
.section h2 { font-size: 14px; font-weight: 700; margin: 0; padding-bottom: 6px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; }
.section h2 small { color: var(--faint); font-weight: 400; font-size: 12px; }
.empty-sec { color: var(--faint); padding: 10px 0; font-size: 13px; }
.list { margin-top: 20px; border-top: 1px solid var(--line); }

.row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.body { flex: 1; min-width: 0; }
.name { overflow-wrap: anywhere; display: block; }
.name.link:hover { color: var(--accent); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; color: var(--muted); font-size: 12px; margin-top: 2px; }
.meta span { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.meta svg { width: 13px; height: 13px; }
.meta .by { color: var(--faint); }
.meta a { color: var(--accent); }
.meta a:hover { text-decoration: underline; }
.thumb { width: 48px; height: 48px; border-radius: 8px; overflow: hidden; flex: none; background: var(--hover); display: grid; place-items: center; color: var(--faint); }
.thumb img, img.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
img.thumb.sm { width: 32px; height: 32px; border-radius: 6px; }
.count { text-align: right; flex: none; font-variant-numeric: tabular-nums; line-height: 1.15; min-width: 44px; }
.count b { font-size: 15px; font-weight: 650; display: block; }
.count small { color: var(--muted); font-size: 11px; }
.row.soon .count b { color: var(--urgent); }
.row.month .count b { color: var(--accent); }
.row.past .count b { color: var(--ok); }
.acts { display: flex; gap: 2px; flex: none; opacity: 0; transition: opacity .12s; }
.row:hover .acts, .row:focus-within .acts, .acts.on { opacity: 1; }
@media (hover: none) { .acts { opacity: 1; } }
.row-acts { display: flex; gap: 2px; flex: none; }

.quick { display: flex; align-items: center; gap: 10px; padding: 10px 4px; color: var(--muted); width: 100%; text-align: left; }
.quick .plus { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: var(--accent); }
.quick:hover { color: var(--accent); }
.quick:hover .plus { background: var(--accent); color: var(--on-accent); }
.quick .plus svg { width: 14px; height: 14px; stroke-width: 2.2; }

.editor { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; background: var(--bg); box-shadow: var(--shadow); }
.editor .fields { padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.editor input[type=text] { border: 0; outline: 0; background: none; font-size: 15px; font-weight: 600; padding: 2px 0; width: 100%; }
.editor input[type=text]::placeholder { color: var(--faint); font-weight: 500; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; color: var(--muted); font-size: 13px; }
.chip svg { width: 15px; height: 15px; }
.chip input { border: 0; background: none; outline: 0; font-size: 13px; color: var(--fg); }
.chip.check { cursor: pointer; }
.chip.check input { accent-color: var(--accent); margin: 0; }
.chip.check:has(input:checked) { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.bar { display: flex; justify-content: flex-end; gap: 8px; }
.editor .bar { padding: 8px 12px; border-top: 1px solid var(--line); }

.empty { text-align: center; color: var(--muted); padding: 56px 16px 8px; }
.empty svg { width: 44px; height: 44px; color: var(--faint); stroke-width: 1.3; }
.empty p { margin: 10px auto 0; max-width: 42ch; }

/* ---------- Página do evento ---------- */
.event { display: flex; flex-direction: column; gap: 14px; }
.cover { aspect-ratio: 2 / 1; max-width: 100%; border-radius: 14px; overflow: hidden; background: var(--hover); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter .3s; }
.cover.loading img { filter: blur(14px); transform: scale(1.06); }
.event h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.15; letter-spacing: -.5px; margin: 6px 0 0; text-wrap: balance; }
.meta.big { font-size: 14px; gap: 4px 16px; }
.meta.big svg { width: 16px; height: 16px; }
.countdown { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 18px 20px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.countdown b { font-size: 44px; line-height: 1; letter-spacing: -1.5px; color: var(--accent); }
.event.soon .countdown b { color: var(--urgent); }
.event.past .countdown b { color: var(--ok); }
.countdown span { font-size: 15px; font-weight: 600; }
.countdown small { flex-basis: 100%; color: var(--muted); font-size: 13px; }
.desc { font-size: 15px; line-height: 1.65; max-width: 65ch; }
.desc p { margin: 0 0 12px; }
.event-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.event-acts .btn { padding: 9px 14px; font-size: 14px; }

/* ---------- Formulário do admin ---------- */
.pform { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--bg); font-size: 14px; }
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; line-height: 1.55; }
.grid2 { display: grid; grid-template-columns: 200px 1fr; gap: 14px; }
.drop { position: relative; aspect-ratio: 2 / 1; max-width: 100%; border-radius: 12px; border: 1.5px dashed var(--line); overflow: hidden; display: grid; place-items: center; background: var(--surface); }
.drop.has { border-style: solid; }
.drop img { width: 100%; height: 100%; object-fit: cover; }
.drop .ph { display: grid; justify-items: center; gap: 6px; color: var(--faint); text-align: center; padding: 16px; }
.drop .ph svg { width: 32px; height: 32px; stroke-width: 1.4; }
.busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / .45); color: #fff; font-weight: 600; }
.img-acts { display: flex; gap: 8px; }
.img-acts label { cursor: pointer; }
.langs { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.lang-tabs { align-self: flex-start; }
.lang-tabs button { padding: 5px 12px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.lang-tabs i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.lang-tabs i.filled { background: var(--ok); }
.hint { color: var(--faint); font-size: 12px; margin: 0; }
.form-error { color: var(--urgent); font-weight: 600; margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: #2b2925; color: #f4efe8; border-radius: 9px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px; font-size: 13px; max-width: calc(100vw - 32px);
}
.toast button { color: #f6b85a; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.toast button:hover { background: rgb(255 255 255 / .08); }

/* ---------- Telas estreitas ---------- */
@media (max-width: 640px) {
  .top-in, .tabs-in, .wrap { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
  .tab span { display: none; }
  .tab[aria-current="page"] span { display: inline; }
  .tabs-in .add span { display: none; }
  .tabs-in .add { padding: 7px 9px; }
  .wrap { padding-block: 22px 96px; }
  .head h1 { font-size: 21px; }
  .grid2 { grid-template-columns: 1fr; }
  .acts { opacity: 1; }
  .row-acts .pill span { display: none; }
  .countdown b { font-size: 36px; }
}
@media (max-width: 400px) {
  .brand b { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Rodapé, política de privacidade, links externos ---------- */
.foot { border-top: 1px solid var(--line); }
.foot-in { max-width: 820px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--faint); font-size: 12px;
  padding-block: 18px calc(18px + env(safe-area-inset-bottom, 0px)); padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.foot-in a:hover { color: var(--fg); }
.tab svg:last-child:not(:first-child) { width: 13px; height: 13px; opacity: .6; }
.pop-link { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; margin: 0 -4px; }
.pop-link:hover { background: var(--hover); }
.prose { max-width: 65ch; margin-top: 8px; }
.prose h2 { font-size: 16px; margin: 26px 0 6px; }
.prose p { margin: 0; line-height: 1.65; color: var(--fg); }

/* ---------- v1.5: filtros, categorias, relógio, formulário ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.filters button { padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 500; }
.filters button:hover { color: var(--fg); background: var(--hover); }
.filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tag { background: var(--hover); color: var(--muted); border-radius: 99px; padding: 0 8px; }
.cat-pill { align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 3px 10px; margin-bottom: -6px; }
.cat-pill:hover { filter: brightness(.96); }
.countdown .clock { flex-basis: 100%; font-size: 15px; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.grid3 { display: grid; grid-template-columns: 1fr 140px 1.3fr; gap: 14px; }
.grid2b { display: grid; grid-template-columns: 1fr 1.5fr; gap: 14px; }
.field select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--bg); font-size: 14px; }
.field input:disabled { opacity: .5; }
.cat-fields { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cat-fields input { font-size: 14px !important; font-weight: 500 !important; border: 1px solid var(--line) !important; border-radius: 8px; padding: 8px 10px !important; }
#cat-form .form-error { padding: 0 12px 8px; }
.chip input[type=time] { width: 92px; }
@media (max-width: 640px) {
  .grid3, .grid2b, .cat-fields { grid-template-columns: 1fr; }
}
.logo svg.mark { width: 22px; height: 22px; fill: currentColor; stroke: none; }
