/* ── RESET & TOKENS ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream:           #FBF5EC;
  --cream-2:         #F4EADB;
  --card:            #FFFFFF;
  --card-warm:       #FFFCF6;
  --ink:             #2E2823;
  --ink-2:           #5C5147;
  --muted:           #94897C;
  --line:            #EBE0D2;
  --terracotta:      #C56A48;
  --terracotta-dark: #B0573A;
  --terracotta-soft: #F6E2D7;
  --sage:            #6E9173;
  --sage-soft:       #E2ECE0;
  --amber:           #CF9A3B;
  --amber-soft:      #F6E8CC;
  --plum:            #9A6A86;
  --plum-soft:       #EFE0E8;
  --blue:            #5E7FB0;
  --blue-soft:       #E0E7F0;
  --done:            #6E9173;

  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans:  'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --r-card:   20px;
  --r-pill:   999px;
  --r-header: 26px;
  --shadow-card: 0 1px 2px rgba(70,50,30,.04), 0 6px 18px rgba(70,50,30,.06);
  --shadow-modal: 0 8px 40px rgba(46,40,35,.18);
}

body {
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ── AUTH SCREENS ───────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(160deg, var(--terracotta) 0%, var(--terracotta-dark) 100%);
}

.auth-card {
  background: var(--card);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-modal);
}

.auth-brand {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo { font-size: 2.2rem; margin-bottom: .6rem; }
.auth-brand h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: .3rem;
}
.auth-brand p { color: var(--muted); font-size: .88rem; }

.auth-form h2 { font-size: 1rem; font-weight: 700; margin-bottom: .25rem; color: var(--ink); }
.auth-hint { color: var(--muted); font-size: .84rem; margin-bottom: 1.1rem; line-height: 1.5; }

.auth-form form label {
  display: block;
  font-size: .84rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: .85rem;
}
.auth-form form input {
  display: block;
  width: 100%;
  margin-top: .3rem;
  padding: .6rem .85rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: .92rem;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--cream);
  transition: border-color .15s;
}
.auth-form form input:focus {
  outline: none;
  border-color: var(--terracotta);
  background: #fff;
}

.btn-auth {
  display: block;
  width: 100%;
  margin-top: .75rem;
  padding: .7rem 1rem;
  background: var(--terracotta);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: .93rem;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background .15s;
}
.btn-auth:hover { background: var(--terracotta-dark); }

.form-error { color: #c0392b; font-size: .82rem; margin-top: .5rem; }

/* ── APP WRAPPER ────────────────────────────────────────────── */
.app-wrap {
  max-width: 760px;
  margin: 0 auto;
}

/* ── APP HEADER BANNER ──────────────────────────────────────── */
.app-header {
  background: linear-gradient(160deg, var(--terracotta) 0%, var(--terracotta-dark) 100%);
  color: #fff;
  border-radius: 0 0 var(--r-header) var(--r-header);
  position: relative;
  overflow: visible;
}

.app-header-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem 1.25rem 1rem;
}

.app-header-left { flex: 1; min-width: 0; }

.proj-switcher {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #fff;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.2;
  text-align: left;
  min-height: 44px;
}
.proj-switcher:hover { opacity: .88; }
.proj-chevron { flex-shrink: 0; transition: transform .2s; }
.proj-switcher[aria-expanded="true"] .proj-chevron { transform: rotate(180deg); }

.app-tagline {
  font-size: .8rem;
  opacity: .75;
  margin-top: .25rem;
  font-style: italic;
  font-family: var(--font-serif);
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.role-badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: var(--r-pill);
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: rgba(255,255,255,.22);
  color: #fff;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.35);
  letter-spacing: .03em;
}
.avatar-sm { width: 26px; height: 26px; font-size: .65rem; border-width: 1.5px; }

/* Profile avatar button + dropdown */
.profile-wrap { position: relative; }

.profile-avatar-btn {
  cursor: pointer;
  border: 2px solid rgba(255,255,255,.45);
  background: var(--terracotta-dark);
  transition: border-color .15s;
}
.profile-avatar-btn:hover { border-color: rgba(255,255,255,.8); }

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--line);
  min-width: 190px;
  z-index: 300;
  overflow: hidden;
  padding: .5rem 0;
}

.profile-menu-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink);
  padding: .55rem 1rem .3rem;
}

