/* =========================================
   ■ 共通設定 (変数・基本)
   ========================================= */
:root {
    --logo-emoji: "💬";
    --ai-icon-emoji: "★";
    --send-btn-emoji: "➤";
    --search-emoji: "🔍";
    --settings-emoji: "⚙️";
    --logout-emoji: "🚪";
    --pass-hide-emoji: "🙈";
    --pass-show-emoji: "🐵";
    --menu-kebab-emoji: "︙";
    --pin-emoji: "📌";
    --title-icon-settings: "⚙️";
    --title-icon-search: "🔍";
    
    --icon-scroll-down: "↓";
    --icon-scroll-up: "↑";

    --icon-plus-content: "＋";
    --icon-mic-content: "🎤";
    --icon-image-content: "🖼️";
    --icon-file-content: "📄";
    --icon-close-content: "×";
    
    --tts-icon-emoji: "🔊";
    
    --main-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --primary-color: #007bff;
    --bg-color: #f0f2f5;
    --color-recording: #d93025;
    --color-recording-bg: #ffeceb;

    --header-icon-camera: "📷";
    --header-icon-file: "📂";
    --icon-photos: "🖼️";
    --icon-folder: "📁";
    --warn-emoji: "⚠️";

    --home-emoji: "🏠";
    --hamburger-emoji: "☰";
    --globe-emoji: "🌐";
    
    --emoji-apology: "🙇";
    
    --vvh: 100dvh;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

input::-webkit-contacts-auto-fill-button,
input::-webkit-credentials-auto-fill-button,
input::-webkit-payment-contact-fill-button,
textarea::-webkit-contacts-auto-fill-button,
textarea::-webkit-credentials-auto-fill-button {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    position: absolute !important;
    right: 0 !important;
}

body { 
    font-family: var(--main-font); margin: 0; background: var(--bg-color); 
    display: flex; overflow: hidden; 
    color: #1f1f1f; font-size: 16px;
    height: 100dvh;
    width: 100vw;
}

body.state-new-chat #chat-window {
    overflow: hidden !important;
    flex: 1 !important;
}

.auth-page { 
    display: flex; flex-direction: column; align-items: center; 
    justify-content: flex-start; 
    height: 100dvh; width: 100%;
    padding-top: 60px; background: #f0f2f5; overflow-y: auto;
}
.login-card, .logout-card { 
    background: white; padding: 40px 30px; border-radius: 24px; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.08); width: 90%; max-width: 400px; 
    text-align: center; margin: 0 auto;
}
.logo-container { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 30px; }
.logo-img { width: 40px; height: 40px; object-fit: contain; }
.logo-emoji { font-size: 40px; }
.logo-emoji::before { content: var(--logo-emoji); }
.auth-page h1, .logout-card h2 { font-size: 1.5rem; margin: 0; color: #333; }

.form-group { margin-bottom: 24px; text-align: left; }
label { display: block; margin-bottom: 8px; font-weight: bold; font-size: 0.9rem; color: #5f6368; }

input, select, textarea { 
    width: 100%; padding: 14px; border: 1px solid #ccc; border-radius: 8px; 
    font-size: 16px; outline: none; background: white;
    appearance: none; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-color); outline: none !important; box-shadow: none !important; }

select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 40px;
}

.btn { 
    width: 100%; padding: 14px; background: var(--primary-color); color: white; 
    border: none; border-radius: 50px; font-size: 16px; font-weight: bold; 
    cursor: pointer; margin-top: 10px; transition: opacity 0.2s;
}
.btn:hover { opacity: 0.9; }

