/* Base e componentes reutilizáveis. Específicos de tela ficam no fim, por seção. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-h1); font-weight: 700; line-height: 1.3; letter-spacing: -0.02em; }
h2 { font-size: var(--fs-h2); font-weight: 700; line-height: 1.4; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-h3); font-weight: 600; line-height: 1.35; }

.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;
}

/* ---------- layout ---------- */
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter) calc(120px + env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; gap: 12px; min-height: var(--tap); margin-bottom: 20px; }
.grow { flex: 1; min-width: 0; }
.eyebrow { color: var(--text-2); font-size: var(--fs-sm); }
.muted { color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: var(--fs-sm);
  transition: transform 0.1s;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn-tonal { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary-text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }

.icon-btn {
  display: inline-grid; place-items: center;
  min-width: var(--tap); min-height: var(--tap);
  border: 0; border-radius: var(--r-full); background: transparent; color: var(--text);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn.subtle { color: var(--text-2); }
.icon { width: 22px; height: 22px; flex: none; }
.icon-sm { width: 18px; height: 18px; flex: none; }

/* Barra fixa do rodapé, com o único botão principal da tela. */
.cta-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  background: var(--bar-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 520px; min-height: 56px; padding: 14px 24px;
  border: 0; border-radius: var(--r-full);
  background: var(--primary); color: var(--on-primary);
  font-size: var(--fs-body); font-weight: 700; letter-spacing: 0.01em;
  box-shadow: var(--shadow-cta);
  transition: transform 0.1s;
}
.cta:active:not(:disabled) { transform: scale(0.97); }
.cta:disabled { box-shadow: none; }

/* ---------- superfícies ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: var(--shadow-1);
}

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 24px; padding: 2px 10px;
  border: 0; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--text-2);
  font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap;
}

.input {
  width: 100%; min-width: 0; min-height: 52px; padding: 12px 16px;
  border: 1.5px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
}
.input::placeholder { color: var(--text-2); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgb(91 76 240 / 0.12); }

.empty {
  padding: 32px 16px; text-align: center; color: var(--text-2);
}

/* ---------- diálogo de confirmação ---------- */
dialog.confirm {
  width: min(92vw, 400px); padding: 24px;
  border: 0; border-radius: var(--r-xl);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-2);
}
dialog.confirm::backdrop { background: rgb(15 14 26 / 0.45); }
dialog.confirm p { margin: 8px 0 20px; color: var(--text-2); }
dialog.confirm .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.icon-xs { width: 14px; height: 14px; flex: none; }

/* ---------- aviso ---------- */
.banner {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; padding: 8px 8px 8px 16px;
  border-radius: var(--r-lg); background: var(--coral-soft); color: var(--coral-text);
  font-size: var(--fs-sm); font-weight: 500;
}
.banner .icon-btn { color: var(--coral-text); }

/* ---------- tela inicial ---------- */
.add-task {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 28px; padding: 6px;
  border: 1.5px solid var(--line); border-radius: var(--r-xl);
  background: var(--surface); box-shadow: var(--shadow-1);
}
.add-task:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgb(91 76 240 / 0.12); }
.add-task .input { border: 0; box-shadow: none; min-height: 48px; padding: 8px 12px; background: transparent; }
.add-task .btn { flex: none; min-height: 48px; border-radius: var(--r-lg); padding: 10px 18px; }

.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-h3); font-weight: 700; }
.section-title .icon-sm { color: var(--primary-text); }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.task-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 8px 14px 14px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow-1);
}
.task-card.is-top { border: 2px solid var(--primary); box-shadow: var(--shadow-2); }
.task-card.is-done { background: transparent; box-shadow: none; }
.task-card.is-done .task-title { text-decoration: line-through; color: var(--text-2); }

.check-btn {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; margin: 10px 0;
  border: 2px solid var(--line); border-radius: var(--r-full);
  background: transparent; color: transparent;
  position: relative;
}
.check-btn::after { content: ''; position: absolute; inset: -10px; } /* área de toque de 48px */
.check-btn:hover { border-color: var(--primary); color: var(--primary-text); }
.check-btn.checked { background: var(--success); border-color: var(--success); color: var(--on-success); }

