/* Artifact platform tokens — auto-resolved */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* App shell — mobile-first, phone-like frame */
.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 88px;
}

/* Header */
.app-header {
  padding: 24px 20px 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 32px; height: 32px;
  background: var(--scrim);
  border-radius: var(--radius-md);
  display: grid; place-items: center;
}

.header-sub {
  margin-top: 4px;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* View container */
.view {
  padding: 20px;
  flex: 1;
}

.view h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.view-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral);
  margin-bottom: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-top: 1px solid var(--neutral);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  padding: 8px 2px 12px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 1px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.58rem;
  font-weight: 600;
  transition: color 0.15s;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn svg {
  width: 18px; height: 18px;
}

/* Profile view */
.profile-hero {
  background: linear-gradient(135deg, var(--primary-tint), var(--surface));
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  border: 1px solid var(--neutral);
  margin-bottom: 20px;
}

.avatar {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  margin: 0 auto 12px;
  box-shadow: var(--shadow-md);
}

.profile-name {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.profile-role {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.accent { background: var(--accent); }
.badge.neutral { background: var(--neutral); color: var(--text); }

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--neutral);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

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

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 10px 16px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-ghost {
  padding: 8px 14px;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
}

.btn-danger {
  padding: 8px 12px;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-link {
  margin-top: 10px;
  padding: 4px 0;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  background: transparent;
}

.btn-link:hover { color: var(--primary-dark); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-tile {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--neutral);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 4px;
  color: var(--primary);
  line-height: 1;
}

.stat-value.accent { color: var(--accent); }

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Match list */
.match-item, .training-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--neutral);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.match-info { flex: 1; min-width: 0; }

.match-opponent {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.match-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.match-stats {
  display: flex;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.match-stat {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--primary);
}

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

.empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  color: var(--neutral);
}

.empty-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-hint {
  font-size: 0.85rem;
}

/* Dialog */
dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 92vw;
  width: 420px;
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(4px);
}

.dialog-inner {
  padding: 24px;
}

.dialog-inner h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.dialog-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.dialog-actions .btn-primary { flex: 1; }

/* Chip filter */
.chips {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chip {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--neutral);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Section header */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 12px;
}

.section-head h2 {
  font-size: 1rem;
  font-weight: 700;
}

/* Progress bar */
.progress-track {
  height: 8px;
  background: var(--neutral);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.4s;
}

/* Tip/exercise cards */
.tip-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 4px solid var(--primary);
  border-top: 1px solid var(--neutral);
  border-right: 1px solid var(--neutral);
  border-bottom: 1px solid var(--neutral);
}

.tip-card.accent { border-left-color: var(--accent); }
.tip-card.success { border-left-color: var(--success); }

.tip-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 6px;
}

.tip-title {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.tip-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Blog cards & article */
.blog-card {
  transition: transform 0.15s, box-shadow 0.15s;
}

.blog-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.article-body {
  margin-top: 16px;
}

.article-body p {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 14px;
}

.article-body strong {
  color: var(--primary-dark);
  font-weight: 700;
}

/* AI Coach view */
.coach-hero {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  padding: 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.coach-hero h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.coach-hero p {
  font-size: 0.85rem;
  opacity: 0.95;
  line-height: 1.5;
}

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--neutral);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Compare (friends) view */
.compare-header,
.compare-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.compare-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--neutral);
  margin-bottom: 4px;
}

.compare-row {
  border-bottom: 1px solid var(--neutral);
}

.compare-row:last-child { border-bottom: none; }

.compare-cell {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  padding: 6px 4px;
  border-radius: var(--radius-sm);
}

.compare-cell.winner {
  background: var(--primary-tint);
  color: var(--primary-dark);
}

.compare-label {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
