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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --green: #00b894;
  --red: #e17055;
  --orange: #fdcb6e;
  --text: #dfe6e9;
  --text-muted: #636e82;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.25);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: 80px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screens ─────────────────────────────────────────── */
.screen { min-height: 100dvh; }

/* ── Auth ────────────────────────────────────────────── */
.auth-container {
  max-width: 360px;
  margin: 0 auto;
  padding: 80px 24px 40px;
}
.auth-logo {
  font-size: 2rem;
  text-align: center;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}
.auth-container input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.auth-container input:focus { border-color: var(--accent); }
.auth-switch {
  text-align: center;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.auth-switch a { color: var(--accent-light); text-decoration: none; }
.btn-full { width: 100%; }

/* ── Header ──────────────────────────────────────────── */
header {
  background: var(--surface);
  padding: 16px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  flex: 1;
}
.header-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 40px;
}

/* ── Tab Navigation ──────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 99;
}
.tab {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

/* ── Group Cards ─────────────────────────────────────── */
.group-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.group-card:active {
  transform: scale(0.98);
  background: rgba(108, 92, 231, 0.08);
}
.group-card .group-name { font-weight: 700; font-size: 1rem; }
.group-card .group-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.group-card .arrow { color: var(--text-muted); font-size: 1.2rem; }

/* ── Sections ────────────────────────────────────────── */
.page { display: none; padding: 16px 20px; }
.page.active { display: block; }

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 20px 0 10px;
}
.section-title:first-child { margin-top: 4px; }

/* ── Task Grid ───────────────────────────────────────── */
.task-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
.task-card:active {
  transform: scale(0.96);
  background: rgba(108, 92, 231, 0.12);
}
.task-card .icon { font-size: 1.6rem; margin-bottom: 6px; display: block; }
.task-card .name { font-size: 0.9rem; font-weight: 600; }
.task-card .done-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--green);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
}

/* ── Today Log ───────────────────────────────────────── */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.log-item .info { flex: 1; }
.log-item .task-name-log { font-weight: 600; font-size: 0.9rem; }
.log-item .meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.log-item .delete-btn {
  background: none;
  border: none;
  color: var(--red);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.6;
}
.log-item .delete-btn:active { opacity: 1; }

/* ── Week Summary ────────────────────────────────────── */
.week-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.week-card .task-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 8px; }
.week-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.85rem;
}
.week-bar-row .user-label { width: 80px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-bar-row .bar-bg {
  flex: 1;
  height: 22px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.week-bar-row .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 6px;
  transition: width 0.4s ease;
  min-width: 0;
}
.week-bar-row .bar-fill-green {
  background: linear-gradient(90deg, var(--green), #55efc4);
}
.week-bar-row .count {
  width: 24px;
  text-align: right;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ── Projects ────────────────────────────────────────── */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.project-card .proj-name { font-weight: 700; font-size: 1rem; }
.project-card .proj-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.project-card .proj-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.project-log-list { margin-top: 10px; }
.project-log-item {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 0;
  border-top: 1px solid var(--border);
}

/* ── Modal ───────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-content {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 40px;
  width: 100%;
  max-width: 480px;
  max-height: 80dvh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}
.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ── Member list ─────────────────────────────────────── */
.member-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ── Invite code ─────────────────────────────────────── */
.invite-code {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.3em;
  color: var(--accent-light);
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 2px dashed var(--accent);
}
.invite-meta {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Forms & Inputs ──────────────────────────────────── */
.add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.add-form input, .add-form textarea {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}
.add-form input:focus, .add-form textarea:focus {
  border-color: var(--accent);
}

.btn {
  padding: 10px 18px;
  border-radius: var(--radius);
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-green {
  background: var(--green);
  color: #fff;
}
.btn-small {
  padding: 8px 12px;
  font-size: 0.8rem;
}
.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-red {
  background: var(--red);
  color: #fff;
}

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--green);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Empty state ─────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