.role-badge-sm {
  display: inline-block;
  margin: 0 1rem .55rem;
  padding: .15rem .55rem;
  border-radius: var(--r-pill);
  font-size: .66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.profile-divider {
  height: 1px;
  background: var(--line);
  margin: .35rem 0;
}

.pmenu-action {
  display: block;
  width: 100%;
  padding: .55rem 1rem;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--font-sans);
  font-size: .86rem;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .12s;
  min-height: 38px;
}
.pmenu-action:hover { background: var(--cream); color: var(--ink); }
.pmenu-signout { color: var(--terracotta); }
.pmenu-signout:hover { background: var(--terracotta-soft); color: var(--terracotta-dark); }

/* Progress bar */
.header-prog-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.25rem 1.1rem;
}
.prog-label {
  font-size: .72rem;
  font-weight: 600;
  opacity: .8;
  white-space: nowrap;
  min-width: 80px;
}
.prog-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,.25);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: rgba(255,255,255,.85);
  border-radius: var(--r-pill);
  transition: width .4s ease;
}

/* Project dropdown menu */
.proj-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 1.25rem;
  right: 1.25rem;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-modal);
  z-index: 200;
  overflow: hidden;
  border: 1px solid var(--line);
}
.pmenu-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .75rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.pmenu-item:last-child { border-bottom: none; }
.pmenu-item:hover { background: var(--cream); }
.pmenu-item.active { background: var(--cream-2); }
.pmenu-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pmenu-name { flex: 1; font-size: .9rem; font-weight: 600; }
.pmenu-count { font-size: .78rem; color: var(--muted); }
.pmenu-mini-prog {
  width: 60px;
  height: 3px;
  background: var(--line);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.pmenu-mini-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--sage);
}

/* ── FILTER STRIP ───────────────────────────────────────────── */
.filter-wrap {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--cream);
  padding: .6rem 1rem .5rem;
  border-bottom: 1px solid transparent;
}

.filter-strip {
  display: flex;
  align-items: center;
  gap: .4rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}
.filter-strip::-webkit-scrollbar { display: none; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .38rem .85rem;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 34px;
  flex-shrink: 0;
  transition: background .12s, color .12s, border-color .12s;
}
.filter-chip:hover { border-color: var(--muted); }
.filter-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.chip-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--chip-dot, var(--muted));
  flex-shrink: 0;
}
.filter-chip.active .chip-dot { background: rgba(255,255,255,.7); }

.filter-chip.add-chip {
  border-color: var(--terracotta-soft);
  color: var(--terracotta);
  background: var(--terracotta-soft);
  font-weight: 700;
}
.filter-chip.add-chip:hover {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: #fff;
}

.mobile-admin-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding-top: .45rem;
}
.sm-lnk {
  background: none;
  border: none;
  color: var(--terracotta);
  font-family: var(--font-sans);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  min-height: 32px;
}
.sm-lnk:hover { text-decoration: underline; }
.mobile-admin-sep { color: var(--line); font-size: .9rem; }

/* ── TASK CONTAINER ─────────────────────────────────────────── */
.task-container {
  padding: .75rem 1rem 6rem;
}

/* ── TASK GROUPS ────────────────────────────────────────────── */
.task-group { margin-bottom: 1.5rem; }
.task-group--done { opacity: .65; }

.task-group-hd {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  margin-bottom: .6rem;
  padding: 0 .25rem;
}
.task-group-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  font-style: italic;
  color: var(--ink-2);
}
.task-group-count {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--cream-2);
  padding: .1rem .45rem;
  border-radius: var(--r-pill);
}
.task-group-empty {
  font-size: .84rem;
  color: var(--muted);
  font-style: italic;
  padding: .5rem .25rem .75rem;
  font-family: var(--font-serif);
}
.task-empty-all {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
}

/* ── TASK CARDS ─────────────────────────────────────────────── */
.task-card {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  background: var(--card);
  border-radius: var(--r-card);
  padding: .95rem 1rem;
  margin-bottom: .55rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
}
.task-card:hover { box-shadow: 0 2px 4px rgba(70,50,30,.06), 0 10px 28px rgba(70,50,30,.09); }
.task-card:active { transform: scale(.995); }
.task-card--done { background: var(--card-warm); }

