/* =========================================
   Pro Buttons (BL Actions)
   ========================================= */
.bl-actions {
    display: flex;
    gap: 12px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

/* 共通ボタンスタイル */
.bl-actions button {
    flex: 1;
    border-radius: 50px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    padding: 10px 0;
}

/* 詳細ボタン (Glass/Outline Style) */
.btn-glass {
    background: #f8f9fa;
    border: 1px solid #d1d5da;
    color: #586069;
}

.btn-glass:hover {
    background: #fff;
    border-color: #2ecc71;
    color: #2ecc71;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.15);
    transform: translateY(-2px);
}

/* 申請ボタン (Primary Gradient Shine) */
.btn-shine {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    border: none;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3);
}

/* 光沢アニメーション */
.btn-shine::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    transition: none;
}

.btn-shine:hover::after {
    left: 150%;
    transition: 0.7s ease;
}

.btn-shine:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.4);
}

/* =========================================
   BL Detail Modal
   ========================================= */
.sm-modal {
    max-width: 400px;
    width: 90%;
    border-radius: 12px;
    overflow: hidden;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #2c3e50;
}

.bl-detail-row {
    margin-bottom: 20px;
}

.bl-detail-row label {
    font-size: 11px;
    font-weight: 700;
    color: #95a5a6;
    text-transform: uppercase;
    display: block;
    margin-bottom: 5px;
}

.detail-value {
    font-size: 15px;
    color: #34495e;
}

.detail-value.highlight {
    font-size: 18px;
    font-weight: bold;
    color: #2ecc71;
}

.detail-value.text-block {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    /* 改行を反映 */
    border: 1px dashed #ddd;
}

.bl-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #2ecc71;
    /* Default recruiting */
}

.bl-badge-proven {
    position: absolute;
    top: 10px;
    left: 10px;
    /* Opposite side of recruiting badge */
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #8e44ad;
    /* Purple for Proven */
    z-index: 2;
}

