/* css/style.css */

/* 基本スタイル */
:root {
    --primary-color: #00ba00; /* 健全版のテーマカラー */
    --secondary-color: #6c757d;
    --light-bg: #f8f9fa;
    --dark-text: #212529;
    --light-text: #ffffff;
    --border-color: #dee2e6;
    --modal-bg: rgba(0, 0, 0, 0.7);
    --tweet-card-bg: #ffffff;
    --tweet-card-border: #e1e8ed;
    --tweet-link-color: #1b95e0;
    --tweet-meta-text: #657786;
    --danger-color: #dc3545;
    --notice-back-color: rgb(254 226 226);
    --notice-color: rgb(220 38 38);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--light-bg);
    color: var(--dark-text);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.container.hidden-by-age-gate {
    visibility: hidden;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button, .sort-button {
    cursor: pointer;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--primary-color);
    background-color: var(--primary-color);
    color: var(--light-text);
    border-radius: 4px;
    font-size: 1rem;
    transition: background-color 0.2s;
}

button:hover, .sort-button:hover {
    background-color: #009900;
    border-color: #009900;
}

input[type="text"], input[type="number"] {
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

/* ヘッダー */
.site-header {
    background-color: var(--light-text);
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; 
    gap: 1rem; 
}

.header-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap; 
}

.site-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.site-header h1 a {
    color: var(--primary-color); 
    text-decoration: none;
}
.site-header h1 a:hover {
    text-decoration: underline;
}

.site-header nav a {
    margin-left: 1rem;
}

.version-switch {
    font-size: 0.8em;
    font-weight: bold;
    padding: 0.3em 0.8em;
    border: 1px solid var(--border-color);
    border-radius: 15px; 
    color: var(--secondary-color);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.version-switch:hover {
    background-color: var(--light-bg);
    border-color: var(--secondary-color);
    text-decoration: none;
}

/* 変更開始: ドロワーメニュー・フォロー一覧・通知用のスタイル追加 */
.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--dark-text);
    padding: 0.5rem;
    cursor: pointer;
}
.mobile-menu-toggle:hover {
    background-color: var(--light-bg);
}

.nav-header-mobile {
    display: none;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1001;
}
.mobile-menu-overlay.active {
    display: block;
}

.notification-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1.5rem;
    padding: 0.2rem;
}
.notification-badge {
    position: absolute;
    top: 0px;
    right: -8px;
    background-color: var(--danger-color);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    line-height: 1;
    display: none; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .site-header {
        flex-wrap: nowrap;
        padding: 0.8rem 1rem;
    }
    .header-controls {
        gap: 0.5rem;
    }
    .mobile-menu-toggle {
        display: block;
    }
    .main-nav {
        position: fixed;
        top: 0;
        right: -260px;
        width: 260px;
        height: 100vh;
        background-color: var(--light-text);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0;
        z-index: 1002;
        transition: right 0.3s ease;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        padding-top: 0;
    }
    .main-nav.active {
        right: 0;
    }
    .nav-header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1.2rem;
        border-bottom: 1px solid var(--border-color);
        font-weight: bold;
        color: var(--primary-color);
    }
    .mobile-menu-close {
        background: none;
        border: none;
        color: var(--dark-text);
        cursor: pointer;
        padding: 0;
    }
    .mobile-menu-close:hover {
        background-color: var(--light-bg);
    }
    .site-header nav a {
        margin: 0;
        padding: 1.2rem;
        border-bottom: 1px solid var(--border-color);
        display: block;
    }
}

.followed-list {
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.followed-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.followed-item:last-child {
    border-bottom: none;
}
.followed-char-link {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--dark-text);
    text-decoration: none;
}
.followed-char-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}
.unfollow-btn {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 4px;
}
.unfollow-btn:hover {
    background-color: #c82333;
    border-color: #bd2130;
}
/* 変更終了 */

/* 検索とソート */
.search-section, .sort-section {
    margin-bottom: 2rem;
    background: var(--light-text);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.search-section form {
    display: flex;
    gap: 0.5rem;
}
.search-section .tagify {
    flex-grow: 1;
}
.search-section input[type="text"] {
    flex-grow: 1;
}
.sort-section {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center; 
}
.sort-button.active {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    font-weight: bold;
}

/* 変更開始: キャラクターヘッダー＆フォローボタン (健全版カラー) */
.character-header-section {
    background: var(--light-text);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.character-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.character-title {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}
.follow-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: bold;
    transition: all 0.2s ease;
}
.follow-button:hover {
    background-color: rgba(0, 186, 0, 0.1); /* 健全版のグリーン系へ */
}
.follow-button.followed {
    background-color: var(--primary-color);
    color: white;
}
.follow-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
/* 変更終了 */

/* ギャラリー */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    align-items: start;
}

.tweet-card {
    background-color: var(--tweet-card-bg);
    border: 1px solid var(--tweet-card-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    pointer-events: auto;
}
.gallery .tweet-card {
    cursor: pointer;
}
#preview-area .tweet-card {
    cursor: default;
    pointer-events: none; 
}
#preview-area .tweet-card a {
    pointer-events: auto;
}

