@charset "UTF-8";

/* --- 共通変数 --- */
:root {
    --primary: #0056b3;
    --primary-bg: #e6f0ff;
    --text-main: #2c3e50;
    --text-sub: #7f8c8d;
    --bg-body: #f8f9fa;
    --white: #ffffff;
    --radius-lg: 16px;
    --header-height: 58px;
    --shadow-card: 0 4px 20px rgba(0,0,0,0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    margin: 0; padding: 0;
    color: var(--text-main);
    overflow-x: hidden;
}

/* --- ビュー切り替え制御 --- */
.view-container {
    width: 100vw;
    min-height: 100vh; min-height: 100dvh;
    position: absolute; top: 0; left: 0;
    background: var(--bg-body);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
}
.view-container.hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: scale(0.98); height: 0; overflow: hidden; transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s, height 0s linear 0.4s;}
.view-container.active { opacity: 1; visibility: visible; pointer-events: auto; transform: scale(1); z-index: 10; }

/* --- 1. ホーム画面スタイル --- */
.home-content { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 90vh; padding: 20px; box-sizing: border-box; }
.logo-area { text-align: center; margin-bottom: 30px; }
.logo-icon { font-size: 64px; margin-bottom: 10px; }
.app-title { font-size: 28px; margin: 0; color: var(--primary); letter-spacing: 0.1em; }
.subtitle { font-size: 14px; color: var(--text-sub); font-weight: normal; }

