body {
    margin: 0;
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    display: flex;
    overflow-x: auto;
}

.container {
    flex: 1;
    display: grid;
    grid-template-columns: 250px 1fr;
    grid-template-rows: auto 1fr;
    gap: 40px 80px;
    margin: 0 auto;
    padding: 40px 40px 40px 0;
}

.instruction-panel {
    grid-column: 1;
    grid-row: 1 / span 2;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: fit-content;
    width: 250px;
    margin-left: 40px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: 30px;
}

.instruction-panel h2 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 20px;
}

.instruction-panel h3 {
    color: #2196F3;
    margin: 20px 0 10px 0;
    font-size: 16px;
}

.instruction-panel p {
    margin: 5px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    padding-left: 15px;
}

.mode-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.control-panel {
    grid-column: 2;
    grid-row: 1;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 800px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

h1 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 24px;
}

.input-group {
    display: flex;
    gap: 4px;
    flex-direction: column;
    align-items: flex-start;
}

label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #555;
}

input[type="number"] {
    width: 68px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* 更紧凑的数字输入宽度 */
.num-input {
    width: 48px; /* 约为原80px的60% */
}

button {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #45a049;
}

.matrix-wrapper {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    width: 100%;
}

.matrix-container {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    position: relative;
    width: fit-content;
    height: fit-content;
    box-sizing: border-box;
    min-width: fit-content;
}

.matrix {
    display: inline-flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

/* 顺序箭头覆盖层 */
#arrowOverlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 5;
}

#arrowOverlay .arrow-segment {
    stroke-width: 2.5px;
    fill: none;
    opacity: 1;
    stroke: #666;
}

#arrowOverlay .arrow-dot {
    stroke: #f0f0f0;
    stroke-width: 1.5px;
}



/* 第一行：矩阵参数 */
.matrix-params {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin: 0;
    padding: 0;
}

.matrix-params label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #555;
    font-size: 14px;
}

/* 第二行：功能开关 */
.function-controls {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    margin: 0;
    padding: 2px 0;
}

.control-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-label {
    color: #555;
    font-size: 14px;
    font-weight: 500;
}

.mode-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f6f8fa;
    border: 1px solid #e6e8eb;
    border-radius: 6px;
    font-size: 13px;
}

.toggles-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

/* 颜色选择器布局调整 */
.color-selector {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 4px;
    padding: 8px 0;
    border-top: 1px solid #e6e8eb;
}

.color-boxes {
    display: flex;
    gap: 5px;
    z-index: 100;
    pointer-events: all !important;
}

.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: 15px;
}



.matrix-row {
    display: flex;
    gap: 8px;
}

.rect {
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
    color: white;
    user-select: none;
    font-size: 14px;
    position: relative;
}

.rect.numbered.serial {
    background: #2196F3;
}

.rect.numbered.parallel {
    background: #f44336;
}

button#exportImage {
    background: #2196F3;
}

button#exportImage:hover {
    background: #1976D2;
}

.mode-description, .shortcut-description, .click-description {
    margin-bottom: 20px;
}

button#undoButton {
    background: #FF9800;
}

button#undoButton:hover {
    background: #F57C00;
}

button#undoButton:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 重做按钮样式 */
button#redoButton {
    background: #9C27B0;  /* 紫色 */
}

button#redoButton:hover {
    background: #7B1FA2;  /* 深紫色 */
}

/* 开关样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    margin: 0 30px 0 0px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:checked + .slider:before {
    transform: translateX(18px);
}

/* 颜色样本样式 */
.color-samples {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    margin-top: 10px;
    width: 105px;
    margin-left: 15px;
}

.color-sample {
    width: 33px;
    height: 33px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.color-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    z-index: 100;
    pointer-events: all !important;
}

.color-boxes {
    display: flex;
    gap: 5px;
    z-index: 100;
    pointer-events: all !important;
}

.color-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid transparent;
    padding: 0;
    background-color: inherit;
}

.color-box:hover {
    transform: scale(1.1);
}

.color-box.active {
    border-color: #333;
    transform: scale(1.1);
    box-shadow: 0 0 0 2px white, 0 0 0 4px #333;
}

button#resetMatrix {
    background: #f44336;  /* 红色 */
}

button#resetMatrix:hover {
    background: #d32f2f;  /* 深红色，用于悬停效果 */
}
 