@charset "UTF-8";

/* ===== ベース ===== */
:root {
  /* bottom_nav: 画面下から 15px、上に 5px の余白で統一 */
  --bottom-nav-h: 70px;              /* 中身（アイコン+ラベル）が収まる領域 */
  --bottom-nav-pad-top: 5px;        /* アイコンの上に余白 */
  --bottom-nav-pad-bottom: 15px;     /* 画面下からアイコン群までの余白 */
  --safe-bottom: env(safe-area-inset-bottom);
  --bottom-nav-total: calc(
    var(--bottom-nav-h)
    + var(--bottom-nav-pad-top)
    + var(--bottom-nav-pad-bottom)
    + var(--safe-bottom)
  );

  /* back button */
  --back-btn-w: 44px;
  --back-btn-h: 32px;
  --back-stroke: 2.5px;
}



/* =========================================================
   Safari(ブラウザ)だけ：ボトムナビを 7px 下げる
   - アイコン群を7px下げる：--bottom-nav-pad-bottom を 15px → 8px
   - 白い帯（背景）の高さも 7px 減る（上から削れる）
   - PWA（standalone）は現状の見た目を維持
   ========================================================= */

/* iOS Safari(ブラウザ)向け：タッチ端末 + WebKit のみ適用 */
@media (hover: none) and (pointer: coarse){
  @supports (-webkit-touch-callout: none){
    :root{ --bottom-nav-pad-bottom: 8px; }
  }
}

/* PWA(アプリ版)は従来どおり */
@media (display-mode: standalone){
  :root{ --bottom-nav-pad-bottom: 15px; }
}

html, body { background: #fff; }

body,
input,
textarea,
button,
select {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans JP", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
}

body {
  margin: 0;
  background: #f5f8fa;
  padding-bottom: var(--bottom-nav-total); /* ボトムナビ+安全領域分（統一） */
}

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 10px 20px;
}

/* ===== ヘッダー（メロディー共通） ===== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 600;
  background: #ffffff;
}

.header-inner {
  max-width: 700px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 8px;
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
}

.header-left,
.header-right {
  gap: 8px;
}

/* タイトルをガチ中央に固定 */
.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none; /* タイトルの上でも右ボタンが押せるように */
}

.header-avatar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.header-title {
  font-size: 18px;
  font-weight: bold;
  color: #14171a;
}

/* 右側の小アイコンボタン（共通） */
.header-icon-button {
  border: none;
  background: transparent;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}



/* ===== 戻るボタン（全ページ共通） ===== */
.header-back-button,
a.header-back-button,
button.header-back-button,
.profile-back,
a.back,
.chat-back,
.app-header .header-left .header-icon-button[aria-label="戻る"]
{
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  width: var(--back-btn-w) !important;
  height: var(--back-btn-h) !important;
  border-radius: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  color: #14171a !important;
  text-decoration: none !important;
  position: relative !important;
  font-size: 0 !important; /* 「＜ 戻る」を消してアイコンだけに */
}


/* header-icon-button（戻る）に中身（←など）が入っていても、アイコンを統一する */
.app-header .header-left .header-icon-button[aria-label="戻る"] > * {
  display: none !important;
}

.header-back-button::before,
.profile-back::before,
a.back::before,
.chat-back::before,
.app-header .header-left .header-icon-button[aria-label="戻る"]::before {
  content: "" !important;
  position: absolute !important;
  left: 16px !important;
  top: 50% !important;
  width: 11px !important;
  height: 11px !important;
  border-top: var(--back-stroke) solid currentColor !important;
  border-left: var(--back-stroke) solid currentColor !important;
  transform: translateY(-50%) rotate(-45deg) !important;
}

.header-back-button::after,
.profile-back::after,
a.back::after,
.chat-back::after,
.app-header .header-left .header-icon-button[aria-label="戻る"]::after {
  content: "" !important;
  position: absolute !important;
  left: 16px !important;
  top: 50% !important;
  width: 16px !important;
  height: var(--back-stroke) !important;
  background: currentColor !important;
  transform: translateY(-50%) !important;
  border-radius: 999px !important;
}
/* ===== メッセージ（エラーなど共通） ===== */

.errors {
  background: #ffe6e6;
  border: 1px solid #ff9999;
  padding: 10px;
  margin: 10px 10px 15px;
  border-radius: 4px;
}

.info {
  background: #e6f7ff;
  border: 1px solid #99d6ff;
  padding: 10px;
  margin-bottom: 15px;
}

/* ===== ツイート共通部分 ===== */

/* 1つのつぶやき */
.tweet {
  background: #ffffff;
  border-top: 1px solid #e1e8ed;
  padding: 10px 0;
}

/* ヘッダー（アイコン＋名前＋ID＋時間） */
.tweet-header {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #657786;
}

.tweet-icon {
  width: 40px;
  height: 40px;
  margin-right: 8px;
  flex-shrink: 0;
}

.tweet-icon img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.tweet-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tweet-name {
  font-weight: bold;
  color: #14171a;
  margin-right: 4px;
}

.tweet-username {
  color: #657786;
  margin-right: 6px;
}

.tweet-time {
  color: #657786;
}