.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.task-title { font-size: var(--fs-body); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.task-meta { font-size: var(--fs-xs); color: var(--text-2); }
.task-actions { display: flex; flex: none; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rank-badge {
  display: inline-grid; place-items: center; min-width: 28px; height: 24px; padding: 0 6px;
  border-radius: var(--r-sm); background: var(--primary); color: var(--on-primary);
  font-size: var(--fs-xs); font-weight: 800;
}
.chip-focus { background: var(--primary-soft); color: var(--primary-text); }
.chip-coral { background: var(--coral-soft); color: var(--coral-text); }
.chip-status { min-height: 24px; position: relative; }
.chip-status::after { content: ''; position: absolute; inset: -12px -4px; } /* área de toque */
.chip-status.status-doing { background: var(--coral-soft); color: var(--coral-text); }

.rename { display: flex; gap: 8px; align-items: center; }
.input-inline { min-height: 44px; padding: 8px 12px; }
.rename .btn { flex: none; }

.collapse-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 56px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--text);
  font-size: var(--fs-body); font-weight: 600; text-align: left;
}
.collapse-head + .task-list { margin-top: 12px; }
.collapse-icon {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text-2);
}
.collapse-icon.done { color: var(--success-text); }

.btn-sm { min-height: 40px; padding: 6px 14px; font-size: var(--fs-sm); position: relative; }
.btn-sm::after { content: ''; position: absolute; inset: -4px 0; } /* área de toque de 48px */
.lead { margin: 6px 0 20px; color: var(--text-2); }