.password-wrapper { position: relative; }
.toggle-password { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 1.2rem; }
.msg-alert { padding: 12px; border-radius: 8px; margin-bottom: 20px; font-size: 0.9rem; text-align: center; }
.error { background: #fce8e6; color: #c5221f; }
.success { background: #e6f4ea; color: #137333; }

.loader { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary-color); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 30px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#sidebar { 
    width: 260px; min-width: 260px; flex-shrink: 0;
    background: #f8f9fa; border-right: none; padding: 15px; 
    display: flex; flex-direction: column; transition: transform 0.3s;
    z-index: 1000;
}
#sidebar-header { padding: 5px 5px 15px 5px; display: flex; justify-content: space-between; align-items: center; }
.site-title { font-weight: bold; font-size: 1.2rem; color: #5f6368; display: flex; align-items: center; }
.sidebar-logo { width: 24px; height: 24px; margin-right: 8px; }
.sidebar-emoji::before { content: var(--logo-emoji); margin-right: 8px; font-size: 20px; }

#mobile-menu-btn, #sidebar-close-btn, #mobile-overlay, #header-hamburger-btn { display: none; }

#token-usage-container { padding: 0 5px 15px 5px; }
.token-label { font-size: 0.8rem; color: #666; margin-bottom: 5px; }
.progress-bg { background: #e0e0e0; border-radius: 10px; height: 4px; width: 100%; overflow: hidden; }
.progress-bar { background: var(--primary-color); height: 100%; transition: width 0.3s; }

.new-chat-btn { 
    display: flex; align-items: center; background: #dde3ea; color: #001d35; 
    border: none; padding: 12px 16px; border-radius: 16px; 
    font-size: 0.9rem; font-weight: bold; margin-bottom: 15px; 
    text-decoration: none; transition: background 0.2s;
}
.new-chat-btn:hover { background: #d3e3fd; }

.list-header { font-size: 0.85rem; color: #5f6368; margin: 10px 10px; display: flex; align-items: center; gap: 8px; font-weight: bold; }
.home-icon { text-decoration: none; font-size: 1.2rem; line-height: 1; cursor: pointer; }

#thread-list { flex: 1; overflow-y: auto; padding-right: 5px; }
.thread-item { display: flex; align-items: center; margin-bottom: 2px; border-radius: 50px; position: relative; padding-right: 5px; }
.thread-item:hover { background: #e8eaed; }
.thread-item.active { background: #c2e7ff; color: #001d35; font-weight: 500; }
.thread-item.active a { color: #001d35; }
.thread-link { flex: 1; color: #444; text-decoration: none; padding: 10px 15px; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.thread-pinned-icon { font-size: 0.8rem; margin-right: 5px; }
.thread-pinned-icon::before { content: var(--pin-emoji); }
.thread-menu-btn { background: none; border: none; cursor: pointer; padding: 8px; font-size: 1.1rem; color: #5f6368; opacity: 0; border-radius: 50%; }
.thread-item:hover .thread-menu-btn, .thread-item.active .thread-menu-btn { opacity: 1; }
.thread-menu-btn::after { content: var(--menu-kebab-emoji); }

.bottom-links { display: flex; justify-content: center; align-items: center; gap: 5px; padding-top: 5px; margin-top: auto; border-top: 1px solid #dadce0; }
.bottom-links a { text-decoration: none; font-size: 1.2rem; color: #5f6368; padding: 6px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.bottom-links a:hover { background: #e8eaed; }

.link-settings::before { content: var(--settings-emoji); }
.link-search::before { content: var(--search-emoji); }
.link-logout::before { content: var(--logout-emoji); }
.link-photos::before { content: var(--icon-photos); }
.link-files::before { content: var(--icon-folder); }

.thread-menu-dropdown { display: none; position: absolute; right: 10px; top: 35px; background: white; border: 1px solid #dadce0; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 1000; min-width: 130px; flex-direction: column; overflow: hidden; }
.thread-menu-dropdown.show { display: flex; }
.thread-menu-dropdown.upward-menu { top: auto; bottom: 45px; }

.menu-action { display: block; width: 100%; text-align: left; padding: 12px 15px; background: white; border: none; font-size: 0.9rem; color: #3c4043; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.menu-action.delete { color: #d93025; }

#main { 
    flex: 1; background: white; 
    display: flex; flex-direction: column; 
    overflow: hidden; position: relative; 
    height: 100dvh;
}

#chat-header { 
    flex-shrink: 0; width: 100%; padding: 15px 30px; 
    border-bottom: 1px solid #f0f0f0; background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(5px); font-weight: 500; font-size: 1.1rem; color: #1f1f1f; 
    z-index: 10; text-align: center;
    display: flex; justify-content: center; align-items: center; position: relative;
}
.header-title-container { 
    flex: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 10px;
}
.header-menu-btn { display: none; }

.mobile-header { display: none; }

#chat-window { 
    flex: 1; overflow-y: auto; padding: 20px 0; 
    display: flex; flex-direction: column; width: 100%; 
}

.message-row { display: flex; width: 100%; max-width: 800px; margin: 0 auto 20px auto; gap: 15px; align-items: flex-start; padding: 0 20px; }
.message-row.user { justify-content: flex-end; }

.chat-content-wrapper { max-width: 70%; display: flex; flex-direction: column; }
.message-row.user .chat-content-wrapper { align-items: flex-end; }
.message-row.model .chat-content-wrapper { align-items: flex-start; }

.chat-msg { width: 100%; padding: 12px 18px; border-radius: 18px; line-height: 1.6; font-size: 1rem; word-wrap: break-word; position: relative; }
.chat-msg.model { background: #f4f6f8; color: #1f1f1f; border-top-left-radius: 4px; }
.chat-msg.model::before { content: ""; position: absolute; left: -8px; top: 12px; width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-right: 8px solid #f4f6f8; }
.chat-msg.user { background: #d3e3fd; color: #001d35; border-top-right-radius: 4px; }
.chat-msg.user::before { content: ""; position: absolute; right: -8px; top: 12px; width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 8px solid #d3e3fd; }

.chat-icon { width: 32px; height: 32px; border-radius: 50%; background: white; border: 1px solid #ccc; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-icon::after { content: var(--ai-icon-emoji); font-size: 18px; }

.message-time { font-size: 0.7rem; color: #aaa; margin-top: 3px; margin-left: 5px; margin-right: 5px; }

#input-area { 
    flex-shrink: 0; 
    padding: 20px; 
    background: white; 
    width: 100%; 
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    z-index: 5001;
    border-top: 1px solid #f0f0f0;
}

#chat-form-container { 
    width: 100%; max-width: 800px; display: flex; align-items: flex-end; gap: 10px; 
    background: transparent; border: 1px solid #ccc; border-radius: 32px; padding: 10px 20px; min-height: 50px;
    position: relative;
}

#mgs_v2_input_7k29 { flex: 1; border: none !important; background: transparent; outline: none !important; box-shadow: none !important; font-size: 1rem; line-height: 1.5; padding: 5px 0; margin: 0; resize: none; overflow-y: auto; height: 24px; max-height: 200px; color: #1f1f1f; }
#send-btn { background: none; border: none; font-size: 24px; color: var(--primary-color); cursor: pointer; padding: 0; margin-bottom: 4px; line-height: 1; }
#send-btn::after { content: var(--send-btn-emoji); }

#scroll-down-btn {
    position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 40px; border-radius: 50%; background-color: rgba(240, 240, 240, 0.9);
    border: 1px solid #ccc; display: none; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1.2rem; color: #555; z-index: 6000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#scroll-down-btn.show { display: flex; }
#scroll-down-btn::after { content: var(--icon-scroll-down); }

.scrollable-content { flex: 1; overflow-y: auto; width: 100%; }
.card { background: white; padding: 30px; border-radius: 12px; border: 1px solid #dadce0; margin: 30px auto; max-width: 700px; width: 90%; }
.page-title { font-size: 1.5rem; text-align: center; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.page-title-settings::before { content: var(--title-icon-settings); font-size: 1.5rem; }
.page-title-search::before { content: var(--title-icon-search); font-size: 1.5rem; }
.card h2 { font-size: 1.2rem; border-left: 4px solid var(--primary-color); padding-left: 10px; margin-bottom: 15px; margin-top: 0; }
.card .db-grid { margin-bottom: 25px; }
.card > label { margin-top: 20px; display: block; }
.card .btn { margin-top: 25px; }
.db-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.history-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.history-table th, .history-table td { border-bottom: 1px solid #eee; padding: 12px; text-align: left; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(2px); z-index: 20000 !important; display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal-content { background: white; padding: 30px; border-radius: 16px; width: 90%; max-width: 350px; text-align: center; }
.modal-content h3 { margin-top: 0; margin-bottom: 15px; color: #333; display: flex; align-items: center; justify-content: center; gap: 8px; } 
.modal-content h3.warn-style::before { content: var(--warn-emoji); }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.btn-save { background: var(--primary-color); color: white; padding: 10px 20px; border-radius: 8px; border: none; font-weight: bold; }
.btn-cancel { background: #f0f2f5; color: #333; padding: 10px 20px; border-radius: 8px; border: none; font-weight: bold; }
.btn-delete { background: #d93025; color: white; padding: 10px 20px; border-radius: 8px; border: none; font-weight: bold; }

#context-menu {
    display: none;
    position: fixed;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 15000;
    min-width: 150px;
    overflow: hidden;
}
.ctx-item {
    padding: 12px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #3c4043;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}
.ctx-item:hover { background: #f5f5f5; }
.ctx-item.delete { color: #d93025; }

@media (max-width: 1024px) {
    #sidebar {
        position: fixed; top: 0; left: -320px; width: 85vw !important; max-width: 320px; height: 100dvh;
        box-shadow: 10px 0 30px rgba(0,0,0,0.2); padding: 20px 20px 5px 20px; z-index: 9999;
    }
    #sidebar.open { left: 0; }
    #header-hamburger-btn {
        display: flex; align-items: center; justify-content: center;
        width: 38px; height: 38px; background: rgba(255, 255, 255, 0.8);
        border: 1px solid #ddd; border-radius: 50%; font-size: 20px; color: #333;
        backdrop-filter: blur(4px); padding: 0; margin: 0; cursor: pointer;
    }
    .header-menu-btn { display: block; background: none; border: none; font-size: 1.2rem; color: #333; cursor: pointer; padding: 10px; }
    .header-menu-btn::after { content: var(--menu-kebab-emoji); }
    #chat-header { justify-content: space-between; padding: 0 10px; height: 60px; font-size: 1rem; }
    
    .mobile-header {
        display: flex; 
        align-items: center;
        justify-content: space-between;
        padding: 0 15px;
        height: 60px;
        border-bottom: 1px solid #eee;
        background: #fff;
        flex-shrink: 0;
    }
    .header-page-title { font-weight: bold; color: #333; }
    .header-spacer { width: 38px; }

    #sidebar-close-btn { display: block; background: none; border: none; font-size: 28px; color: #666; }
    #mobile-overlay.show { display: block; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 9000; backdrop-filter: blur(2px); }
    
    #main { height: var(--vvh) !important; width: 100vw; overflow: hidden; }
    #chat-window { padding: 15px 0; } 
    #input-area {
        padding: 10px 10px; 
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    #chat-form-container { width: 100%; max-width: none; background: #f0f4f9; padding: 8px 15px; min-height: 44px; border: none !important; }
    #mgs_v2_input_7k29 { font-size: 16px; }
    #send-btn { margin-left: 10px; font-size: 28px; }
    
    .message-row { padding: 0 10px; gap: 8px; margin-bottom: 15px; }
    .chat-msg { width: 100%; max-width: none; padding: 10px 14px; font-size: 16px; }
    .chat-content-wrapper { max-width: 90%; }
}

.icon-btn { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: #555; padding: 5px; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; transition: background 0.2s; outline: none !important; }
.icon-btn:hover { background: #f0f0f0; }
.btn-plus::before { content: var(--icon-plus-content); }
.btn-mic::before { content: var(--icon-mic-content); }
.remove-file::before { content: var(--icon-close-content); }
.icon-btn.recording { color: var(--color-recording); background: var(--color-recording-bg); animation: pulse 1.5s infinite; }

#plus-menu { position: absolute; bottom: 60px; left: 0; background: white; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: none; flex-direction: column; z-index: 6000; overflow: hidden; width: auto; min-width: 240px; white-space: nowrap; }
#plus-menu.show { display: flex; }
.menu-item { padding: 12px 20px; text-align: left; background: none; border: none; width: 100%; cursor: pointer; font-size: 14px; color: #333; display: flex; align-items: center; gap: 10px; }
.menu-item:hover { background: #f5f5f5; }
.menu-item:not(:last-child) { border-bottom: 1px solid #eee; }
.btn-upload-image::before { content: var(--icon-image-content); font-size: 1.2em; }
.btn-upload-file::before { content: var(--icon-file-content); font-size: 1.2em; }

#file-preview { display: none; width: 100%; max-width: 800px; padding: 10px; gap: 10px; margin-bottom: 5px; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.preview-item { position: relative; display: inline-block; flex-shrink: 0; }
.preview-thumb { height: 60px; border-radius: 8px; border: 1px solid #ddd; display: block; }
.preview-icon-thumb { width: 60px; height: 60px; border-radius: 8px; border: 1px solid #ddd; background: #f9f9f9; display: flex; align-items: center; justify-content: center; }
.preview-icon-thumb::before { content: var(--icon-file-content); font-size: 24px; color: #555; }
.preview-remove { position: absolute; top: -5px; right: -5px; background: #666; color: white; width: 20px; height: 20px; border-radius: 50%; text-align: center; line-height: 18px; cursor: pointer; font-size: 14px; border: 2px solid white; }

@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

#lightbox-overlay { display: none; position: fixed; z-index: 10000; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.85); justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s ease; }
#lightbox-overlay.show { display: flex; opacity: 1; }
#lightbox-img { max-width: 90%; max-height: 90%; box-shadow: 0 0 20px rgba(0,0,0,0.5); border-radius: 4px; object-fit: contain; }
#lightbox-close { position: absolute; top: 20px; right: 30px; font-size: 40px; color: white; cursor: pointer; font-weight: bold; z-index: 10001; }

.image-gallery { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chat-image-link { display: block; }
.chat-image-display { height: 80px; width: auto; object-fit: cover; border-radius: 8px; border: 1px solid #ddd; box-shadow: 0 1px 3px rgba(0,0,0,0.1); cursor: pointer; transition: transform 0.2s; display: block; }

.typing-indicator { position: relative; display: flex; align-items: center; justify-content: center; width: 160px; height: 32px; border-radius: 999px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); background: #fff; z-index: 1; }
.typing-indicator::before { content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 200px; height: 200px; background: conic-gradient(transparent 0deg, transparent 60deg, #00d2ff 100deg, #9c27b0 180deg, #ff4081 260deg, transparent 300deg); animation: rotate-border 2s linear infinite; z-index: -2; }
.typing-indicator::after { content: ""; position: absolute; inset: 2px; background: #fff; border-radius: 999px; z-index: -1; }
.typing-indicator span { display: inline-block; width: 6px; height: 6px; background: linear-gradient(135deg, #00d2ff, #9c27b0); border-radius: 50%; margin: 0 3px; animation: typing-bounce 1.4s infinite both; }

input[type="checkbox"] { -webkit-appearance: checkbox !important; appearance: auto !important; width: 20px !important; height: 20px !important; display: inline-block !important; margin-right: 10px !important; padding: 0 !important; border: none !important; background: none !important; }

.photo-lib-link, .file-lib-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #5f6368; padding: 12px 16px; margin: 10px 0; font-weight: bold; font-size: 0.95rem; border-radius: 50px; transition: background 0.2s; }
.photo-lib-link:hover, .file-lib-link:hover { background: #e8eaed; }
.photo-lib-link::before { content: var(--icon-photos); font-size: 1.2rem; }
.photo-library-card { width: 96%; max-width: 1200px; padding: 20px; }
.library-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.photo-title-icon::before { content: var(--header-icon-camera); margin-right: 5px; }
.file-title-icon::before { content: var(--header-icon-file); margin-right: 5px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo-item { position: relative; aspect-ratio: 1 / 1; background: #f0f0f0; border-radius: 8px; overflow: hidden; cursor: pointer; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.file-item-box { background: #fff; border: 1px solid #ddd; display: flex; align-items: center; justify-content: center; }
.file-item-inner { width: 100%; height: 100%; padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.file-ext-badge { background: #e6f4ea; color: #1e8e3e; padding: 4px 8px; border-radius: 4px; font-weight: bold; font-size: 0.8rem; margin-bottom: 8px; }
.file-name-text { font-size: 0.8rem; color: #333; line-height: 1.4; word-break: break-all; max-height: 2.8em; overflow: hidden; }

.modal-body { margin-bottom: 20px; text-align: left; }
.modal-desc { font-size: 0.9rem; color: #666; margin: 0; }
.modal-input { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 8px; margin-top: 10px; }

.hamburger-icon::before { content: var(--hamburger-emoji); }
.home-icon::before { content: var(--home-emoji); }
.globe-icon::before { content: var(--globe-emoji); }

.lang-switch-container { position: relative; margin-bottom: 5px; text-align: center; }
.lang-switch-btn { background: #fff; border: 1px solid #ddd; border-radius: 20px; padding: 5px 15px; font-size: 0.8rem; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; color: #555; }

.chat-file-container { margin: 5px 0; }
.chat-file-link { text-decoration: none; color: #333; background: #f0f0f0; padding: 8px 12px; border-radius: 8px; display: inline-flex; align-items: center; border: 1px solid #ccc; }
.chat-file-icon::before { content: var(--icon-file-content); font-size: 1.2em; margin-right: 5px; }

#lightbox-close::before { content: var(--icon-close-content); }

.search-form-container { display: flex; gap: 10px; margin-bottom: 20px; align-items: center; }
.search-input { flex: 1; padding: 14px; height: 48px; }
.btn-search-submit { width: auto; margin: 0 !important; padding: 0 25px; height: 48px; display: flex; align-items: center; justify-content: center; }

.tts-btn {
    width: 34px;
    height: 34px;
    background-color: #f2f2f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: none;
    cursor: pointer;
    outline: none;
    transition: transform 0.1s, background-color 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    margin-top: 2px;
}
.tts-btn::after {
    content: var(--tts-icon-emoji);
    font-size: 16px;
    display: block;
}
.tts-btn:active {
    transform: scale(0.92);
    background-color: #e8e8e8;
}
.tts-btn.speaking {
    background-color: #e0e0e0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    animation: tts-pulse 1.5s infinite;
}
@keyframes tts-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* --- エラーページ用 --- */
.emoji-apology::before {
    content: var(--emoji-apology);
    font-size: 60px;
    display: block;
}
.error-card h1 {
    font-size: 1.3rem;
    font-weight: bold;
}
.error-message-content {
    text-align: left;
    line-height: 1.8;
    color: #555;
    margin-bottom: 20px;
}
.error-time-box {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 30px;
    text-align: left;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

/* --- 設定画面用タブ・デザイン --- */
.settings-tabs {
    display: flex;
    background: white;
    border-bottom: 1px solid #dadce0;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 10px;
    gap: 5px;
}
.tab-btn {
    padding: 15px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: #5f6368;
    font-weight: bold;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}
.settings-panel { display: none; }
.settings-panel.active { display: block; }

.admin-add-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-bottom: 15px;
    position: relative;
}
.admin-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    background: #ffeceb;
    color: #d93025;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    border: 1px solid #f5c6cb;
}
.color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
.color-input-group {
    display: flex;
    align-items: center;
    gap: 5px;
}
.hex-input {
    width: 90px;
    padding: 6px;
    text-align: center;
    font-family: monospace;
    border: 1px solid #ccc;
    border-radius: 4px;
}
input[type="color"] {
    width: 35px;
    height: 35px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}
.reset-option-box {
    text-align: left;
    margin: 15px 0;
    font-size: 0.9rem;
    background: #f0f0f0;
    padding: 10px;
    border-radius: 8px;
}

/* 汎用・微調整用クラス */
.btn-hidden { display: none; }
.form-hidden { display: none; }
.form-no-margin { margin: 0; }
.label-flex-center { display: flex; align-items: center; cursor: pointer; }
.label-bold { font-weight: bold; }
.auth-warning-box { background: #fff3cd; padding: 15px; border-radius: 8px; }
.button-row-flex { display: flex; gap: 10px; }
.margin-0 { margin: 0 !important; }
.margin-left-5 { margin-left: 5px; }
.spacing-top-10 { margin-top: 10px; }
.spacing-top-15 { margin-top: 15px; }
.spacing-top-20 { margin-top: 20px; }
.spacing-top-30 { margin-top: 30px; }
.spacing-top-40 { margin-top: 40px; }
.spacing-bottom-20 { margin-bottom: 20px; }
.separator-40 { margin: 40px 0; border: 0; border-top: 1px solid #eee; }
.heading-primary { border-left-color: var(--primary-color); }
.heading-sub { border-left-color: #666; }
.flex-1 { flex: 1; }
.text-danger { color: #d93025; }
.feedback-alert { margin: 20px; }
.feedback-alert-container { border: none; padding: 0; margin-top: 10px; }
.no-results-msg { grid-column: 1/-1; text-align: center; padding: 40px; color: #888; }

@media (max-width: 1024px) {
    .settings-tabs {
        top: 60px;
        overflow-x: auto;
        white-space: nowrap;
    }
}