/* テキスト */
.tweet-content {
  margin: 6px 0;
  font-size: 14px;
}

/* ===== 画像・動画 共通レイアウト ===== */

.tweet-media {
  margin-top: 6px;
}

.tweet-media-grid {
  display: grid;
  gap: 2px;
  border-radius: 8px;
  overflow: hidden;
}

/* ベース：正方形コンテナ */
.tweet-image-item-inner {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 正方形 */
}

.tweet-image-item-inner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 1枚：正方形1つ（横幅いっぱい） */
.tweet-media--one .tweet-media-grid {
  grid-template-columns: 1fr;
}

/* 2枚：横並びで正方形2つ */
.tweet-media--two .tweet-media-grid {
  grid-template-columns: 1fr 1fr;
}

/* 3枚：上に2枚の正方形、下に横幅2マス分で高さ1マス分の横長1枚 */
.tweet-media--three .tweet-media-grid {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  grid-template-areas:
    "a b"
    "c c";
}

.tweet-media--three .tweet-image-item--1 { grid-area: a; }
.tweet-media--three .tweet-image-item--2 { grid-area: b; }
.tweet-media--three .tweet-image-item--3 { grid-area: c; }

/* 下の1枚は 2:1 の横長（高さは上の正方形と同じ） */
.tweet-media--three .tweet-image-item--3 .tweet-image-item-inner {
  padding-top: 50%; /* 2:1 */
}

/* 4枚：2x2 の正方形 */
.tweet-media--four .tweet-media-grid {
  grid-template-columns: 1fr 1fr;
}

/* ===== 動画サムネイル（タイムライン用・グリッド共通） ===== */

/* タイムライン上の動画：必ず正方形の枠を作る */
.tweet-media--video .tweet-video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%;      /* 正方形 */
  border-radius: 8px;
  overflow: hidden;
  background: #000;       /* 読み込み中は黒背景 */
}

/* 中の <video> を枠いっぱいに広げる */
.tweet-media--video .tweet-video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== 共通ボタン ===== */

button {
  background: #1da1f2;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  margin-top: 8px;
}

button:hover {
  opacity: 0.9;
}

/* ===== ボトムナビ（下メニュー） ===== */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0; /* 背景は常に最下部まで */
  height: var(--bottom-nav-total);
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid #e1e8ed;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  z-index: 1000;
  backdrop-filter: blur(8px);
  box-sizing: border-box;
  padding-top: var(--bottom-nav-pad-top);
  padding-bottom: calc(var(--bottom-nav-pad-bottom) + var(--safe-bottom));
  transition: transform 0.15s ease-out;
}

/* アイコン類は「画面下から15px」に揃える（padding-bottom で制御） */
.bottom-nav .nav-item {
  flex: 1;
  height: 100%;
  justify-content: flex-end;
  transform: none !important;
}


/* キーボード表示中はボトムナビを隠す（body.keyboard-open は JS で付ける） */
body.keyboard-open .bottom-nav {
  display: none;
}

/* コメント入力中はボトムナビを下に隠す */
body.comment-input-open .bottom-nav {
  transform: translateY(100%);
}

.nav-item {
  text-decoration: none;
  color: #657786;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
}

.nav-item.nav-item--disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* アイコン本体を大きくして、周りの青丸は無し */
.nav-icon {
  width: 44px;   /* もともとの青丸のサイズ */
  height: 44px;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 3px;
  box-shadow: none;
}

.nav-icon-emoji {
  font-size: 24px;
  line-height: 1;
}

/* 画像アイコンは青丸と同じサイズまで拡大 */
.nav-icon-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.nav-label {
  font-size: 11px;
  position: relative;
  top: -3px;
}


/* アクティブでも青い丸は出さない */
.nav-item--active .nav-icon {
  background: transparent;
}

.nav-item--active .nav-label {
  color: #1da1f2;
  font-weight: bold;
}

/* ===== 追加: ボトムナビのタップ時の黒いハイライト対策 ===== */
.bottom-nav a,
.bottom-nav button,
.bottom-nav .nav-item,
.bottom-nav .nav-icon,
.bottom-nav .nav-label,
.bottom-nav img {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* タイムライン以外でも使えるように共通化 */
.bottom-nav.is-bottom-nav-hidden {
  transform: translateY(110%);
  transition: transform 0.18s ease, opacity 0.18s ease;
  will-change: transform;
}
/* =========================================================
   Back button: text fallback (has-text)
   - CSSアイコンが出ない環境でも「←」を必ず表示したいページだけで使用
   ========================================================= */
.header-back-button.has-text,
.profile-back.has-text,
a.back.has-text,
.chat-back.has-text{
  font-size: 18px !important;
}
.header-back-button.has-text::before,
.header-back-button.has-text::after,
.profile-back.has-text::before,
.profile-back.has-text::after,
a.back.has-text::before,
a.back.has-text::after,
.chat-back.has-text::before,
.chat-back.has-text::after{
  content: none !important;
  display: none !important;
}
.header-back-button.has-text .back-txt,
.profile-back.has-text .back-txt,
a.back.has-text .back-txt,
.chat-back.has-text .back-txt{
  display: block !important;
  font-size: 18px !important;
  line-height: 1 !important;
}
