* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #3b82f6;
        --primary-dark: #2563eb;
        --secondary: #94a3b8;
        --success: #34d399;
        --danger: #f87171;
        --bg: #0f172a;
        --surface: #1e293b;
        --text: #f1f5f9;
        --text-light: #94a3b8;
        --border: #334155;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Auth Screen */
#auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-form button:hover {
    background: var(--primary-dark);
}

.error-message {
    color: var(--danger);
    margin-top: 10px;
    font-size: 14px;
    min-height: 20px;
}

/* Navigation */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.nav-header h1 {
    font-size: 20px;
}

.logout-btn {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.nav-tabs {
    display: flex;
    overflow-x: auto;
}

.nav-tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    color: var(--text-light);
    transition: all 0.2s;
}

.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Views */
.view {
    display: none;
    min-height: calc(100vh - 120px);
    padding-bottom: 40px;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.view-header h2 {
    font-size: 24px;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-full {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.card h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.card p {
    color: var(--text-light);
    font-size: 14px;
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.card-actions button {
    padding: 6px 12px;
    font-size: 13px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

/* Exercise Items */
.exercise-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.exercise-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.exercise-item h4 {
    font-size: 16px;
}

.remove-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.exercise-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.input-group input {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Exercise Categories */
.category {
    margin-bottom: 20px;
}

.category h4 {
    font-size: 14px;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 10px;
}

.exercise-option {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.exercise-option:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Timer */
.timer {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

/* Workout Active */
.workout-set {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
}

.workout-set > span {
    flex-shrink: 0;
    font-size: 14px;
}

.workout-set input {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.workout-set button {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 13px;
}

.workout-set.completed input {
    background: #d1fae5;
    border-color: var(--success);
}

/* History */
.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.history-header h3 {
    font-size: 18px;
}

.history-date {
    font-size: 14px;
    color: var(--text-light);
}

.history-duration {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

.history-exercises {
    margin-top: 12px;
}

.history-exercise {
    padding: 8px;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 14px;
}

.history-exercise strong {
    display: block;
    margin-bottom: 4px;
}

.history-exercise-details {
    color: var(--text-light);
    font-size: 13px;
}

/* Progress */
.progress-entry {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.progress-entry-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.progress-date {
    font-weight: 600;
}

.progress-stats {
    color: var(--text-light);
    font-size: 14px;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state h3 {
    margin-bottom: 10px;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 15px;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .view-header button {
        width: 100%;
    }

    .timer {
        font-size: 24px;
    }

    .exercise-inputs {
        grid-template-columns: 1fr 1fr;
    }

    .workout-set {
        gap: 4px;
    }

    .workout-set > span {
        min-width: 50px;
        font-size: 12px;
    }

    .workout-set input {
        padding: 8px 4px;
        font-size: 14px;
    }

    .workout-set button {
        padding: 8px;
        font-size: 12px;
        min-width: 50px;
    }
}