/* Circular checkbox */
.task-cb {
  width: 26px; height: 26px;
  min-width: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.task-cb:hover { border-color: var(--muted); }
.task-cb svg { display: block; }

/* Card body */
.task-body { flex: 1; min-width: 0; }

.task-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .45rem;
  flex-wrap: wrap;
}
.task-chips-left {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.task-chips-right { flex-shrink: 0; }

/* Category chip (in card) */
.cat-chip {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: var(--r-pill);
  font-size: .71rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
/* Project chip (in card, shown in All-projects scope) */
.proj-chip {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: var(--r-pill);
  font-size: .71rem;
  font-weight: 600;
  background: var(--cream-2);
  color: var(--muted);
  white-space: nowrap;
  border: 1px solid var(--line);
}

/* Due / Done pills */
.due-pill {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: var(--r-pill);
  font-size: .71rem;
  font-weight: 700;
  white-space: nowrap;
}
.due-pill--far  { background: var(--cream-2); color: var(--muted); }
.due-pill--soon { background: var(--amber-soft); color: #8a5e00; }
.due-pill--overdue { background: var(--terracotta-soft); color: var(--terracotta-dark); }
.done-pill { display: inline-block; padding: .18rem .6rem; border-radius: var(--r-pill); font-size: .71rem; font-weight: 700; background: var(--sage-soft); color: var(--sage); white-space: nowrap; }

/* Task title */
.task-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: .3rem;
}
.task-title--done {
  text-decoration: line-through;
  color: var(--muted);
}

/* Task description */
.task-desc {
  font-size: .8rem;
  color: var(--ink-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: .4rem;
}

/* Footer */
.task-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .35rem;
}
.task-owner {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.owner-name {
  font-size: .78rem;
  color: var(--ink-2);
  font-weight: 600;
}
.card-comments {
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .2rem;
}

/* Card action area — lives inside task-foot, bottom-right */
.card-action-area {
  position: relative;
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.card-more-btn {
  width: 32px; height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background .12s, color .12s;
}
.card-more-btn:hover { background: var(--cream-2); color: var(--ink); }

.card-actions {
  display: none;
  align-items: center;
  gap: .25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .3rem .35rem;
  box-shadow: 0 4px 14px rgba(70,50,30,.12);
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 10;
  white-space: nowrap;
}

.task-card.menu-open .card-more-btn { background: var(--cream-2); color: var(--ink); }
.task-card.menu-open .card-actions { display: flex; }

.card-act-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--ink-2);
  padding: .3rem .55rem;
  border-radius: 7px;
  min-height: 32px;
  transition: background .12s;
}
.card-act-btn:hover { background: var(--cream); }
.card-act-del { color: var(--terracotta); }
.card-act-del:hover { background: var(--terracotta-soft); }

/* Card comment thread button */
.card-thread-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .75rem;
  color: var(--muted);
  padding: .15rem .4rem;
  border-radius: 6px;
  transition: background .12s, color .12s;
  white-space: nowrap;
  font-family: var(--font-sans);
}
.card-thread-btn:hover,
.card-thread-btn.has-comments { color: var(--ink-2); }
.card-thread-btn.has-comments { font-weight: 600; }

/* Note pill (legacy comments field) */
.card-note-pill {
  font-size: .72rem;
  color: var(--muted);
  cursor: default;
}

/* ── Card wrap + comment thread ─────────────────────────────── */
.card-wrap { margin-bottom: .55rem; }
.card-wrap .task-card { margin-bottom: 0; }
.card-wrap.thread-open .task-card {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}

.comment-thread {
  display: none;
  background: var(--cream);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--r-card) var(--r-card);
  padding: .75rem 1rem .8rem 1.1rem;
}
.comment-thread.open { display: block; }

.comment-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-bottom: .65rem;
}

.comment-empty,
.comment-loading {
  font-size: .8rem;
  color: var(--muted);
  font-style: italic;
  margin: 0 0 .65rem;
}

.comment-item {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}

.comment-content { flex: 1; min-width: 0; }

.comment-meta {
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-bottom: .1rem;
}

.comment-author {
  font-size: .75rem;
  font-weight: 700;
  color: var(--ink);
}

.comment-time {
  font-size: .7rem;
  color: var(--muted);
}

.comment-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1;
  padding: 0 .2rem;
  border-radius: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity .12s, color .12s;
}
.comment-item:hover .comment-del { opacity: 1; }
.comment-del:hover { color: var(--terracotta); }