.tweet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.tweet-author-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-grow: 1;
    min-width: 0;
}
.tweet-author-container:hover .tweet-author-name:hover {
    text-decoration: none;
}
.tweet-author-name-link:hover{
    text-decoration: underline;
    text-decoration-color: rgb(15, 20, 25);
}
.tweet-author-screen-name-link:hover{
    text-decoration: none;
}
.tweet-avatar-link{
    display: flex;
}
.tweet-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--tweet-card-border);
    flex-shrink: 0;
    transition-duration: 0.2s;
    min-width: 0;
}
.tweet-avatar:hover{
    filter: brightness(0.8);
}

.tweet-author-info {
    line-height: 1.3;
    min-width: 0;
    flex-grow: 1;
    text-decoration: none;
}
.tweet-author-info:hover{
    text-decoration: none;
}

.tweet-author-name, .tweet-author-screen-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tweet-author-name {
    font-weight: bold;
    color: var(--dark-text);
}
.tweet-author-screen-name {
    color: var(--tweet-meta-text);
}
.tweet-author-screen-name:hover {
    text-decoration: none;
}

.tweet-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.tweet-body {
    font-size: 0.95rem;
    word-wrap: break-word;
}
.tweet-body p {
    margin: 0;
}
.tweet-body a {
    color: var(--tweet-link-color);
}
.tweet-body a:hover {
    text-decoration: underline;
}

.tweet-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--tweet-meta-text);
    gap: 1rem;
}
.tweet-stats {
    display: flex;
    gap: 0.5rem;
}
.tweet-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.tweet-view-on-x {
    color: var(--tweet-meta-text);
    text-decoration: none;
    white-space: nowrap;
}
.tweet-view-on-x:hover {
    text-decoration: underline;
}

.tweet-timestamp {
    color: var(--tweet-meta-text);
    white-space: nowrap;
}

.period-favorite-count, .total-favorite-count {
    font-weight: bold;
    color: #f5b82b;
}

.favorite-icon, .tweet-x-icon {
    flex-shrink: 0;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}

.favorite-icon svg {
    width: 100%;
    height: 100%;
    fill: #cccccc;
    transition: all 0.2s ease;
}
.favorite-icon:hover {
    background-color: rgba(255, 193, 7, 0.1);
}
.favorite-icon:hover svg {
    fill: #ffdb58;
}
.favorite-icon.active svg {
    fill: #ffc107;
    transform: scale(1.1);
}

/* 変更開始: ミュートアイコンのスタイル追加 */
.mute-icon {
    flex-shrink: 0;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}
.mute-icon svg { width: 100%; height: 100%; fill: #cccccc; transition: all 0.2s ease; }
.mute-icon:hover { background-color: rgba(220, 53, 69, 0.1); }
.mute-icon:hover svg { fill: var(--danger-color); }
/* 変更終了 */

.tweet-x-icon {
    padding: 7px;
}
.tweet-x-icon svg {
    width: 100%;
    height: 100%;
    fill: rgb(15, 20, 25);
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    font-size: 1.2rem;
    color: var(--secondary-color);
}

.tweet-media-grid {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--tweet-card-border);
    display: grid;
    gap: 2px;
}
.grid-image-wrapper {
    position: relative;
    background-color: #f7f7f7;
}
.grid-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-count-1 {
    aspect-ratio: auto;
}
.image-count-1 .grid-image-wrapper {
    position: static;
}
.image-count-1 .grid-image-wrapper img {
    position: static;
    object-fit: contain;
    width: 100%;
    height: auto;
}

.image-count-2 {
    grid-template-columns: 1fr 1fr;
    aspect-ratio: 16 / 8;
}
.image-count-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    aspect-ratio: 16 / 9;
}
.image-count-3 .grid-image-wrapper:first-child {
    grid-row: span 2;
}
.image-count-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    aspect-ratio: 16 / 9;
}


/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    background-color: var(--light-text);
    padding: 2rem;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
}
.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}
.modal-actions button {
    min-width: 100px;
}
#age-gate-no {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* 変更開始: 通知モーダルのリスト用スタイル */
.notification-list {
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.notification-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--dark-text);
    transition: background-color 0.2s;
}
.notification-item:last-child {
    border-bottom: none;
}
.notification-item:hover {
    background-color: #f1f3f5;
    text-decoration: none;
}
.notification-char-name {
    font-weight: bold;
    font-size: 1.1rem;
}
.notification-count {
    background-color: var(--notice-back-color);
    color: var(--notice-color);
    padding: 0.2rem 0.8rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: bold;
}
.notification-empty {
    text-align: center;
    color: var(--secondary-color);
    padding: 2rem 0;
    margin: 0;
    border: none;
    line-height: 1.6;
}
/* 変更終了 */


