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

        html, body {
            overflow-x: hidden;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
            color: #333;
        }

        .container {
            max-width: 1200px;
            width: 100%;
            margin: 0 auto;
        }

        header {
            background: white;
            border-radius: 12px;
            padding: 15px 20px;
            margin-bottom: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .header-top {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 15px;
            margin-bottom: 10px;
        }

        .header-titles {
            flex: 1;
            min-width: 0;
        }

        h1 {
            font-size: 2em;
            color: #667eea;
            margin-bottom: 5px;
        }

        .subtitle {
            color: #666;
            font-size: 1.1em;
        }

        .controls {
            display: flex;
            gap: 8px;
            margin-top: 10px;
            flex-wrap: wrap;
        }

        button {
            padding: 10px 20px;
            border: none;
            border-radius: 6px;
            background: #667eea;
            color: white;
            cursor: pointer;
            font-size: 1em;
            transition: background 0.3s;
        }

        button:hover {
            background: #764ba2;
        }

        button:disabled {
            background: #ccc;
            cursor: not-allowed;
        }

        #relevanceBtn {
            background: #d3d3d3;
            color: #666;
        }

        #relevanceBtn.active {
            background: #667eea;
            color: white;
        }

        #relevanceBtn:hover {
            background: #764ba2;
        }

        #relevanceBtn.active:hover {
            background: #764ba2;
        }

        .toggle-switch {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .link-btn {
            background: transparent;
            color: #555;
            border: 1px solid #ccc;
            padding: 6px 12px;
            font-size: 0.85rem;
            border-radius: 4px;
            cursor: pointer;
        }
        .link-btn:hover {
            background: #f0f0f0;
            color: #333;
        }

        .toggle-checkbox {
            display: none;
        }

        .toggle-slider-container {
            cursor: pointer;
        }

        .toggle-slider {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 26px;
            background-color: #d3d3d3;
            border-radius: 26px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .toggle-checkbox:checked + .toggle-slider {
            background-color: #667eea;
        }

        .toggle-slider:before {
            content: '';
            position: absolute;
            height: 20px;
            width: 20px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            border-radius: 50%;
            transition: transform 0.3s;
        }

        .toggle-checkbox:checked + .toggle-slider:before {
            transform: translateX(24px);
        }

        .toggle-label {
            font-size: 0.95em;
            color: #333;
            cursor: pointer;
            user-select: none;
            font-weight: 500;
        }

        .search-box {
            padding: 10px 15px;
            border: 2px solid #ddd;
            border-radius: 6px;
            font-size: 1em;
            width: 100%;
            flex-basis: 100%;
        }

        .articles-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
            gap: 15px;
            margin-bottom: 30px;
            min-width: 0;
        }

        .article-card {
            background: white;
            border-radius: 12px;
            padding: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s, box-shadow 0.3s, opacity 0.2s;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            min-width: 0;
            overflow: hidden;
        }

        .article-card.read {
            opacity: 0.55;
            background: #f0f0f0;
        }

        .article-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
        }

        .article-card.unprocessed {
            opacity: 0.7;
            border-left: 4px solid #ffc107;
        }

        .article-header {
            display: flex;
            justify-content: space-between;
            align-items: start;
            gap: 8px;
            margin-bottom: 8px;
        }

        .article-title {
            font-size: 1.1em;
            font-weight: bold;
            color: #333;
            flex: 1;
            line-height: 1.3;
        }

        .badge {
            display: inline-block;
            padding: 5px 12px;
            border-radius: 20px;
            font-size: 0.8em;
            font-weight: bold;
            white-space: nowrap;
        }

        .badge-processed {
            background: #d4edda;
            color: #155724;
        }

        .badge-unprocessed {
            background: #fff3cd;
            color: #856404;
        }

        .badge-app {
            background: #cce5ff;
            color: #004085;
        }

        .badge-threatactor {
            background: #f8d7da;
            color: #721c24;
        }

        .badge-clickable {
            cursor: pointer;
            transition: opacity 0.2s, transform 0.1s;
            text-decoration: none;
        }
        .badge-clickable:hover { opacity: 0.8; transform: scale(1.05); }

        .article-source {
            color: #667eea;
            font-size: 0.85em;
            font-weight: 500;
            margin-bottom: 6px;
        }

        .article-url {
            color: #667eea;
            text-decoration: none;
            font-size: 0.8em;
            word-break: break-all;
            margin-bottom: 8px;
            display: block;
        }

        .article-url:hover {
            text-decoration: underline;
        }

        .article-date {
            color: #999;
            font-size: 0.8em;
            margin-bottom: 10px;
        }

        .article-summary {
            flex: 1;
            color: #555;
            font-size: 0.9em;
            line-height: 1.4;
            margin-bottom: 10px;
            max-height: 120px;
            overflow: hidden;
        }

        .summary-json {
            background: #f5f5f5;
            padding: 10px;
            border-radius: 6px;
            font-family: 'Courier New', monospace;
            font-size: 0.8em;
            color: #333;
            overflow-y: auto;
            max-height: 100px;
        }

        .relevance-score {
            margin-top: 8px;
            font-size: 0.85em;
        }

        .relevance-bar {
            width: 100%;
            height: 6px;
            background: #eee;
            border-radius: 3px;
            overflow: hidden;
            margin-top: 5px;
        }

        .relevance-fill {
            height: 100%;
            background: linear-gradient(90deg, #667eea, #764ba2);
        }

        .loading {
            text-align: center;
            padding: 40px;
            font-size: 1.2em;
            color: white;
        }

        .error {
            background: #f8d7da;
            color: #721c24;
            padding: 15px;
            border-radius: 6px;
            margin: 20px 0;
        }

        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            background: white;
            border-radius: 12px;
            padding: 30px;
            max-width: 800px;
            width: 100%;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            gap: 10px;
        }

        .modal-close {
            float: none;
            font-size: 2em;
            cursor: pointer;
            color: #999;
            padding: 0;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: none;
            border: none;
        }

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

        .modal-actions {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid #ddd;
        }

        .modal-actions button {
            padding: 8px 15px;
            background: #667eea;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.9em;
            font-weight: 500;
            transition: background 0.3s;
        }

        .modal-actions button:hover {
            background: #764ba2;
        }

        .modal-actions button.secondary {
            background: #ddd;
            color: #333;
        }

        .modal-actions button.secondary:hover {
            background: #ccc;
        }

        .modal-title {
            font-size: 1.5em;
            color: #333;
            margin-bottom: 20px;
            clear: both;
        }

        @media (max-width: 768px) {
            body {
                padding: 10px;
            }

            header {
                padding: 12px 15px;
            }

            .header-top {
                flex-direction: column;
                align-items: stretch;
                gap: 8px;
            }

            .auth-bar {
                justify-content: flex-start;
            }

            h1 {
                font-size: 1.4em;
                margin-bottom: 3px;
            }

            .subtitle {
                font-size: 0.9em;
            }

            .controls {
                flex-direction: column;
                gap: 8px;
            }

            .controls > * {
                width: 100%;
            }

            .search-box {
                min-width: auto;
                flex-basis: auto;
            }

            .styled-select {
                width: 100%;
            }

            .controls button {
                width: 100%;
            }

            .toggle-switch {
                justify-content: space-between;
                width: 100%;
                padding: 4px 0;
            }

            .articles-grid {
                grid-template-columns: 1fr;
                gap: 12px;
            }

            .article-card {
                padding: 12px;
            }

            .article-title {
                font-size: 1em;
            }

            .badge {
                padding: 3px 8px;
                font-size: 0.75em;
            }

            .modal {
                padding: 0;
                align-items: flex-end;
            }

            .modal-content {
                padding: 20px;
                border-radius: 16px 16px 0 0;
                max-height: 95vh;
                max-width: 100%;
            }

            .modal-header {
                gap: 8px;
            }

            .modal-title {
                font-size: 1.15em;
            }

            .modal-actions {
                flex-wrap: wrap;
                gap: 8px;
            }

            .modal-actions a {
                flex-basis: 100%;
            }

            .event-group-header {
                padding: 10px 14px;
            }

            .event-group-name {
                font-size: 0.9em;
            }

            .feedback-btn {
                width: 40px;
                height: 40px;
                font-size: 1.2em;
            }
        }

        @media (max-width: 400px) {
            body {
                padding: 6px;
            }

            header {
                padding: 10px 12px;
                border-radius: 8px;
            }

            h1 {
                font-size: 1.2em;
            }

            .article-card {
                border-radius: 8px;
                padding: 10px;
            }

            .modal-content {
                padding: 16px;
            }
        }

        .no-articles {
            background: white;
            padding: 40px;
            border-radius: 12px;
            text-align: center;
            color: #999;
        }

        .feedback-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            border: 2px solid #ddd;
            background: white;
            cursor: pointer;
            font-size: 1.1em;
            transition: all 0.2s;
            padding: 0;
        }

        .feedback-btn:hover {
            transform: scale(1.15);
        }

        .feedback-btn.active-up {
            border-color: #28a745;
            background: #d4edda;
        }

        .feedback-btn.active-down {
            border-color: #dc3545;
            background: #f8d7da;
        }

        /* ── Tag chips (interactive boost/mute) ───────────────────── */
        .tag-chip {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 0.78em;
            font-weight: 600;
            padding: 4px 10px;
            border-radius: 12px;
            border: 1.5px solid transparent;
            cursor: pointer;
            font-family: inherit;
            line-height: 1.4;
            transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
        }
        .tag-chip:hover {
            transform: scale(1.05);
            box-shadow: 0 2px 4px rgba(0,0,0,0.12);
        }
        .tag-chip:focus-visible {
            outline: 2px solid #4c6ef5;
            outline-offset: 2px;
        }
        .tag-chip.chip-app {
            background: #cce5ff;
            color: #004085;
        }
        .tag-chip.chip-threatactor {
            background: #f8d7da;
            color: #721c24;
        }
        .tag-chip.chip-boosted {
            border-color: #28a745;
            box-shadow: 0 0 0 1px #28a745 inset;
        }
        .tag-chip.chip-boosted::before {
            content: "↑";
            font-weight: bold;
            color: #1e7e34;
        }
        .tag-chip.chip-muted {
            opacity: 0.55;
            border-color: #dc3545;
            text-decoration: line-through;
        }
        .tag-chip.chip-muted::before {
            content: "↓";
            font-weight: bold;
            color: #a71d2a;
        }

        /* ── Chip popover ─────────────────────────────────────────── */
        .tag-chip-popover {
            position: absolute;
            z-index: 1100;
            background: white;
            border-radius: 8px;
            box-shadow: 0 6px 20px rgba(0,0,0,0.18);
            padding: 6px;
            min-width: 180px;
            display: flex;
            flex-direction: column;
            gap: 2px;
            border: 1px solid #e0e0e0;
        }
        .chip-popover-header {
            font-weight: 600;
            font-size: 0.85em;
            color: #333;
            padding: 6px 8px;
            border-bottom: 1px solid #eee;
            margin-bottom: 4px;
            word-break: break-word;
        }
        .chip-popover-signin {
            font-size: 0.8em;
            color: #999;
            padding: 4px 8px;
        }
        .chip-popover-action {
            display: block;
            text-align: left;
            background: none;
            border: none;
            padding: 8px 10px;
            font-size: 0.9em;
            border-radius: 4px;
            cursor: pointer;
            color: #333;
            font-family: inherit;
            text-decoration: none;
        }
        .chip-popover-action:hover:not(:disabled) {
            background: #f0f0f5;
        }
        .chip-popover-action:focus-visible {
            outline: 2px solid #4c6ef5;
            outline-offset: -2px;
            background: #f0f0f5;
        }
        .chip-popover-action:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }
        .chip-popover-action.is-current {
            background: #eaf3ff;
            font-weight: 600;
        }

        /* ── Score explanation ────────────────────────────────────── */
        .score-explanation {
            font-size: 0.72em;
            color: #777;
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            justify-content: flex-end;
        }
        .score-explanation .exp-boost { color: #1e7e34; }
        .score-explanation .exp-mute { color: #a71d2a; }

        /* ── Preferences modal ────────────────────────────────────── */
        .prefs-list {
            list-style: none;
            padding: 0;
            margin: 0;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .prefs-row {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 10px;
            background: #f7f7fa;
            border-radius: 6px;
        }
        .prefs-row-tag {
            font-weight: 600;
            flex: 1;
            word-break: break-word;
        }
        .prefs-row-type {
            font-size: 0.75em;
            color: #888;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }
        .prefs-row-remove {
            background: transparent;
            border: 1px solid #ccc;
            border-radius: 4px;
            cursor: pointer;
            padding: 2px 8px;
            color: #666;
            font-size: 0.9em;
        }
        .prefs-row-remove:hover {
            background: #f8d7da;
            border-color: #dc3545;
            color: #721c24;
        }

        .auth-bar {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            justify-content: flex-end;
            flex-shrink: 0;
        }

        .auth-user {
            font-size: 0.9em;
            color: #555;
        }

        .auth-btn {
            padding: 6px 14px;
            font-size: 0.9em;
            background: #667eea;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            text-decoration: none;
            display: inline-block;
            transition: background 0.2s;
        }

        .auth-btn:hover {
            background: #764ba2;
        }

        .auth-role-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 4px 10px;
            font-size: 0.78em;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            color: #5b3aa3;
            background: linear-gradient(135deg, #ede4ff, #dcd0ff);
            border: 1px solid #c5b3f5;
            border-radius: 999px;
            white-space: nowrap;
        }

        .auth-btn-admin {
            background: linear-gradient(135deg, #764ba2, #667eea);
            box-shadow: 0 1px 3px rgba(102, 126, 234, 0.35);
        }

        .auth-btn-admin:hover {
            background: linear-gradient(135deg, #5d3a85, #4f63cf);
        }

        .personalized-score {
            display: flex;
            align-items: center;
            gap: 4px;
            font-size: 0.8em;
            color: #28a745;
            font-weight: 600;
        }

        .event-group {
            margin-bottom: 25px;
        }

        .event-group-header {
            background: white;
            border-radius: 10px;
            padding: 12px 18px;
            margin-bottom: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
            cursor: pointer;
        }

        .event-group-header:hover {
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
        }

        .event-group-name {
            font-weight: 600;
            color: #667eea;
            font-size: 1em;
        }

        .event-group-count {
            background: #667eea;
            color: white;
            border-radius: 12px;
            padding: 2px 10px;
            font-size: 0.8em;
            font-weight: 600;
        }

        .event-group .articles-grid {
            margin-bottom: 0;
        }

        .styled-select {
            padding: 10px 20px;
            border: none;
            border-radius: 6px;
            background: #667eea;
            color: white;
            cursor: pointer;
            font-size: 1em;
            font-weight: 500;
            transition: background 0.3s;
            -webkit-appearance: none;
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 10px center;
            padding-right: 30px;
        }

        .styled-select:hover,
        .styled-select:focus {
            background-color: #764ba2;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 10px center;
            outline: none;
        }

        .styled-select option {
            background: white;
            color: #333;
        }
