body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f4;
    color: #1d1d1f;
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    min-height: 100svh; /* Use small viewport height for better mobile support */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

@media (prefers-color-scheme: dark) {
    body {
        background: #1e293b;
        color: #ffffff;
    }
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.05em;
    color: #1d1d1f;
    line-height: 1.1;
}

@media (prefers-color-scheme: dark) {
    h1 {
        color: #ffffff;
    }
}

p {
    font-size: 1.2rem;
    color: #666;
    margin: 1rem 0;
    font-weight: 400;
}

@media (prefers-color-scheme: dark) {
    p {
        color: #a1a1aa; /* zinc-400 */
    }
}

main {
    max-width: 400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    main {
        max-width: 500px;
        gap: 2rem;
    }
}

.upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

.upload-label {
    background: linear-gradient(135deg, #1d1d1f 0%, #333 100%);
    color: #fff;
    padding: 1.25rem 2rem;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    display: block;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 2px solid transparent;
    box-sizing: border-box;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.upload-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    background: linear-gradient(135deg, #333 0%, #1d1d1f 100%);
}

@media (prefers-color-scheme: dark) {
    .upload-label {
        background: linear-gradient(135deg, #ffffff 0%, #e5e5e5 100%);
        color: #1d1d1f;
        box-shadow: 0 4px 15px rgba(255,255,255,0.1);
    }
    
    .upload-label:hover {
        background: linear-gradient(135deg, #f3f3f3 0%, #ffffff 100%);
        box-shadow: 0 8px 25px rgba(255,255,255,0.15);
    }
}

input[type="file"] {
    display: none;
}

.nav-item {
    font-size: 1.5rem;
    font-weight: 400;
    color: #1d1d1f;
    text-decoration: none;
    margin: 0.5rem 0;
    transition: color 0.2s ease;
}

.nav-item:hover {
    color: #666;
}

.hidden {
    display: none;
}

#analysis {
    width: 100%;
    max-width: 600px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

@media (min-width: 768px) {
    #analysis {
        max-width: 700px;
    }
}

@media (min-width: 1024px) {
    #analysis {
        max-width: 800px;
    }
}

#analysis.visible {
    opacity: 1;
    transform: translateY(0);
}

section {
    margin-bottom: 2rem;
    width: 100%;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

section.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

section.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    text-align: center;
}

.card {
    background-color: #ffffff;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
    backdrop-filter: blur(10px);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

@media (prefers-color-scheme: dark) {
    .card {
        background-color: rgba(51, 65, 85, 0.9);
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        border: 1px solid rgba(255,255,255,0.1);
        backdrop-filter: blur(10px);
    }
    
    .card:hover {
        box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    }
}

.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    width: 100%;
}

.summary-card {
    background-color: #ffffff;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.summary-card h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.summary-card p {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
}

.summary-card span {
    font-size: 0.8rem;
    color: #666;
    display: block;
    margin-top: 0.25rem;
}

@media (prefers-color-scheme: dark) {
    .summary-card {
        background-color: rgb(51 65 85); /* slate-700 */
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        border: 1px solid rgba(255,255,255,0.1);
    }
    
    .summary-card h3 {
        color: #a1a1aa; /* zinc-400 */
    }
    
    .summary-card p {
        color: #ffffff;
    }
    
    .summary-card span {
        color: #a1a1aa; /* zinc-400 */
    }
}

canvas {
    max-height: 300px;
}

#conclusion-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #1d1d1f;
    text-align: left;
}

.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 250px;
    align-items: center;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    text-align: center;
}

@media (prefers-color-scheme: dark) {
    .filter-group label {
        color: #d1d5db;
    }
}

.filter-group select {
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 0.9rem;
    background-color: #ffffff;
    color: #374151;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: center;
}

.filter-group select:focus {
    outline: none;
    border-color: #1d1d1f;
    box-shadow: 0 0 0 3px rgba(29, 29, 31, 0.1);
}

@media (prefers-color-scheme: dark) {
    .filter-group select {
        background-color: #374151;
        border-color: #6b7280;
        color: #ffffff;
        width: 100%;
        text-align: center;
    }
    
    .filter-group select:focus {
        border-color: #ffffff;
        box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
    }
}

.exercise-details {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 2px solid #e2e8f0;
}

.exercise-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.exercise-stat {
    background: #ffffff;
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #f1f5f9;
}

