.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    justify-content: space-around;
    gap: .25rem;
    padding: .35rem max(env(safe-area-inset-left),12px) calc(.35rem + env(safe-area-inset-bottom)) max(env(safe-area-inset-right),12px);
    background: rgba(18, 26, 42, .85);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,.1);
}

.bottom-nav__center-spacer {
    width: 92px; /* FAB分のスペースを少し拡大 */
    pointer-events: none;
}

/* ベース */
.bottom-nav__item,
.bottom-nav__btn {
    position: relative;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    color: #e1e7ff;
    text-decoration: none;
    padding: .5rem .25rem;
    border-radius: 12px;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.08);
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.bottom-nav__form {
    margin: 0;
    display: contents; /* ボタンをフレックス子要素として扱う */
}

/* hover を hover 対応デバイスのみに限定 */
@media (hover: hover) and (pointer: fine) {
  .bottom-nav__item:hover:not(.active),
  .bottom-nav__btn:hover {
      background: rgba(255,255,255,.06);
      color: #fff;
  }

  /* featured も未選択時は薄い hover のみ */
  .bottom-nav__item--featured:hover:not(.active) {
      background: rgba(255,255,255,.06);
      box-shadow: 0 2px 8px rgba(0,0,0,.20);
  }
}

/* キーボードフォーカス: 背景は変えずアウトラインのみ */
.bottom-nav__item:focus-visible,
.bottom-nav__btn:focus-visible {
    outline: 2px solid #4e73df;
    outline-offset: 2px;
}
/* Safari 等のフォールバック（背景が変わらないよう focus は無効） */
.bottom-nav__item:focus,
.bottom-nav__btn:focus {
    outline: none;
}

/* 選択中の見た目は aria-current=page のみで適用 */
.bottom-nav__item[aria-current=page] {
    background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.07));
    color: #fff;
    border-color: rgba(78,115,223,.55);
    box-shadow: inset 0 0 0 1px rgba(78,115,223,.25), 0 2px 8px rgba(0,0,0,.25);
}
.bottom-nav__item[aria-current=page] .bottom-nav__label { font-weight: 700; }
.bottom-nav__item[aria-current=page]::after {
    content: '';
    position: absolute; left: 8px; right: 8px; bottom: -1px;
    height: 3px; border-radius: 3px 3px 0 0; background: #4e73df;
}
/* featured の選択時 */
.bottom-nav__item--featured[aria-current=page] {
    background: linear-gradient(180deg, rgba(78,115,223,.45), rgba(78,115,223,.30));
    border-color: rgba(78,115,223,.65);
    box-shadow: 0 6px 14px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.12);
}

.bottom-nav__icon { display: block; }
.bottom-nav__label { font-size: .78rem; }

/* 中央の凸ボタン（FAB）: テキストを円内に表示 */
.bottom-nav__fab {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom) + 28px); /* 少し持ち上げる */
    width: 72px;
    height: 72px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff; /* テキスト色 */
    text-decoration: none;
    z-index: 1040;
    background: radial-gradient(120% 120% at 30% 20%, #6ea8fe 0%, #4e73df 35%, #2b3f9a 100%);
    box-shadow: 0 10px 20px rgba(0,0,0,.45), inset 0 2px 6px rgba(255,255,255,.25);
    border: 1px solid rgba(255,255,255,.25);
    padding: 0 6px; /* 円内のテキスト左右に余白 */
}

.bottom-nav__fab:active {
    transform: translateX(-50%) translateY(2px);
    box-shadow: 0 6px 12px rgba(0,0,0,.45), inset 0 1px 2px rgba(255,255,255,.2);
}

/* 円内テキスト */
.bottom-nav__fab-text {
    display: block;
    width: 100%;
    text-align: center;
    font-weight: 700;
    font-size: .72rem;         /* 収まりを優先して小さめ */
    line-height: 1.05;         /* 2行になっても潰れないように */
    letter-spacing: .02em;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,.55);
    user-select: none;
    white-space: normal;       /* 折返し許可（<wbr>で制御） */
}

/* コミュニティ（強調） */
.bottom-nav__item--featured {
    flex: 1.2 1 0; /* わずかに幅を広く */
}

/* 未選択時は通常項目と同等の見た目 */
.bottom-nav__item--featured:not(.active) {
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: none;
    transform: none;
}

/* 以前のアイコン/下ラベル用スタイルはそのままでも悪影響なし */
@media (min-width: 992px) {
    .bottom-nav { display: none; }
}

/* --- 追加: ボトムナビ折返し対策 & さらにコンパクト化 (2025-11-10) --- */
@media (max-width: 991.98px) {
    .bottom-nav__item,
    .bottom-nav__btn {
        padding: .42rem .2rem;
        gap: .12rem;
    }
    .bottom-nav__label {
        font-size: .72rem;
        line-height: 1.05;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .bottom-nav__icon {
        width: 20px !important;
        height: 20px !important;
    }
    /* 推定高さ CSS 変数（チャット高さ計算用） */
    :root {
        --bottom-nav-est-height: 56px;
    }
}

@media (max-width: 480px) {
    .bottom-nav__label {
        font-size: .68rem;
        letter-spacing: .01em;
    }
    :root { --bottom-nav-est-height: 52px; }
}

@media (max-width: 390px) {
    .bottom-nav__item,
    .bottom-nav__btn {
        padding: .36rem .15rem;
    }
    .bottom-nav__label {
        font-size: .64rem;
    }
    :root { --bottom-nav-est-height: 48px; }
}
