@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #f8faf8;
  --bg-card:   #ffffff;
  --bg-card-2: #f0f4f0;
  --bg-deep:   #e8ede8;

  --border:        #d4dcd4;
  --border-bright: #b8c8b8;

  --text:        #1a1f1a;
  --text-dim:    #4a5a4a;
  --text-dimmer: #8a9a8a;

  --teal:      #14b8a6;
  --teal-dark: #0d9488;
  --teal-glow: rgba(20,184,166,0.10);
  --teal-bg:   rgba(20,184,166,0.08);

  --red:       #dc2626;
  --red-bg:    rgba(220,38,38,0.08);
  --amber:     #d97706;
  --amber-bg:  rgba(217,119,6,0.08);
  --green:     #16a34a;
  --green-bg:  rgba(22,163,74,0.08);

  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --header-h: 56px;
  --nav-h: 64px;
  --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-hover: 0 2px 8px rgba(0,0,0,0.1), 0 8px 24px rgba(0,0,0,0.06);
}

/* ─── Reset + Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-dark); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ─── Typography ────────────────────────────────────────────────────────── */
.font-display { font-family: 'Bebas Neue', sans-serif; letter-spacing: 0.04em; }

h1 { font-family: 'Bebas Neue', sans-serif; font-size: 2rem; letter-spacing: 0.04em; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }

.text-sm    { font-size: 0.8125rem; }
.text-xs    { font-size: 0.75rem; }
.text-dim   { color: var(--text-dim); }
.text-dimmer{ color: var(--text-dimmer); }
.text-teal  { color: var(--teal-dark); }
.text-red   { color: var(--red); }
.text-amber { color: var(--amber); }
.text-green { color: var(--green); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.page {
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + 16px);
  min-height: 100vh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.section { margin-bottom: 24px; }
.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 16px 16px 8px;
}

/* ─── App Header ────────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}

.app-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  color: var(--teal-dark);
}

.member-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 24px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s;
}
.member-btn:hover { background: var(--bg-deep); }
.member-btn .avatar { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; color: #fff; flex-shrink: 0; }

/* ─── Bottom Nav ────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px;
  border-radius: var(--radius);
  color: var(--text-dimmer);
  font-size: 0.7rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s;
  position: relative;
  min-width: 56px;
}
.nav-item .nav-icon { font-size: 1.25rem; line-height: 1; }
.nav-item.active { color: var(--teal-dark); }
.nav-item.active .nav-icon { filter: none; }

.nav-badge {
  position: absolute;
  top: 4px; right: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ─── Member Picker Modal ───────────────────────────────────────────────── */
.member-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.member-modal-overlay.hidden { display: none; }

.member-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px 40px;
  width: 100%;
  max-width: 480px;
}

.member-modal h2 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 500;
}

.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.member-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-card-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.member-card:hover { background: var(--bg-deep); transform: translateY(-1px); }
.member-card.selected { border-color: var(--teal); background: var(--teal-bg); }

.member-card .avatar-lg {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; color: #fff;
}

.member-card .member-name { font-size: 0.875rem; font-weight: 600; text-align: center; }
.member-card .member-role { font-size: 0.7rem; color: var(--text-dimmer); }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card-sm { padding: 12px; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  cursor: pointer;
  border: none;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--teal);
  color: #fff;
}
.btn-primary:hover { background: var(--teal-dark); }

.btn-secondary {
  background: var(--bg-card-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-deep); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 0.8125rem; }

/* ─── FAB ───────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(20,184,166,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 150;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.fab:hover { background: var(--teal-dark); transform: scale(1.06); box-shadow: 0 6px 20px rgba(20,184,166,0.5); }
.fab:active { transform: scale(0.96); }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-glow);
}
.form-input::placeholder { color: var(--text-dimmer); }
.form-textarea { resize: vertical; min-height: 72px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Urgency buttons */
.urgency-group { display: flex; gap: 8px; }
.urgency-btn {
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  font-size: 0.8125rem; font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text-dim);
  transition: all 0.15s;
}
.urgency-btn[data-value="normal"].active  { background: var(--teal-bg); border-color: var(--teal); color: var(--teal-dark); }
.urgency-btn[data-value="urgent"].active  { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.urgency-btn[data-value="critical"].active{ background: var(--red-bg); border-color: var(--red); color: var(--red); }

/* ─── Bottom Sheet ──────────────────────────────────────────────────────── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 250;
  transition: opacity 0.2s;
}
.sheet-overlay.hidden { display: none; }

.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 260;
  padding: 0 20px 32px;
  max-height: 92vh;
  overflow-y: auto;
  transform: translateY(0);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  max-width: 560px;
  margin: 0 auto;
}
.sheet.hidden { transform: translateY(100%); pointer-events: none; }

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--border-bright);
  border-radius: 2px;
  margin: 12px auto 20px;
}

.sheet-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }

/* ─── List Tabs ─────────────────────────────────────────────────────────── */
.list-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.list-tabs::-webkit-scrollbar { display: none; }

.list-tab {
  flex-shrink: 0;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dimmer);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.list-tab.active { color: var(--teal-dark); border-bottom-color: var(--teal); }
.list-tab .tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-deep); color: var(--text-dimmer);
  font-size: 0.7rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  margin-left: 6px;
}
.list-tab.active .tab-count { background: var(--teal-glow); color: var(--teal-dark); }

