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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a1a;
    color: #eee;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

h1 {
    font-size: 1.5rem;
    color: #4ade80;
}

.status {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status.idle      { background: #333; color: #aaa; }
.status.waiting   { background: #854d0e; color: #fde68a; }
.status.matched   { background: #166534; color: #bbf7d0; }
.status.error     { background: #7f1d1d; color: #fecaca; }

main {
    flex: 1;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 350px;
    grid-template-rows: auto auto 1fr;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.videos {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.video-wrapper {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.controls {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

button {
    background: #4ade80;
    color: #000;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

button:hover:not(:disabled) {
    background: #22c55e;
}

button:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
}

#skipBtn { background: #f59e0b; }
#skipBtn:hover:not(:disabled) { background: #d97706; }

#stopBtn { background: #ef4444; color: #fff; }
#stopBtn:hover:not(:disabled) { background: #dc2626; }

#toggleVideoBtn, #toggleAudioBtn {
    background: #475569;
    color: #fff;
}
#toggleVideoBtn:hover:not(:disabled), #toggleAudioBtn:hover:not(:disabled) {
    background: #334155;
}

.chat {
    grid-column: 2;
    grid-row: 1 / 4;
    background: #222;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 400px;
}

.messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    padding: 0.5rem 0.8rem;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    font-size: 0.9rem;
}

.message.mine {
    background: #4ade80;
    color: #000;
    align-self: flex-end;
}

.message.theirs {
    background: #374151;
    align-self: flex-start;
}

.message.system {
    background: transparent;
    color: #888;
    font-style: italic;
    font-size: 0.8rem;
    align-self: center;
    text-align: center;
}

.message-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.8rem;
    border-top: 1px solid #333;
}

.message-form input {
    flex: 1;
    background: #1a1a1a;
    color: #eee;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
}

.message-form input:focus {
    outline: none;
    border-color: #4ade80;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }
    .chat {
        grid-column: 1;
        grid-row: 3;
    }
    .videos {
        grid-template-columns: 1fr;
    }
}
