body {
    background: linear-gradient(to bottom, #f4f7fa, #e0e7ff);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #2d3748;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    margin: 0;
    box-sizing: border-box;
    min-height: 100vh;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 20px;
}

#container {
    background: linear-gradient(to bottom, #ffffff, #f7fafc);
    border: 1px solid #e2e8f0;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 1080px;
    position: relative;
}

svg {
    background-color: #f8fafc;
    width: 100%;
    max-width: 1080px;
    border-radius: 8px;
}

.axis-line {
    stroke: #a0aec0;
    stroke-width: 2;
}

.tick-line {
    stroke: #cbd5e0;
    stroke-width: 1;
}

.tick-label {
    fill: #718096;
    font-size: 12px;
    text-anchor: middle;
    font-weight: 500;
}

#x-point {
    fill: #4a5568;
    transition: cx 0.05s ease;
}

#x-label {
    fill: #4a5568;
    font-size: 14px;
    font-weight: 600;
    text-anchor: middle;
}

.fixed-point {
    stroke: #fff;
    stroke-width: 2;
}

.point-label {
    fill: #2d3748;
    font-size: 12px;
    text-anchor: middle;
    font-weight: 500;
}

#input-and-list-section {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-top: 24px;
    gap: 24px;
    flex-wrap: wrap;
}

#input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex: 0 1 auto;
    justify-content: center;
    position: relative;
}

#preview {
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background-color: #fff;
    width: 242px; /* 默认与 #keypad 一致 */
    max-width: 100%;
    text-align: center;
    font-size: 16px;
    min-height: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

#keypad {
    display: grid;
    grid-template-columns: repeat(4, 60px);
    gap: 8px;
    justify-content: center;
    max-width: 100%;
}

.keypad-button {
    padding: 12px;
    background-color: #edf2f7;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.keypad-button:hover {
    background-color: #e2e8f0;
    transform: translateY(-1px);
}

.keypad-button:active {
    transform: translateY(0);
}

.keypad-button:disabled {
    background-color: #f7fafc;
    cursor: not-allowed;
    opacity: 0.6;
}

#points-list-section {
    position: absolute;
    right: 24px;
    width: 100%;
    max-width: 180px;
}

#points-list-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a202c;
}

#points-list {
    list-style: none;
    padding: 0;
    max-height: 252px;
    overflow-y: auto;
    margin-top: 0;
    margin-bottom: 0;
}

#points-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #edf2f7;
    font-size: 13px;
}

#points-list li:last-child {
    border-bottom: none;
}

#points-list button {
    background-color: #edf2f7;
    border: 1px solid #e2e8f0;
    color: #666666;
    padding: 6px 6px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

#points-list button:hover {
    background-color: #e2e8f0;
}

#settings-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    cursor: pointer;
    font-size: 24px;
    color: #4a5568;
    background-color: #edf2f7;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

#settings-icon:hover {
    background-color: #e2e8f0;
    transform: rotate(90deg);
}

#settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

#settings-modal.show {
    display: flex;
    opacity: 1;
}

#settings-content {
    background-color: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 320px;
    text-align: center;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#settings-modal.show #settings-content {
    transform: scale(1);
    opacity: 1;
}

#settings-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 16px;
}

#length-input {
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 80px;
    margin: 12px 0;
    font-size: 16px;
}

#settings-content button {
    padding: 10px 20px;
    margin: 0 8px;
    background-color: #4a5568;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

#settings-content button:hover {
    background-color: #2d3748;
    transform: translateY(-1px);
}

#settings-content button:active {
    transform: translateY(0);
}

#cancel-button {
    background-color: #e53e3e;
}

#cancel-button:hover {
    background-color: #c53030;
}

#error-toast {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #e53e3e;
    color: #fff;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 1000;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

#error-toast.show {
    display: block;
    animation: fadeIn 0.3s ease-in-out forwards;
}

#error-toast {
    animation: fadeOut 0.3s ease-in-out forwards;
    animation-delay: 2.7s;
}

@media (max-width: 768px) {
    #input-and-list-section {
        flex-direction: column;
        align-items: center;
    }
    #points-list-section {
        position: relative;
        bottom: auto;
        right: auto;
        max-width: 100%;
        padding: 0;
    }
    #keypad {
        grid-template-columns: repeat(4, 50px);
    }
    #preview {
        width: 206px;
    }
    .keypad-button {
        padding: 10px;
        font-size: 14px;
    }
}

@media (max-width: 600px) {
    #keypad {
        grid-template-columns: repeat(4, 45px);
    }
    #preview {
        width: 182px;
    }
    .keypad-button {
        padding: 8px;
        font-size: 14px;
    }
    #settings-content {
        width: 90%;
    }
}