:root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface-hover: #222;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #e53935;
    --accent-dark: #b71c1c;
    --tag-area: #1b3a4b;
    --tag-category: #3a1b1b;
    --urgency-high: #e53935;
    --urgency-medium: #ff9800;
    --urgency-low: #4caf50;
}

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

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

.container { max-width: 1000px; margin: 0 auto; padding: 20px; }

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

header h1 { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
header h1 span { color: var(--text-muted); font-weight: 400; }

.stats { display: flex; gap: 20px; font-size: 0.85rem; color: var(--text-muted); }
.stats .count { color: var(--accent); font-weight: 700; font-size: 1.1rem; }

.ollama-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.ollama-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.ollama-status .dot.online { background: var(--urgency-low); }
.ollama-status .dot.offline { background: var(--urgency-high); }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.toolbar button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.toolbar button.running { opacity: 0.5; cursor: wait; }

.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters select, .filters input {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.filters input { flex: 1; min-width: 200px; }

.filters button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.filters button:hover { background: var(--accent-dark); }

.article-list { display: flex; flex-direction: column; gap: 10px; }

.article {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    transition: background 0.2s;
}

.article:hover { background: var(--surface-hover); }
.article.unread { border-left: 3px solid var(--accent); }

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

.article-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    line-height: 1.4;
}

.article-title:hover { color: var(--accent); }

.article-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.article-source { font-weight: 600; }

.urgency-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.urgency-dot.high { background: var(--urgency-high); }
.urgency-dot.medium { background: var(--urgency-medium); }
.urgency-dot.low { background: var(--urgency-low); }

.score {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
}

.article-summary {
    font-size: 0.9rem;
    color: #bbb;
    line-height: 1.5;
    margin-bottom: 10px;
    font-style: italic;
}

.tags { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag.area { background: var(--tag-area); color: #6db3d6; }
.tag.category { background: var(--tag-category); color: #d66d6d; }

.article-actions { display: flex; gap: 8px; flex-shrink: 0; }

.article-actions button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.article-actions button:hover { border-color: var(--accent); color: var(--accent); }
.article-actions button.active { background: var(--accent); color: white; border-color: var(--accent); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state h2 { font-size: 1.2rem; margin-bottom: 10px; }

.pagination { display: flex; justify-content: center; gap: 10px; margin-top: 30px; }

.pagination a {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
}

.pagination a:hover { border-color: var(--accent); }
.pagination a.active { background: var(--accent); border-color: var(--accent); }

.status-bar {
    text-align: center;
    padding: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* Chat */
.chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 1000;
    transition: transform 0.2s;
}

.chat-toggle:hover { transform: scale(1.1); }
.chat-toggle.hidden { display: none; }

.chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    height: 500px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: none;
    flex-direction: column;
    z-index: 1001;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.chat-panel.open { display: flex; }

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
}

.chat-header button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.chat-header button:hover { color: var(--accent); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 90%;
}

.chat-msg.user {
    background: var(--accent-dark);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}

.chat-msg.assistant {
    background: var(--bg);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}

.chat-msg.thinking {
    opacity: 0.5;
    font-style: italic;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.chat-input-area input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-input-area button {
    background: var(--accent);
    color: white;
    border: none;
    width: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
}

.chat-input-area button:hover { background: var(--accent-dark); }
.chat-input-area button:disabled { opacity: 0.5; cursor: wait; }

.chat-context-editor {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}
.chat-context-editor textarea {
    width: 100%;
    min-height: 80px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    resize: vertical;
    font-family: inherit;
}
.chat-context-editor textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.chat-context-editor button {
    margin-top: 6px;
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}
.chat-context-editor button:hover { background: var(--accent-dark); }

.chat-header div {
    display: flex;
    gap: 4px;
}

@media (max-width: 600px) {
    .container { padding: 12px; }
    header { flex-direction: column; gap: 10px; }
    .filters { flex-direction: column; }
    .article-header { flex-direction: column; }
    .chat-panel { width: calc(100% - 16px); right: 8px; bottom: 8px; height: 60vh; }
    .chat-toggle { bottom: 16px; right: 16px; }
}
