/* --- Global & Base --- */
#link-hub-app * { box-sizing: border-box; }
#link-hub-app { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif; color: #333; background-color: #f4f5f7; }

/* --- Header & Main (修正箇所) --- */
.lh-header { 
    background: linear-gradient(90deg, #ff8a00, #e52e71); 
    color: white; 
    padding: 1rem 1rem; 
    display: flex; 
    justify-content: space-between; /* タイトルとフィルターボタンを左右に配置 */
    align-items: center; 
    flex-wrap: wrap; /* モバイルで折り返すように */
    gap: 1rem; /* アイテム間の隙間 */
}
.lh-header h1 { margin: 0; font-size: 1.5rem; font-weight: 600; }
.lh-header-filters { 
    display: flex; 
    gap: 1rem; /* ボタン間のギャップ */ 
}
.lh-filter-btn { 
    padding: 0.75rem 1.5rem; 
    font-size: 1rem; 
    background-color: white; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    cursor: pointer; 
    transition: all 0.2s; 
    white-space: nowrap; /* ボタン内のテキストが改行しないように */
}
.lh-filter-btn.active { background-color: #be185d; color: white; border-color: #be185d; font-weight: bold; }

.lh-main { padding: 1rem; }

/* --- Search & Filters --- */
.lh-search-filter-area { margin-bottom: 1rem; }
#search-box { width: 100%; padding: 0.8rem 1rem; font-size: 1rem; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 1rem; }
.lh-category-filters { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 0.5rem; 
    margin-bottom: 1.5rem; 
    justify-content: center; /* 中央寄せ */ 
}
.category-btn { 
    padding: 0.5rem 1rem; 
    border: 1px solid #ddd; 
    background-color: #fff; 
    border-radius: 20px; 
    cursor: pointer; 
    font-size: 0.9rem; 
    transition: all 0.2s; 
}
.category-btn.active, .category-btn:hover { background-color: #be185d; color: white; border-color: #be185d; }

/* --- Form --- */
.lh-form-toggle { background-color: #fff; border: 1px dashed #ccc; border-radius: 8px; padding: 1rem; text-align: center; color: #555; cursor: pointer; margin-bottom: 1.5rem; font-weight: 500; }
.lh-form-toggle span { display: inline-block; transition: transform 0.3s; }
.lh-form-toggle.open span { transform: rotate(45deg); }
.lh-form-container { display: none; background-color: #fff; padding: 1.5rem; border-radius: 8px; margin-bottom: 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
#add-site-form { display: flex; flex-direction: column; gap: 1rem; }
#add-site-form input, #add-site-form select, #add-site-form textarea { width: 100%; padding: 0.8rem 1rem; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; background-color: white; }
#add-site-form textarea { padding-bottom: 30px; min-height: 100px; resize: vertical; }
#add-site-form button { padding: 0.9rem; border: none; background-color: #be185d; color: white; border-radius: 4px; cursor: pointer; font-size: 1rem; font-weight: bold; }
.lh-textarea-wrapper { position: relative; }
.lh-char-counter { position: absolute; bottom: 8px; right: 10px; font-size: 0.8rem; color: #888; background-color: rgba(255, 255, 255, 0.7); padding: 2px 5px; border-radius: 3px; }

/* --- Sites List (修正箇所) --- */
.lh-sites-list { background-color: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.05); min-height: 100px; }
.lh-list-item { display: flex !important; align-items: flex-start; padding: 0; border-bottom: 1px solid #f0f0f0; transition: background-color 0.2s; }
.lh-list-item:last-child { border-bottom: none; }
.lh-item-main-link { display: flex !important; align-items: flex-start; flex-grow: 1; padding: 1rem; text-decoration: none; color: inherit; min-width: 0; }
.lh-item-icon { width: 40px; height: 40px; margin-right: 1rem; flex-shrink: 0; margin-top: 2px; }
.lh-item-icon img { width: 100%; height: 100%; object-fit: contain; border-radius: 6px; background-color: #f4f5f7; }
.lh-item-info { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; /* 子要素を縦並びにする */ }
.lh-item-info-main { 
    display: flex !important; 
    align-items: center; 
    gap: 0.5rem; 
    margin-bottom: 0.5rem; /* 少し下の要素との間に余白 */ 
    flex-wrap: wrap; /* スマホでタイトルの横にアイコンが収まりきらない場合折り返す */
}
.lh-item-title { font-size: 1rem; font-weight: 500; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 説明文とタグをまとめる新しいコンテナ */
.lh-item-details { width: 100%; } 
.lh-item-description { font-size: 0.85rem; color: #777; margin: 0 0 0.5rem 0; /* 下に余白を追加 */ width: 100%; }
.lh-tags-container { display: flex; flex-wrap: wrap; gap: 0.3rem 0.5rem; }
.tag-link { display: inline-block; padding: 2px 8px; background-color: #eee; color: #555; border-radius: 4px; font-size: 0.8rem; text-decoration: none; transition: background-color 0.2s; }
.tag-link:hover { background-color: #ddd; }

/* --- Accordion & Badges & Controls (修正箇所) --- */
.accordion-wrapper { cursor: pointer; width: 100%; }
.accordion-trigger { display: flex !important; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%; }
.accordion-excerpt { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.accordion-toggle-icon { color: red; font-size: 0.8em; transition: transform 0.3s ease; flex-shrink: 0; padding-left: 5px; }
.accordion-content { display: none; padding-top: 0.5rem; }
.accordion-content p { white-space: normal; word-break: break-word; margin: 0; } /* paragraphのデフォルトmarginをリセット */
.accordion-wrapper.open .accordion-content { display: block; }
.accordion-wrapper.open .accordion-toggle-icon { transform: rotate(180deg); }
.accordion-wrapper.open .accordion-excerpt { display: none; }

.lh-item-new-badge { background-color: #ff4757; color: white; font-size: 0.7rem; font-weight: bold; padding: 2px 6px; border-radius: 3px; animation: blinker 1.5s linear infinite; flex-shrink: 0; } @keyframes blinker { 50% { opacity: 0.3; } }
.lh-spam-badge { font-size: 0.8rem; border-radius: 50%; width: 20px; height: 20px; display: inline-flex; justify-content: center; align-items: center; color: white; font-weight: bold; flex-shrink: 0; margin-left: auto;}
.lh-item-controls { display: flex; align-items: center; gap: 0.2rem; padding-right: 1rem; flex-shrink: 0; margin-left: 0.5rem; /* アイコン列との間に少し余白 */ }
.lh-btn-fav { font-size: 1.5rem; background: none; border: none; cursor: pointer; color: #ccc; padding: 0.2rem; line-height: 1; transition: color 0.2s; }
.lh-list-item[data-fav="true"] .lh-btn-fav { color: #f0c420; }
.lh-list-item:hover .lh-btn-fav { color: #f0c420; }
.lh-btn-details { background: none; border: none; color: #aaa; font-size: 1rem; font-weight: bold; cursor: pointer; padding: 0.5rem; line-height: 1; }

/* --- Modal & Loading --- */
.lh-modal { position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; }
.lh-modal-content { background-color: #fefefe; margin: auto; padding: 20px; border-radius: 8px; width: 90%; max-width: 500px; display: flex; flex-direction: column; }
.lh-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.lh-modal-header h3 { margin: 0; font-size: 1.2rem; }
.lh-modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0; line-height: 1; }
.lh-modal-body { margin-bottom: 15px; }
.lh-modal-body p { margin: 0 0 10px; }
.lh-modal-footer { display: flex; flex-direction: column; gap: 10px; }
.lh-btn-spam, .lh-btn-delete { padding: 10px; border-radius: 5px; border: 1px solid #ccc; cursor: pointer; }
.lh-btn-spam.reported { background-color: #f8d7da; border-color: #f5c6cb; }
.lh-btn-delete { background-color: #dc3545; color: white; border: none; }
.lh-delete-error { color: red; font-size: 0.9rem; }
.lh-loading { text-align: center; padding: 2rem; color: #888; font-weight: 500; }

/* --- Mobile Responsive --- */
@media (max-width: 600px) { 
    .lh-header { flex-direction: column; /* ヘッダー全体を縦並びにする */ }
    .lh-header h1 { margin-bottom: 1rem; /* タイトルとボタンの間に余白 */ }
    .lh-header-filters { width: 100%; justify-content: center; /* ボタンを中央寄せ */ }
    .lh-filter-btn { width: auto; /* 幅を自動調整 */ padding: 0.75rem 1rem; /* パディングを少し狭める */ }
    
    .lh-item-title, .accordion-excerpt { white-space: normal; } 
    .lh-item-main-link { padding: 0.75rem; } 
    .lh-item-icon { width: 35px; height: 35px; } 
    .lh-item-controls { padding-right: 0.75rem; } 
    .lh-category-filters { justify-content: center; } 
}

/* style.cssに以下のスタイルを追加してください */

/* === ソート選択 === */
.lh-sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    justify-content: center;
}

.lh-sort-controls label {
    font-weight: 500;
    color: #555;
}

.lh-sort-controls select {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

/* === サイトリストの評価表示 === */
.lh-item-rating {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    margin-left: auto; /* 右寄せ */
}

.lh-rating-stars {
    display: flex;
    gap: 1px;
}

.lh-rating-stars .star {
    font-size: 0.8rem;
    line-height: 1;
}

.lh-rating-stars .star.filled {
    color: #f0c420;
}

.lh-rating-stars .star.half {
    color: #f0c420;
}

.lh-rating-stars .star.empty {
    color: #ddd;
}

.lh-rating-text {
    color: #666;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* === モーダル内のレビューセクション === */
#review-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.lh-review-summary {
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: #f9f9f9;
    border-radius: 6px;
}

.lh-rating-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lh-rating-display .lh-stars {
    display: flex;
    gap: 2px;
}

.lh-rating-display .star {
    font-size: 1.2rem;
    line-height: 1;
}

.lh-rating-display .star.filled {
    color: #f0c420;
}

.lh-rating-display .star.half {
    color: #f0c420;
}

.lh-rating-display .star.empty {
    color: #ddd;
}

#modal-rating-text {
    font-weight: 500;
    color: #333;
}

/* === ユーザーレビューフォーム === */
.lh-user-review-form {
    margin: 1rem 0;
    padding: 1rem;
    background-color: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #eee;
}

.lh-user-review-form h4 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1rem;
}

.lh-rating-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.rating-label {
    font-weight: 500;
    color: #555;
}

.star-rating {
    display: flex;
    gap: 2px;
    cursor: pointer;
}

.star-rating .star {
    font-size: 1.5rem;
    color: #ddd;
    transition: color 0.2s;
    user-select: none;
}

.star-rating .star:hover,
.star-rating .star.selected {
    color: #f0c420;
}

#user-review-comment {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 1rem;
}

.review-form-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.lh-btn-primary {
    padding: 0.75rem 1.5rem;
    background-color: #be185d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.lh-btn-primary:hover {
    background-color: #9d1348;
}

.lh-btn-secondary {
    padding: 0.75rem 1.5rem;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.lh-btn-secondary:hover {
    background-color: #5a6268;
}

/* === レビュー一覧 === */
.lh-reviews-list h4 {
    margin: 1.5rem 0 1rem 0;
    color: #333;
    font-size: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

#reviews-container {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.review-item {
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    background-color: white;
}

.review-item:last-child {
    margin-bottom: 0;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.review-rating {
    display: flex;
    gap: 1px;
}

.review-rating .star {
    font-size: 1rem;
    line-height: 1;
}

.review-rating .star.filled {
    color: #f0c420;
}

.review-rating .star.half {
    color: #f0c420;
}

.review-rating .star.empty {
    color: #ddd;
}

.review-date {
    font-size: 0.8rem;
    color: #888;
}

.review-comment {
    color: #555;
    line-height: 1.5;
    font-size: 0.9rem;
    word-break: break-word;
}

.no-reviews {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 2rem;
}

#load-more-reviews {
    width: 100%;
    margin-top: 0.5rem;
}

/* === モバイル対応 === */
@media (max-width: 600px) {
    .lh-sort-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .lh-sort-controls select {
        width: 100%;
    }
    
    .lh-item-rating {
        margin-left: 0;
        margin-top: 0.3rem;
    }
    
    .lh-item-info-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
    
    .review-form-buttons {
        flex-direction: column;
    }
    
    .lh-btn-primary,
    .lh-btn-secondary {
        width: 100%;
        text-align: center;
    }
    
    .review-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
    
    .star-rating .star {
        font-size: 1.3rem;
    }
}

/* === フォーカス・アクセシビリティ === */
.star-rating .star:focus {
    outline: 2px solid #be185d;
    outline-offset: 2px;
    border-radius: 2px;
}

#user-review-comment:focus {
    border-color: #be185d;
    outline: none;
    box-shadow: 0 0 0 2px rgba(190, 24, 93, 0.2);
}

.lh-btn-primary:focus,
.lh-btn-secondary:focus {
    outline: 2px solid #333;
    outline-offset: 2px;
}

/* === アニメーション === */
.review-item {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.star-rating .star {
    transition: color 0.2s, transform 0.1s;
}

.star-rating .star:hover {
    transform: scale(1.1);
}

#reviews-container::-webkit-scrollbar {
    width: 6px;
}

#reviews-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#reviews-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

#reviews-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}