:root {
  --bg: #f6f8f7;
  --surface: #fff;
  --text: #1c2420;
  --muted: #5b6761;
  --border: #dfe5e2;
  --accent: #1f7a4d;
  --accent-dark: #17613c;
  --tint: #e8f4ed;
  --danger: #b42318;
  --l-green: #2f9e63;
  --l-yellow: #d9a406;
  --l-red: #d64545;
  --l-blue: #3b7dd8;
  --l-gray: #8a948e;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  display: flex;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* buttons */
.btn {
  font: inherit; color: var(--text); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 6px 10px; cursor: pointer; text-align: left;
  transition: background .12s, color .12s;
}
.btn:hover { background: var(--tint); }
.btn.primary { background: var(--accent); color: #fff; text-align: center; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger:hover { color: var(--danger); background: transparent; }

/* sidebar */
.sidebar {
  width: 220px; flex: none; display: flex; flex-direction: column; gap: 8px;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { margin: 0 0 8px 10px; font-size: 16px; font-weight: 650; color: var(--accent); }
.board-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.board-item {
  font: inherit; color: var(--text); background: transparent; border: 0;
  border-left: 3px solid transparent; border-radius: var(--radius);
  padding: 6px 10px; text-align: left; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.board-item:hover { background: var(--tint); }
.board-item.active { background: var(--tint); border-left-color: var(--accent); color: var(--accent-dark); font-weight: 600; }
.badge {
  margin-left: 6px; padding: 0 6px; border-radius: 9px; font-size: 12px; font-weight: 600;
  background: var(--accent); color: #fff;
}
.sidebar-foot { margin-top: auto; display: flex; gap: 4px; }
.sidebar-foot .btn { flex: 1; text-align: center; color: var(--muted); }

/* main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; }
.board-title {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; font-weight: 650; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius); padding: 4px 8px;
}
.search {
  width: 220px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px;
}
.board-title:hover, .list-title:hover, .add-card-input:hover, .add-list-input:hover { background: var(--tint); }
.board-title:focus, .list-title:focus, .add-card-input:focus, .add-list-input:focus,
.search:focus { background: var(--surface); border-color: var(--accent); outline: none; }
.search:focus-visible, .board-title:focus-visible, .list-title:focus-visible,
.add-card-input:focus-visible, .add-list-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* lists */
.lists {
  flex: 1; min-height: 0; display: flex; align-items: flex-start; gap: 12px;
  padding: 4px 20px 20px; overflow-x: auto; overflow-y: hidden;
}
.list {
  flex: none; width: 280px; max-height: 100%; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px;
}
.list-head { display: flex; align-items: center; gap: 4px; padding: 0 0 6px; cursor: grab; }
/* Pan stays allowed so fingers scroll; app.js blocks scrolling (touchmove) only once a drag has started. */
.card, .list-head { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.list-title { user-select: text; -webkit-user-select: text; }
.list-title {
  flex: 1; min-width: 0; font: inherit; font-weight: 600; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius); padding: 4px 6px;
}
.list-count { font-size: 12px; color: var(--muted); padding: 0 4px; }
.list-del {
  flex: none; font: inherit; font-size: 18px; line-height: 1; color: var(--muted); background: transparent;
  border: 0; border-radius: var(--radius); width: 26px; height: 26px; cursor: pointer;
}
.list-del:hover { color: var(--danger); background: var(--tint); }

.cards {
  flex: 1; min-height: 40px; display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; padding: 2px; border-radius: var(--radius);
}
.cards.drag-over { background: var(--tint); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.dragging { opacity: .45; }
.drag-ghost { position: fixed; z-index: 10; margin: 0; pointer-events: none; box-shadow: 0 8px 30px rgba(0, 0, 0, .12); }
.card-label { display: block; width: 32px; height: 4px; border-radius: 2px; margin-bottom: 6px; }
.card-title { margin: 0; overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.card-due.overdue { color: var(--danger); font-weight: 600; }
.card-check.complete { color: var(--accent); font-weight: 600; }

[data-label="green"] { background: var(--l-green); }
[data-label="yellow"] { background: var(--l-yellow); }
[data-label="red"] { background: var(--l-red); }
[data-label="blue"] { background: var(--l-blue); }
[data-label="gray"] { background: var(--l-gray); }

.add-card { margin-top: 6px; }
.add-card-input, .add-list-input {
  width: 100%; font: inherit; color: var(--text); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius); padding: 6px 8px;
}
.add-card-input::placeholder, .add-list-input::placeholder, .search::placeholder { color: var(--muted); }
.add-list { background: transparent; border-style: dashed; padding: 4px; }

/* views: Prazos / Arquivados */
.view-title { flex: 1; min-width: 0; margin: 0; padding: 4px 8px; font-size: 18px; font-weight: 650; }
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 20px; }
.view-group { max-width: 720px; }
.view-group-title {
  margin: 12px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.view-empty { color: var(--muted); padding: 0 8px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 6px; padding: 8px 10px;
  font: inherit; color: var(--text); text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
button.row { cursor: pointer; }
button.row:hover { border-color: var(--accent); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { overflow-wrap: anywhere; }
.row-where { font-size: 12px; color: var(--muted); }
.row .card-due { font-size: 12px; color: var(--muted); }
.row .card-due.overdue { color: var(--danger); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
}
.toast:empty { display: none; }
.toast .btn { color: var(--accent); font-weight: 600; }

/* dialog */
.card-dialog {
  width: min(480px, calc(100vw - 32px)); padding: 20px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
}
.card-dialog::backdrop { background: rgba(20, 30, 25, .35); }
#card-form { display: flex; flex-direction: column; gap: 14px; }
#card-title {
  font: inherit; font-size: 17px; font-weight: 650; color: var(--text);
  border: 1px solid transparent; border-radius: var(--radius); padding: 4px 6px; margin: 0 -6px;
}
#card-title:hover { background: var(--tint); }
#card-title:focus { border-color: var(--accent); background: var(--surface); outline: none; }
#card-desc, #card-due {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px;
}
#card-desc { resize: vertical; }
#card-desc:focus, #card-due:focus { border-color: var(--accent); outline: none; }
#card-form > label { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.label-picker { display: flex; gap: 8px; align-items: center; border: 0; padding: 0; margin: 0; }
.label-picker legend { float: left; padding: 0; margin-right: 8px; color: var(--muted); }
.label-opt { position: relative; cursor: pointer; }
.label-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch {
  display: block; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.swatch[data-label=""] { background: var(--surface); }
.label-opt input:checked + .swatch { box-shadow: 0 0 0 2px var(--accent); }
.label-opt input:focus-visible + .swatch { outline: 2px solid var(--accent); outline-offset: 3px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dialog-actions .btn { text-align: center; }
.dialog-actions #card-archive { margin-right: auto; }

.checklist { display: flex; flex-direction: column; gap: 4px; border: 0; padding: 0; margin: 0; }
.checklist legend { padding: 0; margin-bottom: 4px; color: var(--muted); }
.checklist-items { display: flex; flex-direction: column; gap: 2px; list-style: none; margin: 0; padding: 0; }
.check-item { display: flex; align-items: center; gap: 6px; }
.check-item input[type="checkbox"] { flex: none; width: 16px; height: 16px; margin: 0 4px; accent-color: var(--accent); }
.check-text, #checklist-new {
  flex: 1; min-width: 0; font: inherit; color: var(--text); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius); padding: 4px 6px;
}
.check-item:has(:checked) .check-text { color: var(--muted); text-decoration: line-through; }
.check-text:hover, #checklist-new:hover { background: var(--tint); }
.check-text:focus, #checklist-new:focus { background: var(--surface); border-color: var(--accent); outline: none; }
#checklist-new::placeholder { color: var(--muted); }

/* narrow: sidebar becomes a top strip */
@media (max-width: 700px) {
  body { flex-direction: column; }
  .sidebar {
    width: auto; flex-direction: row; align-items: center; gap: 8px; overflow-x: auto;
    padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { margin: 0 8px 0 0; }
  .board-list { flex-direction: row; overflow: visible; }
  .board-item { border-left: 0; border-bottom: 3px solid transparent; flex: none; }
  .board-item.active { border-bottom-color: var(--accent); }
  .sidebar-foot { margin: 0 0 0 auto; }
  .btn, .sidebar .btn { flex: none; white-space: nowrap; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; }
  .search { width: 100%; order: 3; }
  .lists { padding: 4px 12px 12px; scroll-snap-type: x proximity; scroll-padding-left: 12px; }
  .list { width: min(300px, 86vw); scroll-snap-align: start; }
  /* abaixo de 16px o Safari do iOS dá zoom na página ao focar o campo */
  input, textarea { font-size: 16px !important; }
  .list-del { width: 36px; height: 36px; }
}

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