.comment-body {
  font-size: .82rem;
  color: var(--ink-2);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.mention {
  color: var(--terracotta);
  font-weight: 600;
  background: var(--terracotta-soft);
  border-radius: 4px;
  padding: 0 .15rem;
}

/* Comment compose */
.comment-compose {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  border-top: 1px solid var(--line);
  padding-top: .6rem;
}

.compose-wrap { flex: 1; position: relative; }

.compose-input {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: .4rem .65rem;
  font-size: .82rem;
  font-family: var(--font-sans);
  color: var(--ink);
  resize: none;
  overflow: hidden;
  min-height: 34px;
  max-height: 120px;
  line-height: 1.4;
  display: block;
}
.compose-input:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px var(--terracotta-soft);
}

.compose-send {
  background: var(--terracotta);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  padding: .4rem .75rem;
  font-size: .78rem;
  font-weight: 700;
  font-family: var(--font-sans);
  min-height: 34px;
  flex-shrink: 0;
  transition: background .12s;
  align-self: flex-end;
}
.compose-send:hover { background: #a85230; }

/* @mention dropdown */
.mention-drop {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(70,50,30,.12);
  overflow: hidden;
  min-width: 140px;
}
.mention-drop.hidden { display: none; }

.mention-candidate {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: .4rem .65rem;
  font-size: .82rem;
  font-family: var(--font-sans);
  color: var(--ink);
  cursor: pointer;
}
.mention-candidate:hover { background: var(--cream-2); }

/* ── FAB ────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  padding: .7rem 1.4rem;
  font-family: var(--font-sans);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(46,40,35,.28);
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.fab:hover { background: #1a1410; }

/* ── MODALS ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(46,40,35,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
  padding: 0;
}

.modal {
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 1.5rem 1.25rem 2rem;
  width: 100%;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
/* drag handle hint */
.modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 0 auto .9rem;
}

.modal-wide { max-width: 100%; }
.modal-sm   { max-width: 100%; }

.modal-heading {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: .3rem;
}
.modal-subtitle {
  font-size: .84rem;
  color: var(--muted);
  margin-bottom: 1.1rem;
  line-height: 1.55;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1.2rem;
}

/* ── FORM ELEMENTS ──────────────────────────────────────────── */
.form-field { margin-bottom: .9rem; }

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: .4rem;
}
.field-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: .76rem;
}
.required { color: var(--terracotta); }

.form-input {
  display: block;
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: .9rem;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--cream);
  transition: border-color .15s, background .15s;
}
.form-input:focus { outline: none; border-color: var(--terracotta); background: #fff; }
.form-input[readonly] { color: var(--muted); cursor: default; }

.form-select {
  display: block;
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: .9rem;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--cream);
  cursor: pointer;
  transition: border-color .15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2394897C' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  padding-right: 2.2rem;
}
.form-select:focus { outline: none; border-color: var(--terracotta); background-color: #fff; }

.form-textarea { min-height: 64px; resize: vertical; line-height: 1.5; }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}

.project-new-input { margin-top: .45rem; }

/* Category chip picker */
.cat-picker {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .3rem;
}
.cat-pick-chip {
  padding: .28rem .7rem;
  border-radius: var(--r-pill);
  border: 1.5px solid transparent;
  font-size: .78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: opacity .12s;
  min-height: 32px;
}
.cat-pick-chip:hover { opacity: .82; }
.cat-pick-other {
  background: var(--cream-2) !important;
  color: var(--muted) !important;
  border-color: var(--line) !important;
}

/* Form buttons */
.btn-save {
  display: inline-flex;
  align-items: center;
  padding: .6rem 1.4rem;
  background: var(--terracotta);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  transition: background .15s;
}
.btn-save:hover { background: var(--terracotta-dark); }
.btn-save:disabled { opacity: .6; cursor: not-allowed; }

.btn-cancel {
  display: inline-flex;
  align-items: center;
  padding: .6rem 1.1rem;
  background: none;
  color: var(--ink-2);
  border: none;
  font-family: var(--font-sans);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}
.btn-cancel:hover { color: var(--ink); }

.btn-copy {
  padding: .45rem .85rem;
  background: var(--cream-2);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-2);
  white-space: nowrap;
  min-height: 36px;
}
.btn-copy:hover { background: var(--line); }