/* --- サンプル版バッジ --- */
.sample-badge {
    display: inline-block;
    background-color: #ff9800;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 16px;
    margin-top: 12px;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
    letter-spacing: 0.05em;
    animation: fadeIn 0.5s ease;
}
.sample-badge.hidden {
    display: none !important;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.home-search-wrapper { width: 100%; max-width: 400px; position: relative; margin-bottom: 30px; }
.search-input-lg { width: 100%; padding: 16px 20px; border-radius: 30px; border: 1px solid #ddd; font-size: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); outline: none; transition: 0.3s; box-sizing: border-box; }
.search-input-lg:focus { border-color: var(--primary); box-shadow: 0 4px 16px rgba(0, 86, 179, 0.2); }
.search-btn-primary { position: absolute; right: 6px; top: 6px; bottom: 6px; padding: 0 20px; border-radius: 24px; background: var(--primary); color: white; border: none; font-weight: bold; cursor: pointer; }

.home-favorites { width: 100%; max-width: 400px; margin-bottom: 30px; }
.favorites-list { list-style: none; padding: 0; margin: 0; }
.fav-item { background: #fff; padding: 12px 16px; margin-bottom: 8px; border-radius: 12px; border: 1px solid #eee; font-size: 14px; font-weight: bold; color: var(--text-main); cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: 0.2s; }
.fav-item:active { transform: scale(0.98); background: #fafafa; }
.no-fav-msg { font-size: 13px; color: #aaa; text-align: center; padding: 10px; }

.home-categories { width: 100%; max-width: 400px; }
.cat-label { font-size: 14px; font-weight: bold; color: var(--text-sub); margin-bottom: 10px; text-align: center; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-card { padding: 12px; background: var(--white); border: 1px solid #eee; border-radius: 12px; font-size: 14px; color: var(--text-main); cursor: pointer; transition: 0.2s; font-family: inherit; text-align: center; }
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); border-color: var(--primary); }
.cat-card[data-cat="favorites"] { background-color: #fffde7; color: #f57f17; border-color: #fff59d; font-weight: bold; }
.cat-card[data-cat="favorites"]:hover { background-color: #fff9c4; border-color: #fdd835; box-shadow: 0 4px 12px rgba(253, 216, 53, 0.2); }

.home-footer { margin-top: 40px; text-align: center; }
.text-link-btn { background: none; border: none; color: var(--text-sub); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 10px; }
.text-link-btn:hover { color: var(--primary); }

.home-action-area {
    width: 100%;
    max-width: 400px;
    margin-bottom: 24px; /* カテゴリとの間隔 */
}


/* カテゴリセクションのヘッダー */
.cat-header {
    display: flex;
    justify-content: space-between; /* 両端揃え */
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
    padding: 0 4px; /* 端に寄りすぎないように少し余白 */
    box-sizing: border-box;
}

/* ラベルテキスト */
.cat-label-text {
    font-size: 14px;
    color: var(--text-sub);
    font-weight: bold;
}

/* 「すべて見る」ボタン */
.view-all-btn {
    background: none;
    border: none;
    color: var(--primary); /* テーマカラーを使用 */
    font-size: 13px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 16px;
    transition: background-color 0.2s;
    font-weight: bold;
    margin-top: 20px;
}

.view-all-btn:hover {
    background-color: var(--primary-bg); /* ホバー時に薄い背景色 */
}

.view-all-btn:active {
    opacity: 0.7;
}



/* --- 2. 検索結果画面スタイル --- */
.result-header { background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); padding: 10px 16px; display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 110; border-bottom: none; }
.back-btn { background: none; border: none; font-size: 32px; color: var(--primary); cursor: pointer; padding: 0 8px; line-height: 1; }
.header-search-box { flex: 1; }
#result-input { width: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid #eee; background: #f0f2f5; font-size: 14px; outline: none; box-sizing: border-box; }
#result-input:focus { background: white; border-color: var(--primary); }

/* ▼▼▼ 修正: フィルターバーのレイアウト ▼▼▼ */
.filter-bar {
    position: sticky; top: 58px; z-index: 105; background: var(--white);
    padding: 8px 16px; border-bottom: 1px solid #eee; box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    transition: all 0.3s ease;
    
    /* 縦並び（上：タグ、下：コントロール）に指定 */
    display: flex;
    flex-direction: column; 
    gap: 8px;
    position: relative;
    position: relative;
}

/* タグエリア */
.categories-scroll {
    display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    max-height: 40px; transition: max-height 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
}
.categories-scroll::-webkit-scrollbar { display: none; }
.categories-scroll.expanded { flex-wrap: wrap; overflow-x: visible; justify-content: center; max-height: 500px; }

/* ▼▼▼ コントロールエリア（スイッチと開閉ボタン） ▼▼▼ */
.filter-controls {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* タグをすべて見るボタンを右側に寄せる */
#filter-expand-btn { margin-left: auto; }

/* ソート関連ラッパー: スマホでは初期非表示、タグ展開時に表示 */
.sort-controls-wrapper {
    display: none; /* スマホでは初期非表示 */
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
}

/* 閉じるボタンは初期非表示 */
#filter-close-btn {
    display: none;
}

/* タグ展開時のレイアウト: タグ一覧＋複数選択→線→ソート→線→閉じる */
.filter-bar.expanded .filter-controls {
    flex-direction: column;
    align-items: stretch;
}

/* タグエリアを相対配置にして、複数選択を絶対配置可能に */
.filter-bar.expanded .categories-scroll {
    position: relative;
    padding-bottom: 12px;
    margin-bottom: 0;
    /* 中央揃えは維持（justify-content: center） */
}

/* 複数選択をタグ列の下の行・左側に配置 */
.filter-bar.expanded .toggle-switch {
    order: 999;           /* タグ群の後ろに回す */
    flex-basis: 100%;     /* 新しい行を占有 */
    display: inline-flex;
    align-items: center;
    margin-top: 6px;
}

/* タグエリア全体の下に線 */
.filter-bar.expanded .categories-scroll::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: #e0e0e0;
}

/* ソート */
.filter-bar.expanded .sort-controls-wrapper {
    display: flex;
    order: 1;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

/* 閉じるボタン */
.filter-bar.expanded #filter-expand-btn {
    order: 2;
    padding-top: 8px;
    justify-content: flex-end;
}

/* 展開時は「タグをすべて見る」のアイコンを上向きに */
.filter-bar.expanded #filter-expand-btn .btn-icon {
    transform: rotate(180deg);
}

/* デスクトップでは常時表示 */
@media (min-width: 768px) {
    /* PC: 上部固定。1行目=タグ（折り返し表示）、2行目=左:複数選択 右:ソート */
    .filter-bar { position: sticky; top: 58px; z-index: 105; padding-bottom: 12px; padding-top: 8px; }
    .categories-scroll { flex-wrap: wrap; overflow-x: visible; justify-content: flex-start; max-height: none; margin-bottom: 4px; }
    .filter-controls { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
    /* PCでは「タグをすべて見る」「閉じる」は非表示 */
    #filter-expand-btn, #filter-close-btn { display: none !important; }
    /* 複数選択はデフォルト位置に固定（フィルターバーの左下） */
    .toggle-switch { position: absolute !important; left: 16px !important; bottom: 6px !important; }
    .sort-controls-wrapper { display: flex !important; width: auto; padding: 0 !important; border-bottom: none !important; margin-left: auto; align-items: center; }
}

/* スマホ専用の調整 */
@media (max-width: 767px) {
    /* スマホでは常にフィルターバーを1つのまとまりにする */
    .filter-bar {
        position: sticky; 
        top: 58px; 
        z-index: 105; 
        padding-bottom: 12px;
        padding-top: 8px;
        min-height: auto;
    }
    
    /* スマホでは常にトグルを左下に固定表示 */
    .toggle-switch {
        position: absolute !important;
        left: 12px !important;
        bottom: 6px !important;
        transform: none !important;
        margin: 0 !important;
        padding: 4px 8px !important;
        border: none !important;
        background: var(--white) !important;
        border-radius: 14px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        z-index: 120 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .filter-bar.collapsed-overflow {
        position: sticky;
        min-height: auto;
    }
    
    .filter-bar.collapsed-overflow .categories-scroll {
        padding-bottom: 4px;
    }
}

/* ソート関連コントロールの調整: タグやカードと雰囲気を合わせる */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.sort-controls .label-text {
    white-space: nowrap;
    font-size: 12px;
    flex-shrink: 0;
}

.sort-select {
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid #dbe4ff;
    background: linear-gradient(180deg, #fafdff 0%, #f3f7ff 100%);
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    appearance: none;
    min-width: 0;
    flex-shrink: 1;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.sort-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(0,86,179,0.12);
    transform: translateY(-1px);
}

/* ドロップダウンであることが視認できるよう、右端に逆三角アイコンを表示 */
.sort-select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M0 0 L5 6 L10 0 Z' fill='%23666' /></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    padding-right: 36px; /* アイコン分の余白を確保 */
}

/* ドロップダウンリストの色味を合わせる（対応ブラウザ限定） */
.sort-select option {
    background: #ffffff;
    color: var(--text-main);
}
.sort-select option:checked {
    background: var(--primary-bg);
    color: var(--primary);
}

.filter-toggle-btn {
    display: flex; justify-content: center; align-items: center; gap: 6px;
    padding: 6px; background: none; border: none;
    font-size: 12px; color: #888; font-weight: bold; cursor: pointer;
}
.btn-icon { display: inline-block; transition: transform 0.3s ease; }
.categories-scroll.expanded + .filter-controls .btn-icon { transform: rotate(180deg); } /* divを経由してアイコンを回転させるセレクタだと少し複雑になるため、JSでクラス付与か、シンプルに回転なしでもOKですが、必要ならJSでボタンにクラスを付けたほうが確実です */

/* スイッチのデザイン */
.toggle-switch { 
    display: flex; 
    align-items: center; 
    cursor: pointer; 
    font-size: 11px; 
    color: var(--text-sub); 
    font-weight: bold;
    position: absolute;
    left: 16px;
    bottom: 8px;
    z-index: 120;
    background: var(--white);
    padding: 4px 8px;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin: 0;
    border: none;
}
.toggle-switch input { display: none; }
.slider { position: relative; width: 36px; height: 20px; background-color: #e0e0e0; border-radius: 20px; transition: 0.3s; }
.slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; border-radius: 50%; transition: 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.toggle-switch input:checked + .slider { background-color: var(--primary); }
.toggle-switch input:checked + .slider::before { transform: translateX(16px); }
.toggle-switch input:checked ~ .label-text { color: var(--primary); }

/* スマホでタグが折り込まれるときはトグルを左下に固定表示 */
.filter-bar.collapsed-overflow .toggle-switch {
    position: absolute !important;
    left: 12px !important;
    bottom: 10px !important;
    transform: none !important;
    background: var(--white) !important;
    padding: 4px 8px !important;
    border-radius: 14px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    z-index: 120 !important;
    pointer-events: auto !important;
    -webkit-transform: none !important;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* --- 地図画面スタイル (刷新版) --- */

/* 地図ビュー全体 */
#view-map {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #f0f2f5;
    z-index: 2000; /* 最前面 */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* スクロール禁止 */
}

/* --- 固定ヘッダー --- */
.map-header {
    position: absolute; /* 地図の上に浮く */
    top: 0; left: 0; width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 10;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top)); /* iPhoneのノッチ対応 */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ヘッダー上段（キャンパス選択 + 閉じる） */
.map-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-select {
    font-size: 14px;
    font-weight: bold;
    padding: 6px 24px 6px 12px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background: #fff;
    color: var(--text-main);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M0 0 L5 6 L10 0 Z' fill='%23666' /></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.map-close-btn {
    background: #eee;
    border: none;
    width: 32px; height: 32px;
    border-radius: 50%;
    font-size: 20px;
    color: #666;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}

/* ヘッダー下段（検索バー） */
.map-search-bar {
    position: relative; /* ボタンを絶対配置するための基準 */
    width: 100%;
}

#map-search-input {
    width: 100%;
    padding: 10px 20px;
    box-sizing: border-box;

}

#map-search-submit {
    /* バーが細くなった分、ボタンの上下の隙間も減らしてバランスを取る */
    top: 4px;
    bottom: 4px;
    right: 4px;
    
    /* ボタン内の文字サイズ微調整 */
    font-size: 13px;
    padding: 0 16px;
}

/* --- 地図コンテナ --- */
.map-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-image: radial-gradient(#ddd 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: #f0f2f5;
    cursor: grab;
    touch-action: none; /* タッチデバイスでのブラウザのデフォルトジェスチャーを無効化 */
}
.map-container:active {
    cursor: grabbing;
}

.map-content {
    position: absolute;
    top: 0; left: 0;
    transform-origin: 0 0; /* 左上を基準に変形 */
    will-change: transform;
}

.map-image {
    display: block;
    max-width: none; /* 親要素の幅に制限されない */
    pointer-events: none; /* 画像自体のドラッグ防止 */
    user-select: none;
}

/* 1. 「用語一覧」と「地図ボタン」をまとめる枠 */
.view-all-wrapper {
    position: relative;       /* ボタン位置の基準点にする */
    display: inline-block;    /* 中身の幅に合わせる */
    margin-top: 20px;         /* 上との間隔 */
}

/* 2. 地図ボタン (FAB) のデザインと位置 */
.map-fab-btn {
    position: absolute;       /* 親の枠に対して絶対配置 */
    bottom: -15px;            /* 少し下へ */
    right: -80px;             /* 右側へずらす（位置はお好みで調整してください） */
    
    width: 56px;
    height: 56px;
    background: #ffffff;      /* 背景は白 */
    color: var(--primary);    /* アイコンは青 */
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    font-size: 26px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.map-fab-btn:hover {
    background: #f5f7fa;
    transform: scale(1.05);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
}

.map-fab-btn:active {
    transform: scale(0.95);
    background: #eef2f6;
}

/* 用語リスト内の「地図で確認」ボタン */
.map-jump-btn {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    padding: 6px 14px;
    background-color: #f0f7ff; /* 薄い青背景 */
    color: var(--primary);
    border: 1px solid #daeaff;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.map-jump-btn:hover {
    background-color: #e0efff;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.map-jump-btn:active {
    transform: scale(0.98);
}


/* --- マップ上のピン --- */
.map-pin {
    position: absolute;
    width: 56px;
    height: 84px;
    margin-left: -28px;
    margin-top: -84px;
    
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 28 42"><path fill="%23555555" stroke="%23ffffff" stroke-width="2" d="M12 0C5.373 0 0 5.373 0 12c0 8.25 12 24 12 24s12-15.75 12-24C24 5.373 18.627 0 12 0zm0 18c-3.314 0-6-2.686-6-6s2.686-6 6-6 6 2.686 6 6-2.686 6-6 6z"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    transform-origin: center bottom; 
    cursor: pointer;
    z-index: 50;
    filter: drop-shadow(0px 8px 8px rgba(0,0,0,0.25));
}

.map-pin:active {
    filter: drop-shadow(0px 4px 4px rgba(0,0,0,0.4));
}

.map-pin.highlighted-pin {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 28 42"><path fill="%230056b3" stroke="%23ffffff" stroke-width="2" d="M12 0C5.373 0 0 5.373 0 12c0 8.25 12 24 12 24s12-15.75 12-24C24 5.373 18.627 0 12 0zm0 18c-3.314 0-6-2.686-6-6s2.686-6 6-6 6 2.686 6 6-2.686 6-6 6z"/></svg>');
}

/* --- 下部ポップアップ --- */
.map-popup {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--white);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 100;
    width: 85%;
    max-width: 400px;
    text-align: center;
    transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.map-popup.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(150%); /* 下に隠す */
}
.map-popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #f0f2f5;
    border: none;
    width: 28px; height: 28px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-sub);
}

.map-popup-body {
    max-height: 120px; /* 説明文が長すぎる場合はスクロールさせる */
    overflow-y: auto;
    margin-bottom: 16px;
    padding: 0 10px;
    text-align: left; /* 説明文は左揃えが読みやすい */
    /* スクロールバーを見えにくくする */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    touch-action: pan-y; /* タッチデバイスでの縦スクロールを有効にする */
}

.map-popup-body::-webkit-scrollbar {
    width: 6px;
}
.map-popup-body::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}

.map-popup-desc {
    margin: 0;
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* 既存の #map-popup-term の margin-bottom を少し減らしてバランスを取る */
#map-popup-term {
    margin: 0 0 12px 0; /* 元は 16px */
    font-size: 18px;
    color: var(--text-main);
}

/* --- トースト通知 (おしゃれなポップアップ) --- */
.toast-notification {
    position: fixed;
    top: 20px; /* 画面上部からの位置 */
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--primary); 
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0, 86, 179, 0.3); 
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 表示時のクラス */
.toast-notification.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast-message {
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
}

/* チップ */
.chip { padding: 6px 14px; border-radius: 6px; font-size: 13px; border: 1px solid #eee; background: var(--white); color: var(--text-sub); white-space: nowrap; cursor: pointer; transition: 0.2s; user-select: none; flex-shrink: 0; font-family: inherit; line-height: inherit; appearance: none; }
.chip.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 2px 6px rgba(0, 86, 179, 0.2); }
.chip[data-cat="favorites"].active { background: #ffecb3; color: #f57f17; border-color: #ffe082; box-shadow: 0 2px 6px rgba(255, 193, 7, 0.3); }
.chip[data-cat="favorites"] { color: #fbc02d; border-color: #fff8e1; }

.scrollable-content { padding: 16px; padding-bottom: 80px; }
.result-count-area { font-size: 12px; color: var(--text-sub); margin-bottom: 10px; text-align: right; }
#result-list { list-style: none; padding: 0; margin: 0; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.item { background: var(--white); padding: 16px; margin-bottom: 12px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.03); cursor: pointer; border: 1px solid transparent; position: relative; transition: transform 0.2s; animation: fadeInUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.item:active { transform: scale(0.98); background: #fafafa; }

.fav-btn { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border: none; background: none; font-size: 20px; color: #ddd; cursor: pointer; z-index: 5; padding: 0; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; }
.fav-btn.active { color: #f1c40f; text-shadow: 0 2px 5px rgba(241, 196, 15, 0.4); transform: scale(1.1); }

.item-header-row { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 8px; margin-bottom: 8px; padding-right: 40px; }
.term { font-size: 17px; font-weight: bold; color: var(--text-main); width: 100%; line-height: 1.4; }
.reading { font-size: 11px; color: var(--text-sub); margin-left: 6px; font-weight: normal;}
.category-badge { font-size: 10px; padding: 3px 8px; border-radius: 4px; white-space: nowrap; font-weight: bold; cursor: pointer; transition: opacity 0.2s; }
.category-badge:active { opacity: 0.6; }
.badges-wrapper { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; justify-content: flex-start; }
.description { font-size: 13px; color: #555; margin-top: 8px; line-height: 1.5; }
.highlight-text { background: transparent; border-bottom: 2px solid #ffd700; font-weight: bold; padding: 0 1px; }

.no-result { display: none; text-align: center; margin-top: 40px; color: var(--text-sub); }
#reset-search-btn { margin-top: 10px; padding: 8px 16px; background: #eee; border: none; border-radius: 6px; cursor: pointer; }

/* モーダル */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.2); backdrop-filter: blur(1px); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-card { background: var(--white); width: 90%; max-width: 500px; border-radius: 20px; padding: 24px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); position: relative; transform: translateY(20px) scale(0.95); transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
.modal-overlay.active .modal-card { transform: translateY(0) scale(1); }
.modal-close-btn { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border: none; background: #f0f2f5; border-radius: 50%; font-size: 20px; color: var(--text-sub); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.modal-close-btn:hover { background: #e4e6eb; color: var(--text-main); }
.modal-fav-btn { position: absolute; top: 16px; right: 60px; width: 32px; height: 32px; border: none; background: #f0f2f5; border-radius: 50%; font-size: 20px; color: #ccc; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; z-index: 10; }
.modal-fav-btn.active { color: #f1c40f; background: #fff9c4; box-shadow: 0 2px 5px rgba(241, 196, 15, 0.3); transform: scale(1.1); }
.modal-fav-btn:active { transform: scale(0.95); }
.modal-header { margin-bottom: 16px; padding-right: 30px; }
#modal-term { margin: 0 0 8px 0; font-size: 24px; color: var(--text-main); }
.modal-body { font-size: 15px; color: #555; line-height: 1.7; max-height: 60vh; overflow-y: auto; }
#modal-description { white-space: pre-wrap;}

/* お問い合わせフォーム */
.contact-desc { font-size: 14px; color: #555; margin-bottom: 20px; text-align: center; }
.contact-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: bold; color: var(--text-main); }
.form-group select, .form-group textarea { padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; background: #f9f9f9; outline: none; font-family: inherit; }
.form-group select:focus, .form-group textarea:focus { border-color: var(--primary); background: #fff; }
.submit-btn { margin-top: 10px; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 24px; font-weight: bold; font-size: 15px; cursor: pointer; transition: 0.2s; }
.submit-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* 部局別タグカラー */
.category-badge[data-tag="四役"] { background-color: #fff9c4; color: #f57f17; }
.category-badge[data-tag="企画部"] { background-color: #fce4ec; color: #c2185b; }
.category-badge[data-tag="情報部"] { background-color: #e1f5fe; color: #0277bd; }
.category-badge[data-tag="渉外部"] { background-color: #f3e5f5; color: #7b1fa2; }
.category-badge[data-tag="技術部"] { background-color: #e8f5e9; color: #2e7d32; }
.category-badge[data-tag="八役"] { background-color: #e3f2fd; color: #1565c0; }

.category-badge[data-tag="機材"], .category-badge[data-tag="物品"], .category-badge[data-tag="作業"], .category-badge[data-tag="場所"] { background-color: #eceff1; color: #37474f; }
.category-badge[data-tag="新歓"], .category-badge[data-tag="本祭典"] { background-color: #fff3e0; color: #ef6c00; }
.category-badge[data-tag="全体"], .category-badge[data-tag="他団体"] { background-color: #ffebee; color: #c62828; }
.category-badge[data-tag="その他"] { background-color: #f5f5f5; color: #616161; }