body { margin: 0; overflow: hidden; font-family: 'Inter', sans-serif; display: flex; flex-direction: column; height: 100vh; }
#app-header { flex-shrink: 0; padding: 1rem; background-color: #1f2937; color: white; border-bottom: 2px solid #374151; }
/* 임베드(iframe) 모드: 바깥 사이트 헤더와 겹치므로 자체 헤더를 뺀다 */
html.embedded #app-header { display: none; }
#main-content { display: flex; flex-grow: 1; min-height: 0; }
#input-panel { flex-basis: 350px; flex-shrink: 0; padding: 1rem; background-color: #f3f4f6; overflow-y: auto; }
/* min-width:0 이 없으면 flex 항목이 내용(캔버스)보다 좁아지지 못해 사이드바를
   넓혀도 그래픽 영역이 줄지 않는다. */
#visualization-container { flex-grow: 1; position: relative; min-width: 0; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; }

/* 패널 / 그래픽 영역 폭 조절 손잡이 */
#panel-resizer {
    flex: 0 0 6px;
    position: relative;
    cursor: col-resize;
    background: #e5e7eb;
    border-left: 1px solid #d1d5db;
    border-right: 1px solid #d1d5db;
    touch-action: none;
    user-select: none;
}
#panel-resizer:hover,
#panel-resizer:focus-visible,
#panel-resizer.dragging { background: #93c5fd; outline: none; }
/* 6px는 잡기 어려우니 히트 영역만 좌우로 넓힌다 */
#panel-resizer::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: -4px; right: -4px;
}
#panel-resizer::after {
    content: '⋮';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: #6b7280;
    font-size: 13px;
    line-height: 1;
}
/* 드래그 중에는 캔버스 위에서도 커서와 선택 동작을 고정한다 */
body.resizing { cursor: col-resize; }
body.resizing * { user-select: none !important; }
#mct-input { height: 220px; resize: vertical; min-height: 150px; font-family: monospace; font-size: 10px; }

/* --- Label Styles Start --- */
/* 번호 라벨은 이 캔버스에 직접 그린다. DOM 요소로 만들면 11만 개가 되어 못 버틴다. */
#label-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 90;
}
/* --- Label Styles End --- */

#info-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 300px;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 100;
}
#zoom-selection-rect {
    position: absolute;
    border: 2px dashed #00aaff;
    background: rgba(0, 170, 255, 0.1);
    pointer-events: none;
    z-index: 95;
    display: none;
}
#instructions {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 12px;
    z-index: 100;
}

/* 요소 종류별 표시 토글 패널 */
#element-class-panel .class-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 0;
}
#element-class-panel .class-count {
    font-family: monospace;
    font-size: 11px;
    color: #6b7280;
}
#element-class-panel .class-row.disabled {
    opacity: 0.4;
}

/* 경계조건 심볼 범례 */
#constraint-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 2px 24px;
    padding: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
}
#constraint-legend.hidden { display: none; }
#constraint-legend svg { flex: 0 0 auto; }

/* 그룹 목록 */
#group-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
}
#group-list .group-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    cursor: pointer;
}
#group-list .group-row:hover {
    background: #eef2ff;
}
#group-list .group-name {
    flex: 1 1 auto;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#group-list .group-name.group-orphan {
    font-style: italic;
    color: #6b7280;
}
#group-list .group-count {
    flex: 0 0 auto;
    font-family: monospace;
    font-size: 11px;
    color: #6b7280;
}

/* 표준 시점 툴바 (등각/평면/정면/측면) */
#view-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 2px;
    padding: 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #d1d5db;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    color: #374151;
    z-index: 100;
}
#view-toolbar .view-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    width: 40px;
    padding: 3px 0 2px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: inherit;
    font: inherit;
    font-size: 10px;
    line-height: 1.1;
    cursor: pointer;
}
#view-toolbar .view-btn:hover { background: rgba(59, 130, 246, 0.18); border-color: #93c5fd; }
#view-toolbar .view-btn:active { background: rgba(59, 130, 246, 0.35); }
#view-toolbar .view-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }
#view-toolbar svg { width: 22px; height: 22px; display: block; }
/* 아이콘은 등각 상자 한 개. 보는 면만 진하게 칠한다. */
#view-toolbar .face { fill: currentColor; fill-opacity: 0.08; }
#view-toolbar .face.on { fill-opacity: 0.6; }
#view-toolbar .ic-iso .face { fill-opacity: 0.42; }
#view-toolbar .ic-iso .face:nth-of-type(2) { fill-opacity: 0.2; }
#view-toolbar .ic-iso .face:nth-of-type(3) { fill-opacity: 0.3; }
#view-toolbar.theme-dark {
    background: rgba(31, 41, 55, 0.85);
    border-color: #4b5563;
    color: #e5e7eb;
}
