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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0d1117;
    color: #e6edf3;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    padding: 2rem 1rem;
    border-bottom: 1px solid #30363d;
}

header h1 {
    font-size: 2rem;
    color: #58a6ff;
}

.subtitle {
    color: #8b949e;
    margin-top: 0.5rem;
}

main {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

.research-form h2,
.results h2,
.history h2,
.model-setup h2 {
    margin-bottom: 1rem;
    color: #c9d1d9;
}

textarea {
    width: 100%;
    padding: 0.75rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 1rem;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: #58a6ff;
}

button {
    margin-top: 1rem;
    padding: 0.75rem 2rem;
    background: #238636;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #2ea043;
}

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

/* Model setup */
.model-setup {
    padding: 1.5rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    margin-bottom: 2rem;
}

.setup-desc {
    color: #8b949e;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.model-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.model-controls label {
    color: #8b949e;
    font-size: 0.9rem;
}

.model-controls select {
    width: 100%;
    padding: 0.5rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 0.9rem;
}

.model-status {
    font-size: 0.85rem;
    color: #8b949e;
}

.model-status.ready {
    color: #3fb950;
}

.model-status.error {
    color: #f85149;
}

.model-progress {
    position: relative;
    height: 24px;
    background: #0d1117;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #30363d;
}

.model-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #1f6feb, #58a6ff);
    border-radius: 6px;
    transition: width 0.3s ease;
    width: 0%;
}

.model-progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #e6edf3;
}

.webgpu-warning {
    padding: 1rem;
    background: #3d1f00;
    border: 1px solid #da3633;
    border-radius: 6px;
    color: #f85149;
    line-height: 1.5;
    font-size: 0.9rem;
}

/* Results */
.results {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
}

.hidden {
    display: none !important;
}

