:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: #1a1a3e;
    --bg-card-hover: #222255;
    --bg-input: #0d0d24;
    --text-primary: #eef0ff;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --accent-blue: #00d2ff;
    --accent-purple: #7b2ff7;
    --accent-pink: #ff6b9d;
    --accent-red: #ff6b6b;
    --accent-orange: #ffa44f;
    --accent-yellow: #ffd93d;
    --accent-green: #4ecdc4;
    --gradient-main: linear-gradient(135deg, #00d2ff 0%, #7b2ff7 100%);
    --gradient-warm: linear-gradient(135deg, #ff6b9d 0%, #ffa44f 100%);
    --gradient-cool: linear-gradient(135deg, #4ecdc4 0%, #00d2ff 100%);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --nav-height: 72px;
    --header-height: 60px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
body::before {
    content: '';
    position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(ellipse at 20% 20%, rgba(0,210,255,0.05) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 80%, rgba(123,47,247,0.05) 0%, transparent 50%);
    pointer-events: none; z-index: 0;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

.install-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    background: var(--gradient-main); padding: 12px 16px;
    animation: slideDown 0.4s ease;
}
.install-content {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    max-width: 600px; margin: 0 auto; font-size: 0.85rem; font-weight: 500;
}
.install-actions { display: flex; gap: 8px; flex-shrink: 0; }

.header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; height: var(--header-height);
    background: rgba(10,10,26,0.85);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 14px; }
.app-title {
    font-size: 1.2rem; font-weight: 700;
    background: var(--gradient-main);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.offline-badge {
    display: flex; align-items: center; gap: 6px; font-size: 0.75rem;
    color: var(--accent-orange); background: rgba(255,164,79,0.15);
    padding: 4px 10px; border-radius: 20px;
}
.offline-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent-orange); animation: pulse 2s infinite;
}
.step-counter {
    display: flex; align-items: center; gap: 4px; font-size: 0.8rem;
    color: var(--accent-green); background: rgba(78,205,196,0.12);
    padding: 4px 10px; border-radius: 20px;
}

.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-around;
    height: var(--nav-height); padding-bottom: var(--safe-bottom);
    background: rgba(12,12,30,0.92);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.06);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 8px 16px; border: none; background: none;
    color: var(--text-muted); font-size: 0.65rem; cursor: pointer;
    transition: all 0.3s ease; position: relative;
}
.nav-item svg { transition: all 0.3s ease; }
.nav-item.active { color: var(--accent-blue); }
.nav-item.active::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 24px; height: 3px; background: var(--gradient-main); border-radius: 0 0 4px 4px;
}
.nav-item:active { transform: scale(0.9); }

.main-content {
    position: relative; z-index: 1; padding: 20px 16px;
    padding-bottom: calc(var(--nav-height) + 20px + var(--safe-bottom));
    max-width: 600px; margin: 0 auto;
}
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