.exercise-stat h4 {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0 0 0.5rem 0;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.exercise-stat p {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.exercise-stat .unit {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

#selected-exercise-title {
    color: #1e293b;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

#exercise-analysis {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#exercise-analysis.visible {
    opacity: 1;
    transform: translateY(0);
}

.insights-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.insight-item {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    padding: 1rem;
    border-radius: 12px;
    border-left: 4px solid #3b82f6;
}

.insight-item.warning {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
}

.insight-item.positive {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

.insight-item.negative {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);
}

.insight-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.insight-description {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.5;
    margin: 0;
}

.filter-btn {
    background-color: #1d1d1f;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.filter-btn:hover {
    background-color: #333;
    transform: translateY(-1px);
}

@media (prefers-color-scheme: dark) {
    #conclusion-text {
        color: #ffffff;
    }
    
    .filter-group label {
        color: #a1a1aa;
    }
    
    .filter-group select {
        background-color: rgb(71 85 105);
        color: #ffffff;
        border-color: #475569;
        width: 100%;
        text-align: center;
    }
    
    .filter-group select:focus {
        border-color: #a78bfa;
    }
    
    .filter-btn {
        background-color: #ffffff;
        color: #1d1d1f;
    }
    
    .filter-btn:hover {
        background-color: #e5e5e5;
    }
    
    .exercise-details {
        background: linear-gradient(135deg, rgb(51 65 85) 0%, rgb(30 41 59) 100%);
        border-color: #475569;
    }
    
    .exercise-stat {
        background-color: rgb(71 85 105);
        border-color: #64748b;
    }
    
    .exercise-stat h4 {
        color: #94a3b8;
    }
    
    .exercise-stat p {
        color: #f1f5f9;
    }
    
    .exercise-stat .unit {
        color: #94a3b8;
    }
    
    #selected-exercise-title {
        color: #f1f5f9;
    }
    
    .insight-item {
        background: linear-gradient(135deg, rgb(71 85 105) 0%, rgb(51 65 85) 100%);
    }
    
    .insight-item.warning {
        background: linear-gradient(135deg, #92400e 0%, #78350f 100%);
    }
    
    .insight-item.positive {
        background: linear-gradient(135deg, #166534 0%, #14532d 100%);
    }
    
    .insight-item.negative {
        background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%);
    }
    
    .insight-title {
        color: #f1f5f9;
    }
    
    .insight-description {
        color: #cbd5e1;
    }
}

.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

@media (min-width: 600px) {
    .filter-controls {
        flex-direction: row;
        align-items: end;
        gap: 1.5rem;
    }
    
    .filter-group {
        flex: 1;
    }
    
    .filter-btn {
        margin-top: 0;
        height: fit-content;
        flex-shrink: 0;
    }
}


@media (max-width: 600px) {
    body {
        padding: 1rem 0.75rem;
        justify-content: flex-start;
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    header {
        margin-bottom: 1.5rem;
        margin-top: 1rem;
    }

    .disclaimer {
        font-size: 0.75rem;
        margin-top: 0.25rem;
    }

    h1 {
        font-size: clamp(2rem, 10vw, 3rem);
        line-height: 1.1;
    }

    p {
        font-size: 1rem;
        margin: 0.75rem 0;
    }

    main {
        max-width: 100%;
        gap: 1.25rem;
        padding: 0 0.5rem;
    }

    .upload-label {
        padding: 1.5rem 1rem;
        font-size: 1rem;
        min-height: 64px;
        border-radius: 14px;
    }

    .card-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .summary-card {
        padding: 0.75rem;
    }

    .summary-card p {
        font-size: 1.5rem;
    }

    .card {
        padding: 1rem;
    }

    canvas {
        max-height: 250px;
    }

    .file-info {
        padding: 0.75rem;
        min-height: 56px;
        border-radius: 14px;
    }

    .remove-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .analysis-btn {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
        min-height: 44px;
        max-width: 120px;
    }
}

/* iPhone specific adjustments */
@media (max-width: 430px) {
    body {
        padding: 0.75rem 0.5rem;
    }

    header {
        margin-bottom: 1rem;
    }

    .disclaimer {
        font-size: 0.7rem;
        margin-top: 0.25rem;
    }

    h1 {
        font-size: clamp(1.75rem, 12vw, 2.5rem);
    }

    main {
        gap: 1rem;
        padding: 0 0.25rem;
    }

    .upload-label {
        padding: 1.25rem 0.75rem;
        font-size: 0.95rem;
        min-height: 56px;
    }

    .card-container {
        gap: 0.5rem;
    }

    .summary-card {
        padding: 0.5rem;
    }

    .summary-card p {
        font-size: 1.25rem;
    }

    .file-info {
        padding: 0.75rem;
        min-height: 56px;
        border-radius: 14px;
    }

    .remove-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .analysis-btn {
        padding: 0.875rem 1rem;
        font-size: 0.9rem;
        min-height: 44px;
        max-width: 120px;
    }
}

.file-info {
    display: none;
    align-items: center;
    justify-content: space-between;
    background-color: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
    margin-top: 0;
    min-height: 60px;
    touch-action: manipulation;
}

.file-info.hidden {
    display: none !important;
}

@media (prefers-color-scheme: dark) {
    .file-info {
        background-color: #374151;
        border-color: #6b7280;
        color: #ffffff;
    }
}

#fileName {
    font-size: 0.9rem;
    color: #374151;
    font-weight: 500;
    flex-grow: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
    #fileName {
        color: #d1d5db;
    }
}

.remove-btn {
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.2s ease;
    margin-left: 1rem;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.remove-btn:hover {
    background-color: #dc2626;
    transform: scale(1.1);
}

.analysis-options {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.analysis-btn {
    background-color: #f3f4f6;
    border: 2px solid #e5e7eb;
    color: #374151;
    padding: 1rem 1.5rem;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 150px;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.analysis-btn:hover {
    background-color: #e5e7eb;
    transform: translateY(-1px);
}

.analysis-btn.active {
    background-color: #1d1d1f;
    color: white;
    border-color: #1d1d1f;
}

@media (prefers-color-scheme: dark) {
    .analysis-btn {
        background-color: #374151;
        border-color: #6b7280;
        color: #d1d5db;
    }
    
    .analysis-btn:hover {
        background-color: #4b5563;
    }
    
    .analysis-btn.active {
        background-color: #ffffff;
        color: #1d1d1f;
        border-color: #ffffff;
    }
}

.disclaimer {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.5rem;
    font-weight: 400;
    opacity: 0.8;
}

@media (prefers-color-scheme: dark) {
    .disclaimer {
        color: #a1a1aa;
    }
}
