/* ==== Reset & Base ==== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #e9edf0;
    color: #222;
    display: flex;
    flex-direction: column;
}

/* ==== Header ==== */
.header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #111827;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    user-select: none;
}

.htext {
    line-height: 1.2;
}

.htitle {
    font-size: 15px;
    font-weight: 700;
}

.hsub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

/* ==== Toolbar ==== */
.toolbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 12px;
    display: flex;
    gap: 8px;
}

.tb-btn {
    appearance: none;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #111827;
    padding: 6px 10px;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 12px;
}

.tb-btn:hover {
    background: #f9fafb;
}

/* ==== Chat Area ==== */
.chat {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.msg {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: fade .2s ease;
}

.msg.bot {
    justify-content: flex-start;
}

.msg.user {
    justify-content: flex-end;
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #111827;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.bubble {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    max-width: 80%;
    padding: 10px 12px;
    white-space: pre-wrap;
    line-height: 1.6;

    /* ← 修正点 */
    display: inline-block;
    vertical-align: middle;
}

.bubble.user {
    background: #e8f0ff;
    border-color: transparent;
}

/* ==== Options ==== */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    align-items: stretch;
}

.opt {
    appearance: none;
    background: #fff;
    border: 2px solid #2563eb;
    color: #2563eb;
    padding: 12px 14px;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 15px;
    text-align: center;
    transition: background .15s, color .15s, box-shadow .15s;
}

.opt:hover {
    background: #eff6ff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .04);
}

.opt:disabled {
    opacity: .5;
    cursor: default;
}

/* ==== Typing Indicator ==== */

.bubble-typing {
    display: inline-flex;
    /* インラインで最小幅に縮む */
    align-items: center;
    gap: 4px;
    white-space: normal;
    /* 改行を無視して横並び */
}

.typing-dot {
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
    animation: blink 1s infinite;
    font-size: 10px;
    font-weight: 600;
}

.typing-dot:nth-child(2) {
    animation-delay: .15s;
}

.typing-dot:nth-child(3) {
    animation-delay: .3s;
}

@keyframes blink {

    0%,
    80%,
    100% {
        opacity: .2;
    }

    40% {
        opacity: 1;
    }
}

@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}