/* style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:       #0e0e0e;
    --surface:  #161616;
    --border:   #252525;
    --muted:    #3a3a3a;
    --text:     #e8e8e8;
    --dim:      #888;
    --accent:   #c8f135;   /* sharp lime — the single color pop */
    --danger:   #ff4d4d;
    --radius:   6px;
    --font:     'DM Sans', system-ui, sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap');

html { font-size: 16px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-weight: 400;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.page {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 80px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.logo {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

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

.card-label {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 6px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, transform 0.1s;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: #0e0e0e;
    width: 100%;
}
.btn-primary:hover { opacity: 0.88; }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    width: 100%;
}
.btn-ghost:hover { border-color: var(--muted); }

.btn-success {
    background: var(--accent);
    color: #0e0e0e;
    flex: 1;
}

.btn-fail {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    flex: 1;
}
.btn-fail:hover { background: rgba(255,77,77,0.08); }

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--dim);
    cursor: pointer;
    padding: 4px;
    font-size: 1.1rem;
    line-height: 1;
    transition: color 0.15s;
}
.btn-icon:hover { color: var(--text); }

/* ── Inputs ── */
.field {
    margin-bottom: 16px;
}
.field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 6px;
}
.field input, .field select, .field textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    padding: 11px 14px;
    transition: border-color 0.15s;
    outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent);
}
.field input[type="number"] {
    -moz-appearance: textfield;
}
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

/* ── Auth page ── */
.auth-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    max-width: 360px;
    margin: 0 auto;
    padding: 0 16px;
}
.auth-logo {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 40px;
}
.auth-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.auth-sub {
    color: var(--dim);
    font-size: 0.875rem;
    margin-bottom: 32px;
}
.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--dim);
}
.auth-switch a { color: var(--accent); text-decoration: none; }

/* ── Alert ── */
.alert {
    padding: 11px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
}
.alert-error { background: rgba(255,77,77,0.1); border: 1px solid rgba(255,77,77,0.3); color: #ff8080; }
.alert-success { background: rgba(200,241,53,0.08); border: 1px solid rgba(200,241,53,0.25); color: var(--accent); }

/* ── Exercise set row ── */
.exercise-block {
    margin-bottom: 24px;
}
.exercise-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 3px;
    letter-spacing: -0.01em;
}
.exercise-meta {
    font-size: 0.78rem;
    color: var(--dim);
    margin-bottom: 12px;
}

.set-row {
    display: grid;
    grid-template-columns: 28px 1fr 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s, opacity 0.2s;
}
.set-row.done {
    border-color: rgba(200,241,53,0.3);
    opacity: 0.65;
}
.set-row.failed {
    border-color: rgba(255,77,77,0.25);
    opacity: 0.55;
}

.set-num {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--dim);
    letter-spacing: 0.05em;
    text-align: center;
}

.set-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.set-input-wrap span {
    font-size: 0.65rem;
    color: var(--dim);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.set-input-wrap input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 7px 10px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
    -moz-appearance: textfield;
}
.set-input-wrap input::-webkit-outer-spin-button,
.set-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }
.set-input-wrap input:focus { border-color: var(--accent); }

.set-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    grid-column: 1 / -1;
    margin-top: 6px;
}

.last-week-bar {
    background: rgba(200,241,53,0.06);
    border: 1px solid rgba(200,241,53,0.12);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.78rem;
    color: var(--dim);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.last-week-bar strong { color: var(--accent); font-weight: 500; }

/* ── Progress bar ── */
.progress-track {
    background: var(--border);
    border-radius: 99px;
    height: 3px;
    margin: 16px 0;
    overflow: hidden;
}
.progress-fill {
    background: var(--accent);
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* ── Stat chips ── */
.stat-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.stat-chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    flex: 1;
    min-width: 80px;
}
.stat-chip .val {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--accent);
}
.stat-chip .lbl {
    font-size: 0.68rem;
    color: var(--dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ── Nav bottom ── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(14,14,14,0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
    z-index: 100;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--dim);
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color 0.15s;
    padding: 4px 16px;
}
.nav-item svg { width: 20px; height: 20px; stroke-width: 1.75; }
.nav-item.active { color: var(--accent); }

/* ── History list ── */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--muted); }
.history-item .hi-name { font-weight: 500; font-size: 0.95rem; }
.history-item .hi-date { font-size: 0.75rem; color: var(--dim); margin-top: 2px; }
.history-item .hi-arrow { color: var(--dim); font-size: 1.1rem; }
.hi-badge {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(200,241,53,0.1);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 99px;
}

/* ── Template manager ── */
.template-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
}
.template-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
}
.template-card-header:hover { background: rgba(255,255,255,0.02); }
.template-card-body {
    border-top: 1px solid var(--border);
    padding: 14px 16px;
    display: none;
}
.template-card-body.open { display: block; }

.ex-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.82rem;
    margin: 4px 4px 4px 0;
}
.ex-pill .pill-del {
    background: none;
    border: none;
    color: var(--dim);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 0 0 4px;
}
.ex-pill .pill-del:hover { color: var(--danger); }

/* ── Chart ── */
.chart-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.chart-title {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 14px;
}

/* ── Misc ── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}
.text-dim { color: var(--dim); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 0.82rem; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }

.empty-state {
    text-align: center;
    padding: 48px 0;
    color: var(--dim);
}
.empty-state .es-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

.tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 3px;
    background: rgba(200,241,53,0.1);
    color: var(--accent);
}

select option { background: var(--surface); }

/* ── Responsive fine-tuning ── */
@media (max-width: 380px) {
    .set-row { grid-template-columns: 24px 1fr 1fr; }
}
