:root {
    --bg-dark: #0a0c10;
    --bg-card: rgba(23, 27, 34, 0.7);
    --accent-blue: #3d8bff;
    --accent-glow: rgba(61, 139, 255, 0.3);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --border-color: rgba(255, 255, 255, 0.1);
    --sidebar-width: 320px;
    --glass-blur: blur(12px);
    --marker-color: #ff3d3d;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
}

/* Screen reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: #101217;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.5rem;
    color: var(--accent-blue);
    margin-bottom: 0.2rem;
}

.sidebar-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.search-box {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    background: #1d2128;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-box input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    fill: var(--text-secondary);
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
}

.filter-tabs button {
    flex: 1;
    background: #1d2128;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-tabs button.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* Calibration Controls */
.calibration-controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #444;
}

.calibration-controls h4 {
    color: #aaa;
    margin-bottom: 10px;
}

.calibration-btn {
    width: 100%;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calibration-toggle {
    background: #444;
    margin-bottom: 8px;
}

.calibration-toggle.calibration-active {
    background: #ed8936;
}

.calibration-copy {
    background: #2c5282;
}

.calibration-status {
    font-size: 0.8rem;
    color: #48bb78;
    text-align: center;
    display: none;
}

.muscle-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.5rem;
}

/* Muscle item as button - reset button styles */
.muscle-item {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
}

.muscle-item:hover,
.muscle-item:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    outline: none;
}

.muscle-item:focus-visible {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.muscle-item.active {
    background: rgba(61, 139, 255, 0.1);
    border-color: var(--accent-blue);
}

.muscle-item h4 {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.muscle-item span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.sidebar-footer {
    padding: 1rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

/* Content Area */
.content {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
    background: radial-gradient(circle at top right, #1a1e26, #0a0c10);
    position: relative;
}

.glass {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.view {
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Welcome View */
.welcome-view {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-card {
    padding: 4rem;
    text-align: center;
    max-width: 600px;
}

.welcome-card h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, #fff, #3d8bff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-card p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.stat-item span {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-blue);
}

/* Detail View */
.muscle-header {
    margin-bottom: 3rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.badge {
    background: rgba(61, 139, 255, 0.15);
    color: var(--accent-blue);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.8rem;
    display: inline-block;
}

#muscleName {
    font-size: 3rem;
    font-weight: 700;
}

.pattern-section {
    text-align: right;
}

.pattern-section label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pattern-section p {
    font-size: 1.2rem;
    font-weight: 500;
}

.grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.image-panel .image-wrapper {
    aspect-ratio: 1/1.4;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background: #000;
}

#diagramContainer {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#diagramContainer img {
    max-width: 100%;
    max-height: 100%;
    opacity: 0.6;
    margin-bottom: 20px;
}

body.editing-mode .image-wrapper {
    cursor: crosshair;
    border: 2px solid #ed8936;
}

.marker {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--marker-color);
    border: 4px solid white;
    border-radius: 50%;
    box-shadow: 0 0 20px var(--marker-color);
    transform: translate(-50%, -50%);
    z-index: 5;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.info-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-card {
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.info-card h3 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
    color: var(--accent-blue);
}

.info-card h3 svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.info-card p {
    font-size: 1.05rem;
    color: var(--text-primary);
}

.dosage-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #ff3d3d;
    padding: 0.4rem 1rem;
    border-radius: 8px;
    font-weight: 700;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* =============================================
   Responsive Design
   ============================================= */

/* Tablet */
@media (max-width: 1024px) {
    .grid-layout {
        grid-template-columns: 1fr;
    }

    #muscleName {
        font-size: 2rem;
    }

    .muscle-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .pattern-section {
        text-align: left;
    }

    .content {
        padding: 2rem;
    }

    .welcome-card {
        padding: 2.5rem;
    }

    .welcome-card h2 {
        font-size: 2rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .muscle-list {
        max-height: 40vh;
    }

    .content {
        padding: 1.5rem;
    }

    #muscleName {
        font-size: 1.75rem;
    }

    .welcome-card {
        padding: 2rem;
    }

    .welcome-card h2 {
        font-size: 1.5rem;
    }

    .stats {
        flex-direction: column;
        gap: 1rem;
    }

    .image-panel .image-wrapper {
        aspect-ratio: 1/1;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .sidebar-header {
        padding: 1.5rem 1rem;
    }

    .content {
        padding: 1rem;
    }

    #muscleName {
        font-size: 1.4rem;
    }

    .info-card {
        padding: 1rem;
    }

    .info-card p {
        font-size: 0.95rem;
    }
}
