/* Gym-AX — 다크 기본, 시스템 폰트, 카드 레이아웃, 모바일(390px) 우선 */
:root {
  --bg: #0b0d10;
  --surface: #15181d;
  --surface-2: #1d2129;
  --border: #2a2f38;
  --text: #e8eaed;
  --muted: #8b93a1;
  --accent: #5b8def;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --warn: #f5a524;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body { padding-bottom: 72px; }

a { color: inherit; text-decoration: none; }

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

/* ---------- nav ---------- */
.topnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px max(8px, env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.topnav a, .topnav button {
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 10px;
}
.topnav a.active, .topnav a:hover { color: var(--text); }
.topnav a.cta {
  background: var(--accent);
  color: #06101f;
  font-weight: 600;
  padding: 8px 14px;
}
.topnav .brand { display: none; }

@media (min-width: 640px) {
  body { padding-bottom: 0; padding-top: 56px; }
  .topnav {
    top: 0; bottom: auto;
    justify-content: flex-start;
    gap: 20px;
    border-top: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
  }
  .topnav .brand { display: inline; font-weight: 700; margin-right: auto; color: var(--text); }
  .topnav form.logout-form { margin-left: auto; }
}

/* ---------- primitives ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
h1 { font-size: 20px; margin: 4px 0 16px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.accent { background: rgba(91,141,239,.15); color: var(--accent); border-color: transparent; }

button, input, select {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
button { cursor: pointer; }
button.primary { background: var(--accent); color: #06101f; border: none; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--border); }
button:active { transform: scale(0.98); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 12px; color: var(--muted); }

/* ---------- login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card { width: 100%; max-width: 340px; }
.login-card h1 { text-align: center; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ---------- calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 1px solid transparent;
}
.cal-cell.empty { background: transparent; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.has-session { background: rgba(34,197,94,.12); }
.cal-cell .d { color: var(--muted); }
.cal-cell.has-session .d { color: var(--text); }
.cal-cell .mini-badge { font-size: 9px; color: var(--accent-2); margin-top: 2px; }
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* ---------- library ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs a { padding: 8px 14px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.tabs a.active { background: var(--accent); color: #06101f; font-weight: 600; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tip-card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- workout ---------- */
.set-row { display: grid; grid-template-columns: 28px 1fr 1fr 44px; gap: 8px; align-items: center; margin-bottom: 6px; }
.set-row input { width: 100%; text-align: center; }
.set-row .set-no { text-align: center; color: var(--muted); font-size: 13px; }
.set-row button.done { background: var(--surface-2); }
.set-row button.done.completed { background: var(--accent-2); color: #06180d; }
.banner { border: 1px solid var(--warn); background: rgba(245,165,36,.1); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.banner.error { border-color: var(--danger); background: rgba(239,68,68,.1); }
.timer { font-size: 32px; font-weight: 700; text-align: center; color: var(--accent); }
.exercise-block { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 12px; }
.exercise-block:last-child { border-bottom: none; }
.search-results { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.search-results button { text-align: left; }

/* ---------- stats ---------- */
.chart { width: 100%; height: 280px; }

/* coach page */
.chat-item{border-bottom:1px solid var(--border,#333);padding:.7rem 0}
.chat-q{font-weight:600;margin-bottom:.3rem}
.chat-a{white-space:pre-wrap;line-height:1.5}
.note-list{list-style:none;padding:0}
.note-list li{padding:.45rem 0;border-bottom:1px solid var(--border,#333)}
.badge{display:inline-block;padding:.05rem .5rem;border-radius:9px;font-size:.75rem;margin-right:.3rem;background:#444}
.badge-pain{background:#7a2e2e}.badge-form{background:#2e5a7a}.badge-feel{background:#2e7a4e}
.small{font-size:.75rem}

/* ---------- analysis / master ---------- */
.grid-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid-table th, .grid-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border, #2a2f38); }
.grid-table th { color: var(--muted, #8b93a1); font-weight: 600; }
.grid-table td strong { color: var(--accent, #5b8def); }
.mini-h { font-size: .95rem; margin: 0 0 6px; }
ul.tight { list-style: none; padding: 0; margin: 0; }
ul.tight li { padding: 4px 0; border-bottom: 1px solid var(--border, #2a2f38); }
ul.tight li:last-child { border-bottom: none; }
.master-line { font-size: .85rem; margin-top: 4px; line-height: 1.45; }
.mlabel { display: inline-block; min-width: 44px; font-size: .72rem; color: var(--muted, #8b93a1); }
.mlabel.warn { color: var(--warn, #f5a524); }
