:root {
  --bg: #111318;
  --card: #1c1f26;
  --card2: #262a33;
  --text: #f1f2f4;
  --muted: #9aa0ab;
  --accent: #e63946;
  --green: #2a9d8f;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 560px; margin: 0 auto; padding-bottom: 90px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; padding: 24px; gap: 12px;
}
.login-wrap h1 { text-align: center; font-size: 2.4rem; margin-bottom: 8px; }
.login-wrap h1 span { color: var(--accent); }

/* ---------- Common ---------- */
.view { padding: 16px 16px 0; }
h2 { font-size: 1.3rem; margin: 8px 0 14px; }

input, select, textarea, button {
  font: inherit; color: inherit; border: none; outline: none;
}
input, select, textarea {
  width: 100%; background: var(--card); border-radius: 12px;
  padding: 13px 14px; border: 1px solid #2e333d;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: .82rem; color: var(--muted); margin: 12px 0 5px; }

.btn {
  display: block; width: 100%; background: var(--accent); color: #fff;
  border-radius: 12px; padding: 14px; font-weight: 600; cursor: pointer;
  text-align: center;
}
.btn.secondary { background: var(--card2); }
.btn.small { width: auto; padding: 8px 14px; font-size: .85rem; border-radius: 10px; display: inline-block; }
.btn:active { opacity: .8; }

.error { color: #ff7b87; font-size: .9rem; margin-top: 8px; min-height: 1.2em; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}

.muted { color: var(--muted); font-size: .85rem; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }

/* ---------- Feed ---------- */
.day-header { color: var(--muted); text-align: center; font-size: .9rem; margin: 14px 0 10px; }

.workout .cat-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.workout .title { font-weight: 600; }
.workout .meta { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.chip {
  background: var(--card2); border-radius: 999px; padding: 5px 11px;
  font-size: .82rem; color: var(--text);
}
.wo-actions { display: flex; gap: 14px; margin-top: 10px; align-items: center; }
.wo-actions button { background: none; color: var(--muted); cursor: pointer; font-size: .88rem; }
.wo-actions button.active { color: var(--accent); }
.react-summary { font-size: .88rem; }
.comments { margin-top: 8px; border-top: 1px solid #2e333d; padding-top: 8px; }
.comment { font-size: .88rem; margin-bottom: 6px; }
.comment b { font-size: .82rem; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { padding: 9px 12px; }
.comment-form button { background: var(--accent); border-radius: 10px; padding: 0 14px; cursor: pointer; }
.emoji-picker { display: flex; gap: 6px; margin-top: 8px; }
.emoji-picker button { background: var(--card2); border-radius: 10px; padding: 6px 10px; font-size: 1.1rem; cursor: pointer; }

/* ---------- Nav ---------- */
nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #16181e; border-top: 1px solid #262a33;
  display: flex; justify-content: space-around; padding: 8px 0 max(10px, env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
}
nav button {
  background: none; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; width: 64px;
}
nav button .ico { font-size: 1.35rem; }
nav button.active { color: var(--text); }

.fab {
  position: fixed; right: 18px; bottom: 84px;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.45);
}
@media (min-width: 600px) { .fab { right: calc(50% - 280px + 18px); } }

/* ---------- Rankings ---------- */
.seg {
  display: flex; background: var(--card); border-radius: 999px; padding: 4px; margin-bottom: 12px;
}
.seg button {
  flex: 1; background: none; color: var(--muted); padding: 8px 0;
  border-radius: 999px; cursor: pointer; font-size: .88rem;
}
.seg button.active { background: var(--card2); color: var(--text); }
.cat-filter { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; }
.cat-filter button {
  background: var(--card); color: var(--muted); border-radius: 999px;
  padding: 7px 14px; white-space: nowrap; cursor: pointer; font-size: .85rem;
}
.cat-filter button.active { background: var(--accent); color: #fff; }

.rank-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #262a33; }
.rank-row:last-child { border-bottom: none; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
  flex-shrink: 0;
}
.rank-pos { font-weight: 700; font-size: 1.05rem; width: 44px; text-align: right; }

/* ---------- Me ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat .big { font-size: 1.7rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .8rem; margin-top: 3px; }
.goal-bar { background: var(--card2); border-radius: 999px; height: 10px; overflow: hidden; margin-top: 10px; }
.goal-bar > div { background: var(--green); height: 100%; transition: width .3s; }
.weekchart { display: flex; align-items: flex-end; gap: 6px; height: 70px; margin-top: 10px; }
.weekchart .bar { flex: 1; background: var(--card2); border-radius: 4px 4px 0 0; min-height: 3px; }
.weekchart .bar.hit { background: var(--green); }

.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-select { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cat-select button {
  background: var(--card); border-radius: 12px; padding: 12px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .82rem;
  border: 2px solid transparent; color: var(--text);
}
.cat-select button.active { border-color: var(--accent); background: var(--card2); }
.cat-select .ico { font-size: 1.5rem; }

.admin-user { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #262a33; }
.admin-user:last-child { border-bottom: none; }
