:root {
    --bg: #0f0f13;
    --surface: #1a1a24;
    --surface-alt: #13131d;
    --border: #2a2a38;
    --text: #e8e8f0;
    --text-dim: #9a9aa8;
    --text-faint: #666672;
    --accent: #3b82f6;
    --accent-2: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --pink: #ec4899;
}

* { box-sizing: border-box; }

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

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    color: #fff;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 6;
}
header h1 {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 700;
}
header a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.85rem;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.day-heading {
    margin: 1.5rem 0 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    font-weight: 700;
}

.entry-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}
.entry-title {
    font-weight: 600;
}
.entry-meta {
    color: var(--accent);
    font-size: 0.85rem;
    margin-top: 0.3rem;
}
.entry-notes {
    margin-top: 0.35rem;
    color: var(--text-dim);
    font-size: 0.87rem;
}
.entry-actions a {
    font-size: 0.82rem;
    color: var(--accent);
    text-decoration: none;
    margin-left: 0.75rem;
    white-space: nowrap;
}

form label {
    display: block;
    margin: 0.75rem 0 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
}
form input, form textarea, form select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--surface-alt);
    color: var(--text);
    font-family: inherit;
}
form input:focus, form textarea:focus, form select:focus {
    outline: none;
    border-color: var(--accent);
}
form small.hint {
    display: block;
    color: var(--text-faint);
    font-size: 0.75rem;
    margin-top: 0.3rem;
}

.btn {
    display: inline-block;
    margin-top: 1.25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.7rem 1.25rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn.secondary {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn.danger {
    background: var(--danger);
}
.btn.small {
    margin-top: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
}

.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--accent);
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    z-index: 4;
}

.empty {
    text-align: center;
    color: var(--text-faint);
    padding: 2rem 0;
    font-size: 0.9rem;
}

.error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.35);
    color: #fca5a5;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.88rem;
}

/* === person chooser === */
.chooser {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 8rem);
}
.person-box {
    flex: 1 1 150px;
    max-width: 200px;
    aspect-ratio: 1;
    background: linear-gradient(160deg, var(--surface), var(--surface-alt));
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    cursor: pointer;
    color: var(--text);
    transition: border-color 0.15s, transform 0.1s;
}
.person-box:active {
    transform: scale(0.97);
    border-color: var(--accent);
}
.person-box svg {
    width: 44px;
    height: 44px;
}
.person-box .person-name {
    font-size: 1.1rem;
    font-weight: 700;
}
.person-box.p-keith svg { color: var(--accent); }
.person-box.p-shannon svg { color: var(--pink); }

/* === nav tabs (person switch + section switch) === */
.tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 57px;
    z-index: 5;
}
.tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.75rem 0.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-faint);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.subtabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem 0;
    max-width: 640px;
    margin: 0 auto;
}
.subtab {
    flex: 1;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    padding: 0.55rem 0.5rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.subtab.active {
    background: #1e3a5f;
    border-color: var(--accent);
    color: #60a5fa;
}

/* === panel / modal === */
.panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: flex-end;
    z-index: 10;
}
.panel {
    background: var(--surface);
    border-top: 1px solid var(--border);
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    border-radius: 16px 16px 0 0;
    padding: 1.25rem 1.25rem 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
}
.panel h2 {
    margin: 0;
    font-size: 1.05rem;
}
.panel .btn { margin-right: 0.5rem; }

/* === routine builder === */
.routine-selector {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    margin-bottom: 1rem;
}
.routine-chip {
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.routine-chip.active {
    background: #1e3a5f;
    border-color: var(--accent);
    color: #60a5fa;
}
.routine-chip.add-chip {
    color: var(--accent);
    border-style: dashed;
}
.routine-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.5rem;
}
.routine-header h2 {
    font-size: 1.05rem;
    margin: 0;
}
.routine-header .actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}
.routine-header .actions a {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-decoration: none;
}
.pill {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(16,185,129,0.15);
    color: var(--accent-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.day-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 14px;
    overflow: hidden;
}
.day-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}
.day-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.day-title {
    font-weight: 600;
    font-size: 0.95rem;
    flex: 1;
}
.day-tag {
    font-size: 0.72rem;
    background: var(--surface-alt);
    color: var(--text-dim);
    padding: 3px 8px;
    border-radius: 6px;
}
.chevron {
    font-size: 0.8rem;
    color: var(--text-faint);
    transition: transform 0.2s;
}
.chevron.open { transform: rotate(180deg); }
.day-body {
    padding: 0 16px 16px;
    display: none;
}
.day-body.open { display: block; }
.day-edit-actions {
    display: flex;
    gap: 0.75rem;
    padding: 0 16px 12px;
}
.day-edit-actions a {
    font-size: 0.78rem;
    color: var(--text-faint);
    text-decoration: none;
}

