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

body {
    background: #0d0d0d;
    color: #e0e0e0;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 16px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Top Header ── */
.top-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #2a2a2a;
    background: #111111;
    flex-shrink: 0;
}

.top-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.header-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

#model-select {
    background: #1a1a1a;
    color: #888888;
    border: 1px solid #3a3a3a;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

#model-select option {
    background: #1a1a1a;
    color: #e0e0e0;
}

#refresh-btn,
#chat-toggle-btn {
    background: none;
    color: #888888;
    border: 1px solid #3a3a3a;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}

#refresh-btn:hover,
#chat-toggle-btn:hover {
    color: #cccccc;
    border-color: #555555;
}

#chat-toggle-btn.active {
    color: #5a9bcf;
    border-color: #5a9bcf;
}

/* ── Main Two-Panel Layout ── */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Left: News Panel ── */
.news-panel {
    flex: 1;
    min-width: 0;
    border-right: 1px solid #2a2a2a;
    overflow-y: auto;
    padding: 0;
    background: #0d0d0d;
    transition: flex 0.3s ease;
}

/* When chat is open, news takes less space */
.main-layout.chat-open .news-panel {
    flex: 1;
}

.main-layout.chat-open .chat-panel {
    flex: 0 0 40%;
    max-width: 500px;
}

/* When chat is closed, news fills everything */
.news-panel:only-child,
.main-layout:not(.chat-open) .news-panel {
    border-right: none;
}

/* Investigation search bar */
.investigate-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a2a;
    background: #111111;
    position: sticky;
    top: 0;
    z-index: 10;
}

#investigate-input {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #e0e0e0;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 15px;
    outline: none;
}

#investigate-input::placeholder {
    color: #555555;
}

#investigate-btn {
    background: none;
    color: #888888;
    border: 1px solid #3a3a3a;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

#investigate-btn:hover {
    color: #cccccc;
    border-color: #555555;
}

#investigate-btn:disabled {
    color: #333333;
    border-color: #222222;
    cursor: default;
}

/* Investigation sections */
.investigation-section {
    border-bottom: 1px solid #2a2a2a;
    background: #0f1114;
}

.investigation-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    cursor: pointer;
    user-select: none;
    background: #131620;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 16px;
    color: #7aa4d4;
    font-weight: 600;
}

.investigation-header:hover {
    background: #181c28;
}

.investigation-remove {
    margin-left: auto;
    background: none;
    border: none;
    color: #555555;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    font-family: inherit;
    line-height: 1;
}

.investigation-remove:hover {
    color: #cc5555;
}

.news-loading {
    color: #555555;
    font-style: italic;
    font-size: 15px;
    padding: 24px 20px;
    text-align: center;
}

.news-summary {
    padding: 14px 20px;
    color: #666666;
    font-size: 14px;
    border-bottom: 1px solid #1a1a1a;
}

/* Category sections */
.category-section {
    border-bottom: 1px solid #1a1a1a;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    cursor: pointer;
    user-select: none;
    background: #111111;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 16px;
    color: #cccccc;
    font-weight: 600;
    transition: background 0.15s;
}

.category-header:hover {
    background: #1a1a1a;
}

.category-toggle {
    font-size: 12px;
    color: #555555;
    transition: transform 0.2s;
    display: inline-block;
    width: 14px;
    text-align: center;
}

.category-toggle.collapsed {
    transform: rotate(-90deg);
}

.category-count {
    margin-left: auto;
    font-size: 13px;
    color: #555555;
    font-weight: 400;
}

.category-articles {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.category-articles.collapsed {
    max-height: 0 !important;
}

/* Individual articles */
.news-article {
    padding: 12px 20px 12px 34px;
    border-top: 1px solid #141414;
    line-height: 1.6;
}

.news-article:hover {
    background: #111111;
}

.article-title {
    font-size: 15px;
    color: #e0e0e0;
    font-weight: 600;
    margin-bottom: 4px;
}

.article-summary {
    font-size: 14px;
    color: #999999;
    margin-bottom: 4px;
}

.article-relevance {
    font-size: 13px;
    color: #666666;
    font-style: italic;
    margin-bottom: 5px;
}

.article-meta {
    font-size: 13px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.article-meta a {
    color: #5a9bcf;
    text-decoration: none;
}

.article-meta a:hover {
    text-decoration: underline;
}

.article-meta .source {
    color: #555555;
}

/* ── Right: Chat Panel ── */
.chat-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    transition: flex 0.3s ease, max-width 0.3s ease;
}

/* Hidden state */
.chat-panel.hidden {
    flex: 0 0 0% !important;
    max-width: 0 !important;
    border: none;
    overflow: hidden;
}

/* Chat tabs */
.chat-tabs {
    display: flex;
    border-bottom: 1px solid #2a2a2a;
    background: #111111;
    flex-shrink: 0;
}

.chat-tab {
    flex: 1;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #666666;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.chat-tab:hover {
    color: #aaaaaa;
}

.chat-tab.active {
    color: #5a9bcf;
    border-bottom-color: #5a9bcf;
}

/* Tab content */
.chat-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-tab-content.active {
    display: flex;
}

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

.message {
    max-width: 90%;
    padding: 14px 18px;
    line-height: 1.7;
    font-size: 15px;
}

.message.assistant {
    align-self: flex-start;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #d0d0d0;
}

.message.user {
    align-self: flex-end;
    background: #1a2a3a;
    border: 1px solid #2a3a4a;
    color: #e0e0e0;
}

.message.system {
    align-self: center;
    color: #555555;
    font-style: italic;
    font-size: 14px;
    border: none;
    padding: 8px;
}

/* Markdown inside messages */
.message h1 {
    font-size: 20px;
    color: #ffffff;
    margin: 0 0 10px 0;
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 6px;
}

.message h2 {
    font-size: 17px;
    color: #cccccc;
    margin: 16px 0 8px 0;
    border-bottom: 1px solid #1f1f1f;
    padding-bottom: 4px;
}

.message strong {
    color: #ffffff;
}

.message em {
    color: #888888;
}

.message a {
    color: #5a9bcf;
    text-decoration: none;
}

.message ul, .message ol {
    margin: 4px 0 4px 24px;
}

.message li {
    margin: 3px 0;
}

.message p {
    margin: 5px 0;
}

.message hr {
    border: none;
    border-top: 1px solid #2a2a2a;
    margin: 12px 0;
}

/* ── Tool Checkboxes ── */
.tool-checkboxes {
    display: flex;
    gap: 14px;
    padding: 8px 16px;
    border-top: 1px solid #2a2a2a;
    background: #111111;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.tool-checkboxes label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: #777777;
    cursor: pointer;
    user-select: none;
}

.tool-checkboxes label:hover {
    color: #aaaaaa;
}

.tool-checkboxes input[type="checkbox"] {
    accent-color: #5a9bcf;
    cursor: pointer;
}

/* ── Input Area ── */
.input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #2a2a2a;
    background: #111111;
    flex-shrink: 0;
}

#user-input {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    color: #e0e0e0;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 15px;
    outline: none;
}

#user-input:disabled {
    color: #555555;
}

#send-btn {
    background: none;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
    padding: 12px 22px;
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
}

#send-btn:disabled {
    color: #333333;
    border-color: #222222;
    cursor: default;
}

/* ── Scrollbars ── */
.news-panel::-webkit-scrollbar,
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.news-panel::-webkit-scrollbar-track,
.messages-area::-webkit-scrollbar-track {
    background: #0d0d0d;
}

.news-panel::-webkit-scrollbar-thumb,
.messages-area::-webkit-scrollbar-thumb {
    background: #2a2a2a;
}