#status-bar {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.status-badge.completed { background: #238636; }
.status-badge.searching { background: #1f6feb; }
.status-badge.synthesizing { background: #8957e5; }
.status-badge.pending { background: #9e6a03; }
.status-badge.failed { background: #da3633; }

.confidence-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.confidence-badge.high { background: #238636; }
.confidence-badge.medium { background: #9e6a03; }
.confidence-badge.low { background: #da3633; }

.result-question {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.result-answer {
    line-height: 1.7;
    white-space: pre-wrap;
    margin-bottom: 1.5rem;
}

/* Sources */
#sources-section {
    margin-top: 1.5rem;
    border-top: 1px solid #30363d;
    padding-top: 1rem;
}

#sources-section h3,
#search-terms h3 {
    color: #8b949e;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

#sources-list {
    list-style: none;
}

.source-item {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: #0d1117;
    border-radius: 4px;
}

.source-item a {
    color: #58a6ff;
    text-decoration: none;
    display: block;
}

.source-item a:hover {
    text-decoration: underline;
}

.source-meta {
    display: block;
    color: #8b949e;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.source-type {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: #30363d;
    border-radius: 3px;
    font-size: 0.75rem;
    color: #c9d1d9;
}

/* Search terms */
#search-terms {
    margin-top: 1rem;
    border-top: 1px solid #30363d;
    padding-top: 1rem;
}

.term-chip {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    background: #1f2937;
    border: 1px solid #30363d;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #58a6ff;
    margin-bottom: 0.25rem;
}

/* History */
.history {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
}

#history-list {
    list-style: none;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #21262d;
    cursor: pointer;
    transition: background 0.15s;
}

.history-item:hover {
    background: #0d1117;
    border-radius: 4px;
}

.history-item:last-child {
    border-bottom: none;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.completed { background: #238636; }
.status-dot.pending { background: #9e6a03; }

.history-question {
    flex: 1;
    color: #c9d1d9;
    font-size: 0.9rem;
}

.history-sources {
    color: #8b949e;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Feedback widget */
.feedback-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #58a6ff;
    color: #0d1117;
    font-size: 1.4rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 100;
    margin: 0;
    padding: 0;
    transition: background 0.2s;
}

.feedback-toggle:hover {
    background: #79c0ff;
}

.feedback-panel {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    width: 340px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 101;
    padding: 1rem;
}

.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.feedback-header h3 {
    color: #c9d1d9;
    font-size: 1rem;
    margin: 0;
}

.feedback-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: auto;
}

.feedback-close:hover {
    color: #e6edf3;
    background: none;
}

.feedback-panel select {
    width: 100%;
    padding: 0.5rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.feedback-panel textarea {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.feedback-panel input[type="email"] {
    width: 100%;
    padding: 0.5rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.feedback-panel input[type="email"]:focus {
    outline: none;
    border-color: #58a6ff;
}

.feedback-panel button[type="submit"] {
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.6rem;
    font-size: 0.9rem;
}

.feedback-success {
    text-align: center;
    color: #3fb950;
    padding: 1rem 0;
    font-size: 0.95rem;
}

/* Deep Research */
.form-buttons {
    display: flex;
    gap: 0.75rem;
}

#deep-research-btn {
    background: #8957e5;
}

#deep-research-btn:hover {
    background: #a371f7;
}

.deep-controls {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.deep-controls label {
    color: #8b949e;
    font-size: 0.9rem;
}

.deep-controls input[type="range"] {
    flex: 1;
    accent-color: #8957e5;
}

#turns-label {
    color: #a371f7;
    font-size: 0.9rem;
    min-width: 60px;
}

.deep-results {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
}

.deep-results h2 {
    margin-bottom: 1rem;
    color: #c9d1d9;
}

.deep-status {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.deep-status.searching { color: #58a6ff; }
.deep-status.completed { color: #3fb950; }
.deep-status.failed { color: #f85149; }

.deep-turn-card {
    margin-bottom: 0.75rem;
    border: 1px solid #30363d;
    border-radius: 6px;
    overflow: hidden;
}

.deep-turn-card[open] {
    border-color: #8957e5;
}

.deep-turn-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #0d1117;
    cursor: pointer;
    user-select: none;
}

.deep-turn-header:hover {
    background: #161b22;
}

.turn-number {
    font-weight: bold;
    color: #a371f7;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.turn-question {
    flex: 1;
    color: #c9d1d9;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deep-turn-body {
    padding: 1rem;
    line-height: 1.6;
}

.turn-answer {
    white-space: pre-wrap;
    margin-bottom: 1rem;
    color: #e6edf3;
}

.turn-sources {
    list-style: none;
    margin: 0.5rem 0;
}

.turn-sources li {
    padding: 0.25rem 0;
}

.turn-sources a {
    color: #58a6ff;
    text-decoration: none;
    font-size: 0.85rem;
}

.turn-sources a:hover {
    text-decoration: underline;
}

.turn-terms {
    margin-top: 0.5rem;
}

.deep-summary {
    margin-top: 1rem;
    padding: 1rem;
    background: #0d1117;
    border: 1px solid #8957e5;
    border-radius: 6px;
}

.deep-summary h3 {
    color: #a371f7;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

#deep-summary-content {
    white-space: pre-wrap;
    line-height: 1.7;
}

/* Activity indicator */
.activity-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
}

.activity-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #30363d;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.activity-indicator.deep .activity-spinner {
    border-top-color: #a371f7;
}

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

.activity-label {
    color: #8b949e;
    font-size: 0.9rem;
}

.activity-progress {
    flex: 1;
    height: 3px;
    background: #30363d;
    border-radius: 2px;
    overflow: hidden;
}

.activity-progress-bar {
    height: 100%;
    background: #58a6ff;
    border-radius: 2px;
    animation: progress-pulse 2s ease-in-out infinite;
}

.activity-indicator.deep .activity-progress-bar {
    background: #a371f7;
}

@keyframes progress-pulse {
    0%, 100% { width: 20%; opacity: 0.6; }
    50% { width: 80%; opacity: 1; }
}

/* Action type badges */
.action-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.action-badge.action-literature_search { background: #1f6feb; color: #fff; }
.action-badge.action-clinical_trials { background: #238636; color: #fff; }
.action-badge.action-compound_comparison { background: #da6d28; color: #fff; }
.action-badge.action-target_analysis { background: #8957e5; color: #fff; }
.action-badge.action-hypothesis { background: #bf4b8a; color: #fff; }

/* Experiment data section */
.experiment-data {
    margin: 1rem 0;
    padding: 0.75rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
}

/* Comparison table */
.experiment-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.experiment-table th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 2px solid #30363d;
    color: #8b949e;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.experiment-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #21262d;
    color: #e6edf3;
}

.experiment-table tr:hover td {
    background: #161b22;
}

/* Trial cards */
.trial-card {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid #30363d;
    border-radius: 4px;
    background: #161b22;
}

.trial-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.trial-phase {
    font-size: 0.8rem;
    color: #a371f7;
}

.trial-status-badge {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: #30363d;
    color: #c9d1d9;
}

.trial-title {
    color: #c9d1d9;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.trial-meta {
    color: #8b949e;
    font-size: 0.8rem;
}

/* Target analysis lists */
.target-list, .target-compounds {
    list-style: none;
    margin: 0.25rem 0 0.5rem 0;
}

.target-list li, .target-compounds li {
    padding: 0.25rem 0;
    color: #c9d1d9;
    font-size: 0.85rem;
}

.deep-status.searching::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #30363d;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

footer {
    text-align: center;
    padding: 1rem;
    color: #484f58;
    border-top: 1px solid #30363d;
}

/* Responsive */
@media (max-width: 600px) {
    header h1 { font-size: 1.5rem; }
    main { padding: 1rem 0.75rem; }
    .form-buttons { flex-direction: column; }
    .feedback-panel { width: calc(100% - 2rem); right: 1rem; }
}
