* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background: var(--vscode-editor-background, #1e1e1e);
    color: var(--vscode-editor-foreground, #d4d4d4);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

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

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--vscode-sideBar-background, #252526);
    border-bottom: 1px solid var(--vscode-panel-border, #3c3c3c);
    flex-shrink: 0;
}

.title {
    font-size: 16px;
    font-weight: 600;
}

.file-info {
    font-size: 12px;
    color: var(--vscode-descriptionForeground, #808080);
}

.file-info .dimensions {
    margin-left: 12px;
}

.main {
    display: flex;
    flex: 1;
    min-height: 0;
}

.layer-panel {
    width: 240px;
    min-width: 200px;
    background: var(--vscode-sideBar-background, #252526);
    border-right: 1px solid var(--vscode-panel-border, #3c3c3c);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.layer-panel-header {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid var(--vscode-panel-border, #3c3c3c);
    flex-shrink: 0;
}

.layer-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    user-select: none;
}

.layer-item:hover {
    background: var(--vscode-list-hoverBackground, #2a2d2e);
}

.layer-item.group {
    font-weight: 600;
    color: var(--vscode-descriptionForeground, #808080);
}

.layer-item .layer-eye {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: 14px;
    padding: 0;
}

.layer-item .layer-eye:hover {
    color: var(--vscode-focusBorder, #007acc);
}

.layer-item .layer-eye.hidden {
    opacity: 0.4;
}

.layer-item .layer-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-item .layer-view-btn {
    flex-shrink: 0;
    padding: 2px 8px;
    font-size: 11px;
    border: 1px solid var(--vscode-button-border, transparent);
    background: var(--vscode-button-secondaryBackground, #3a3d41);
    color: var(--vscode-button-secondaryForeground, #fff);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
}

.layer-item:hover .layer-view-btn {
    opacity: 1;
}

.layer-item .layer-view-btn:hover {
    background: var(--vscode-button-secondaryHoverBackground, #45494e);
}

.layer-item .layer-spacer {
    width: 20px;
    flex-shrink: 0;
}

.canvas-area {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--vscode-editor-background, #1e1e1e);
}

.loading, .error {
    padding: 24px;
    text-align: center;
    font-size: 14px;
}

.error {
    color: var(--vscode-errorForeground, #f48771);
}

.canvas-wrapper {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mainCanvas {
    max-width: 100%;
    height: auto;
    display: block;
    background: transparent;
}

/* Checkerboard background for transparency */
.canvas-wrapper.checker {
    background-image:
        linear-gradient(45deg, #2d2d2d 25%, transparent 25%),
        linear-gradient(-45deg, #2d2d2d 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2d2d2d 75%),
        linear-gradient(-45deg, transparent 75%, #2d2d2d 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #1e1e1e;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--vscode-editor-background, #1e1e1e);
    border: 1px solid var(--vscode-panel-border, #3c3c3c);
    border-radius: 8px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--vscode-panel-border, #3c3c3c);
    flex-shrink: 0;
}

.modal-title {
    font-size: 14px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--vscode-editor-foreground);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
}

.modal-close:hover {
    background: var(--vscode-toolbar-hoverBackground);
}

.modal-body {
    padding: 16px;
    overflow: auto;
    flex: 1;
    min-height: 0;
}

.modal-canvas-wrap {
    display: inline-block;
    background-image:
        linear-gradient(45deg, #2d2d2d 25%, transparent 25%),
        linear-gradient(-45deg, #2d2d2d 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2d2d2d 75%),
        linear-gradient(-45deg, transparent 75%, #2d2d2d 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #252526;
    padding: 0;
}

.modal-canvas-wrap canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--vscode-scrollbarSlider-background);
}

::-webkit-scrollbar-thumb {
    background: var(--vscode-scrollbarSlider-background);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--vscode-scrollbarSlider-hoverBackground);
}
