:root {
    /* chat.js が固定入力欄の実測高さへ更新する */
    --chat-bottom-safe-area: 208px;
}

body {
    background-color: #FAFAFA;
    color: #1B1B1B;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    font-weight: 350;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: auto;
    transition: background-color 0.3s ease, color 0.3s ease;
}

img {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -o-user-select: none;
    -webkit-user-drag: none;
    -moz-user-drag: none;
    -ms-user-drag: none;
    -o-user-drag: none;
    pointer-events: none;
}

header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 24px 0 24px 0;
    height: 80px;
    transition: color 0.3s ease;
    z-index: 10;
}

header::before,
header::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.3s ease;
}

header::before {
    background-image: linear-gradient(0deg, transparent, #fafafa 75%);
    opacity: 1;
}

header::after {
    background-image: linear-gradient(0deg, transparent, #1B1B1B 75%);
    opacity: 0;
}

html[data-theme="dark"] header::before {
    opacity: 0;
}

html[data-theme="dark"] header::after {
    opacity: 1;
}

.header-container {
    width: 100%;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.header-logo {
    height: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

main {
    width: 100%;
    min-height: 100vh; /* dvh非対応ブラウザへのフォールバック */
    min-height: 100dvh; /* モバイル端末のツールバー伸縮に動的対応 */
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 104px; /* ヘッダーとの被りを防ぐための上部余白 */
    padding-bottom: 104px; /* 上下を対称にすることで完全な幾何学的一致を実現 */
    box-sizing: border-box;
}

.main-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-content-container {
    width: calc(100% - 80px);
    max-width: 1152px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 40px; /* タイトルと入力欄の間の余白 */
}

.starter-prompts {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: min(100%, 640px);
    gap: 6px;
    margin-top: -18px;
}

.starter-prompt {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #3C4043;
    font: inherit;
    font-size: 15px;
    font-weight: 450;
    text-align: left;
    cursor: pointer;
    opacity: 0;
    transform: translateY(-14px);
    animation: starterPromptIn 0.48s cubic-bezier(0.16, 1, 0.3, 1) var(--starter-delay) forwards;
}

.starter-prompt:hover {
    background: #F1F3F4;
}

.starter-prompt .material-symbols-rounded {
    font-size: 18px;
    font-weight: 500;
}

@keyframes starterPromptIn {
    to { opacity: 1; transform: translateY(0); }
}

.main-content-message-title {
    font-size: 48px;
    color: #1B1B1B;
    text-align: center;
    line-height: 58px;
    font-weight: 400;
    font-family: 'Google Sans Flex', sans-serif;
    font-optical-sizing: auto;
    font-style: normal;
    font-variation-settings:
        "slnt" -10,
        "wdth" 65,
        "GRAD" 0,
        "ROND" 0;
    transition: color 0.3s ease;
    margin: 0;
}

.main-content-message-title-highlight {
    font-weight: 500;
    font-family: 'Google Sans Flex', sans-serif;
    font-optical-sizing: auto;
    font-style: normal;
    font-variation-settings:
        "slnt" -10,
        "wdth" 80,
        "GRAD" 0,
        "ROND" 0;
    padding-right: 2px;
    background: linear-gradient(#34cdff, #0061fe);
    color: transparent;
    background-clip: text;
    transition: color 0.3s ease;
}

.input-container {
    --prompt-base-height: 36;
    --prompt-max-height: 200;
    max-width: 600px;
    width: 100%;
    min-height: 56px;
    height: auto;
    border-radius: 28px;
    padding: 8px 8px 8px 24px;
    font-size: 16px;
    font-weight: 350;
    color: #1B1B1B;
    background-color: #FFFFFF;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: row;
    align-items: center;
    box-sizing: border-box;
    animation: Hello 0.4s ease-in;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

@keyframes Hello {
    0% { max-width: 272px; }
    40% { max-width: 648px; }
    57% { max-width: 600px; }
    65% { max-width: 590px; }
    100% { max-width: 600px; }
}

.input-container.expanded {
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
}

#user-prompt {
    flex: 1;
    width: 100%;
    margin: 0;
    padding: 6px 0;
    border: none;
    background: none;
    outline: none;
    font: inherit;
    color: inherit;
    resize: none;
    overflow-y: hidden;
    line-height: 24px;
    min-height: calc(var(--prompt-base-height) * 1px);
    height: calc(var(--prompt-base-height) * 1px);
    box-sizing: border-box;
}

.input-container.expanded #user-prompt {
    flex: none;
    max-height: calc(var(--prompt-max-height) * 1px);
    padding: 8px 16px 0px 16px;
}

.buttons-container {
    display: flex;
    align-items: center;
    margin-left: 8px;
}

.input-container.expanded .buttons-container {
    justify-content: flex-end;
    margin-left: 0;
    margin-top: 4px;
}

.send-button {
    background: none;
    user-select: none;
    border: none;
    padding: 8px;
    cursor: not-allowed;
    border-radius: 20px;
    width: 40px;
    height: 40px;
    background-color: #EFEFEF;
    color: #898989;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.3s cubic-bezier(0.16, 0.5, 0.3, 1.4), background-color 0.3s ease, color 0.3s ease;
}

.send-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.send-button.active {
    width: 48px;
    background: linear-gradient(#1B1B1B);
    color: #FFFFFF;
    cursor: pointer;
}

.send-button.active:hover {
    background: linear-gradient(#34cdff, #0061fe);
}

.send-button span {
    width: 24px;
    height: 24px;
    display: block;
    transform: translateY(0px);
    transition: transform 0.2s cubic-bezier(0.16, 0.5, 0.3, 1.4);
}

.send-button.active:active span {
    transform: translateY(-4px);
}

/* --- Chat Page Styles --- */
.chat-page {
    display: block;
    min-height: 100vh;
    overflow-y: auto;
    scroll-snap-type: none;
    position: relative;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

html {
    background-color: #FAFAFA;
    transition: background-color 0.3s ease;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    scrollbar-width: thin;
}

.chat-header {
    user-select: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    z-index: 20;
    pointer-events: none;
}

.chat-header .header-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.chat-header .header-logo {
    grid-column: 2;
    justify-self: center;
}

.chat-header .new-chat-button {
    margin-right: 40px;
    grid-column: 3;
    justify-self: end;
    pointer-events: auto;
}

.chat-main {
    position: relative;
    width: 100%;
    min-height: 100vh;
    z-index: 1;
    overflow-y: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.chat-messages-container {
    max-width: 800px;
    width: calc(100% - 80px);
    padding: 104px 24px calc(var(--chat-bottom-safe-area) + 24px);
    display: flex;
    flex-direction: column;
    gap: 32px;
    box-sizing: border-box;
}

.chat-message {
    display: flex;
    gap: 16px;
    width: 100%;
    align-items: flex-start;
}

.chat-message.user-message {
    justify-content: flex-end;
}

.chat-message.ai-message {
    justify-content: flex-start;
}

.ai-icon {
    width: 56px;
    height: 56px;
    top: 0px;
    position: relative;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ai-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.message-bubble {
    position: relative;
    top: 11px;
    max-width: 70%;
    padding: 16px 24px;
    border-radius: 32px;
    font-size: 18px;
    line-height: 1.6;
    color: #1B1B1B;
    word-wrap: break-word;
    white-space: pre-wrap;
    transition: background-color 0.3s ease, color 0.3s ease;
}

@keyframes Bubble {
    0% { transform: translateX(16px); }
    50% { transform: translateX(-4px); }
    100% { transform: translateX(0px); }
}

.user-message .message-bubble {
    background-color: #F1F1F1;
    border-top-right-radius: 4px;
    animation: Bubble 0.2s ease-in;
}

.ai-message .message-bubble {
    background-color: transparent;
    padding: 4px 0;
    max-width: 85%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.chat-bottom-section {
    user-select: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

/* 修正後の .chat-gradient-mask */
.chat-gradient-mask {
    position: relative;
    width: 100%;
    height: 80px;
    pointer-events: none;
    /* 背景色を設定し、切り替え時にトランジションさせる */
    background-color: #FAFAFA;
    transition: background-color 0.3s ease;
    /* マスクを使用してグラデーション状に透過させる */
    -webkit-mask-image: linear-gradient(0deg, black 10%, transparent);
    mask-image: linear-gradient(0deg, black 10%, transparent);
}


.chat-bottom-controls {
    width: 100%;
    background-color: #FAFAFA;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    position: relative;
    pointer-events: auto;
    transition: background-color 0.3s ease;
}

.chat-input-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}

.chat-disclaimer {
    margin: 0;
    padding: 0 16px;
    box-sizing: border-box;
    color: #898989;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
}

.new-chat-button {
    user-select: none;
    background-color: #FFFFFF;
    color: #1B1B1B;
    border: 2px solid #f0f0f0;
    border-radius: 40px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.new-chat-button:hover {
    transform: scale(1.02);
    background-color: #F1F1F1;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.new-chat-button:active {
    transform: scale(1.005);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.new-chat-button .material-symbols-rounded {
    font-size: 24px;
}

.dots {
    display: inline-block;
    min-width: 15px;
    text-align: left;
}

.ai-message.loading-state .message-bubble {
    color: #898989;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-message .message-bubble p {
    margin: 0 0 6px 0;
}

.ai-message .message-bubble p:last-child {
    margin-bottom: 0;
}

.ai-message .message-bubble ul,
.ai-message .message-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.ai-message .message-bubble li {
    margin: 4px 0;
}

.ai-message .message-bubble li ul,
.ai-message .message-bubble li ol {
    margin: 4px 0 2px 20px;
    padding-left: 0;
}

.ai-message .message-bubble li li {
    margin: 2px 0;
    font-size: 14px;
    color: #555555;
    list-style-type: circle;
}

.ai-message .message-bubble li:last-child {
    margin-bottom: 0;
}

.ai-message .message-bubble li p {
    margin: 0;
}

.ai-message .message-bubble strong {
    font-weight: 600;
    color: #000000;
}

.ai-message .message-bubble code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.ai-message .message-bubble pre {
    background-color: #F6F8FA;
    border: 1px solid #E1E4E8;
    border-radius: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    margin: 8px 0;
}

.ai-message .message-bubble pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 14px;
    color: #24292E;
}

.ai-message .message-bubble h1,
.ai-message .message-bubble h2,
.ai-message .message-bubble h3 {
    margin: 12px 0 6px 0;
    font-weight: 600;
    color: #1B1B1B;
}

.ai-message .message-bubble h1 { font-size: 22px; }
.ai-message .message-bubble h2 { font-size: 20px; }
.ai-message .message-bubble h3 { font-size: 18px; }

.send-button.stop-active {
    cursor: pointer;
    background: #1b1b1b;
    color: #ffffff;
    width: 48px;
    opacity: 1;
}

.send-button.stop-active:hover {
    background: #d93025;
}

.send-button.stop-active:active span {
    transform: scale(0.87);
}

/* --- Dialog Styles --- */
.custom-dialog {
    border: none;
    border-radius: 40px;
    padding: 0;
    max-width: 600px;
    width: calc(100% - 48px);
    max-height: calc(100vh - 80px); 
    background-color: #FFFFFF;
    box-sizing: border-box;
    display: none;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    margin: 0;
    opacity: 0;
    filter: blur(0px);
    transform: scale(0.92) translate(-50%, -50%);
    transform-origin: top left;
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.2s cubic-bezier(0.16, 0.5, 0.3, 1.4),
        display 0.4s allow-discrete,
        overlay 0.4s allow-discrete;
    overflow: hidden;
}

.custom-dialog[open] {
    display: flex;
    opacity: 1;
    filter: blur(0px);
    transform: scale(1) translate(-50%, -50%);
    @starting-style {
        opacity: 0;
        filter: blur(0px);
        transform: scale(0.92) translate(-50%, -50%);
    }
}

.custom-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition:
        background-color 0.2s ease-out,
        backdrop-filter 0.2s ease-out,
        -webkit-backdrop-filter 0.4s ease-out,
        display 0.4s allow-discrete,
        overlay 0.4s allow-discrete;
}

.custom-dialog[open]::backdrop {
    background-color: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    @starting-style {
        background-color: rgba(0, 0, 0, 0);
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
}

.dialog-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    text-align: left;
    padding: 40px 24px 24px 40px;
    max-height: 100dvh;
    box-sizing: border-box;
    min-height: 0;
    overflow: hidden;
}

.dialog-scroll-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 16px;
    scrollbar-gutter: stable;
}

.dialog-title {
    margin: 0;
    font-size: 26px;
    font-weight: 400;
    color: #1B1B1B;
    line-height: 1.3;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
}

.dialog-body {
    margin: 0 0 28px 0;
    font-size: 16px;
    color: #555555;
    line-height: 1.6;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
}

.dialog-body:last-child {
    margin-bottom: 0;
}

.dialog-body strong {
    color: #1B1B1B;
    font-weight: 600;
}

.dialog-disclosure {
    margin: 0;
    border-top: 1px solid #E6E6E6;
    color: #555555;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    font-size: 14px;
    line-height: 1.65;
}

.dialog-disclosure summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0;
    color: #1B1B1B;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

.dialog-disclosure summary::-webkit-details-marker {
    display: none;
}

.dialog-disclosure summary::after {
    content: 'expand_more';
    margin-left: auto;
    font-family: 'Material Symbols Rounded';
    font-size: 20px;
    font-weight: 400;
    transition: transform 0.2s ease;
}

.dialog-disclosure[open] summary::after {
    transform: rotate(180deg);
}

.dialog-disclosure p {
    margin: 0 0 16px;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    flex-shrink: 0;
}

.dialog-btn {
    border: none;
    border-radius: 28px;
    padding: 14px 28px;
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.2s ease, border-radius 0.2s cubic-bezier(0.16, 0.5, 0.3, 1.4), opacity 0.2s ease;
    user-select: none;
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
}

.dialog-btn:active {
    border-radius: 8px;
}

.confirm-btn {
    background-color: #1B1B1B;
    color: #FFFFFF;
}

.cancel-btn {
    background-color: #E2E2E2;
    color: #1B1B1B;
}

.cancel-btn:hover {
    background-color: #D5D5D5;
}

.fade-in-word {
    display: inline-block;
    animation: fadeInUp 0.4s ease-out both;
}

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

.fade-in-done {
    opacity: 1;
}

/* ============================================================
   左上コントロールボタン群
   ============================================================ */
.top-left-controls {
    position: fixed;
    top: 40px;
    left: 40px;
    z-index: 100;
    display: flex;
    gap: 16px;
}

.control-icon-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1B1B1B;
    background-color: #FFFFFF;
    border: 2px solid #f0f0f0;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.2s, box-shadow 0.2s;
}

.control-icon-btn:hover {
    background-color: #F1F1F1;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.control-icon-btn:active {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.control-icon-btn span {
    font-size: 24px;
    display: block;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ダイアログ本体にフォーカスが当たった際の枠線を消す */
.custom-dialog:focus,
.custom-dialog:focus-visible {
    outline: none;
}

/* もしダイアログ内のボタンなどに枠線が出ている場合はこちらも追加 */
.dialog-btn:focus,
.dialog-btn:focus-visible {
    outline: none;
}

/* 新しく追加された単語・文節の塊に適用されるインライン対応のフェードインアニメーション */
.fade-in-node {
    display: inline; /* テキストの流れ・自動改行を崩さないために必須 */
    animation: inlineFadeInUp 0.6s cubic-bezier(0.33, 1, 0.68, 1) forwards;
    will-change: opacity;
}

@keyframes inlineFadeInUp {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@media (max-width: 720px) {
    .input-container {
        --prompt-base-height: 40;
        --prompt-max-height: 160;
        max-width: 512px;
        width: 100%;
        height: auto;
        border-radius: 38px;
        padding: 12px 12px 12px 32px;
        font-size: 20px;
        font-weight: 350;
        color: #1B1B1B;
        background-color: #FFFFFF;
        box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: row;
        align-items: center;
        box-sizing: border-box;
        animation: none;
    }

    .input-container.expanded {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .send-button {
        background: none;
        border: none;
        padding: 8px;
        cursor: not-allowed;
        border-radius: 24px;
        width: 48px;
        height: 48px;
        background-color: #EFEFEF;
        color: #898989;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: width 0.3s cubic-bezier(0.16, 0.5, 0.3, 1.4), background-color 0.3s ease, color 0.3s ease;
    }

    .send-button.active {
        width: 64px;
        background: linear-gradient(#1B1B1B);
        color: #FFFFFF;
        cursor: pointer;
    }

    .send-button.stop-active {
        cursor: pointer;
        background: #1b1b1b;
        color: #ffffff;
        width: 64px;
        opacity: 1;
    }

    #user-prompt {
        line-height: 28px;
        padding: 6px 0;
    }

    .main-content-container {
        width: calc(100% - 32px);
        max-width: 512px;
        gap: 24px; /* モバイルでは少し狭める */
    }

    header {
        padding: 8px 0 24px 0;
        height: 80px;
    }

    .header-logo {
        height: 48px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .chat-header {
        position: fixed;
        top: 0;
        right: 0px;
        width: 100%;
        z-index: 20;
    }

    .chat-header .new-chat-button {
        margin-right: 16px;
        grid-column: 3;
        justify-self: end;
    }

    .new-chat-button {
        background-color: #FFFFFF;
        color: #1B1B1B;
        border: 2px solid #f0f0f0;
        border-radius: 32px;
        padding: 12px 16px;
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 16px;
        font-weight: 500;
        cursor: pointer;
        transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    }

    .new-chat-button:hover {
        transform: scale(1);
        background-color: #FFFFFF;
        box-shadow: none;
    }

    .new-chat-button:active {
        transform: scale(1.02);
        background-color: #F1F1F1;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    }

    .chat-messages-container {
        max-width: none;
        width: 100%;
        padding: 64px 16px calc(var(--chat-bottom-safe-area) + 16px);
        display: flex;
        flex-direction: column;
        gap: 32px;
        box-sizing: border-box;
    }

    .chat-message {
        display: grid;
        gap: 8px;
        width: 100%;
        align-items: flex-start;
    }

    /* 通常回答はアイコンの下、処理中の短い表示だけは横へ並べる */
    .chat-message.ai-message.loading-state {
        display: flex;
        gap: 8px;
        align-items: flex-start;
    }

    /* Naviの通常回答は、画面左右の余白を残したチャット領域いっぱいに使う */
    .chat-message.ai-message:not(.loading-state) .message-bubble {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* ユーザーの吹き出しは右端へ固定し、短すぎる折り返しを防ぐ */
    .chat-message.user-message {
        display: flex;
        justify-content: flex-end;
        gap: 0;
    }

    .chat-message.user-message .message-bubble {
        width: fit-content;
        max-width: calc(100% - 32px);
        margin-left: auto;
        box-sizing: border-box;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .chat-bottom-controls {
        width: 100%;
        background-color: #FAFAFA;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        position: relative;
        pointer-events: auto;
        transition: background-color 0.3s ease;
    }

    .chat-disclaimer {
        width: 100%;
        padding: 0 16px;
        font-size: 14px;
    }

    .ai-icon {
        width: 48px;
        height: 48px;
        top: 0px;
        position: relative;
        flex-shrink: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .custom-dialog {
        border: none;
        border-radius: 40px;
        padding: 0;
        max-width: 480px;
        width: calc(100% - 32px);
        max-height: calc(100vh - 48px); 
        background-color: #FFFFFF;
        box-sizing: border-box;
        display: none;
        flex-direction: column;
        position: fixed;
        top: 50%;
        left: 50%;
        margin: 0;
        opacity: 0;
        filter: blur(0px);
        transform: scale(0.93) translate(-50%, -50%);
        transform-origin: top left;
        transition:
            background-color 0.3s ease,
            color 0.3s ease,
            opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
            filter 0.4s cubic-bezier(0.16, 1, 0.3, 1),
            transform 0.2s cubic-bezier(0.16, 0.7, 0.3, 1.3),
            display 0.4s allow-discrete,
            overlay 0.4s allow-discrete;
    }

    .custom-dialog[open] {
        display: flex;
        opacity: 1;
        filter: blur(0px);
        transform: scale(1) translate(-50%, -50%);
        @starting-style {
            opacity: 0;
            filter: blur(0px);
            transform: scale(0.93) translate(-50%, -50%);
        }
    }

    .dialog-content {
        padding: 32px 28px 28px 28px;
        max-height: calc(100dvh - 32px);
    }

    .dialog-body {
        margin: 0 0 16px 0;
        font-size: 16px;
        color: #555555;
        line-height: 1.6;
        font-family: 'Inter', 'Noto Sans JP', sans-serif;
    }

    .top-left-controls {
        top: 24px;
        left: 16px;
        gap: 12px;
    }

    .control-icon-btn {
        width: 40px;
        height: 40px;
    }

    .control-icon-btn span {
        font-size: 20px;
    }

    .control-icon-btn:hover {
        background-color: #FFFFFF;
        transform: scale(1);
        box-shadow: none;
    }

    .control-icon-btn:active {
        background-color: #F1F1F1;
        transform: scale(1.04);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    }

    .message-bubble {
    position: relative;
    top: 8px;
    max-width: 70%;
    padding: 16px 24px;
    border-radius: 32px;
    font-size: 18px;
    line-height: 1.6;
    color: #1B1B1B;
    word-wrap: break-word;
    white-space: pre-wrap;
    transition: background-color 0.3s ease, color 0.3s ease;
}

    @media (max-height: 560px) {
        .main-content-message-title {
            font-size: 28px;
            line-height: 38px;
        }      

        .input-container {
        --prompt-base-height: 40;
        --prompt-max-height: 128;
    }

    .main-content-container {
    gap: 16px;
    }

    header {
        padding: 8px 0 8px 0;
        height: 80px;
    }
    
    }

}
