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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    background: #2a2a2a;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #3a3a3a;
}

.header h1 {
    font-size: 1.5rem;
    color: #fff;
}

.status {
    display: flex;
    gap: 1rem;
}

.status-indicator {
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    background: #3a3a3a;
}

.status-indicator.connected {
    background: #2d5016;
    color: #7cb342;
}

.status-indicator.disconnected {
    background: #5d1a1a;
    color: #e57373;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1rem;
    padding: 1rem;
}

/* Blackboard Section */
.blackboard-section {
    flex: 2;
    display: flex;
    flex-direction: column;
    background: #2a2a2a;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow: hidden;
}

.blackboard-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #1a1a1a;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tool-btn {
    padding: 0.5rem 1rem;
    background: #3a3a3a;
    border: 2px solid #4a4a4a;
    border-radius: 0.25rem;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #4a4a4a;
    border-color: #5a5a5a;
}

.tool-btn.active {
    background: #0066cc;
    border-color: #0088ff;
}

.blackboard-container {
    flex: 1;
    background: #1a1a1a;
    border-radius: 0.5rem;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

#blackboard {
    background: #2d2d1e;
    border: 3px solid #4a4a3a;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    cursor: crosshair;
}

.controls-panel {
    margin-top: 1rem;
    padding: 1rem;
    background: #1a1a1a;
    border-radius: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.controls-panel h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: #fff;
}

.slider-control {
    margin-bottom: 1rem;
}

.slider-control label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: #b0b0b0;
}

.slider-control input[type="range"] {
    width: 100%;
    margin-bottom: 0.25rem;
}

.slider-control .value {
    font-size: 0.75rem;
    color: #888;
}

/* Chat Section */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #2a2a2a;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #3a3a3a;
}

.chat-header h2 {
    font-size: 1.25rem;
    color: #fff;
}

.connect-btn {
    padding: 0.5rem 1rem;
    background: #0066cc;
    border: none;
    border-radius: 0.25rem;
    color: #fff;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.connect-btn:hover {
    background: #0088ff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #1a1a1a;
    border-radius: 0.5rem;
}

.message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #2a2a2a;
    border-radius: 0.5rem;
    border-left: 3px solid #4a4a4a;
}

.message.sender {
    border-left-color: #0066cc;
}

.message .sender-name {
    font-weight: 600;
    color: #0066cc;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.message .content {
    color: #e0e0e0;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message .timestamp {
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.25rem;
}

.chat-input-container {
    display: flex;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    padding: 0.75rem;
    background: #1a1a1a;
    border: 2px solid #3a3a3a;
    border-radius: 0.25rem;
    color: #e0e0e0;
    font-size: 0.875rem;
}

#chat-input:focus {
    outline: none;
    border-color: #0066cc;
}

#send-btn {
    padding: 0.75rem 1.5rem;
    background: #0066cc;
    border: none;
    border-radius: 0.25rem;
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

#send-btn:hover {
    background: #0088ff;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Hide header on mobile */
    .header {
        display: none;
    }

    /* Full height container without header */
    .container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }

    /* Vertical layout: whiteboard on top, chat below */
    .main-layout {
        flex-direction: column;
        gap: 0;
        padding: 0;
        height: 100%;
    }

    /* Blackboard section - takes top portion */
    .blackboard-section {
        flex: 1;
        min-height: 0;
        border-radius: 0;
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
    }

    /* Compact toolbar for mobile */
    .blackboard-toolbar {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        gap: 0.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tool-btn {
        padding: 0.5rem;
        font-size: 1rem;
        min-width: 44px; /* Touch target size */
        flex-shrink: 0;
    }

    /* Blackboard container - full width */
    .blackboard-container {
        flex: 1;
        min-height: 0;
        padding: 0.5rem;
    }

    /* Responsive canvas */
    #blackboard {
        width: 100% !important;
        height: 100% !important;
        max-width: 100%;
        max-height: 100%;
        border: 2px solid #4a4a4a;
    }

    /* Hide controls panel on mobile or make it collapsible */
    .controls-panel {
        display: none; /* Hide by default on mobile, can be toggled */
        max-height: 150px;
        margin-top: 0.5rem;
    }

    /* Chat section - takes bottom portion */
    .chat-section {
        flex: 0 0 auto;
        max-height: 40vh;
        border-radius: 0;
        padding: 0.5rem;
        border-top: 2px solid #3a3a3a;
    }

    /* Hide chat header on mobile */
    .chat-header {
        display: none;
    }

    /* Compact chat messages */
    .chat-messages {
        margin-bottom: 0.5rem;
        padding: 0.25rem;
    }

    .message {
        margin-bottom: 0.5rem;
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    .message .sender-name {
        font-size: 0.75rem;
    }

    .message .content {
        font-size: 0.875rem;
    }

    .message .timestamp {
        font-size: 0.625rem;
    }

    /* Compact input */
    .chat-input-container {
        gap: 0.25rem;
    }

    #chat-input {
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    #send-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        min-width: 60px;
    }
}

/* Very small mobile devices */
@media (max-width: 480px) {
    .blackboard-toolbar {
        padding: 0.25rem;
    }

    .tool-btn {
        padding: 0.375rem;
        font-size: 0.875rem;
        min-width: 40px;
    }

    .chat-section {
        max-height: 35vh;
    }

    #blackboard {
        border-width: 1px;
    }
}
