:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --bg: #f8fafc;
    --surface: #ffffff;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 12px;
    --shadow: 0 4px 12px -2px rgba(0,0,0,0.05), 0 2px 6px -1px rgba(0,0,0,0.03);
}

.dark-mode {
    --bg: #020617;
    --surface: #0f172a;
    --card: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Readex Pro', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s ease;
}

.app-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    background: var(--bg);
}

.app-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 20;
}

.app-header h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.app-main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 100px;
}

.screen {
    display: none;
    animation: slideIn 0.3s ease-out;
}

.screen.active {
    display: block;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.hero-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 30px 20px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.progress-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-track {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.ring-bar {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.steps-count {
    display: block;
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--primary);
}

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

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

/* Stats Grid */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-tile {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tile-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.tile-icon svg { width: 20px; }
.tile-icon.calories { background: #fee2e2; color: #ef4444; }
.tile-icon.distance { background: #dcfce7; color: #22c55e; }

.tile-value { font-size: 1.25rem; font-weight: 700; margin-bottom: 2px; }
.tile-label { font-size: 0.8rem; color: var(--text-muted); }

/* Buttons */
.btn-primary {
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    padding: 18px;
    border-radius: var(--radius-lg);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
    transition: transform 0.2s;
}

.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 14px;
    border-radius: var(--radius-md);
    margin-top: 12px;
    font-size: 0.9rem;
}

.pulse { animation: pulseAnim 2s infinite; }
@keyframes pulseAnim {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Settings & List */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-title { font-size: 1rem; margin: 0 0 8px; font-weight: 700; }
.card-subtitle { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 20px; }

.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    padding: 8px;
    border-radius: var(--radius-md);
}

.step-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: none;
    background: var(--surface);
    color: var(--primary);
    font-size: 1.5rem;
    box-shadow: var(--shadow);
}

.step-value { text-align: center; }
.step-value span { display: block; }
.step-value .unit { font-size: 0.75rem; color: var(--text-muted); }

.menu-item {
    display: flex;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.menu-item:last-child { border-bottom: none; }
.menu-icon { color: var(--primary); width: 24px; }
.menu-item.danger { color: #ef4444; }
.menu-item.danger .menu-icon { color: #ef4444; }

/* Stats Chart */
.chart-area { height: 200px; display: flex; flex-direction: column; margin-top: 20px; }
.bar-chart { flex: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 0 10px; }
.bar-col { flex: 1; height: 100%; background: var(--bg); border-radius: 6px; position: relative; overflow: hidden; }
.bar-val { position: absolute; bottom: 0; width: 100%; background: var(--primary); border-radius: 6px; transition: height 0.8s ease; }
.chart-labels { display: flex; justify-content: space-between; padding: 10px 10px 0; font-size: 0.75rem; color: var(--text-muted); }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: var(--surface);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}
.h-main span { display: block; }
.h-date { font-size: 0.75rem; color: var(--text-muted); }
.h-steps { font-weight: 600; font-size: 0.95rem; }
.h-status { font-size: 0.7rem; padding: 4px 8px; border-radius: 20px; background: #f1f5f9; color: #64748b; }
.h-status.success { background: #dcfce7; color: #166534; }

/* Navigation */
.bottom-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 75px;
    background: var(--surface);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 30;
}

.tab-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 33.33%;
    transition: color 0.2s;
}

.tab-item svg { width: 24px; height: 24px; }
.tab-item span { font-size: 0.75rem; font-weight: 600; }
.tab-item.active { color: var(--primary); }

/* Utilities */
.icon-btn { background: none; border: none; color: var(--text); padding: 8px; }
.hidden { display: none !important; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-body { background: var(--surface); border-radius: var(--radius-xl); padding: 24px; width: 100%; max-width: 340px; text-align: center; }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.btn-secondary { flex: 1; padding: 12px; border: 1px solid var(--border); background: none; border-radius: var(--radius-md); }
.btn-danger { flex: 1; padding: 12px; background: #ef4444; color: white; border: none; border-radius: var(--radius-md); }

.toast-message {
    position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
    background: #1e293b; color: white; padding: 10px 20px; border-radius: 50px;
    font-size: 0.85rem; z-index: 50; animation: toastIn 0.3s ease;
}
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.app-info { text-align: center; padding: 20px; color: var(--text-muted); font-size: 0.75rem; }
