:root {
    --bg: #d1d5db;
    --line-bg: #8AA9D7;
    --you-bubble: #ffffff;
    --me-bubble: #c7edc0;
    --accent: #00c300;
    --muted: rgba(0, 0, 0, 0.6);
    --day-sep: rgba(0, 0, 0, 0.2);
    --white: #FFFFFF;
    --black: #000000;
}

* {
    box-sizing: border-box;
    font-family: "Helvetica Neue", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

*, *:before, *:after {
    box-sizing: inherit;
}

html {
    box-sizing: border-box;
    height: 100%;
    overflow: hidden !important;
}

body {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    overflow: hidden !important;
    margin: 0;
    padding: 0;
}

.app {
    width: 390px;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(12, 24, 40, 0.2);
    background: #e5ddd5;
    display: flex;
    flex-direction: column;

    position: relative; /* ★ これを追加 (または確認) */
}

.header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    color: var(--black);
    background: var(--white);
    /*border-bottom: 1px solid #d0d0d0;*/
}

.back-button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.back-button::before {
    content: '';
    width: 12px;
    height: 12px;
    border-top: 1px solid var(--black);
    border-right: 1px solid var(--black);
    transform: rotate(-135deg);
    position: absolute;
}

.title { flex: 1; }
.name { font-weight: 700; }
.status { font-size: 12px; color: var(--muted); }

.messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--line-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.day-sep {
    align-self: center;
    background: var(--day-sep);
    padding: 4px 12px;
    border-radius: 12px;
    color: var(--white);
    font-size: 12px;
}

.msg { max-width: 90%; display: flex; align-items: flex-end; gap: 8px; position: relative; }
.msg.you { align-self: flex-start; align-items: flex-start; }
.msg.me { align-self: flex-end; }

.msg .avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}

.bubble-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.msg.me .bubble-wrapper {
    flex-direction: row-reverse;
}

.bubble {
    padding: 10px 12px;
    border-radius: 18px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    word-break: break-all;
    font-size: 0.85rem;
}

.you .bubble {
    background: var(--you-bubble);
}

.you .bubble::before {
    content: "";
    position: absolute;
    top: 0;
    left: -10px;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 0 0, transparent, transparent 19px, var(--you-bubble) 20px);
}

.me .bubble {
    background: var(--me-bubble);
}

.me .bubble::before {
    content: "";
    position: absolute;
    top: 0;
    right: -10px;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 100% 0, transparent, transparent 19px, var(--me-bubble) 20px);
}

.meta {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
    padding-bottom: 2px;
}

.composer {
    flex-shrink: 0;
    padding: 10px;
    /*border-top: 1px solid #ccc;*/
    background: var(--white);
    display: flex;
    gap: 8px;
    align-items: center;

    position: relative;
    z-index: 10; /* メニューより手前 */
}

.composer input[type=text] {
    flex: 1;
    border: 1px solid var(--day-sep);
    /*border: none;*/
    border-radius: 20px;
    padding: 10px 14px;
    outline: none;
    font-size: 15px;
}

.send {
    background: none;
    border: none;
    border-radius: 0;
    width: auto;
    height: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--black);
}

.send svg {
    width: 28px;
    height: 28px;
}

@media (max-width: 420px) {
    .app {
        width: 100%;
        height: 100dvh;
        border-radius: 0;
    }
}

/* メニュー開閉 */
.composer .menu-toggle {
    background: none;
    border: none;
    color: var(--black);
    cursor: pointer;
    padding: 8px 10px; /* Adjust padding */
    font-size: 16px; /* Adjust size */
    line-height: 1; /* Ensure consistent height */
}

.action-menu {
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 5;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    visibility: hidden;
}

.action-menu img {
    display: block;
    width: 100%;
    height: auto;
}

.action-menu.visible {
    transform: translateY(0);
    visibility: visible;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    color: #555;
    cursor: pointer;
    padding: 5px 0;
}

.menu-item i {
    font-size: 20px;
    margin-bottom: 4px;
    color: #777;
}

/* ★ メニュー表示時にメッセージエリアの下パディングを調整 */
.app.menu-open .messages {
    /* padding-bottom: calc(メニューの高さ + 元のpadding); */
    /* JSで動的に設定する方が確実 */
}

/* ★ メニュー表示時にcomposerを上に押し上げる */
.app.menu-open .composer {
    /* JSで動的に設定 */
}

.bubble-wrapper:has(.flex-card-small),
.bubble-wrapper:has(.image-slider),
.bubble-imagemap-wrapper {
    display: inline-block;
    width: auto;
}
.bubble-wrapper:has(.flex-card-small) .meta,
.bubble-wrapper:has(.image-slider) .meta,
.bubble-imagemap-wrapper .meta {
    margin-left: 0;
    width: 295px; /* Or card width */
    text-align: right;
    margin-top: 4px;
}
.bubble-imagemap-wrapper .meta {
    width: 300px;
}

.rounded-image {
    border-radius: 18px;
    display: block;
    overflow: hidden;
}

.bubble.no-tail::before {
    content: none !important; /* contentを無くすのが確実 */
    /* または background: none !important; でも可 */
}