/* ── TEMPLATE GRID ──────────────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
  margin-bottom: .5rem;
}
.template-card {
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  background: var(--card-warm);
  transition: border-color .15s, background .15s;
}
.template-card:hover { border-color: var(--terracotta); background: var(--terracotta-soft); }
.template-card-title { font-weight: 700; font-size: .9rem; margin-bottom: .25rem; color: var(--ink); }
.template-card-desc  { font-size: .78rem; color: var(--muted); line-height: 1.45; margin-bottom: .5rem; }
.template-card-count {
  font-size: .72rem; font-weight: 700; color: var(--terracotta);
  background: var(--terracotta-soft);
  display: inline-block; padding: .12rem .5rem; border-radius: var(--r-pill);
}

/* ── TEAM MODAL ─────────────────────────────────────────────── */
.team-section { margin-bottom: 1.5rem; }
.team-section-title { font-size: .9rem; font-weight: 700; color: var(--ink); margin-bottom: .85rem; }

.invite-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
  margin-bottom: .8rem;
}
.invite-form .form-input, .invite-form .form-select { font-size: .86rem; }
.inv-role-sel { grid-column: 1 / -1; }
.invite-form .btn-save { grid-column: 1 / -1; justify-content: center; }

.invite-link-label { font-size: .8rem; color: var(--muted); margin-bottom: .4rem; }
.invite-link-row { display: flex; gap: .5rem; }
.invite-link-row .form-input { font-size: .8rem; }

.team-member {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 0;
  border-bottom: 1px solid var(--cream-2);
}
.team-member:last-child { border-bottom: none; }
.team-member-info { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.team-member-name  { font-weight: 700; font-size: .88rem; color: var(--ink); }
.team-member-email { font-size: .78rem; color: var(--muted); }
.role-badge-small {
  display: inline-block; padding: .12rem .45rem; border-radius: var(--r-pill);
  font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
}
.role-admin  { background: var(--terracotta-soft); color: var(--terracotta-dark); }
.role-member { background: var(--blue-soft); color: var(--blue); }
.role-guest  { background: var(--cream-2); color: var(--muted); }
.pending-badge {
  display: inline-block; padding: .12rem .45rem; border-radius: var(--r-pill);
  font-size: .68rem; background: var(--amber-soft); color: #7a5500;
  border: 1px solid var(--amber-soft);
}
.you-label { font-size: .75rem; color: var(--muted); }
.btn-remove {
  background: none; border: 1.5px solid var(--line);
  border-radius: 8px; color: var(--terracotta);
  font-family: var(--font-sans); font-size: .78rem; font-weight: 600;
  padding: .3rem .7rem; cursor: pointer; min-height: 32px;
  transition: background .12s;
}
.btn-remove:hover { background: var(--terracotta-soft); }

/* ── DESKTOP OVERRIDES (≥641px) ─────────────────────────────── */
@media (min-width: 641px) {
  .app-wrap { padding-top: 28px; padding-bottom: 40px; }

  .app-header { border-radius: 20px; }

  .app-header-main { padding: 1.6rem 1.75rem 1rem; }
  .proj-switcher { font-size: 1.8rem; }
  .header-prog-wrap { padding: 0 1.75rem 1.3rem; }

  .proj-menu { left: 1.75rem; right: 1.75rem; }

  .filter-wrap { padding: .7rem 1.75rem .6rem; }

  .task-container { padding: .9rem 1.75rem 4rem; }

  /* Hide FAB on desktop — use add chip in filter strip instead */
  .fab { display: none; }

  /* Modal becomes centered dialog on desktop */
  .modal-overlay { align-items: center; padding: 1.5rem; }
  .modal {
    border-radius: 20px;
    max-width: 500px;
    max-height: 88vh;
  }
  .modal::before { display: none; }
  .modal-wide { max-width: 680px; }
  .modal-sm   { max-width: 380px; }

  /* Card hover actions on desktop */
  .card-more-btn { display: none; }
  .card-actions {
    display: flex;
    position: static;
    box-shadow: none;
    border: none;
    background: none;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
  }
  .task-card:hover .card-actions {
    opacity: 1;
    pointer-events: auto;
  }
  .card-act-btn {
    padding: .25rem .5rem;
    font-size: .75rem;
  }

  .task-foot { gap: .75rem; }

  /* Hide mobile admin row on desktop (use header buttons) */
  .mobile-admin-row { display: none !important; }
}

/* ── MOBILE SPECIFICS (≤640px) ──────────────────────────────── */
@media (max-width: 640px) {
  .app-wrap { padding: 0; }
  .app-header { border-radius: 0 0 20px 20px; }
}
