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

body {
    font-family: var(--font-sans, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    background: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

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

header {
    margin-bottom: 20px;
}

header h1 {
    color: #58a6ff;
    margin-bottom: 15px;
}

.version {
    font-size: 0.6em;
    background: #238636;
    padding: 2px 8px;
    border-radius: 4px;
    vertical-align: middle;
}

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

.controls select,
.controls input,
.controls button {
    padding: 10px 15px;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 14px;
}

.controls input {
    flex: 1;
    min-width: 300px;
}

.controls button {
    cursor: pointer;
    font-weight: 600;
}

.controls button:hover {
    background: var(--border-default);
}

#sendBtn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
}

#sendBtn:hover {
    background: rgba(255, 255, 255, 0.14);
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1200px) {
    main {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    padding: 15px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.panel h2 {
    color: #58a6ff;
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-default);
}

.panel h2 span {
    color: var(--text-muted);
    font-weight: normal;
}

.section {
    margin-bottom: 20px;
}

.section h3 {
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

/* Events Panel */
.events-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.event-item {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.event-item .event-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    margin-right: 10px;
    font-size: 11px;
}

.event-item .event-time {
    color: var(--text-muted);
    font-size: 11px;
}

.event-item .event-data {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* Event type colors */
.event-connected { background: #238636; color: white; }
.event-thinking { background: #1f6feb; color: white; }
.event-tool_start { background: #a371f7; color: white; }
.event-tool_complete { background: #8957e5; color: white; }
.event-reference_table { background: #f0883e; color: white; }
.event-viz_start { background: #db61a2; color: white; }
.event-viz_complete { background: #bf4b8a; color: white; }
.event-text_delta { background: #3fb950; color: white; }
.event-citation { background: #d29922; color: white; }
.event-references { background: #f85149; color: white; }
.event-images { background: #79c0ff; color: black; }
.event-done { background: #238636; color: white; }
.event-error { background: #f85149; color: white; }

/* Response Text */
.response-text {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 6px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.response-text .citation {
    background: #388bfd;
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.response-text .viz-placeholder {
    display: inline-block;
    background: #a371f7;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 5px 0;
}

.response-text .unmatched-viz {
    background: #f85149;
}

/* Visualizations */
.viz-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.viz-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    overflow: hidden;
}

.viz-card-header {
    background: var(--border-default);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.viz-card-header .viz-type {
    background: #a371f7;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.viz-card-header .viz-id {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

.viz-card-body {
    padding: 15px;
}

/* Drug Interaction Card */
.drug-interaction {
    border-left: 4px solid #f0883e;
}

.drug-interaction .drugs {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.drug-interaction .severity {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 15px;
}

.severity-major { background: #f85149; color: white; }
.severity-moderate { background: #f0883e; color: white; }
.severity-minor { background: #d29922; color: white; }
.severity-unknown { background: var(--text-muted); color: white; }

.drug-interaction .detail {
    margin-bottom: 10px;
}

.drug-interaction .detail-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

/* References */
.references-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reference-item {
    background: var(--bg-tertiary);
    padding: 10px 15px;
    border-radius: 6px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.reference-item .ref-num {
    background: #388bfd;
    color: white;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.reference-item .ref-content {
    flex: 1;
}

.reference-item .ref-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.reference-item .ref-type {
    font-size: 11px;
    color: var(--text-muted);
}

.reference-item .ref-id {
    font-family: var(--font-mono);
    font-size: 11px;
    color: #58a6ff;
}

/* JSON Display */
.json-display {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

/* Footer */
footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-default);
}

.status {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 13px;
}

#status.streaming {
    color: #3fb950;
}

#status.error {
    color: #f85149;
}
