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

body {
    background: linear-gradient(135deg, #cecece 0%, #bababa 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    
    font-family: 
        'Meiryo',                    /* 元の日本語フォント(1) */
        'メイリオ',                   /* 元の日本語フォント(2) */
        'Hiragino Kaku Gothic ProN', /* 元の日本語フォント(3) */
        'ヒラギノ角ゴ ProN W3',        /* 元の日本語フォント(4) */
        'Noto Sans CJK SC',          /* 中国語用Webフォント */
        'Microsoft YaHei',           /* Windows中国語フォント */
        '微软雅黑',                   /* 中国語代替フォント */
        'SimSun',                    /* 中国語フォールバック */
        '宋体',                      /* 中国語最終フォールバック */
        sans-serif;                  /* 最終フォールバック */
    /* font-family: 'Meiryo', 'メイリオ', 'Hiragino Kaku Gothic ProN', 'ヒラギノ角ゴ ProN W3', sans-serif; */
}

/* Common container styles */
.role-selector,
.language-selector {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Common card styles */
.role-container,
.language-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 60px 40px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 700px;
    width: 100%;
}

.language-container {
    position: relative;
}

/* Common headings */
.role-container h1,
.language-container h1 {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #333;
}

/* Common text styles */
.subtitle,
.language-container p {
    font-size: 18px;
    color: #666;
    margin-bottom: 50px;
    font-weight: 300;
}

/* Common button grids */
.role-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
}

.language-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

