* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 16px;
    font-size: 16px;
    color: #666;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #2c3e50;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

.search-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-wrapper {
    position: relative;
}

.settings-btn {
    width: 36px;
    height: 36px;
    background: #34495e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: #4a6278;
}

.settings-panel {
    position: absolute;
    top: 44px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 16px;
    min-width: 200px;
    z-index: 1000;
}

.settings-panel.hidden {
    display: none;
}

.settings-item {
    margin-bottom: 12px;
}

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

.settings-item label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.settings-item select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.settings-item.vector-only.hidden {
    display: none;
}

.threshold-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    margin-top: 8px;
}

.threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
}

.threshold-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
}

.settings-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.settings-buttons button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-cancel {
    background: #e0e0e0;
    color: #333;
}

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

.btn-confirm {
    background: #3498db;
    color: white;
}

.btn-confirm:hover {
    background: #2980b9;
}

.search-wrapper {
    position: relative;
}

.search-box {
    display: flex;
    gap: 8px;
}

.search-box input {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    width: 250px;
    font-size: 14px;
}

.search-box button {
    padding: 8px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-box button:hover {
    background: #2980b9;
}

.keyword-tags {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 500px;
    z-index: 1000;
}

.keyword-tags.hidden {
    display: none;
}

.keyword-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ecf0f1;
}

.keyword-group:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.keyword-label {
    font-size: 11px;
    font-weight: 600;
    color: #7f8c8d;
    min-width: 50px;
    text-transform: uppercase;
}

.keyword-tag {
    padding: 4px 10px;
    background: #ecf0f1;
    color: #2c3e50;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.keyword-tag:hover {
    background: #3498db;
    color: white;
}

.keyword-tag-hot {
    background: #fff5f5;
    color: #e74c3c;
    border: 1px solid #f8d7da;
}

.keyword-tag-hot:hover {
    background: #e74c3c;
    color: white;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.map-container {
    flex: 1;
    height: 100%;
}

.news-panel {
    width: 400px;
    background: white;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.news-panel.collapsed {
    transform: translateX(100%);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.panel-header h2 {
    font-size: 1.1rem;
    color: #2c3e50;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.close-btn:hover {
    color: #333;
}

.news-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.placeholder {
    color: #999;
    text-align: center;
    padding: 40px 20px;
}

.news-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.news-item:hover {
    background: #f8f9fa;
}

.news-item h3 {
    font-size: 0.95rem;
    color: #2c3e50;
    margin-bottom: 6px;
    line-height: 1.4;
}

.news-item .meta {
    font-size: 0.8rem;
    color: #999;
    line-height: 1.5;
}

.news-item .meta-source {
    color: #666;
}

.news-item .meta-date {
    color: #999;
}

.similarity-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.8rem;
    color: #999;
}

.similarity-fill {
    width: 60px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.similarity-fill::after {
    content: '';
    display: block;
    height: 100%;
    background: #3498db;
    border-radius: 3px;
    width: var(--percent, 0%);
}

.similarity-text {
    color: #999;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    border-radius: 8px;
    padding: 24px;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.modal-content h2 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 12px;
    padding-right: 30px;
}

.modal-meta {
    font-size: 0.85rem;
    color: #999;
    margin-bottom: 16px;
}

.modal-meta span {
    margin-right: 16px;
}

#modal-content {
    line-height: 1.7;
    color: #333;
}

#modal-content img {
    max-width: 100%;
    height: auto;
}

.read-more {
    display: inline-block;
    margin-top: 16px;
    color: #3498db;
    text-decoration: none;
}

.read-more:hover {
    text-decoration: underline;
}

/* Summary Modal */
.summary-modal-content {
    width: 60%;
    max-width: none;
}

.summary-content {
    line-height: 1.8;
    color: #333;
}

.summary-text {
    font-size: 15px;
}

.summary-text h1, .summary-text h2, .summary-text h3 {
    margin: 16px 0 8px;
    color: #2c3e50;
}

.summary-text p {
    margin: 8px 0;
}

.summary-text ul, .summary-text ol {
    margin: 8px 0;
    padding-left: 24px;
}

.summary-text li {
    margin: 4px 0;
}

.summary-text code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
}

.summary-text a {
    color: #3498db;
}

.summary-content .error {
    color: #e74c3c;
    text-align: center;
}

#summary-btn {
    background: #27ae60;
}

#summary-btn:hover {
    background: #219a52;
}

/* Map styles */
.country-label {
    background: transparent;
    border: none;
    font-weight: bold;
    color: #333;
    text-shadow: 1px 1px 2px white;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 12px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .search-container {
        width: 100%;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    .search-box button {
        padding: 8px 12px;
        font-size: 13px;
    }

    .keyword-tags {
        left: 0;
        right: 0;
        max-width: none;
        margin: 8px 12px;
        width: auto;
    }

    .main-container {
        flex-direction: column;
    }

    .map-container {
        height: 50vh;
        min-height: 250px;
    }

    .news-panel {
        position: relative;
        width: 100%;
        height: 50vh;
        max-width: none;
    }

    .news-panel.collapsed {
        display: none;
    }

    .panel-header h2 {
        font-size: 1rem;
    }

    .modal-content {
        width: 95%;
        padding: 16px;
        max-height: 85vh;
    }

    .summary-modal-content {
        width: 95%;
    }

    .settings-panel {
        right: -8px;
        min-width: 180px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1rem;
    }

    .search-box button {
        padding: 6px 10px;
        font-size: 12px;
    }

    .keyword-group {
        flex-wrap: wrap;
    }

    .keyword-label {
        width: 100%;
        margin-bottom: 4px;
    }

    .news-item h3 {
        font-size: 0.9rem;
    }
}

/* Ticker Button */
.ticker-btn {
    padding: 8px 12px;
    background: #34495e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.ticker-btn:hover {
    background: #4a6278;
}

.ticker-btn.active {
    background: #e74c3c;
}

/* News Ticker */
.news-ticker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(90deg, #2c3e50 0%, #34495e 100%);
    display: flex;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.news-ticker.hidden {
    display: none;
}

.ticker-label {
    background: #e74c3c;
    color: white;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    font-weight: bold;
    font-size: 14px;
    white-space: nowrap;
}

.ticker-wrapper {
    flex: 1;
    overflow: hidden;
    height: 100%;
    position: relative;
}

.ticker-content {
    display: inline-flex;
    align-items: center;
    height: 100%;
    white-space: nowrap;
}

.ticker-content:hover {
    animation-play-state: paused;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    color: white;
    padding: 0 30px;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
    flex-shrink: 0;
}

.ticker-item:hover .ticker-title {
    color: #3498db;
}

.ticker-meta {
    color: #95a5a6;
    font-size: 12px;
    margin-left: 8px;
}

.ticker-item::after {
    content: '•';
    margin-left: 30px;
    color: #7f8c8d;
}

.ticker-item:last-child::after {
    content: '';
}

/* Adjust main container when ticker is visible */
body.ticker-active .main-container {
    height: calc(100vh - 60px - 40px);
}

body.ticker-active .news-panel {
    height: calc(100vh - 60px - 40px);
}