.bl-species {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.bl-name {
    font-weight: bold;
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
}

.bl-owner {
    font-size: 11px;
    color: #999;
    display: flex;
    align-items: center;
}

.bl-actions {
    display: flex;
    gap: 10px;
}

.bl-actions button {
    flex: 1;
}

/* Specific Badge Colors */
.bl-badge.recruiting {
    background: #2ecc71;
}

.bl-badge.loaned {
    background: #f39c12;
}

.bl-badge-proven {
    position: absolute;
    top: 10px;
    left: 10px;
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #8e44ad;
    /* Purple for Proven */
    z-index: 2;
}


/* =========================================
   Contracts Grid Layout
   ========================================= */

/* =========================================
   Contracts Grid Layout (Pro Unified)
   ========================================= */

/* カード本体 */
.contract-card {
    background: #fff;
    border-radius: 16px;
    /* 境界線をなくし、影で階層を表現 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.contract-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

/* ヘッダー: ステータスと日付 */
.contract-header {
    padding: 12px 16px;
    background: #fff;
    /* 白背景で統一 */
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contract-date {
    font-size: 11px;
    color: #aeaeb2;
    font-weight: 500;
    font-family: var(--setae-font-main);
}

/* ステータスバッジ（モダンなパステルスタイル） */
.contract-status {
    font-size: 10px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ステータス別カラー設定 */
.badge-REQUESTED {
    background: #fff8e1;
    color: #f5a623;
    border: 1px solid rgba(245, 166, 35, 0.1);
}

.badge-APPROVED {
    background: #e3f2fd;
    color: #007aff;
    border: 1px solid rgba(0, 122, 255, 0.1);
}

.badge-PAIRED {
    background: #f3e5f5;
    color: #af52de;
    border: 1px solid rgba(175, 82, 222, 0.1);
}

.badge-SUCCESS {
    background: #e8f5e9;
    color: #34c759;
    border: 1px solid rgba(52, 199, 89, 0.1);
}

.badge-FAIL,
.badge-REJECTED {
    background: #ffebee;
    color: #ff3b30;
    border: 1px solid rgba(255, 59, 48, 0.1);
}

/* コンテンツエリア */
.contract-body {
    padding: 16px;
    display: flex;
    gap: 14px;
    flex: 1;
}

/* サムネイル画像 */
.c-thumb {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    background-color: #f2f2f7;
    border: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* 詳細テキストラッパー */
.c-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.c-details strong {
    font-size: 15px;
    color: var(--setae-text, #1c1c1e);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.c-meta {
    font-size: 11px;
    color: #8e8e93;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* メッセージ吹き出し（引用デザイン） */
.c-message {
    font-size: 12px;
    color: #48484a;
    background: #f2f2f7;
    /* iOS System Gray 6 */
    padding: 8px 12px;
    border-radius: 0 12px 12px 12px;
    /* 左上を直角にして吹き出し感を出す */
    line-height: 1.4;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.02);

    /* 2行制限 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* フッターアクション */
.contract-actions {
    padding: 12px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    /* 右寄せ */
    background: #fcfcfc;
    /* ほんの少しグレー */
}

/* チャットボタン */
.btn-open-chat {
    margin-right: auto;
    /* 左端に寄せる */
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #d1d1d6;
    color: #1c1c1e;
    transition: all 0.2s;
}

.btn-open-chat:hover {
    background: #f2f2f7;
    border-color: #aeaeb2;
    transform: translateY(-1px);
}

/* アイコンサイズ補正 */
.btn-open-chat img {
    width: 14px !important;
    height: 14px !important;
    vertical-align: middle;
    margin-top: -2px;
}

/* 右側のアクションボタン群 */
.contract-actions .action-group {
    display: flex;
    gap: 8px;
}

/* ▼ 追加: チャットボタン用未読バッジ */
.bl-chat-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background-color: #ff3b30;
    /* Apple Red */
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    /* 背景に溶け込まないよう白フチ */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    z-index: 10;
    line-height: 1;
    padding: 0 3px;
    box-sizing: border-box;
}

/* =========================================
   Pro Button Styling (BL Settings)
   ========================================= */
#btn-save-bl-settings {
    /* グラデーションと基本スタイル */
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    /* 太字で視認性アップ */
    padding: 12px 36px;
    /* 横幅を広めに */
    border-radius: 50px;
    /* 角丸（カプセル型） */
    cursor: pointer;
    letter-spacing: 0.5px;
    /* 文字間隔を少し広げる */

    /* リッチな影（発光感） */
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);

    /* 滑らかなアニメーション */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ホバー時の浮き上がり効果 */
#btn-save-bl-settings:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.5);
    /* 影を濃く・広く */
}

/* クリック時の押し込み効果 */
#btn-save-bl-settings:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.2);
}

/* 保存中（disabled）の状態 */
#btn-save-bl-settings:disabled {
    background: #bdc3c7;
    /* グレーアウト */
    color: #ecf0f1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* =========================================
   BL Settings Panel (Pro Design)
   ========================================= */
.bl-settings-panel {
    border: 1px solid #e1e4e8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    margin-top: 20px;
    transition: all 0.3s ease;
}

/* Header Area */
.bl-panel-header {
    background: #f8f9fa;
    padding: 20px 24px;
    border-bottom: 1px solid #eaecef;
    display: flex;
    align-items: center;
    gap: 16px;
}

.bl-icon-box {
    width: 44px;
    height: 44px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #2ecc71;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.bl-header-text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #24292e;
    letter-spacing: -0.3px;
}

.bl-header-text p {
    margin: 4px 0 0 0;
    font-size: 12px;
    color: #586069;
    line-height: 1.4;
}

/* Body Area */
.bl-panel-body {
    padding: 24px;
}

.bl-form-group {
    margin-bottom: 24px;
}

.bl-form-group:last-child {
    margin-bottom: 0;
}

.bl-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #24292e;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Custom Select & Inputs */
.setae-input-wrapper {
    position: relative;
}

.setae-input-wrapper select,
.setae-input-wrapper textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    color: #24292e;
    background-color: #fff;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.setae-input-wrapper select {
    appearance: none;
    /* デフォルトの矢印を消す */
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236a737d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.setae-input-wrapper textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.6;
}

.setae-input-wrapper select:focus,
.setae-input-wrapper textarea:focus {
    border-color: #2ecc71;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.15);
}

.input-helper {
    font-size: 11px;
    color: #6a737d;
    margin-top: 6px;
    display: block;
}

/* Footer & Button */
.bl-panel-footer {
    padding: 16px 24px;
    background: #fff;
    border-top: 1px solid #eaecef;
    display: flex;
    justify-content: flex-end;
}

.btn-wide {
    padding-left: 32px;
    padding-right: 32px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.25);
    transition: transform 0.1s;
}

.btn-wide:active {
    transform: translateY(1px);
}

/* =========================================
   Section Headers (Modern iOS Style)
   ========================================= */
.bl-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 4px 10px 4px;
    margin-bottom: 12px;
    border-bottom: none;
    /* 罫線を削除し、余白で区切る */
}