.section-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.section-header h2 { font-size: 1.4rem; font-weight: 700; }
.date-label { font-size: 0.85rem; color: var(--text-secondary); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius-md); padding: 16px;
    display: flex; align-items: center; gap: 12px;
    border: 1px solid rgba(255,255,255,0.04);
    transition: all 0.3s ease; position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%;
    background: var(--accent, var(--accent-blue)); border-radius: 0 4px 4px 0;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); background: rgba(255,255,255,0.04);
    color: var(--accent, var(--accent-blue)); flex-shrink: 0;
}
.stat-info { display: flex; flex-direction: column; }
.stat-value {
    font-size: 1.5rem; font-weight: 800; line-height: 1.2;
    background: var(--gradient-main);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.stat-label { font-size: 0.72rem; color: var(--text-secondary); font-weight: 500; }

.card {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 20px;
    margin-bottom: 16px; border: 1px solid rgba(255,255,255,0.04);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }

.chart-card { overflow: hidden; }
.chart-container { position: relative; height: 220px; }
.chart-toggle { display: flex; gap: 4px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px; border: none; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: all 0.3s ease; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
    background: var(--gradient-main); color: white;
    box-shadow: 0 4px 15px rgba(0,210,255,0.25);
}
.btn-primary:hover { box-shadow: 0 6px 25px rgba(0,210,255,0.35); }
.btn-ghost { background: transparent; color: var(--accent-blue); padding: 8px 12px; }
.btn-ghost:hover { background: rgba(0,210,255,0.08); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-danger { background: rgba(255,107,107,0.15); color: var(--accent-red); }
.btn-danger:hover { background: rgba(255,107,107,0.25); }

.chip {
    padding: 4px 12px; border: 1px solid rgba(255,255,255,0.1); border-radius: 20px;
    background: transparent; color: var(--text-secondary); font-size: 0.75rem;
    cursor: pointer; transition: all 0.3s ease;
}
.chip.active { background: var(--gradient-main); color: white; border-color: transparent; }

.workout-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.type-card {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 16px 8px; background: var(--bg-card); border: 2px solid transparent;
    border-radius: var(--radius-md); cursor: pointer; transition: all 0.3s ease;
    color: var(--text-secondary); font-size: 0.8rem; font-weight: 500;
}
.type-card:hover { background: var(--bg-card-hover); }
.type-card.active {
    border-color: var(--accent-blue); color: var(--text-primary);
    background: rgba(0,210,255,0.08);
}
.type-icon { font-size: 1.8rem; }

.workout-form { padding: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

input[type="text"], input[type="number"], input[type="date"], textarea, .select-input {
    width: 100%; padding: 12px 14px; background: var(--bg-input);
    border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 0.95rem; font-family: inherit;
    transition: border-color 0.3s ease; outline: none;
}
input:focus, textarea:focus, .select-input:focus {
    border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(0,210,255,0.1);
}
textarea { resize: vertical; }
.select-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%238888aa' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

.workout-list { display: flex; flex-direction: column; gap: 8px; }
.workout-item {
    display: flex; align-items: center; gap: 14px; padding: 14px;
    background: rgba(255,255,255,0.02); border-radius: var(--radius-md);
    transition: all 0.3s ease; cursor: pointer; border: 1px solid transparent;
}
.workout-item:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.06); }
.workout-icon {
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); font-size: 1.4rem; flex-shrink: 0;
}
.workout-icon.running { background: rgba(0,210,255,0.12); }
.workout-icon.cycling { background: rgba(123,47,247,0.12); }
.workout-icon.weightlifting { background: rgba(255,107,157,0.12); }
.workout-icon.swimming { background: rgba(78,205,196,0.12); }
.workout-icon.yoga { background: rgba(255,217,61,0.12); }
.workout-icon.hiking { background: rgba(255,164,79,0.12); }

.workout-details { flex: 1; min-width: 0; }
.workout-title {
    font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 8px;
}
.workout-meta {
    display: flex; gap: 12px; font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px;
}
.workout-meta span { display: flex; align-items: center; gap: 3px; }
.workout-actions { display: flex; gap: 4px; flex-shrink: 0; }
.workout-actions button {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: var(--text-muted); cursor: pointer;
    border-radius: var(--radius-sm); transition: all 0.2s;
}
.workout-actions button:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.workout-actions button.delete-btn:hover { color: var(--accent-red); }

.workout-date-group {
    font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    padding: 8px 0 4px; border-bottom: 1px solid rgba(255,255,255,0.04); margin-top: 8px;
}
.workout-date-group:first-child { margin-top: 0; }

.goals-list { display: flex; flex-direction: column; gap: 16px; }
.goal-card {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 20px;
    border: 1px solid rgba(255,255,255,0.04); transition: all 0.3s ease;
}
.goal-card:hover { border-color: rgba(255,255,255,0.08); }
.goal-header {
    display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px;
}
.goal-title { font-size: 1rem; font-weight: 700; }
.goal-badge {
    padding: 3px 10px; border-radius: 20px; font-size: 0.7rem;
    font-weight: 600; text-transform: uppercase;
}
.goal-badge.active { background: rgba(0,210,255,0.15); color: var(--accent-blue); }
.goal-badge.completed { background: rgba(78,205,196,0.15); color: var(--accent-green); }
.goal-badge.expired { background: rgba(255,107,107,0.15); color: var(--accent-red); }

.goal-progress { margin-bottom: 16px; }
.goal-progress-header {
    display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px;
}
.goal-progress-value {
    font-size: 1.6rem; font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.goal-progress-target { font-size: 0.85rem; color: var(--text-secondary); }
.goal-bar {
    height: 8px; background: rgba(255,255,255,0.06); border-radius: 10px;
    overflow: hidden; position: relative;
}
.goal-bar-fill {
    height: 100%; background: var(--gradient-main); border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.4,0,0.2,1); position: relative;
}
.goal-bar-fill.completed { background: var(--gradient-cool); }

