* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background-color: #f3f2f1;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    background-color: #ffffff;
    border-bottom: 1px solid #edebe9;
    padding: 8px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.toolbar-info {
    margin-left: auto;
    color: #b0b0b0;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.tool-section {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.tool-section:not(:last-child)::after {
    content: '';
    width: 1px;
    height: 24px;
    background-color: #edebe9;
    margin-left: 20px;
}

.tool-btn {
    background-color: transparent;
    border: none;
    padding: 6px 12px;
    font-size: 14px;
    color: #323130;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.1s ease;
    font-weight: 400;
    min-width: 70px;
}

.tool-btn:hover {
    background-color: #f3f2f1;
    color: #201f1e;
}

.tool-btn:active {
    background-color: #edebe9;
}

.tool-btn.active {
    background-color: #0078d4;
    color: #ffffff;
    font-weight: 600;
}

.tool-btn.active:hover {
    background-color: #106ebe;
}

.tool-group {
    flex-wrap: wrap;
}

.control-group {
    gap: 12px;
}

.size-control {
    gap: 8px;
}

.color-control {
    display: flex;
    align-items: center;
}

.action-group {
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-btn {
    background-color: transparent;
    border: 1px solid #8a8886;
    padding: 6px 16px;
    font-size: 14px;
    color: #323130;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.1s ease;
    font-weight: 400;
}

.action-btn:hover {
    background-color: #f3f2f1;
    border-color: #323130;
}

.action-btn:active {
    background-color: #edebe9;
}

label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #323130;
    font-weight: 400;
}

#penSize {
    width: 100px;
    height: 4px;
    background: #edebe9;
    outline: none;
    border-radius: 2px;
    -webkit-appearance: none;
}

#penSize::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #0078d4;
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

#penSize::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #0078d4;
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

#penSize:hover::-webkit-slider-thumb {
    background: #106ebe;
}

#penSize:hover::-moz-range-thumb {
    background: #106ebe;
}

#sizeValue {
    min-width: 20px;
    text-align: right;
    font-size: 14px;
    color: #605e5c;
    font-weight: 600;
}

#penColor {
    width: 32px;
    height: 32px;
    border: 1px solid #edebe9;
    border-radius: 2px;
    cursor: pointer;
    padding: 2px;
    background-color: #ffffff;
}

#penColor::-webkit-color-swatch-wrapper {
    padding: 0;
}

#penColor::-webkit-color-swatch {
    border: none;
    border-radius: 1px;
}

#penColor::-moz-color-swatch {
    border: none;
    border-radius: 1px;
}

#canvas {
    display: block;
    background-color: #ffffff;
    margin: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    cursor: crosshair;
}

.o365-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 120ms ease;
    opacity: 1;
}

.o365-dialog-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.o365-dialog {
    background: #ffffff;
    border-radius: 6px;
    width: min(90vw, 340px);
    padding: 20px 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #323130;
}

.o365-dialog h2 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
}

.o365-dialog p {
    margin: 0 0 20px;
    font-size: 14px;
    color: #605e5c;
}

.o365-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.o365-btn {
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
}

.o365-btn.primary {
    background: #0078d4;
    color: #ffffff;
}

.o365-btn.primary:hover {
    background: #106ebe;
}

.o365-btn.secondary {
    background: #f3f2f1;
    color: #201f1e;
}

.o365-btn.secondary:hover {
    background: #e1dfdd;
}

@media (max-width: 768px) {
    body {
        padding-bottom: 150px;
    }

    .toolbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 10px;
        padding: 10px 14px;
    }

    .tool-section {
        width: 100%;
        padding: 0;
    }

    .tool-section:not(:last-child)::after {
        display: none;
    }

    .tool-group {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
        gap: 6px;
    }

    .tool-btn {
        min-width: 0;
        padding: 10px 0;
    }

    .control-group {
        justify-content: space-between;
    }

    .size-control {
        flex: 1;
        justify-content: space-between;
    }

    .color-control {
        width: 44px;
        height: 44px;
    }

    .color-control #penColor {
        width: 100%;
        height: 100%;
    }

    .action-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .action-btn {
        justify-content: center;
        padding: 10px;
    }

    .action-btn span {
        display: none;
    }

    .toolbar-info {
        order: 5;
        width: 100%;
        margin-left: 0;
        text-align: center;
    }
}