* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #eee;
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 顶部工具栏 */
#toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    flex-shrink: 0;
}

.logo {
    font-size: 1.4rem;
    font-weight: bold;
    background: linear-gradient(90deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff, #b983ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls-group label {
    font-size: 0.9rem;
    color: #aaa;
}

select {
    background: #2d2d44;
    color: #eee;
    border: 1px solid #555;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #4d96ff;
}

.btn {
    background: #2d2d44;
    color: #eee;
    border: 1px solid #555;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: #3d3d5c;
    border-color: #777;
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary-btn {
    background: #4d96ff;
    border-color: #4d96ff;
    color: white;
    font-weight: bold;
}

.btn.primary-btn:hover {
    background: #3a7bd5;
    border-color: #3a7bd5;
}

.btn.loop-btn {
    background: #6bcb77;
    border-color: #6bcb77;
    color: white;
    font-weight: bold;
}

.btn.loop-btn:hover {
    background: #55a862;
    border-color: #55a862;
}

.btn.loop-btn.active {
    background: #ff6b6b;
    border-color: #ff6b6b;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 主区域 */
#main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#canvasContainer {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#renderCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

#hint {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #aaa;
    white-space: nowrap;
    pointer-events: none;
}

/* 侧边面板 */
#sidePanel {
    width: 320px;
    background: rgba(0, 0, 0, 0.5);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    overflow-y: auto;
    flex-shrink: 0;
}

.panel-section {
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.panel-section h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #4d96ff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
}

.layer-row {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.layer-row label {
    font-size: 0.85rem;
    color: #aaa;
    width: 55px;
    flex-shrink: 0;
    text-align: left;
    line-height: 1;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.axis-btns, .layer-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.axis-btns {
    flex-wrap: nowrap;
}

.axis-btn, .layer-btn {
    background: #2d2d44;
    color: #eee;
    border: 1px solid #555;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 28px;
    text-align: center;
    flex-shrink: 1;
    white-space: nowrap;
    flex: 0 0 auto;
}

.axis-btn:hover, .layer-btn:hover {
    background: #3d3d5c;
}

.axis-btn.active, .layer-btn.active {
    background: #4d96ff;
    border-color: #4d96ff;
    color: white;
}

.direction-btn {
    flex: 1;
    white-space: nowrap;
    padding: 5px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
}

/* 命令输入 */
.command-hint {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 4px;
}

.command-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    min-width: 0;
}

.command-row input {
    flex: 1;
    min-width: 0;
    background: #2d2d44;
    color: #eee;
    border: 1px solid #555;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: 'Consolas', 'Courier New', monospace;
}

.command-row input:focus {
    outline: none;
    border-color: #4d96ff;
}

.command-row .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.speed-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.speed-row label {
    font-size: 0.85rem;
    color: #aaa;
    white-space: nowrap;
}

.speed-row input[type="number"] {
    flex: 1;
    min-width: 0;
    background: #2d2d44;
    color: #eee;
    border: 1px solid #555;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.speed-row input[type="number"]:focus {
    outline: none;
    border-color: #4d96ff;
}

.speed-unit {
    font-size: 0.85rem;
    color: #aaa;
    white-space: nowrap;
}

#commandHistory {
    margin-top: 10px;
    max-height: 100px;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.8rem;
    color: #6bcb77;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 4px;
    display: none;
}

#commandHistory.has-content {
    display: block;
}

/* 帮助列表 */
.help-list {
    list-style: none;
    font-size: 0.8rem;
    color: #bbb;
}

.help-list li {
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.help-list li:last-child {
    border-bottom: none;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: #4d96ff;
    border-radius: 3px;
}

/* 响应式 */
@media (max-width: 1200px) {
    #sidePanel {
        width: 280px;
        padding: 12px;
    }
    .panel-section {
        padding: 10px;
    }
}

@media (max-width: 1000px) {
    #toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 15px;
    }
    .logo {
        font-size: 1.2rem;
    }
    .controls-group {
        flex-wrap: wrap;
        gap: 6px;
    }
    #sidePanel {
        width: 240px;
        padding: 10px;
    }
    .panel-section {
        padding: 8px;
        margin-bottom: 12px;
    }
    .layer-row {
        gap: 4px;
        margin-bottom: 8px;
    }
    .layer-row label {
        width: 48px;
        font-size: 0.8rem;
        flex-shrink: 0;
        line-height: 1;
        display: flex;
        align-items: center;
        white-space: nowrap;
    }
    .axis-btn, .layer-btn {
        padding: 4px 6px;
        font-size: 0.75rem;
        min-width: 26px;
        flex-shrink: 1;
    }
    .axis-btns {
        flex-wrap: nowrap;
    }
    .layer-btns {
        flex-wrap: wrap;
    }
    .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    .direction-btn {
        padding: 4px 6px;
        font-size: 0.75rem;
    }
    .command-hint {
        font-size: 0.7rem;
    }
    .help-list {
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    #main {
        flex-direction: column;
    }
    #canvasContainer {
        flex: 0 0 55%;
        min-height: 0;
    }
    #sidePanel {
        width: 100%;
        flex: 1;
        height: auto;
        min-height: 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        overflow-y: auto;
        padding: 10px;
    }
    #toolbar {
        padding: 8px 10px;
    }
    .logo {
        font-size: 1rem;
    }
    .controls-group {
        gap: 4px;
    }
    .controls-group label {
        font-size: 0.8rem;
    }
    select {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
    .btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
    .direction-btn {
        padding: 4px 6px;
        font-size: 0.75rem;
    }
    .panel-section h3 {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }
    .command-row {
        flex-direction: column;
    }
    .command-row input {
        width: 100%;
    }
    .command-row .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    #toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .controls-group {
        width: 100%;
        justify-content: space-between;
    }
    #sidePanel {
        max-height: 50vh;
    }
    .command-row {
        flex-direction: column;
    }
    .command-row input {
        width: 100%;
    }
    .command-row .btn {
        width: 100%;
    }
    .layer-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .layer-row label {
        width: auto;
        min-width: 0;
    }
    .axis-btns, .layer-btns {
        flex-wrap: wrap;
        width: 100%;
    }
    .direction-btn {
        width: 100%;
    }
    #hint {
        font-size: 0.7rem;
        white-space: normal;
        max-width: 90%;
        text-align: center;
    }
}