.section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--warn);
    font-weight: 700;
    margin: 12px 0 6px;
}
.exercise-list { list-style: none; margin: 0; padding: 0; }
.exercise-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.87rem;
}
.exercise-list li:last-child { border-bottom: none; }
.ex-name { flex: 1; color: var(--text); font-weight: 600; }
.ex-sets { color: var(--accent); font-size: 0.8rem; white-space: nowrap; margin-top: 1px; }
.ex-note { font-size: 0.78rem; color: var(--text-dim); margin-top: 3px; }
.ex-cues { font-size: 0.78rem; color: var(--accent-2); margin-top: 3px; }
.ex-cues::before { content: "form: "; color: var(--text-faint); }
.ex-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.ex-actions a { font-size: 0.78rem; color: var(--text-faint); text-decoration: none; }
.add-exercise-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.6rem;
    margin-top: 10px;
    background: var(--surface-alt);
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--accent);
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
}
.add-day-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 14px;
}

.tips-box {
    background: #141e2e;
    border: 1px solid #1e3a5f;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}
.tips-box h3 {
    font-size: 0.8rem;
    color: #60a5fa;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin: 0 0 10px;
}
.tips-box textarea {
    background: var(--surface-alt);
}

/* === color swatch picker === */
.swatches { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
}
.swatch.selected { border-color: #fff; }

/* === progress / weight goal === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}
.stat-box {
    background: var(--surface-alt);
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
}
.stat-val { font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.68rem; color: var(--text-faint); margin-top: 2px; }

.progress-bar-wrap { margin-bottom: 6px; }
.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-bottom: 6px;
}
.progress-bar {
    background: var(--surface-alt);
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
}
.progress-fill {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    height: 100%;
    border-radius: 99px;
}

.weighin-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.weighin-list li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.weighin-list li:last-child { border-bottom: none; }
.wi-date { color: var(--text-faint); font-size: 0.78rem; }
.wi-weight { color: var(--text); font-weight: 600; flex: 1; text-align: right; }
.wi-note { color: var(--text-dim); font-size: 0.78rem; }
.weighin-list a.wi-del { color: var(--text-faint); text-decoration: none; font-size: 0.78rem; }

.cal-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.83rem;
    padding: 5px 0;
    border-bottom: 1px solid #1a2a3a;
    color: var(--text-dim);
}
.cal-row:last-child { border-bottom: none; }
.cal-row span:last-child { color: #60a5fa; font-weight: 600; }

/* === exercise picker === */
.chip-row {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 0.75rem 0 0.5rem;
}
.chip {
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-dim);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.chip.active {
    background: #1e3a5f;
    border-color: var(--accent);
    color: #60a5fa;
}
.picker-list {
    max-height: 45vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 0.25rem;
}
.picker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 0.85rem;
    font-size: 0.88rem;
    cursor: pointer;
    font-family: inherit;
}
.picker-item:last-child { border-bottom: none; }
.picker-item:active { background: var(--surface-alt); }
.picker-cat {
    font-size: 0.7rem;
    color: var(--text-faint);
    background: var(--surface-alt);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    flex-shrink: 0;
    margin-left: 0.5rem;
}
.picker-item-new { color: var(--accent); font-weight: 600; }
.picker-chosen {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-alt);
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    margin-top: 0.75rem;
}
.picker-chosen strong { font-size: 0.92rem; }
.picker-chosen a {
    color: var(--accent);
    font-size: 0.8rem;
    text-decoration: none;
}
