:root {
    --bg-dark: #090d16;
    --bg-card: #131b2e;
    --bg-card-hover: #1b2640;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.25);
    --secondary: #f97316;
    --danger: #ef4444;
    --youtube: #ff0033;
    --border: #1e293b;
    --radius: 16px;
}

body.theme-lose {
    --accent: #f97316;
    --accent-glow: rgba(249, 115, 22, 0.25);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    padding-bottom: 90px;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(9, 13, 22, 0.88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo h1 span {
    color: var(--accent);
    margin-left: 2px;
}

.app-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 20px 16px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease;
}

.tab-content.active {
    display: block;
}

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

.btn-primary {
    background: var(--accent);
    color: #051b11;
    font-weight: 700;
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-outline:hover {
    background: var(--bg-card);
}

.btn-block {
    width: 100%;
    font-size: 1rem;
    padding: 14px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}

.welcome-banner {
    background: linear-gradient(135deg, var(--bg-card) 0%, #17253b 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.user-profile-header {
    flex: 1;
}

.greeting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.greeting {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.inline-level-badge {
    background: var(--accent);
    color: #051b11;
    font-weight: 800;
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 99px;
    letter-spacing: 0.5px;
    box-shadow: 0 0 12px var(--accent-glow);
}

.welcome-banner h2 {
    font-size: 1.15rem;
    margin-top: 4px;
    color: var(--accent);
}

.xp-bar-wrapper {
    margin-top: 10px;
}

.xp-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.xp-bar-track {
    width: 100%;
    height: 7px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 99px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #38bdf8);
    transition: width 0.35s ease;
}

.level-pill {
    background: rgba(255,255,255,0.06);
    padding: 12px 14px;
    border-radius: 14px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.1);
    min-width: 92px;
}

.level-pill span {
    display: block;
    font-size: 0.95rem;
}

.level-pill small {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.75rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card .card-header-sm {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-main {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 6px 0;
}

.stat-main small {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.stat-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge {
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent);
}

.section-title h3 {
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 14px;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: var(--accent);
    background: rgba(255,255,255,0.06);
}

.action-icon {
    font-size: 1.6rem;
}

.action-info {
    flex: 1;
}

.action-info strong {
    display: block;
    font-size: 0.95rem;
}

.action-info small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.xp-tag {
    background: var(--accent-glow);
    color: var(--accent);
    padding: 5px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.78rem;
}

.weight-updater {
    display: flex;
    gap: 10px;
}

.weight-updater input {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 10px;
}

.section-header {
    margin-bottom: 18px;
}

.section-header h2 {
    font-size: 1.35rem;
    margin-bottom: 4px;
}

.section-header p {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.days-selector {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 14px;
}

.day-btn {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.day-btn.active {
    background: var(--accent);
    color: #051b11;
    border-color: var(--accent);
}

.exercise-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.exercise-details h4 {
    font-size: 1rem;
    margin-bottom: 6px;
}

.exercise-meta {
    display: flex;
    gap: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.yt-link {
    background: rgba(255, 0, 51, 0.14);
    color: #ff4d6d;
    border: 1px solid rgba(255, 0, 51, 0.35);
    padding: 9px 12px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.yt-link:hover {
    background: var(--youtube);
    color: #fff;
}

.macros-summary-card {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.macro-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
}

.macro-box span {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.macro-box strong {
    font-size: 1.2rem;
    display: block;
    margin: 4px 0;
    color: var(--accent);
}

.macro-box small {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.meal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}

.meal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.meal-time {
    background: rgba(255,255,255,0.07);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.meal-option {
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}

.meal-option:last-child {
    margin-bottom: 0;
}

.meal-option-title {
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 6px;
}

.meal-macros {
    display: flex;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.meal-macros span strong {
    color: var(--text-main);
}

.badges-progress-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.progress-track {
    width: 100%;
    height: 10px;
    background: var(--bg-dark);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #3b82f6);
    transition: width 0.4s ease;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.badge-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    transition: all 0.3s ease;
}

.badge-item.locked {
    filter: grayscale(100%);
    opacity: 0.35;
}

.badge-item.unlocked {
    border-color: var(--accent);
    box-shadow: 0 0 22px var(--accent-glow);
    transform: translateY(-2px);
}

.badge-medal {
    font-size: 2.3rem;
    margin-bottom: 8px;
    display: inline-block;
}

.badge-item h4 {
    font-size: 0.92rem;
    margin-bottom: 4px;
}

.badge-item p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.badge-status {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 99px;
    background: rgba(255,255,255,0.08);
}

.badge-item.unlocked .badge-status {
    background: var(--accent);
    color: #051b11;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(19, 27, 46, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    z-index: 40;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.nav-item.active {
    color: var(--accent);
}

.nav-icon {
    font-size: 1.35rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(6px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    padding: 24px;
}

.modal-header h2 {
    margin-bottom: 6px;
}

.modal-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.form-group {
    margin-bottom: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

input, select {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-dark);
    color: var(--text-main);
    font-size: 0.95rem;
}

.goal-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.goal-selector input {
    display: none;
}

.goal-card {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-dark);
}

.goal-card .goal-icon {
    font-size: 1.6rem;
    display: block;
    margin-bottom: 4px;
}

.goal-card strong {
    display: block;
    color: var(--text-main);
    font-size: 0.9rem;
}

.goal-card small {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.goal-selector input:checked + .goal-card {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.toast {
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #051b11;
    padding: 12px 22px;
    border-radius: 99px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
    z-index: 200;
    transition: opacity 0.3s;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}
