body {
    background-color: #020617;
    color: white;
    font-family: system-ui, sans-serif;
    margin: 0; overflow: hidden;
    touch-action: none;
}

#app { display: flex; flex-direction: column; width: 100vw; height: 100dvh; }

.top-bar {
    height: 50px; background: #1e293b; border-bottom: 1px solid #334155;
    display: flex; align-items: center; padding: 0 15px; z-index: 100;
}

.canvas-area { flex-grow: 1; position: relative; background: #020617; }

canvas { position: absolute; top: 0; left: 0; z-index: 1; }

.side-menu {
    position: absolute; z-index: 50;
    background: rgba(15, 23, 42, 0.7);
    padding: 12px; border-radius: 12px;
    backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.1);
}

.menu-title { font-size: 10px; font-weight: 800; color: #64748b; margin-bottom: 8px; letter-spacing: 1px; }
.menu-item { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 4px; font-size: 13px; font-weight: 600; }

/* 控制介面層級設定 */
.controls-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 90; pointer-events: none;
    /* 加強阻止選取 */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE/Edge */
    user-select: none;         /* 標準 */
}

.connector-line {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.connector-line line {
    stroke: rgba(250, 204, 21, 0.5);
    stroke-width: 2;
    stroke-dasharray: 6, 4;
}

/* 主光源位置控制點 (最大) */
.source-handle {
    position: absolute; width: 44px; height: 44px; transform: translate(-50%, -50%);
    z-index: 100; cursor: grab; display: flex; align-items: center; justify-content: center;
    pointer-events: auto;
}
.source-handle:active { cursor: grabbing; }
.handle-core {
    width: 22px; height: 22px; background: #fff; border: 3px solid #facc15;
    border-radius: 50%; box-shadow: 0 0 15px #fff;
}

.source-handle, .angle-handle {
    pointer-events: auto;
    -webkit-touch-callout: none; /* 阻止 iOS 長按選單 */
}

/* 角度控制點 (較小，半透明) */
.angle-handle {
    position: absolute; width: 28px; height: 28px; transform: translate(-50%, -50%);
    z-index: 95; cursor: grab;
    background: rgba(250, 204, 21, 0.25);
    border: 2px solid #facc15;
    border-radius: 50%;
    backdrop-filter: blur(2px);
    pointer-events: auto;
}
.angle-handle:active { cursor: grabbing; background: rgba(250, 204, 21, 0.5); }


.prism-control {
    position: absolute; 
    transform: translate(-50%, -50%);
    pointer-events: none; 
    width: 100px; 
    height: 100px;
}

.prism-move-handle {
    position: absolute; 
    top: 50%; left: 50%; 
    transform: translate(-50%, -50%);
    width: 28px; height: 28px; 
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.7); 
    color: white;
    display: flex; align-items: center; justify-content: center;
    cursor: grab; pointer-events: auto; 
    font-size: 18px; border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.prism-rotate-handle {
    position: absolute; 
    width: 16px; height: 16px; 
    border-radius: 50%;
    background: #ef4444; 
    border: 2px solid #fff;
    cursor: grab; 
    pointer-events: auto;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    transform: translate(-50%, -50%); 
}

.prism-move-handle:active, .prism-rotate-handle:active { cursor: grabbing; }

.canvas-area, .controls-layer {
    user-select: none; -webkit-user-select: none;
}