:root {
    --bg-gradient: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #1a1625 100%);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    
    --primary-color: #6c5ce7;
    --primary-light: #a29bfe;
    --primary-hover: #5a4bcf;
    
    --text-main: #ffffff;
    --text-sub: #a0a4b8;
    
    --bubble-local: linear-gradient(135deg, #6c5ce7 0%, #8b7dff 100%);
    --bubble-remote: rgba(255, 255, 255, 0.1);
    
    --success: #00cec9;
    --error: #ff7675;
    --shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh; 
    overflow: hidden;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }

.container {
    width: 100%;
    height: 100dvh;
    max-height: none;
    background: rgba(20, 18, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.hidden { display: none !important; }

#signaling-container {
    padding: 30px 20px;
    overflow-y: auto;
    height: 100%;
}

.header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 5px;
}

.header-title h2 {
    margin: 0;
    font-weight: 800;
    font-size: 24px;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    text-align: center;
    color: var(--text-sub);
    font-size: 13px;
    margin-bottom: 30px;
}

.step-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.step {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-a { background: rgba(108, 92, 231, 0.2); color: var(--primary-light); border: 1px solid rgba(108, 92, 231, 0.3); }
.badge-b { background: rgba(0, 206, 201, 0.15); color: var(--success); border: 1px solid rgba(0, 206, 201, 0.3); }

.step h3 { margin: 0; font-size: 17px; color: var(--text-main); }
.step p { font-size: 13px; color: var(--text-sub); margin: 0 0 16px; line-height: 1.5; }

textarea {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    color: #e2e2e2;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px;
    resize: none;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 16px; 
    outline: none;
    transition: all 0.3s ease;
}

textarea:focus {
    border-color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

textarea::placeholder { color: rgba(255, 255, 255, 0.2); }

.input-box { height: 75px; }
.readonly-box { height: 75px; color: var(--primary-light); cursor: pointer; }

.copy-wrapper { position: relative; margin-top: 10px; }
.copy-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(108, 92, 231, 0.2);
    border: 1px solid rgba(108, 92, 231, 0.4);
    color: var(--primary-light);
    padding: 6px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.copy-wrapper:hover .readonly-box {
    border-color: var(--primary-color);
    background: rgba(108, 92, 231, 0.05);
}

.copy-wrapper:hover .copy-overlay {
    background: var(--primary-color);
    color: white;
}

.final-step-wrap { display: flex; flex-direction: column; gap: 12px; }

button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background-color: var(--primary-color);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-glow { box-shadow: 0 0 15px rgba(108, 92, 231, 0.5); }

button:disabled {
    background-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
    animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
    0% { background-color: rgba(255, 255, 255, 0.05); }
    100% { background-color: rgba(108, 92, 231, 0.2); }
}

#chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
}

#chat-header {
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.header-info { display: flex; align-items: center; gap: 12px; }

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.5), rgba(0, 206, 201, 0.5));
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 10px rgba(255,255,255,0.1);
}

.header-info h2 { margin: 0 0 4px 0; font-size: 16px; font-weight: 700; }

#status {
    font-size: 12px;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
}

#messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.message { 
    max-width: 80%; 
    display: flex; 
    flex-direction: column; 
    animation: slideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.message .text {
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.message.system { align-self: center; max-width: 90%; }
.message.system .text {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-sub);
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: none;
}

.message.remote { align-self: flex-start; }
.message.remote .text {
    background: var(--bubble-remote);
    color: var(--text-main);
    border-radius: 20px 20px 20px 4px;
    border: 1px solid rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
}

.message.local { align-self: flex-end; }
.message.local .text {
    background: var(--bubble-local);
    color: white;
    border-radius: 20px 20px 4px 20px;
}

#message-form {
    padding: 16px;
    background: rgba(0,0,0,0.15);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 6px;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: rgba(108, 92, 231, 0.6);
    background: rgba(0, 0, 0, 0.6);
}

#message-input {
    flex-grow: 1;
    height: 44px;
    max-height: 100px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: white;
    font-size: 16px; 
    outline: none;
    line-height: 1.4;
}

#message-input::placeholder { color: rgba(255, 255, 255, 0.3); }

#send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: 8px;
    padding: 0;
}


@media (min-width: 768px) {
    .container {
        max-width: 800px;
        height: 94vh;
        max-height: 900px;
        border-radius: 24px;
        border: 1px solid var(--glass-border);
        background: rgba(20, 18, 30, 0.75);
    }
    
    #signaling-container { padding: 40px 30px; }
    .header-title h2 { font-size: 28px; }
    .subtitle { font-size: 14px; margin-bottom: 40px; }
    
    .step-grid {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
    .step-full { grid-column: span 2; }
    .step { padding: 24px; }
    .step:hover {
        box-shadow: 0 8px 25px rgba(0,0,0,0.2), inset 0 0 20px rgba(108, 92, 231, 0.05);
        transform: translateY(-2px);
    }
    
    .final-step-wrap {
        flex-direction: row;
        align-items: stretch;
    }
    .final-step-wrap .input-box { flex: 1; margin: 0; }
    .final-step-wrap button { flex: 0 0 140px; margin: 0; }
    
    #chat-header { padding: 16px 24px; }
    #messages { padding: 24px; gap: 18px; }
    #message-form { padding: 20px 24px 24px 24px; background: transparent; }
    #message-input { max-height: 120px; }
}