:root {
  --board: #2B3B35;
  --board-dark: #223029;
  --panel: #40534A;
  --paper: #F3EFE4;
  --paper-dim: #E9E2D1;
  --ink: #2B3B35;
  --ink-soft: #5B6B62;
  --mustard: #D9A441;
  --rust: #B5562F;
  --sage: #6E9C6C;
  --line: rgba(243,239,228,0.14);
  --shadow: 0 10px 24px rgba(0,0,0,0.28);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--board);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.03), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255,255,255,0.03), transparent 40%);
  color: var(--paper);
  font-family: 'Karla', sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

button {
  font-family: 'Karla', sans-serif;
  cursor: pointer;
  border: none;
}
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--mustard);
  outline-offset: 2px;
}

input, select, textarea {
  font-family: 'Karla', sans-serif;
  font-size: 1rem;
  padding: 0.6em 0.8em;
  border-radius: 8px;
  border: 1px solid #cfc6ac;
  background: #fff;
  color: var(--ink);
}

/* ---------- Layout shell ---------- */

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.topbar .brand { display: flex; align-items: baseline; gap: 10px; }
.topbar .brand .display { font-size: 1.5rem; color: var(--paper); }
.topbar .brand .tag { color: var(--mustard); font-size: 0.9rem; }

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-actions .who { font-size: 0.9rem; color: var(--paper-dim); }
.linklike {
  background: none; color: var(--paper-dim); text-decoration: underline;
  text-underline-offset: 3px; font-size: 0.9rem; padding: 4px;
}
.linklike:hover { color: var(--mustard); }

/* ---------- Auth screens ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  position: relative;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%) rotate(-2deg);
  width: 46px; height: 20px;
  background: var(--mustard);
  opacity: 0.85;
}

.auth-card h1 { font-size: 1.9rem; margin-bottom: 6px; }
.auth-card p.sub { color: var(--ink-soft); margin: 0 0 26px; font-size: 0.95rem; }

.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.85rem; color: var(--ink-soft); }
.field input, .field select { width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75em 1.4em; border-radius: 8px; font-weight: 700; font-size: 0.95rem;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary { background: var(--rust); color: var(--paper); width: 100%; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(181,86,47,0.35); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid #cfc6ac; }
.btn-ghost:hover { background: rgba(0,0,0,0.04); }
.btn-small { padding: 0.45em 0.9em; font-size: 0.85rem; border-radius: 6px; }
.btn-mustard { background: var(--mustard); color: var(--board-dark); }

.switch-row { margin-top: 22px; text-align: center; font-size: 0.9rem; color: var(--ink-soft); }
.switch-row button { background: none; color: var(--rust); font-weight: 700; text-decoration: underline; }

.member-pick-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.member-chip {
  padding: 8px 14px; border-radius: 20px; background: #fff; border: 2px solid transparent;
  font-weight: 700; font-size: 0.9rem; color: var(--ink);
}
.member-chip.active { border-color: var(--rust); }

.error-msg { background: #f6dcd2; color: #7a2c11; padding: 10px 14px; border-radius: 8px; font-size: 0.88rem; margin-bottom: 14px; }

/* ---------- Quote banner ---------- */

.quote-banner {
  background: var(--panel);
  border-left: 4px solid var(--mustard);
  padding: 16px 20px;
  border-radius: 6px;
  margin-bottom: 26px;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--paper);
}

/* ---------- Week nav ---------- */

.week-nav {
  display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap;
}
.week-nav .week-label { font-size: 0.95rem; color: var(--paper-dim); }
.icon-btn {
  background: var(--panel); color: var(--paper); width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.icon-btn:hover { background: #4c6156; }

/* ---------- Member board cards ---------- */

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 26px;
}

.member-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 3px;
  box-shadow: var(--shadow);
  padding: 22px 20px 18px;
  position: relative;
}
.member-card:nth-child(odd) { transform: rotate(-0.6deg); }
.member-card:nth-child(even) { transform: rotate(0.5deg); }

.member-card .pin {
  position: absolute; top: -9px; left: 24px;
  width: 16px; height: 16px; border-radius: 50%;
  box-shadow: 0 3px 4px rgba(0,0,0,0.3);
}

.member-card .m-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.member-card .m-name { font-size: 1.25rem; }
.member-card .m-progress { font-size: 0.78rem; color: var(--ink-soft); }

.task-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0;
  border-top: 1px dashed #d8cfb8;
}
.task-row:first-of-type { border-top: none; }

.task-check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink-soft);
  flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; background: #fff;
}
.task-check.done { background: var(--sage); border-color: var(--sage); color: #fff; }
.task-check.failed { background: var(--rust); border-color: var(--rust); color: #fff; }

.task-body { flex: 1; }
.task-name { font-weight: 700; font-size: 0.95rem; }
.task-name.done { text-decoration: line-through; color: var(--ink-soft); }
.task-meta { font-size: 0.78rem; color: var(--ink-soft); margin-top: 2px; }

.task-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.reassign-select { font-family: inherit; font-size: 13px; padding: 4px 6px; border-radius: 8px; border: 1px solid rgba(43,59,53,0.25); background: #fff; color: var(--ink); }

.status-tag {
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  text-transform: none;
}
.status-tag.pendiente { background: #eee3c8; color: #8a6d1f; }
.status-tag.cumplido { background: #dcecd8; color: #33622e; }
.status-tag.incumplido { background: #f2d9cf; color: #8a3517; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 6px; margin-bottom: 24px; flex-wrap: wrap; }
.tab-btn {
  background: var(--panel); color: var(--paper-dim); padding: 9px 16px; border-radius: 20px; font-size: 0.9rem; font-weight: 700;
}
.tab-btn.active { background: var(--mustard); color: var(--board-dark); }

/* ---------- Admin panels ---------- */

.panel {
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.panel h2 { font-size: 1.3rem; margin-bottom: 4px; }
.panel .panel-sub { color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 18px; }

.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px dashed #d8cfb8;
}
.list-item:first-of-type { border-top: none; }
.list-item .li-main { display: flex; flex-direction: column; }
.li-title { font-weight: 700; }
.li-sub { font-size: 0.8rem; color: var(--ink-soft); }
.li-actions { display: flex; gap: 8px; }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; min-width: 140px; flex: 1; }

.group-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); margin: 18px 0 6px;
}

.empty-note { color: var(--ink-soft); font-size: 0.9rem; padding: 20px 0; text-align: center; }

.badge-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,26,23,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-box {
  background: var(--paper); color: var(--ink); border-radius: 8px; padding: 26px;
  max-width: 420px; width: 100%; box-shadow: var(--shadow);
}
.modal-box h3 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Congrats toast */
.congrats-toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--sage); color: #17301a; padding: 16px 24px; border-radius: 10px;
  font-family: 'Fraunces', serif; font-weight: 600; box-shadow: var(--shadow);
  z-index: 60; max-width: 90vw; text-align: center;
  animation: rise .25s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 600px) {
  .shell { padding: 18px 14px 50px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
}

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

/* Gamificación: rachas, puntos y recompensas */
.m-badges { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.badge { font-size: 0.75rem; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.badge-streak { background: #fdeecb; color: #9a5b12; }
.badge-points { background: #dfeee0; color: #2f6b34; }
.points-summary { font-size: 1.1rem; font-weight: 700; color: var(--rust); margin: 6px 0 18px; }
.task-row-ondemand .task-check { background: var(--mustard); border-color: var(--mustard); color: #3a2f10; }