/* My Listingsの見出し */
.bl-section-header h4 {
    margin: 0;
    font-size: 20px;
    /* 少し大きくして明確な見出しに */
    font-weight: 700;
    color: var(--setae-text, #1c1c1e);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.5px;
}

/* カウントバッジ */
.count-badge {
    background: rgba(142, 142, 147, 0.2);
    /* システムグレーの薄い色 */
    color: var(--setae-text-light, #8e8e93);
    font-size: 13px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
}

/* トグルエリア全体 */
.toggle-my-listings {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s;
    /* クリックエリアを広げる */
    padding: 8px 0;
}

.toggle-my-listings:active {
    opacity: 0.6;
}

/* 開閉アイコン */
.toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 10px;
    color: var(--setae-text-light, #8e8e93);
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    margin-right: 6px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toggle-icon.open {
    transform: rotate(90deg);
    background: var(--setae-primary, #2c3e50);
    color: #fff;
}

/* Show/Hide ラベル */
.header-hint {
    font-size: 12px;
    color: var(--setae-accent, #007aff);
    font-weight: 500;
    background: rgba(0, 122, 255, 0.1);
    padding: 4px 10px;
    border-radius: 14px;
}

/* =========================================
   Grid Layout (Refined)
   ========================================= */

/* 外枠コンテナ：ここはGridにせず、ブロック要素として縦積みにする */
#setae-bl-grid {
    display: block !important;
    width: 100%;
}

/* 内部のカードリストのみGridレイアウトを適用 */
.setae-grid {
    display: grid;
    /* 300px以上の幅があれば列を増やす（スマホは1列、PCは2列~3列に可変） */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
}

/* セクションごとの余白調整 */
.my-listings-grid {
    margin-bottom: 30px;
    /* 次のセクションとの間隔 */
}

/* 空のグリッドでもレイアウトが崩れないように */
.setae-grid:empty {
    display: none;
}

/* =========================================
   Card Styles (Unified & Refined)
   ========================================= */

/* Grid Layout */
.setae-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    /* 幅を少し広めに確保 */
    gap: 16px;
}

/* Base BL Card */
.bl-card {
    background: #fff;
    border-radius: var(--setae-radius-lg, 16px);
    padding: 16px;
    position: relative;
    /* 柔らかい影のみで境界を表現（ボーダーレス） */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.bl-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

/* Card Content Layout */
.bl-content {
    display: flex;
    gap: 14px;
    margin-bottom: 16px;
}

/* Image Styling */
.bl-img {
    width: 72px;
    height: 72px;
    background-size: cover;
    background-position: center;
    border-radius: 14px;
    /* iOSアプリアイコンのような丸み */
    background-color: #f2f2f7;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

/* Info Text */
.bl-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    /* 文字切れ防止 */
}

.bl-species {
    font-size: 11px;
    color: var(--setae-text-light, #8e8e93);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    font-weight: 600;
}

.bl-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--setae-text, #1c1c1e);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Meta Info (Owner, Tag) */
.bl-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

/* 自分のリストのデザイン（より上品に） */
.bl-card.is-mine {
    background: #fdfdfd;
    /* ほんの少しグレーを入れて区別 */
}

/* 左側のアクセントライン（太すぎないように） */
.bl-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: #e5e5ea;
    /* デフォルト */
}

.bl-card.is-mine::before {
    background: var(--setae-primary, #2c3e50);
    /* 自分のリスト */
}

/* Gender Colors for Accent Line */
.bl-card.gender-male::before {
    background: #5ac8fa;
}

.bl-card.gender-female::before {
    background: #ff3b30;
}

.bl-card.gender-unknown::before {
    background: #8e8e93;
}

/* "Your Listing" Tag */
.my-tag {
    background: rgba(44, 62, 80, 0.08);
    color: var(--setae-primary, #2c3e50);
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Badges (Position adjustment) */
.bl-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    background: #34c759;
    /* iOS Green */
    color: #fff;
    box-shadow: 0 2px 6px rgba(52, 199, 89, 0.25);
    z-index: 10;
}

/* =========================================
   Actions (Buttons inside Card)
   ========================================= */
.bl-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    /* 薄い区切り線 */
    padding-top: 12px;
}

.bl-actions button {
    flex: 1;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 0;
    cursor: pointer;
    transition: all 0.2s;
}

/* 詳細ボタン (Glass style refined) */
.btn-glass {
    background: rgba(242, 242, 247, 0.8);
    /* iOS System Gray 6 */
    color: var(--setae-text, #1c1c1e);
    border: none;
}

.btn-glass:hover {
    background: rgba(229, 229, 234, 1);
    transform: translateY(-1px);
}

/* 申請ボタン (Primary Action) */
.btn-shine {
    background: var(--setae-primary, #2c3e50);
    /* ブランドカラー */
    color: #fff;
    border: none;
    box-shadow: 0 4px 10px rgba(44, 62, 80, 0.2);
}

.btn-shine:hover {
    background: #34495e;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(44, 62, 80, 0.3);
}

/* 空の状態のメッセージ */
.empty-sub-msg {
    color: var(--setae-text-light);
    font-size: 13px;
    text-align: center;
    padding: 30px 0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    border: 1px dashed rgba(0, 0, 0, 0.1);
}

/* =========================================
   Chat Modal (Pro Design Refined)
   ========================================= */

/* モーダルコンテンツ設定（ベース） */
.chat-modal {
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: 700px;
    background: #f2f2f7;
    /* iOSライクな背景色 */
    padding: 0 !important;
    /* デフォルトパディングをリセット */
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* モバイル（スマホ）画面用のフルスクリーン化 & キーボード対策 */
@media screen and (max-width: 768px) {
    .setae-modal-overlay {
        align-items: flex-end;
        /* 下から生えるように配置 */
    }

    .chat-modal {
        width: 100% !important;
        max-width: 100% !important;
        height: 90dvh !important;
        /* キーボード展開時に対応する動的高さ */
        max-height: none !important;
        border-radius: 20px 20px 0 0 !important;
        /* 上部のみ角丸 */
        margin: 0 !important;
    }
}

/* ヘッダー */
.chat-header {
    flex-shrink: 0;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1c1c1e;
    display: flex;
    align-items: baseline;
    gap: 8px;
    line-height: 1.2;
}

.chat-header h3 small {
    font-size: 11px;
    color: #8e8e93;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 閉じるボタン */
.btn-close-modal {
    background: #e5e5ea;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 20px;
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.btn-close-modal:hover {
    background: #d1d1d6;
    color: #1c1c1e;
}

/* メッセージ表示エリア */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background-color: #f2f2f7;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* 気泡間の隙間 */
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
    /* スクロールが裏に貫通するのを防ぐ */
}

/* チャット行（アバター＋気泡） */
.chat-bubble-row {
    display: flex;
    gap: 10px;
    max-width: 90%;
    align-items: flex-end;
    /* アバターと気泡の下端を揃える */
}

/* 自分のメッセージ */
.chat-bubble-row.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* 相手のメッセージ */
.chat-bubble-row.partner {
    align-self: flex-start;
}

/* アバター画像 */
.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* コンテンツラッパー（幅の自動調整用） */
.chat-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-bubble-row.mine .chat-content {
    align-items: flex-end;
}

.chat-bubble-row.partner .chat-content {
    align-items: flex-start;
}

/* 気泡デザイン（共通） */
.chat-bubble {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    max-width: 100%;
}

/* 自分の気泡色（ブランドカラーの濃紺） */
.chat-bubble.mine {
    background: var(--setae-primary, #2c3e50);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    /* 吹き出しの尻尾表現 */
}

/* 相手の気泡色（白） */
.chat-bubble.partner {
    background: #ffffff;
    color: #1c1c1e;
    border-bottom-left-radius: 4px;
}

/* 日時メタ情報 */
.chat-meta {
    font-size: 11px;
    color: #aeaeb2;
    margin-top: 4px;
    padding: 0 4px;
    font-weight: 500;
}

/* 空の状態 */
.chat-empty {
    text-align: center;
    color: #8e8e93;
    font-size: 13px;
    margin: auto;
    padding: 40px 20px;
}

/* =========================================
   フッター（入力エリア）
   ========================================= */
.chat-footer {
    flex-shrink: 0;
    /* env() でiPhoneの下部ホームインジケーターとの被りを防ぐ */
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: flex-end;
    gap: 12px;
    z-index: 10;
}

/* 入力欄 */
#chat-input {
    flex: 1;
    border: 1px solid #d1d1d6;
    background: #f4f4f5;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 15px;
    line-height: 1.4;
    max-height: 120px;
    min-height: 40px;
    resize: none;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

/* iOSの入力時強制ズームを防ぐため、スマホでは16pxに強制する */
@media screen and (max-width: 768px) {
    #chat-input {
        font-size: 16px;
    }
}

#chat-input:focus {
    background: #ffffff;
    border-color: var(--setae-primary, #2c3e50);
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

/* 送信ボタン */
.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--setae-primary, #2c3e50);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    flex-shrink: 0;
    margin-bottom: 2px;
    /* 入力欄の下端に合わせる微調整 */
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.05);
    background: #34495e;
}

.btn-send:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-send:disabled {
    background: #d1d1d6;
    cursor: not-allowed;
}

.btn-send svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    margin-left: -2px;
    /* 紙飛行機アイコンを視覚的に中央に配置 */
    margin-top: 1px;
}

/* =========================================
   Request Modal (Pro Design Refined)
   ========================================= */

/* モーダル内のターゲット情報カード */
.request-target-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f9f9f9;
    border: 1px solid #eee;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 20px;
}

/* サムネイル画像 */
.req-thumb {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    background-color: #f2f2f7;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* テキスト情報 */
.req-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.req-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #999;
    letter-spacing: 0.5px;
    font-weight: 700;
    margin-bottom: 2px;
}

.req-species {
    font-size: 11px;
    color: #8e8e93;
    font-style: italic;
    margin-bottom: 2px;
}

.req-name {
    font-size: 18px;
    font-weight: 700;
    color: #1c1c1e;
    line-height: 1.2;
    margin-bottom: 6px;
}

/* オーナー情報バッジ */
.req-owner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid #e5e5ea;
    font-size: 11px;
    color: #333;
    font-weight: 600;
    align-self: flex-start;
}

.owner-icon {
    font-size: 10px;
}

/* フォームエリア */
.request-form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #1c1c1e;
    margin-bottom: 8px;
    padding-left: 4px;
}

#request-message {
    width: 100%;
    border: 1px solid #d1d1d6;
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    transition: all 0.2s;
    box-sizing: border-box;
    background: #fff;
}

#request-message:focus {
    border-color: var(--setae-primary, #2c3e50);
    outline: none;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

/* フッターボタンエリア (統一デザイン) */
.modal-footer-actions {
    display: flex;
    gap: 12px;
    padding-top: 20px;
    margin-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.modal-footer-actions button {
    flex: 1;
    border-radius: 12px;
    padding: 12px 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

/* キャンセルボタン */
.btn-cancel {
    background: #f2f2f7;
    /* iOS System Gray */
    color: #1c1c1e;
    border: none;
}

.btn-cancel:hover {
    background: #e5e5ea;
}

/* 送信ボタン（メイン） */
.btn-submit-req {
    background: var(--setae-primary, #2c3e50);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.2);
}

.btn-submit-req:hover {
    background: #34495e;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(44, 62, 80, 0.3);
}

.btn-submit-req:active {
    transform: scale(0.98);
}

/* ▼▼▼ Breeding Loan Toolbar Design (Refined) ▼▼▼ */

/* ツールバー全体（コンテナ） */
.setae-toolbar {
    display: flex;
    /* iOS標準に近い背景色と透明度 */
    background-color: rgba(118, 118, 128, 0.12);
    padding: 4px;
    /* globalの角丸ルールに準拠 */
    border-radius: var(--setae-radius-md, 12px);
    margin-top: 15px !important;
    margin-bottom: 20px;
    /* 境界線をなくし、よりモダンに */
    border: none;
    box-shadow: none;
    /* remove previous shadow if any */
}

/* ボタン共通スタイル */
.setae-toolbar .setae-btn-sm {
    flex: 1;
    text-align: center;
    background: transparent;
    /* グローバルの薄いテキスト色を使用 */
    color: var(--setae-text-light, #8e8e93);
    /* 内側のボタンの角丸はコンテナより少し小さく */
    border-radius: 9px;
    padding: 8px 0;
    /* フォント設定を継承 */
    font-family: var(--setae-font-main);
    font-weight: 600;
    font-size: 13px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    line-height: 1.4;
}

/* ホバー時の挙動（非アクティブ時のみ） */
.setae-toolbar .setae-btn-sm:hover:not(.active) {
    color: var(--setae-text, #1c1c1e);
    background: rgba(255, 255, 255, 0.4);
}

/* アクティブ（選択中）のデザイン */
.setae-toolbar .setae-btn-sm.active {
    background: #ffffff;
    /* ブランドカラー（濃紺）で引き締め */
    color: var(--setae-primary, #2c3e50);
    /* 浮き上がるようなシャドウ */
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
    transform: none;
    /* 拡大はせず、色と影で階層を表現 */
}


/* =========================================
   Pro Spec: List View & Tabs (New Addition)
   ========================================= */

/* --- 1. Segmented Control (タブ) --- */
.setae-segment-nav {
    display: flex;
    background: #eef0f2;
    /* 薄いグレー背景 */
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.segment-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: #6e7781;
    border-radius: 9px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.segment-btn:hover {
    color: #24292f;
}

.segment-btn.active {
    background: #fff;
    color: #24292f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.03);
}

.count-badge-inline {
    background: rgba(27, 31, 35, 0.08);
    color: #57606a;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}

.segment-btn.active .count-badge-inline {
    background: #2c3e50;
    color: #fff;
}

/* --- 2. List Header (PC Only) --- */
.setae-list-header {
    display: flex;
    padding: 0 16px 10px 16px;
    border-bottom: 2px solid #f0f2f5;
    color: #8c959f;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.col-status {
    width: 110px;
}

.col-main {
    flex: 1;
}

.col-actions {
    width: 140px;
    text-align: right;
}

/* --- 3. List Item (Rows) --- */
.setae-list-group {
    display: flex;
    flex-direction: column;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.setae-list-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #eaecef;
    transition: background-color 0.15s;
    background: #fff;
}

.setae-list-item:last-child {
    border-bottom: none;
}

.setae-list-item:hover {
    background-color: #f8f9fa;
}

/* Status Column */
.list-col-status {
    width: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    background: #cbd5e1;
}

/* Status Colors (Consistent with badges) */
.status-dot.status-REQUESTED {
    background: #f5a623;
}

.status-dot.status-APPROVED {
    background: #007aff;
}

.status-dot.status-PAIRED {
    background: #af52de;
}

.status-dot.status-SUCCESS {
    background: #34c759;
}

.status-dot.status-REJECTED,
.status-dot.status-FAIL {
    background: #ff3b30;
}

.status-text {
    font-size: 13px;
    font-weight: 700;
    color: #24292f;
    display: flex;
    align-items: center;
}

.list-date {
    font-size: 11px;
    color: #8c959f;
    margin-top: 2px;
    padding-left: 14px;
    /* Align with text after dot */
}

/* Main Column (Thumb + Info) */
.list-col-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    /* Enable truncation */
}

.list-thumb {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-color: #f6f8fa;
    border: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.list-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.list-title {
    font-size: 15px;
    font-weight: 600;
    color: #24292f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.list-meta {
    font-size: 12px;
    color: #57606a;
    line-height: 1.4;
}

.list-msg {
    font-size: 12px;
    color: #8c959f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

/* Actions Column */
.list-col-actions {
    width: 140px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* Small Buttons in List */
.setae-btn-xs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    line-height: 1;
    white-space: nowrap;
}

.btn-primary {
    background: #2c3e50;
    color: #fff;
}

.btn-primary:hover {
    background: #34495e;
}

.btn-danger {
    background: #fff;
    color: #cf222e;
    border-color: rgba(207, 34, 46, 0.3);
}

.btn-danger:hover {
    background: #ffebe9;
}

.btn-glass {
    background: transparent;
    color: #24292f;
    border-color: #d0d7de;
}

.btn-glass:hover {
    background: #f3f4f6;
}

/* Chat Icon Button */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: #f6f8fa;
    color: #57606a;
    border: 1px solid transparent;
}

.btn-icon:hover {
    background: #eaeef2;
    color: #24292f;
}

.btn-icon .icon img {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .setae-list-header {
        display: none;
    }

    .setae-list-item {
        flex-wrap: wrap;
        padding: 16px;
        gap: 12px;
    }

    .list-col-status {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 4px;
    }

    .status-text {
        order: 1;
    }

    .status-dot {
        order: 0;
    }

    .list-date {
        order: 2;
        margin-left: auto;
        padding-left: 0;
    }

    .list-col-main {
        width: 100%;
    }

    .list-col-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 12px;
        border-top: 1px dashed #eaecef;
        margin-top: 4px;
    }

    /* モバイルではメッセージを少し長く表示 */
    .list-msg {
        max-width: none;
    }
}

/* ▼ 追加: Recruiting Status Dot Color */
.status-dot.status-RECRUITING {
    background: #34c759;
    /* Green */
}

/* Gender Mark in List Title */
.gender-mark {
    font-size: 12px;
    margin-left: 4px;
    font-weight: 700;
}

.gender-mark.male {
    color: #007aff;
}

.gender-mark.female {
    color: #ff3b30;
}

.gender-mark.unknown {
    color: #8e8e93;
}

/* Meta Divider */
.list-meta .divider {
    color: #d1d1d6;
    margin: 0 6px;
}

/* Badge for My Listing */
.badge-mine {
    font-size: 10px;
    font-weight: 700;
    color: #8e8e93;
    background: #f2f2f7;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Empty Message in Tab */
.empty-tab-msg {
    text-align: center;
    padding: 40px;
    color: #8e8e93;
    font-size: 13px;
}

/* =========================================
   BL Sub Tabs (Clean Underline Style)
   ========================================= */
/* メインヘッダーの余白調整 */
.bl-main-header .setae-toolbar {
    margin-top: 16px;
}

/* サブタブコンテナ */
.setae-sub-tabs {
    display: flex;
    gap: 20px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
    padding: 0 8px;
}

/* サブタブボタン */
.sub-tab-btn {
    background: none;
    border: none;
    padding: 12px 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--setae-text-light, #8e8e93);
    cursor: pointer;
    position: relative;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sub-tab-btn:hover {
    color: var(--setae-text, #1c1c1e);
}

.sub-tab-btn.active {
    color: var(--setae-primary, #2c3e50);
}

/* アニメーションする下線 */
.sub-tab-btn::after {
    content: '';
    position: absolute;
    bottom: -2px;
    /* ボーダーラインに重ねる */
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--setae-primary, #2c3e50);
    border-radius: 3px 3px 0 0;
    transform: scaleX(0);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sub-tab-btn.active::after {
    transform: scaleX(1);
}

/* バッジのスタイル調整 */
.sub-tab-btn .count-badge-inline {
    background: rgba(0, 0, 0, 0.06);
    color: var(--setae-text-light, #8e8e93);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.sub-tab-btn.active .count-badge-inline {
    background: var(--setae-primary, #2c3e50);
    color: #fff;
}

/* =========================================
   View Display Controllers
   ========================================= */
/* メインビューの切り替え */
.bl-view-content {
    display: none;
}

.bl-view-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* サブタブの切り替え */
.bl-tab-pane {
    display: none;
}

.bl-tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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