/* ─── Category Chips ────────────────────────────────────────────────────── */
.chip-row {
  display: flex; gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all 0.15s;
}
.chip.active, .chip:hover { background: var(--teal-glow); border-color: var(--teal); color: var(--teal-dark); }

/* ─── Item Cards ─────────────────────────────────────────────────────────── */
.items-list { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: opacity 0.3s, transform 0.3s;
}

.item-card[data-urgency="urgent"]  { border-left: 3px solid var(--amber); }
.item-card[data-urgency="critical"] { border-left: 3px solid var(--red); }

.item-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-bright);
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.item-check:hover { border-color: var(--teal); }
.item-check.checking { border-color: var(--green); background: var(--green); }
.item-check.checking::after { content: '✓'; color: #fff; font-size: 0.75rem; font-weight: 700; }

.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 600; font-size: 0.9375rem; color: var(--text); }
.item-meta { font-size: 0.78rem; color: var(--text-dimmer); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.item-meta span { display: flex; align-items: center; gap: 3px; }

.item-card.archiving {
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
}

.urgency-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  margin-top: 8px;
}
.urgency-dot.normal  { background: var(--border-bright); }
.urgency-dot.urgent  { background: var(--amber); }
.urgency-dot.critical { background: var(--red); }

.added-by-avatar {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700; color: #fff;
}

/* ─── Archived Section ──────────────────────────────────────────────────── */
.archived-section {
  margin: 8px 16px 0;
  border-top: 1px solid var(--border);
}

.archived-toggle {
  width: 100%; padding: 12px 0;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-dimmer);
  display: flex; align-items: center; gap: 6px;
  text-align: left;
}

.archived-items { padding: 4px 0 8px; display: flex; flex-direction: column; gap: 6px; }
.archived-items .item-card { opacity: 0.55; }
.archived-items .item-check { border-color: var(--green); background: var(--green-bg); }

/* ─── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dimmer);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; }

/* ─── Dashboard Stats ───────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--teal-dark);
  margin-bottom: 4px;
}
.stat-label { font-size: 0.8rem; font-weight: 500; color: var(--text-dim); }

/* Quick-add row on dashboard */
.quick-add {
  margin: 0 16px 16px;
  display: flex;
  gap: 10px;
}
.quick-add .form-input { flex: 1; }

/* ─── Leaderboard ───────────────────────────────────────────────────────── */
.leaderboard-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.leaderboard-row:last-child { border-bottom: none; }
.lb-rank {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.25rem; color: var(--text-dimmer);
  width: 28px; text-align: center;
}
.lb-rank.gold   { color: #d97706; }
.lb-rank.silver { color: #94a3b8; }
.lb-rank.bronze { color: #a16207; }
.lb-name { flex: 1; font-weight: 600; }
.lb-points { font-family: 'Bebas Neue', sans-serif; font-size: 1.2rem; color: var(--teal-dark); }
.lb-streak { font-size: 0.8rem; color: var(--text-dimmer); }

/* ─── Skeleton Loading ──────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-card-2) 25%, var(--bg-deep) 50%, var(--bg-card-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-item { height: 60px; margin-bottom: 8px; }

/* ─── Utilities ─────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.mt-8    { margin-top: 8px; }
.mt-16   { margin-top: 16px; }
.mt-24   { margin-top: 24px; }
.mb-8    { margin-bottom: 8px; }
.mb-16   { margin-bottom: 16px; }
.p-16    { padding: 16px; }
.flex    { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8   { gap: 8px; }
.gap-12  { gap: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .form-row { grid-template-columns: 1fr 1fr 1fr; }
}

@media (min-width: 768px) {
  .sheet { left: 50%; transform: translateX(-50%) translateY(0); }
  .sheet.hidden { transform: translateX(-50%) translateY(100%); }
  .fab { right: calc(50% - 340px); }
}
