:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card2: #273549;
  --accent: #0d9488;
  --accent2: #14b8a6;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --danger: #ef4444;
  --gold: #f59e0b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* Pin to the visual viewport so the bottom tab bar truly sticks to the screen
     bottom on iOS standalone PWAs — avoids the vh/dvh quirks entirely. */
  position: fixed;
  inset: 0;
  overflow: hidden; /* the app's <main> scrolls, not the page */
  display: flex;
  flex-direction: column;
}

/* The app is a full-height flex column: header / scrollable main / tab bar. */
#app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

/* ---- setup ---- */
.setup {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.setup-card { width: 100%; max-width: 380px; }

.picker { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.picker-name {
  background: var(--card2);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 16px;
  text-align: left;
}
.picker-name:active { background: var(--accent); color: white; }
.picker-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.picker-name.taken { opacity: 0.45; }
.picker-name .tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 2px 8px;
}

/* ---- header ---- */
header {
  flex: 0 0 auto;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1e293b;
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--accent2); }
.whoami { font-size: 0.85rem; color: var(--muted); }

/* ---- banner ---- */
.banner {
  background: var(--card2);
  margin: 12px 16px 0;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
}

main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
}
.view h2 { font-size: 1.1rem; margin: 18px 0 10px; }

/* ---- cards / list ---- */
.list { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  border-left: 4px solid #334155;
}
.task.active { border-left-color: var(--gold); background: var(--card2); }
.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.task-name { font-weight: 600; font-size: 1.05rem; }
.task-meta { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.pill {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}
.pill.due { background: var(--gold); color: #1a1206; }
.pill.idle { background: #334155; color: var(--muted); }
.task-actions { margin-top: 12px; display: flex; gap: 8px; }

/* ---- scoreboard ---- */
.score-row {
  background: var(--card);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.rank { font-size: 1.2rem; width: 28px; text-align: center; }
.score-name { font-weight: 600; flex: 1; }
.score-count { font-weight: 700; color: var(--accent2); font-size: 1.1rem; }
.activity-row {
  background: var(--card);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
}
.activity-row .when { color: var(--muted); font-size: 0.78rem; }

/* ---- inputs / buttons ---- */
label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
input, select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #0b1220;
  color: var(--text);
  font-size: 1rem;
}
.row { display: flex; gap: 10px; }

/* schedule section separators on the New-task form */
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 4px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #334155;
}
.or-sep { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 2px 0; }

/* weekday toggle chips */
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.day {
  flex: 1;
  min-width: 40px;
  padding: 10px 0;
  font-size: 0.82rem;
  background: #0b1220;
  border: 1px solid #334155;
  color: var(--muted);
}
.day.on { background: var(--accent); color: white; border-color: var(--accent); }
.row input { flex: 1; }
.row select { flex: 1; }

button {
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: #334155;
  color: var(--text);
}
button.primary { background: var(--accent); color: white; }
button.primary:active { background: #0b7d72; }
button.done { background: var(--accent2); color: #06231f; flex: 1; }
button.small { padding: 8px 14px; font-size: 0.85rem; width: auto; }
button.danger { background: transparent; color: var(--danger); border: 1px solid #4b2027; }

/* ---- tabbar ---- */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: #0b1220;
  border-top: 1px solid #1e293b;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  background: none;
  border-radius: 0;
  padding: 10px 0 8px;
  color: var(--muted);
  font-size: 1.3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab span { font-size: 0.65rem; font-weight: 600; }
.tab.active { color: var(--accent2); }

/* ---- toast ---- */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #0b1220;
  border: 1px solid #334155;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  z-index: 50;
  max-width: 90%;
}