/* ---------- seleção ---------- */
.pick-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.pick-count { margin-left: auto; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.pick-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pick-item {
  display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 12px 16px;
  border: 1.5px solid var(--line); border-radius: 20px; background: var(--surface);
  box-shadow: var(--shadow-1); cursor: pointer; position: relative;
}
.pick-item.on { border-color: var(--primary); }
.pick-box { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick-box:focus-visible + .pick-mark { outline: 3px solid var(--primary); outline-offset: 2px; }
.pick-mark {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px;
  border: 2px solid var(--line); border-radius: var(--r-full); color: transparent;
}
.pick-item.on .pick-mark { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pick-title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- duelo ---------- */
.duel-top { margin-bottom: 12px; }
.duel-progress { display: flex; flex-direction: column; align-items: center; gap: 10px; }
/* <progress> nativo: dispensa style inline (bloqueado pela CSP). */
.progress {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border: 0; border-radius: var(--r-full);
  background: var(--surface-2); overflow: hidden;
}
.progress::-webkit-progress-bar { background: var(--surface-2); border-radius: var(--r-full); }
.progress::-webkit-progress-value { background: linear-gradient(90deg, var(--primary), var(--coral)); border-radius: var(--r-full); transition: width 0.25s; }
.progress::-moz-progress-bar { background: linear-gradient(90deg, var(--primary), var(--coral)); border-radius: var(--r-full); }
.duel-question { text-align: center; font-size: var(--fs-h1); font-weight: 800; letter-spacing: -0.03em; margin: 8px 0 20px; }

.duel { display: flex; flex-direction: column; align-items: stretch; position: relative; }
.duel-card {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px;
  min-height: clamp(150px, 26dvh, 240px); padding: 24px 20px;
  border: 0; border-radius: var(--r-xl); text-align: center;
  box-shadow: var(--shadow-2); transition: transform 0.1s;
}
.duel-card:active { transform: scale(0.98); }
.duel-a { background: var(--duel-a); color: var(--on-duel-a); }
.duel-b { background: var(--duel-b); color: var(--on-duel-b); }
.duel-label {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: var(--r-full);
  background: rgb(255 255 255 / 0.2); font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.duel-title { font-size: clamp(1.35rem, 6vw, 1.85rem); font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.duel-or {
  position: relative; align-self: center; display: grid; place-items: center; width: 52px; height: 52px; margin: -16px 0; z-index: 1;
  border-radius: var(--r-full); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2);
  font-weight: 800; font-size: var(--fs-sm); letter-spacing: 0.04em;
}
.duel-escape { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: 24px; }
.duel-tie { min-height: 52px; font-size: var(--fs-body); }

/* ---------- ranking ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rank-row {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 8px 12px 16px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-1);
}
.rank-pos { flex: none; min-width: 2.6em; font-weight: 800; }
.rank-title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }

.result-title { font-size: var(--fs-display); font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; margin-bottom: 16px; }
.rank-row.is-top { border: 2px solid var(--primary); box-shadow: var(--shadow-2); }
.rank-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.result-links { display: flex; justify-content: center; margin-top: 16px; }

/* ---------- modo foco ---------- */
.focus-card {
  margin-top: 8px; padding: 28px 24px 20px;
  border: 1px solid var(--line); border-radius: 28px;
  background: radial-gradient(120% 80% at 0% 100%, var(--coral-soft) 0%, transparent 55%), var(--surface);
  box-shadow: var(--shadow-2);
}
.focus-title { margin: 8px 0 28px; font-size: clamp(2rem, 9vw, 2.6rem); font-weight: 800; line-height: 1.12; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.focus-next {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-radius: var(--r-lg); background: var(--surface-2);
}
.focus-next-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-full); background: var(--primary-soft); color: var(--primary-text); flex: none; }
.focus-next-label { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.focus-next-title { font-weight: 600; overflow-wrap: anywhere; }
.focus-hint { margin-top: 20px; text-align: center; font-size: var(--fs-sm); color: var(--text-2); }
#app:has(.focus-card) { padding-bottom: calc(180px + env(safe-area-inset-bottom)); }

.all-done { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 48px; text-align: center; }
.all-done-emoji { font-size: 4rem; line-height: 1; }

/* ---------- triagem ---------- */
.center { text-align: center; }
.triage-count { text-align: right; font-weight: 700; color: var(--text-2); }
.triage-question { margin-top: 24px; margin-bottom: 4px; }
.triage-card {
  display: flex; align-items: center; min-height: clamp(180px, 30dvh, 260px); padding: 28px 24px;
  border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-2);
}
.triage-title { font-size: clamp(1.5rem, 7vw, 2rem); font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.triage-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.triage-btn { min-height: 60px; font-size: var(--fs-body); font-weight: 700; }
.triage-btn.btn-primary { box-shadow: var(--shadow-cta); }

/* ---------- tela da tarefa ---------- */
.task-open {
  display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer;
  min-height: 24px;
}
.task-open:hover { color: var(--primary-text); }
.task-heading { font-size: var(--fs-display); font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; margin-bottom: 16px; overflow-wrap: anywhere; }
.context { margin-bottom: 4px; font-weight: 600; overflow-wrap: anywhere; }
.chip-done { background: var(--success-soft); color: var(--success-text); }
.progress-card {
  display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-1);
}
.sub-card { align-items: center; padding-top: 8px; padding-bottom: 8px; }
.sub-card .check-btn { margin: 0; }
.rank-badge.sm { min-width: 24px; height: 22px; margin-right: 4px; vertical-align: 1px; background: var(--coral-soft); color: var(--coral-text); }
.task-footer { display: flex; justify-content: center; margin: 8px 0 16px; }
.sub-card .task-title { display: flex; align-items: flex-start; gap: 8px; }
.sub-card .rank-badge.sm { margin: 1px 0 0; flex: none; }
.sub-open { flex: 1; min-width: 0; font-weight: inherit; line-height: inherit; }
.focus-context { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-sm); margin-bottom: 8px; }

/* ---------- ajustes ---------- */
.settings-card { padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-1); }
.label-caps { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.backup-date { font-size: var(--fs-h3); font-weight: 700; }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-sm); }
.note .icon-xs { margin-top: 3px; }
.btn-block { width: 100%; min-height: 52px; font-size: var(--fs-body); }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.radio-row { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 6px 2px; cursor: pointer; }
.radio-row + .radio-row { border-top: 1px solid var(--line); }
.radio-row input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.danger-title { color: var(--danger); }
.footer-note { margin-top: 8px; text-align: center; font-size: var(--fs-xs); color: var(--text-2); }
.banner-error { background: var(--danger-soft); color: var(--danger); }
.banner-ok { background: var(--primary-soft); color: var(--primary-text); }
.banner-backup { background: var(--primary-soft); color: var(--primary-text); }
.banner-backup .icon-btn { color: var(--primary-text); }
.link-btn { padding: 0 2px; border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; min-height: 32px; }