.milestones {
    display: flex; justify-content: space-between; position: relative;
    margin-top: 20px; padding-top: 16px;
}
.milestones::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 2px; background: rgba(255,255,255,0.06);
}
.milestone {
    display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative;
}
.milestone::before {
    content: ''; position: absolute; top: -20px; width: 12px; height: 12px;
    border-radius: 50%; background: var(--bg-card);
    border: 2px solid rgba(255,255,255,0.15); transition: all 0.3s ease;
}
.milestone.reached::before {
    background: var(--accent-green); border-color: var(--accent-green);
    box-shadow: 0 0 10px rgba(78,205,196,0.4);
}
.milestone-percent { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); }
.milestone.reached .milestone-percent { color: var(--accent-green); }
.milestone-name {
    font-size: 0.65rem; color: var(--text-muted); max-width: 60px;
    text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.goal-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.04);
}
.goal-info { font-size: 0.78rem; color: var(--text-muted); }
.goal-actions { display: flex; gap: 4px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state p { margin-bottom: 16px; font-size: 0.9rem; }

.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 500;
    display: flex; align-items: flex-end; justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal.hidden { display: none; }
.modal-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
}
.modal-content {
    position: relative; width: 100%; max-width: 500px; max-height: 85vh; overflow-y: auto;
    background: var(--bg-secondary); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 24px; padding-bottom: calc(24px + var(--safe-bottom)); animation: slideUp 0.3s ease;
}
.modal-lg { max-height: 90vh; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border: none; background: rgba(255,255,255,0.06); color: var(--text-secondary);
    font-size: 1.3rem; border-radius: 50%; cursor: pointer; transition: all 0.2s;
}
.modal-close:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }

.milestones-input { display: flex; flex-direction: column; gap: 8px; }
.milestone-row { display: flex; gap: 8px; }
.milestone-row input { flex: 1; }
.milestone-row .milestone-value { max-width: 80px; }

.share-preview { margin-bottom: 16px; border-radius: var(--radius-md); overflow: hidden; }
.share-card {
    background: linear-gradient(135deg, #1a1a3e 0%, #0a0a1a 100%);
    padding: 24px; color: var(--text-primary); position: relative; overflow: hidden;
}
.share-card::before {
    content: ''; position: absolute; top: -30%; right: -30%; width: 60%; height: 60%;
    background: radial-gradient(circle, rgba(0,210,255,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.share-card-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 16px; position: relative;
}
.share-card-icon { font-size: 2rem; }
.share-card-title { font-size: 1.2rem; font-weight: 700; }
.share-card-date { font-size: 0.8rem; color: var(--text-secondary); }
.share-card-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
    margin-bottom: 16px; position: relative;
}
.share-stat {
    text-align: center; padding: 12px 8px;
    background: rgba(255,255,255,0.04); border-radius: var(--radius-sm);
}
.share-stat-value {
    font-size: 1.3rem; font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.share-stat-label { font-size: 0.7rem; color: var(--text-secondary); }
.share-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 0.75rem; color: var(--text-muted); position: relative;
}
.share-card-brand {
    font-weight: 700; background: var(--gradient-main);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.share-actions { display: flex; gap: 10px; }
.share-actions .btn { flex: 1; }

.toast {
    position: fixed; bottom: calc(var(--nav-height) + 16px + var(--safe-bottom));
    left: 50%; transform: translateX(-50%); padding: 12px 24px;
    background: var(--bg-card); color: var(--text-primary);
    border-radius: var(--radius-xl); font-size: 0.85rem; font-weight: 500;
    box-shadow: var(--shadow-lg); z-index: 600; animation: toastIn 0.3s ease;
    border: 1px solid rgba(255,255,255,0.08);
}
.toast.hidden { display: none; }
.toast.success { border-color: rgba(78,205,196,0.3); }
.toast.error { border-color: rgba(255,107,107,0.3); }

.hidden { display: none !important; }
.filter-group .select-input {
    padding: 6px 32px 6px 12px; font-size: 0.8rem; background-color: var(--bg-card);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes confetti {
    0% { transform: translateY(0) rotate(0); opacity: 1; }
    100% { transform: translateY(-100px) rotate(720deg); opacity: 0; }
}

@media (min-width: 768px) {
    .bottom-nav {
        top: 0; bottom: auto; left: 0; width: 80px; height: 100vh;
        flex-direction: column; justify-content: flex-start; padding: 80px 0 20px;
        border-top: none; border-right: 1px solid rgba(255,255,255,0.06);
    }
    .nav-item.active::before {
        top: 50%; left: 0; right: auto; transform: translateY(-50%);
        width: 3px; height: 24px; border-radius: 0 4px 4px 0;
    }
    .main-content { margin-left: 80px; padding-bottom: 40px; }
    .header { padding-left: 100px; }
    .modal-content { border-radius: var(--radius-xl); max-width: 480px; }
    .modal { align-items: center; }
    .toast { bottom: 32px; }
}

@media (max-width: 374px) {
    .stats-grid { grid-template-columns: 1fr; }
    .workout-types { grid-template-columns: repeat(2, 1fr); }
    .share-card-stats { grid-template-columns: repeat(2, 1fr); }
}
