:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface-raised: #eeeeee;
    --border: #d1d1d1;
    --text: #111111;
    --text-dim: #666666;
    --accent: #1f1f1f;
    --accent-dim: #e6e6e6;
    --success: #2e7d32;
    --danger: #b00020;
    --radius: 14px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    padding-bottom: calc(72px + var(--safe-bottom));
    min-height: 100vh;
}

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

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: calc(16px + var(--safe-top)) 20px 14px;
    background: rgba(252, 252, 253, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header h1 {
    font-size: 20px;
    margin: 0;
}

.app-header .subtitle {
    font-size: 13px;
    color: var(--text-dim);
}

main {
    padding: 16px;
    max-width: 640px;
    margin: 0 auto;
}

/* Bottom tab bar */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: #ffffff;
    backdrop-filter: blur(10px);
    border-top: 1px solid #111111;
    padding-bottom: var(--safe-bottom);
    z-index: 20;
}

.bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 0 8px;
    color: var(--text-dim);
    font-size: 11px;
}

.bottom-nav__icon { font-size: 20px; line-height: 1; }
.bottom-nav__item.is-active { color: var(--accent); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}

.card h2, .card h3 { margin-top: 0; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.stat-tile .value { font-size: 24px; font-weight: 700; }
.stat-tile .label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Forms */
label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin: 12px 0 6px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], textarea, select {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px; /* prevents iOS auto-zoom on focus */
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
}

textarea { min-height: 70px; resize: vertical; }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    min-height: 44px; /* iOS-friendly tap target */
}

.btn-primary { background: #ffffff; color: #111111; border: 1px solid #111111; width: 100%; }
.btn-secondary { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }

.btn-fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    color: #111111;
    border: 1px solid #111111;
    font-size: 22px;
    font-weight: 700;
    padding: 0;
    min-height: 0;
}

/* Chips (labels / muscle groups) */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.chip {
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.chip.is-selected {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* Exercise-in-workout block */
.exercise-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.exercise-block__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.exercise-block__title { font-weight: 700; font-size: 16px; }

.set-row {
    display: grid;
    grid-template-columns: 28px 1fr 1fr auto auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.set-row .set-num {
    color: var(--text-dim);
    font-size: 13px;
    text-align: center;
}

.set-row input { padding: 10px; text-align: center; }

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    padding: 6px;
    min-height: auto;
}

.icon-btn.danger { color: var(--danger); }

/* Lists */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.list-item:last-child { border-bottom: none; }

.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 20px;
}

.error-banner {
    background: rgba(255, 84, 112, 0.12);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 14px;
}

.muted { color: var(--text-dim); font-size: 13px; }

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 4px;
}

.auth-card .tagline {
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 20px;
}

.auth-toggle {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: center;
    font-size: 14px;
}

.auth-toggle a { color: var(--accent); font-weight: 600; }

canvas { max-width: 100%; }
