/* Tema escuro colorido, no estilo Trello */
:root {
  --text: #e6e9ee;
  --muted: #9fadbc;
  --col: rgba(16, 18, 22, .9);
  --surface: #22272b;
  --field: #1b1f23;
  --line: #3a434d;
  --hover: rgba(255, 255, 255, .08);
  --accent: #4bce97;
  --accent-ink: #0b1a13;
  --danger: #f87168;
  --danger-soft: rgba(248, 113, 104, .18);
  --shadow: 0 1px 1px rgba(0, 0, 0, .35), 0 0 1px rgba(0, 0, 0, .4);
  --shadow-lift: 0 14px 34px rgba(0, 0, 0, .6);
  --radius: 10px;
  --col-w: 272px;

  /* cores das tarefas */
  --verde: #1f845a;
  --amarelo: #946f00;
  --laranja: #c25100;
  --vermelho: #c9372c;
  --roxo: #6e5dc6;
  --azul: #0c66e4;
  --ceu: #227d9b;
  --lima: #5b7f24;
  --rosa: #ae4787;
  --cinza: #596773;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: #1d2125;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
button:focus:not(:focus-visible) { outline: none; }

/* ---------- fundos do quadro ---------- */
.bg-floresta   { background: linear-gradient(135deg, #0b3d2e 0%, #1f845a 55%, #7ee2b8 130%) fixed; }
.bg-oceano     { background: linear-gradient(135deg, #09326c 0%, #0c66e4 55%, #6cc3e0 130%) fixed; }
.bg-aurora     { background: linear-gradient(135deg, #352c63 0%, #6e5dc6 45%, #1f845a 120%) fixed; }
.bg-por-do-sol { background: linear-gradient(135deg, #5d1f1a 0%, #c9372c 45%, #f5a623 120%) fixed; }
.bg-noite      { background: linear-gradient(160deg, #0c1220 0%, #1c2b4a 60%, #3b2e5a 120%) fixed; }
.bg-lavanda    { background: linear-gradient(135deg, #50253f 0%, #ae4787 50%, #9f8fef 120%) fixed; }
.bg-grafite    { background: linear-gradient(160deg, #161a1d 0%, #2c333a 60%, #454f59 120%) fixed; }
.bg-img        { background-color: #1d2125; background-size: cover; background-position: center; background-attachment: fixed; }

/* ---------- botões ---------- */
.btn {
  border: 0; background: rgba(255, 255, 255, .14); color: #fff; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; min-height: 36px; justify-content: center; font-size: 14px; font-weight: 500;
}
.btn:hover { background: rgba(255, 255, 255, .24); }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn-primary:hover { background: #7ee2b8; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 104, .3); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; }
.btn-late { white-space: nowrap; background: #c9372c; color: #fff; font-weight: 700; font-size: 13px; }
.btn-late:hover { background: #e2483d; }
.btn-late[hidden] { display: none; }
.icon-btn {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 8px;
  display: inline-grid; place-items: center; cursor: pointer; color: inherit; font-size: 18px;
}
.icon-btn:hover { background: var(--hover); }

/* ---------- campos ---------- */
.auth-card label, .field { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=url], input:not([type]), select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--field); border-radius: 8px;
  padding: 8px 10px; font-size: 15px; color: var(--text); min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #579dff; outline-offset: -1px; border-color: transparent; }

/* ---------- login / instalação ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card {
  width: 100%; max-width: 360px; background: rgba(22, 26, 29, .92); border-radius: 16px;
  padding: 28px 24px; box-shadow: var(--shadow-lift); backdrop-filter: blur(6px);
}
.auth-card h1 { margin: 0 0 16px; font-size: 22px; text-align: center; }
.auth-logo {
  width: 54px; height: 54px; border-radius: 14px; margin: 0 auto 12px;
  background: linear-gradient(135deg, #1f845a, #4bce97); color: #fff;
  display: grid; place-items: center; font-size: 28px; font-weight: 800;
}
.auth-card form { display: grid; gap: 14px; }
.auth-msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.auth-msg.err { background: var(--danger-soft); color: var(--danger); }
.auth-msg.ok { background: rgba(75, 206, 151, .16); color: var(--accent); }

/* ---------- topo ---------- */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px; color: #fff;
  padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(0, 0, 0, .32); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 17px; margin-right: auto; display: flex; align-items: center; gap: 8px; letter-spacing: .2px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #1f845a, #4bce97);
  display: grid; place-items: center; font-size: 15px; box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.weeknav { display: flex; align-items: center; gap: 4px; }
.weeknav .range { min-width: 150px; text-align: center; font-weight: 700; font-size: 14px; }
.toolbar { display: flex; align-items: center; gap: 6px; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.toolbar select {
  min-height: 36px; width: auto; padding: 6px 8px; font-size: 14px; border: 0;
  background: rgba(255, 255, 255, .14); color: #fff;
}
.toolbar select option { background: var(--surface); color: var(--text); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }

/* ---------- quadro ---------- */
.board {
  flex: 1; display: flex; gap: 12px; padding: 14px 16px 16px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; overscroll-behavior-x: contain; align-items: flex-start;
}
.col {
  flex: 0 0 var(--col-w); display: flex; flex-direction: column; max-height: 100%;
  background: var(--col); border-radius: 14px; scroll-snap-align: start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25); position: relative; overflow: hidden;
}
.col::before { content: ""; display: block; height: 4px; background: var(--c, var(--cinza)); }
.col.today { box-shadow: 0 0 0 2px #fff, 0 4px 16px rgba(0, 0, 0, .35); }
.col-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 8px; }
.col-name { font-weight: 800; font-size: 14px; text-transform: capitalize; }
.col-date { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.today-pill {
  font-size: 10.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  background: #fff; color: #172b4d; border-radius: 4px; padding: 1px 5px;
}
.col.overdue .col-name { color: var(--danger); }
.col-count {
  margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 700;
  border-radius: 20px; padding: 1px 8px; min-width: 22px; text-align: center; background: var(--hover);
}
.col-list { flex: 0 1 auto; overflow-y: auto; padding: 2px 8px 4px; display: flex; flex-direction: column; gap: 8px; min-height: 12px; }
.col-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 6px 4px; }
.col-add { padding: 6px 8px 10px; }
.col-add input {
  background: transparent; border: 0; min-height: 36px; font-size: 14px; color: var(--muted);
}
.col-add input::placeholder { color: var(--muted); }
.col-add input:hover { background: var(--hover); }
.col-add input:focus { background: var(--field); color: var(--text); }

/* ---------- cartão colorido ---------- */
.c-verde { --c: var(--verde); } .c-amarelo { --c: var(--amarelo); } .c-laranja { --c: var(--laranja); }
.c-vermelho { --c: var(--vermelho); } .c-roxo { --c: var(--roxo); } .c-azul { --c: var(--azul); }
.c-ceu { --c: var(--ceu); } .c-lima { --c: var(--lima); } .c-rosa { --c: var(--rosa); } .c-cinza { --c: var(--cinza); }

.card {
  background: var(--c, var(--cinza)); color: #fff; border-radius: var(--radius); padding: 9px 10px 9px 20px;
  box-shadow: var(--shadow); display: flex; gap: 8px; align-items: flex-start; cursor: pointer;
  position: relative; overflow: hidden; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; touch-action: manipulation; transition: filter .15s, transform .15s;
}
.card:hover { filter: brightness(1.1); }
/* faixa com padrão à esquerda — cada dia tem o seu */
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 11px;
  background-image: var(--pat); opacity: .85;
}
.pat-1 { --pat: repeating-linear-gradient(135deg, rgba(255,255,255,.7) 0 3px, transparent 3px 7px); }
.pat-2 { --pat: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.75) 50% 62%, transparent 62%), linear-gradient(45deg, transparent 50%, rgba(255,255,255,.75) 50% 62%, transparent 62%); background-size: 11px 9px; }
.pat-2::before { background-size: 11px 9px; }
.pat-3 { --pat: repeating-linear-gradient(0deg, rgba(255,255,255,.75) 0 2px, transparent 2px 6px); }
.pat-4 { --pat: repeating-linear-gradient(90deg, rgba(255,255,255,.7) 0 2px, transparent 2px 5px); }
.pat-5 { --pat: radial-gradient(circle, rgba(255,255,255,.8) 1.6px, transparent 2px); }
.pat-5::before { background-size: 6px 6px; background-position: 2px 1px; }
.pat-6 { --pat: repeating-linear-gradient(45deg, rgba(255,255,255,.7) 0 3px, transparent 3px 7px); }
.pat-7 { --pat: conic-gradient(rgba(255,255,255,.7) 25%, transparent 0 50%, rgba(255,255,255,.7) 0 75%, transparent 0); }
.pat-7::before { background-size: 8px 8px; }

.card.done { filter: saturate(.55) brightness(.8); }
.card.done:hover { filter: saturate(.7) brightness(.9); }
.card.done .card-title { text-decoration: line-through; opacity: .85; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 14px; font-weight: 700; line-height: 1.35; word-wrap: break-word; text-shadow: 0 1px 1px rgba(0, 0, 0, .15); }
.card-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; font-size: 12px; align-items: center; }
.meta { background: rgba(0, 0, 0, .22); border-radius: 5px; padding: 1px 6px; font-weight: 600; white-space: nowrap; }
.meta.full { background: rgba(255, 255, 255, .92); color: #1f845a; }
.meta.late { background: #fff; color: #c9372c; font-weight: 800; }
.meta.prio { background: rgba(0, 0, 0, .35); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 5px; padding: 1px 6px;
  font-size: 11.5px; font-weight: 700; background: rgba(0, 0, 0, .22);
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lc, #fff); }

.check {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .85);
  background: transparent; cursor: pointer; display: grid; place-items: center; padding: 0; margin-top: 1px;
  color: transparent; font-size: 12px; font-weight: 900;
}
.check:hover { background: rgba(255, 255, 255, .2); }
.check.on { background: #fff; border-color: #fff; color: var(--c, #1f845a); }

/* arrastar */
.card.dragging-src { opacity: .35; outline: 2px dashed #fff; box-shadow: none; }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; box-shadow: var(--shadow-lift); transform: rotate(3deg); }
.col-list.drop-target { background: rgba(255, 255, 255, .06); border-radius: 8px; min-height: 48px; }
body.is-dragging { cursor: grabbing; }
body.is-dragging .board { scroll-snap-type: none; }
.card.pressing { transform: scale(.97); }

/* ---------- painel da tarefa ---------- */
dialog.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--text);
  width: min(580px, 100%); max-height: min(90vh, 900px); border-radius: 14px; box-shadow: var(--shadow-lift);
  overflow: hidden;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.sheet-inner { display: flex; flex-direction: column; max-height: inherit; }
.sheet-cover {
  height: 64px; background: var(--c, var(--cinza)); position: relative; flex: 0 0 auto;
  display: flex; justify-content: flex-end; align-items: flex-start; padding: 8px;
}
.sheet-cover::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 18px; background-image: var(--pat); opacity: .85;
}
.sheet-cover .icon-btn { color: #fff; background: rgba(0, 0, 0, .25); }
.sheet-cover .icon-btn:hover { background: rgba(0, 0, 0, .4); }
.sheet-daypill {
  position: absolute; left: 26px; top: 10px; background: rgba(0, 0, 0, .3); color: #fff;
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; text-transform: capitalize;
}
.sheet-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 4px; }
.sheet-head .check { width: 22px; height: 22px; margin-top: 7px; border-color: var(--muted); }
.sheet-head .check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sheet-head textarea {
  border: 0; background: transparent; font-size: 20px; font-weight: 800; resize: none; padding: 4px 2px;
  min-height: 34px; line-height: 1.3; overflow: hidden;
}
.sheet-head textarea:hover { background: var(--hover); }
.sheet-body { padding: 8px 16px 16px; overflow-y: auto; display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-body textarea { min-height: 80px; resize: vertical; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 40px; height: 30px; border-radius: 6px; border: 0; cursor: pointer; background: var(--c);
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 900;
}
.swatch.auto { width: auto; padding: 0 10px; background: var(--field); border: 1px solid var(--line); color: var(--text); font-size: 12.5px; font-weight: 600; }
.swatch.sel { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #fff; }
.section-title { font-size: 14px; font-weight: 800; margin: 4px 0 -4px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.section-title .pct { font-size: 12px; color: var(--muted); font-weight: 600; }
.progress { height: 8px; background: var(--field); border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: #579dff; width: 0; transition: width .25s, background .25s; }
.progress.full > i { background: var(--accent); }
.checklist { display: grid; gap: 2px; }
.ci { display: flex; align-items: center; gap: 8px; padding: 2px 0; border-radius: 8px; }
.ci:hover { background: var(--hover); }
.ci .check { margin: 0 0 0 6px; border-color: var(--muted); border-radius: 4px; }
.ci .check.on { background: #579dff; border-color: #579dff; color: #fff; }
.ci input:not([type]) { border-color: transparent; background: transparent; min-height: 34px; padding: 5px 6px; }
.ci.done input:not([type]) { text-decoration: line-through; color: var(--muted); }
.ci .icon-btn { width: 32px; height: 32px; font-size: 14px; color: var(--muted); opacity: .6; }
.ci:hover .icon-btn { opacity: 1; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px 14px; border-top: 1px solid var(--line); gap: 8px; }
.saved-hint { font-size: 12px; color: var(--muted); }

/* ---------- escolha de fundo ---------- */
dialog.picker {
  border: 0; padding: 16px; background: var(--surface); color: var(--text); border-radius: 14px;
  width: min(380px, calc(100% - 24px)); box-shadow: var(--shadow-lift);
}
.picker h2 { margin: 0 0 12px; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.bg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.bg-opt {
  height: 54px; border-radius: 8px; border: 0; cursor: pointer; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: flex-end; padding: 5px 6px; text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  background-attachment: scroll !important;
}
.bg-opt.sel { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #fff; }
.picker form { display: grid; gap: 8px; }
.picker .row { display: flex; gap: 8px; }

/* ---------- aviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #fff; color: #172b4d; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 2000; max-width: calc(100% - 32px);
  box-shadow: var(--shadow-lift);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- celular ---------- */
@media (max-width: 720px) {
  :root { --col-w: calc(100vw - 48px); }
  .topbar { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); gap: 6px; }
  .brand { font-size: 16px; }
  .top-actions { order: 1; }
  .toolbar { order: 2; width: 100%; }
  .toolbar select { flex: 1; min-width: 0; }
  .weeknav { order: 3; width: 100%; justify-content: space-between; }
  .weeknav .range { flex: 1; }
  .board { padding: 12px 16px; gap: 10px; scroll-snap-type: x mandatory; scroll-padding: 0 16px; }
  .card-title { font-size: 15px; }
  dialog.sheet {
    width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .swatch { width: 36px; }
}