/* Common button base styles */
.role-btn,
.language-btn {
    border: 3px solid #e0e0e0;
    background: rgb(233, 232, 232);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.role-btn {
    padding: 40px 30px;
    border-radius: 25px;
    transition-duration: 0.4s;
}

.language-btn {
    padding: 18px 12px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 18px;
}

.role-icon {
    font-size: 64px;
    margin-bottom: 15px;
    transition: transform 0.4s;
}

.role-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.role-desc {
    font-size: 18px;
    color: #4e4e4e;
    font-weight: 300;
}

/* Common hover styles - combined customer and operator btn hovers */
.customer-btn:hover,
.operator-btn:hover,
.language-btn:hover {
    background: linear-gradient(135deg, #939393 0%, #7a7a7a 100%);
    color: white;
    border-color: #939393;
}

.customer-btn:hover,
.operator-btn:hover {
    box-shadow: 0 15px 20px rgba(122, 122, 122, 0.8);
}

.language-btn:hover {
    box-shadow: 0 10px 25px rgba(99, 99, 99, 0.8);
}

.customer-btn:hover .role-desc,
.operator-btn:hover .role-desc {
    color: rgba(255, 255, 255, 0.6);
}

.role-btn:hover .role-icon {
    transform: scale(1.2);
}

/* Home button styles - combined for lang and main */
.btn-home-lang,
.btn-home {
    position: absolute;
    left: 30px;
    top: 30px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-home-lang {
    background: rgba(147, 147, 147, 0.2);
    border: 1px solid rgba(147, 147, 147, 0.3);
    color: #666;
}

.btn-home {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
}

.btn-home-lang:hover {
    background: rgba(147, 147, 147, 0.4);
    color: #333;
    transform: scale(1.2);
}

.btn-home:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.2);
}

/* Dual Container */
.dual-container {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    background: #d0d0d0;
    padding: 20px;
    position: relative; 
}

/* Chat Container */
.container {
    max-width: none;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    justify-content: space-between;
}

.container.half-container {
    width: 80% !important;
}

.half-container {
    position: absolute;
    width: 80%;
    height: calc(100vh - 40px);
    border-radius: 25px;
    transition: all 0.3s ease;
}

.half-container:first-child {
    left: 20px;
}

.half-container:last-child {
    right: 20px;
}

.half-container.active {
    opacity: 1;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.half-container.inactive {
    opacity: 0.4;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
    filter: grayscale(50%);
    z-index: 1;
}

.header {
    background: linear-gradient(135deg, #939393 0%, #7a7a7a 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    height: 90px;
}

.header-left {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-left h1 {
    font-size: 30px;
    font-weight: 600;
    margin-bottom: 0;
    text-align: center;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Settings button - similar to home button */
.btn-settings {
    width: 35px;
    height: 35px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-settings:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.2);
}

/* Settings Panel */
.settings-panel {
    display: flex;
    justify-content: center;
}

.settings-content {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

.settings-content h3 {
    font-size: 18px;
    margin-bottom: 18px;
    color: #333;
    font-weight: 600;
    text-align: center;
}

.settings-language-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.settings-lang-btn {
    padding: 12px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.settings-lang-btn:hover {
    background: #939393;
    color: white;
    border-color: #939393;
    transform: scale(1.2);
}

.settings-lang-btn.active {
    background: linear-gradient(135deg, #939393 0%, #7a7a7a 100%);
    color: white;
    border-color: #939393;
    font-weight: 600;
}

/* Language Indicator */
.language-indicator {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    width: fit-content;
}

.language-settings-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-status-container > div:first-child {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-label {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.lang-value {
    color: white;
    font-weight: 600;
}

.lang-separator {
    color: #999;
    margin: 0 5px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    animation: fadeInUp 0.4s ease-out;
}

.message.user {
    flex-direction: row-reverse;
}

.message-bubble {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 20px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #939393 0%, #7a7a7a 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.operator .message-bubble {
    background: linear-gradient(135deg, #7a7a7a 0%, #5a5a5a 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.customer .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 6px;
}

.message.system .message-bubble {
    background: #e9ecef;
    color: #495057;
    border-radius: 15px;
    font-size: 13px;
    text-align: center;
    max-width: 80%;
    margin: 0 auto;
}

.message-translation {
    font-size: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    opacity: 0.85;
}

.message.customer .message-translation {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    color: #666;
}

.controls {
    padding: 25px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.input-area {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.voice-status-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    gap: 20px;
}

.message-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
    font-family: inherit;
}

.message-input:focus {
    border-color: #939393;
    box-shadow: 0 0 0 3px rgba(147, 147, 147, 0.1);
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    font-family: inherit;
}

.btn-primary {
    background: rgba(86, 86, 86, 0.686);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.btn-primary:hover {
    background: rgba(39, 39, 39, 0.799);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(86, 86, 86, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.voice-controls {
    display: flex;
    gap: 25px;
}

.btn-voice {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 26px;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.btn-record {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.btn-record.recording {
    animation: pulse 1.5s infinite;
}

.btn-stop {
    background: linear-gradient(135deg, #ffa502 0%, #ff7f50 100%);
    color: white;
}

.btn-voice:hover:not(:disabled) {
    transform: scale(1.2);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

.btn-voice:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.status {
    position: absolute;
    right: 15%;
    font-size: 16px;
    min-height: 20px;
    min-width: 150px;
}

.status-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.status-container.error {
    color: #ff6b6b;
}

.status-container.success {
    color: #2ed573;
}

.status-container.recording {
    color: #ff6b6b;
    font-weight: 600;
}

.status-container.loading {
    color: #666;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #939393;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Recording Dialog Styles */
.recording-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 50px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    animation: fadeInScale 0.3s ease-out forwards;
    text-align: center;
    min-width: 300px;
}

.recording-dialog.closing {
    animation: fadeOutScale 0.3s ease-out forwards;
}

.recording-dialog-icon {
    font-size: 48px;
    margin-bottom: 15px;
    animation: pulseIcon 1.5s ease-in-out infinite;
}

.recording-dialog-text {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.recording-dialog-subtext {
    font-size: 14px;
    margin-top: 10px;
    opacity: 0.9;
}

/* Overlay */
.recording-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

.recording-overlay.closing {
    animation: fadeOut 0.3s ease-out forwards;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes fadeOutScale {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

@keyframes pulseIcon {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .role-buttons {
        grid-template-columns: 1fr;
    }
    
    .language-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .settings-language-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dual-container {
        flex-direction: column;
    }
    
    .half-container {
        width: 100%;
        height: 50vh;
    }
    
    .container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }
    
    .header-left h1 {
        font-size: 20px;
    }
    
    .voice-controls {
        gap: 16px;
    }
    
    .btn-voice {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
}