/* 登録ページ */
.register-step { background: var(--light-text); padding: 2rem; border-radius: 8px; margin-bottom: 2rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: bold; }
#preview-area {
    margin-bottom: 1.5rem;
    border: 1px dashed var(--border-color);
    padding: 1rem;
    border-radius: 8px;
}
#preview-area .tweet-card {
    max-width: 500px;
    margin: 0 auto;
}
.author-preview { grid-column: 1 / -1; font-size: 1.2rem; font-weight: bold; }
.notice { margin: 1.5rem 0; padding: 1rem; background-color: #fff3cd; border: 1px solid #ffeeba; border-radius: 4px; color: #856404; }
.error-message { color: var(--danger-color); font-size: 0.9em; min-height: 1.2em; }
.status-message { margin-top: 1rem; }

#parse-url-form {
    display: flex;
    gap: 0.5rem;
}

#parse-url-form input[type="text"] {
    flex-grow: 1; 
}


/* ローダー */
.loader { border: 4px solid #f3f3f3; border-radius: 50%; border-top: 4px solid var(--primary-color); width: 30px; height: 30px; animation: spin 1s linear infinite; margin: 0 auto; }
.loader-container { padding: 2rem; }
.end-message { text-align: center; color: var(--secondary-color); padding: 2rem; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.status-modal-content {
    min-width: 300px;
    padding: 2.5rem;
}
.status-modal-content p {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: bold;
}
.status-modal-content.success {
    border-top: 5px solid #28a745;
}
.status-modal-content.error {
    border-top: 5px solid var(--danger-color);
}
#status-modal-close {
    min-width: 120px;
}

.history-stats { background-color: #fff; padding: 1.5rem; margin-bottom: 2rem; border-radius: 8px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.stats-number { font-size: 2.5rem; font-weight: bold; color: var(--primary-color); line-height: 1.2; }
.stats-label { font-size: 1rem; color: var(--secondary-color); margin-top: 0.5rem; }
.stats-grid { display: flex; justify-content: center; gap: 3rem; }
.disclaimer { font-size: 0.85rem; color: #6c757d; margin-top: 1.5rem; border-top: 1px solid var(--border-color); padding-top: 1rem; }
.disclaimer p { margin: 0.5em 0 0; }
.favorite-count-note { text-align: right; font-size: 0.8em; color: #6c757d; margin-bottom: 1rem; }

.recommend-button-wrapper {
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent; 
    border-radius: 4px;
    transition: border-color 0.2s;
}

.recommend-button-wrapper .sort-button.active {
    border-color: var(--secondary-color);
}

.recommend-button-wrapper .sort-button.active + .info-icon {
    border-color: var(--secondary-color);
}
.recommend-button-wrapper:has(.sort-button.active) {
    border-color: var(--secondary-color);
}

.recommend-button-wrapper .sort-button {
    border: 1px solid var(--border-color);
    border-right: none;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    cursor: pointer;
    color: var(--secondary-color);
    align-self: stretch;
    border: 1px solid var(--border-color); 
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    background-color: transparent;
    transition: all 0.2s;
}

.info-icon:hover {
    color: var(--primary-color);
    background-color: #e9ecef;
}

.info-modal-content {
    max-width: 600px;
    text-align: left;
}

.info-modal-title {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.info-modal-body h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.info-modal-body p {
    margin-top: 0;
    line-height: 1.7;
}

.sub-search-section {
    margin: -1rem 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sub-search-button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 0.7rem 1.4rem;
    background-color: #ffd700;
    color: #14171a;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    border: 1px solid #ffd700;
    transition: all 0.2s ease-in-out;
}

.sub-search-button:hover {
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.1);
    transform: translateY(-2px);
}

.sub-search-button-general {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 0.7rem 1.4rem;
    background-color: rgba(0, 186, 0, 0.15);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    border: none;
    transition: all 0.2s ease-in-out;
}

.sub-search-button-general:hover {
    text-decoration: none;
    background-color: rgba(0, 186, 0, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .search-section form, #parse-url-form {
        flex-direction: column;
        align-items: stretch;
    }

    .info-modal-content {
        max-width: 95vw;
        padding: 1.5rem;
    }

    .info-modal-title {
        font-size: 1.25rem;
    }

    .info-modal-body {
        font-size: 0.9rem;
    }

    .info-modal-body h4 {
        margin-top: 1rem;
    }
}

.blacklist-manager {
    max-width: 700px;
    margin: 2rem auto;
    background: var(--light-text);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.blacklist-manager h1 {
    margin-top: 0;
    text-align: center;
}

.blacklist-description {
    text-align: center;
    color: var(--secondary-color);
    font-size: 0.9em;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

#blacklist-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#blacklist-input {
    flex-grow: 1;
}

.blacklist-list-section {
    margin-top: 2rem;
}

#blacklist-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.blacklist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.blacklist-item:first-child {
    border-top: 1px solid var(--border-color);
}

.blacklist-item span {
    font-family: 'Consolas', 'Monaco', monospace;
}

.blacklist-remove-btn {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    font-size: 0.8em;
    padding: 0.3em 0.8em;
}

.blacklist-remove-btn:hover {
    background-color: #c82333;
    border-color: #bd2130;
}