* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    margin-bottom: 50px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 50px 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.header-content {
    position: relative;
    z-index: 1;
}

header h1 {
    font-size: 3em;
    margin-bottom: 15px;
    font-weight: 700;
    letter-spacing: -1px;
    position: relative;
    z-index: 1;
}

header p {
    font-size: 1.2em;
    opacity: 0.95;
    position: relative;
    z-index: 1;
    font-weight: 300;
    margin-bottom: 20px;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
}

.toolbar {
    background: #ffffff;
    padding: 30px 40px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tool-group label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 90px;
    font-size: 0.95em;
}

.tool-group input[type="color"] {
    width: 55px;
    height: 45px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tool-group input[type="color"]:hover {
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
}

.tool-group input[type="range"] {
    width: 150px;
    cursor: pointer;
    height: 6px;
    accent-color: #667eea;
}

.tool-group select {
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.95em;
    cursor: pointer;
    background: white;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #2c3e50;
}

.tool-group select:hover {
    border-color: #667eea;
}

.tool-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
}

#sizeDisplay {
    min-width: 40px;
    font-weight: 700;
    color: #667eea;
    font-size: 0.95em;
}

.button-group {
    display: flex;
    gap: 12px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #ff6b6b 100%);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c82333 0%, #ff5252 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #343a40 100%);
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8 0%, #00bcd4 100%);
    color: white;
}

.btn-info:hover {
    background: linear-gradient(135deg, #138496 0%, #0097a7 100%);
}

.canvas-container {
    display: flex;
    justify-content: center;
    padding: 40px;
    background: #f8f9fb;
    min-height: 700px;
}

#drawingCanvas {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    cursor: crosshair;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    max-width: 100%;
    height: auto;
    transition: all 0.3s ease;
}

#drawingCanvas:hover {
    box-shadow: 0 20px 50px rgba(102, 126, 234, 0.15);
}

.saved-drawings {
    padding: 50px 40px;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
}

.saved-drawings h2 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.drawings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
}

.drawing-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid #f0f0f0;
}

.drawing-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.drawing-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.drawing-info {
    padding: 18px;
    background: white;
}

.drawing-name {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.95em;
}

.drawing-date {
    font-size: 0.85em;
    color: #95a5a6;
    margin-bottom: 12px;
}

.drawing-actions {
    display: flex;
    gap: 10px;
}

.drawing-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.load-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.load-btn:hover {
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
    transform: scale(1.02);
}

.delete-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
    color: white;
}

.delete-btn:hover {
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.3);
    transform: scale(1.02);
}

.empty-state {
    text-align: center;
    padding: 60px 40px;
    color: #bdc3c7;
}

.empty-state p {
    font-size: 1.2em;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2.2em;
    }

    header p {
        font-size: 1em;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        padding: 20px;
    }

    .tool-group {
        width: 100%;
        justify-content: space-between;
    }

    .button-group {
        width: 100%;
    }

    .button-group button {
        flex: 1;
        padding: 12px 16px;
    }

    .canvas-container {
        padding: 20px;
        min-height: auto;
    }

    .drawings-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .saved-drawings {
        padding: 30px 20px;
    }

    .saved-drawings h2 {
        font-size: 1.4em;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: white;
    border-radius: 15px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 15px 15px 0 0;
}

.modal-header h2 {
    font-size: 1.8em;
    margin: 0;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
}

.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 30px;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-bottom: 2px solid #e9ecef;
    scrollbar-width: none; /* Firefox */
}

.tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 13px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    position: relative;
    bottom: -2px;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.tab-content h3 {
    color: #2c3e50;
    font-size: 1.5em;
    margin-bottom: 15px;
    margin-top: 0;
}

.tab-content h4 {
    color: #667eea;
    font-size: 1.1em;
    margin-top: 20px;
    margin-bottom: 10px;
}

.tab-content p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.tab-content ul {
    margin-left: 20px;
    color: #555;
}

.tab-content li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.tab-content ol {
    margin-left: 20px;
    color: #555;
}

.tab-content ol li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.tab-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #d63384;
}

.tab-content pre {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
    border-left: 4px solid #667eea;
}

.tab-content pre code {
    color: #333;
    padding: 0;
    background: none;
    font-size: 0.9em;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-header h2 {
        font-size: 1.4em;
    }

    .modal-body {
        padding: 20px;
    }

    .tabs {
        flex-direction: column;
        gap: 5px;
    }

    .tab-btn {
        border-bottom: none;
        border-left: 3px solid transparent;
        text-align: left;
        padding-left: 15px;
    }

    .tab-btn.active {
        border-bottom: none;
        border-left-color: #667eea;
    }

    .tab-content h3 {
        font-size: 1.2em;
    }

    .tab-content h4 {
        font-size: 1em;
    }

    .tab-content p {
        font-size: 0.9em;
    }

    .tab-content code {
        font-size: 0.85em;
    }

    .tab-content pre {
        font-size: 0.8em;
        padding: 12px;
        margin: 10px 0;
    }
}

/* Sticky footer */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 20px 0;
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.18);
    letter-spacing: 0.03em;
    z-index: 50;
}

.site-footer a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.4);
    transition: color 0.2s;
}

.site-footer a:hover {
    color: rgba(255, 255, 255, 1);
}
