:root {
    /* Backgrounds */
    --bg-color: #f8f9fa;
    --surface-color: #ffffff;
    --surface-hover: #f1f3f4;
    --surface-active: #e8eaed;

    /* Text */
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;

    /* Borders */
    --border-color: #e8eaed;
    --border-light: #f1f3f4;

    /* Accents */
    --accent-blue: #1a73e8;
    --accent-green: #34a853;
    --accent-orange: #f9ab00;
    --accent-purple: #a142f4;
    --accent-red: #ea4335;

    /* Highlights */
    --highlight-bg: rgba(26, 115, 232, 0.12);
    --highlight-text: #1a73e8;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(60,64,67,0.1);
    --shadow-md: 0 1px 3px rgba(60,64,67,0.12), 0 1px 2px rgba(60,64,67,0.08);
    --shadow-lg: 0 4px 8px rgba(60,64,67,0.15), 0 1px 3px rgba(60,64,67,0.1);
    --shadow-hover: 0 4px 12px rgba(60,64,67,0.15), 0 2px 4px rgba(60,64,67,0.1);

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Google Sans', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Roboto Mono', 'Consolas', 'Monaco', monospace;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #dadce0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #bdc1c6;
}

/* Split Panel Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.search-panel {
    width: 480px;
    min-width: 380px;
    max-width: 560px;
    padding: 24px;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    background-color: var(--surface-color);
    flex-shrink: 0;
}

.detail-panel {
    flex: 1;
    display: none;
    overflow-y: auto;
    background-color: var(--bg-color);
    padding: 0;
}

.detail-panel.open {
    display: block;
}

/* Search Area */
.search-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    background-color: var(--bg-color);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.search-wrapper:focus-within {
    background-color: var(--surface-color);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.search-icon {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-wrapper:focus-within .search-icon {
    color: var(--accent-blue);
}

#search-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    width: 100%;
    outline: none;
}

#search-input::placeholder {
    color: var(--text-tertiary);
}

.stats {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 0 4px;
}

.stats-breakdown {
    color: var(--text-tertiary, #888);
    font-size: 12px;
}

/* Results List */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-item {
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
}

.result-item:hover {
    border-color: var(--border-color);
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

/* Header: Badge + Score/Timestamp */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.result-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.4;
}

.result-title-row {
    margin-bottom: 8px;
}

/* Score Badge */
.score {
    color: var(--accent-blue);
    font-size: 12px;
    font-weight: 500;
    background: rgba(26, 115, 232, 0.08);
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Timestamp Badge (for browse mode) */
.result-header .timestamp {
    color: var(--text-secondary);
    font-size: 12px;
    background: var(--surface-hover);
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Metadata */
.result-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.meta-separator {
    color: var(--text-tertiary);
}

/* Summary Text */
.result-summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Source Badges */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

/* Result Tags */
.result-tags {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.action-tag {
    background-color: rgba(249, 171, 0, 0.1);
    color: #b36b00;
}

.decision-tag {
    background-color: rgba(52, 168, 83, 0.1);
    color: #1e7e34;
}

/* Highlight matched terms */
.highlight {
    color: var(--highlight-text);
    background-color: var(--highlight-bg);
    border-radius: 3px;
    font-weight: 500;
    padding: 1px 3px;
}

/* Detail Panel Header */
.detail-header {
    position: sticky;
    top: 0;
    background-color: var(--surface-color);
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.detail-header h2 {
    margin: 12px 0 0 0;
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.close-btn {
    position: absolute;
    right: 24px;
    top: 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.close-btn:hover {
    background-color: var(--surface-hover);
    color: var(--text-primary);
}

/* Detail Content */
.detail-content {
    padding: 24px 28px;
}

.detail-content h3 {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* AI Insights Container */
.insights-container {
    background-color: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 24px;
}

.insight-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.insight-section:last-child {
    border-bottom: none;
}

.insight-section h4 {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-section p {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

.insight-section ul {
    margin: 0;
    padding-left: 20px;
    color: var(--text-primary);
}

.insight-section li {
    margin-bottom: 8px;
    line-height: 1.5;
    font-size: 14px;
}

.insight-section li:last-child {
    margin-bottom: 0;
}

.keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword {
    background-color: rgba(161, 66, 244, 0.08);
    color: var(--accent-purple);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

/* Messages Section */
.messages-section {
    margin-bottom: 24px;
}

.thread-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thread-message {
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.thread-message:hover {
    border-color: var(--accent-blue);
}

.thread-message.highlighted-message {
    border-color: var(--accent-orange);
    background-color: rgba(249, 171, 0, 0.04);
    box-shadow: 0 0 0 3px rgba(249, 171, 0, 0.1);
}

.thread-message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.thread-author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--accent-purple);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.thread-author {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.thread-timestamp {
    color: var(--text-tertiary);
    font-size: 12px;
}

.thread-msg-id {
    color: var(--text-tertiary);
    font-size: 11px;
    margin-left: auto;
}

.thread-message-body {
    color: var(--text-primary);
    line-height: 1.6;
}

/* Thread Meta */
.thread-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.thread-meta-item {
    display: flex;
    gap: 4px;
}

.thread-meta-item strong {
    color: var(--text-primary);
    font-weight: 500;
}

.message-count {
    font-weight: 400;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* Meeting Styles */
.meeting-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.meeting-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: rgba(249, 171, 0, 0.08);
    border: 1px solid rgba(249, 171, 0, 0.15);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.meeting-meta-pill strong {
    color: #b36b00;
    font-weight: 500;
}

.meeting-short-summary {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.meeting-long-summary {
    background-color: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.meeting-long-summary summary {
    padding: 14px 20px;
    cursor: pointer;
    font-weight: 500;
    color: var(--accent-orange);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    font-size: 14px;
}

.meeting-long-summary summary:hover {
    background-color: var(--surface-hover);
}

.meeting-long-summary summary::before {
    content: '';
}

.meeting-long-summary[open] summary {
    border-bottom: 1px solid var(--border-color);
}

.meeting-long-summary > .markdown-content {
    padding: 20px;
}

/* Transcript Section */
.transcript-section {
    margin-bottom: 24px;
}

.transcript-content {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

/* Markdown Content */
.markdown-content {
    font-size: 14px;
    color: var(--text-primary);
}

.markdown-content p {
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-content a {
    color: var(--accent-blue);
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

.markdown-content code {
    background-color: var(--surface-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-purple);
}

.markdown-content pre {
    background-color: #f1f3f4;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.markdown-content blockquote {
    border-left: 3px solid var(--accent-blue);
    margin: 12px 0;
    padding: 10px 16px;
    background-color: rgba(26, 115, 232, 0.04);
    color: var(--text-secondary);
    border-radius: 0 8px 8px 0;
}

.markdown-content blockquote p {
    margin: 0;
}

.markdown-content ul,
.markdown-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.markdown-content li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
    color: var(--text-primary);
    margin: 20px 0 12px 0;
    font-weight: 600;
}

.markdown-content h1:first-child,
.markdown-content h2:first-child,
.markdown-content h3:first-child,
.markdown-content h4:first-child {
    margin-top: 0;
}

.markdown-content img {
    max-width: 100%;
    border-radius: 8px;
}

/* Chat Messages (legacy support) */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    gap: 12px;
    padding: 16px;
    background-color: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-blue);
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.sender-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.timestamp {
    color: var(--text-tertiary);
    font-size: 12px;
}

.message-text {
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.reactions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.reaction {
    background-color: var(--surface-hover);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 13px;
}

.no-messages {
    color: var(--text-secondary);
    font-style: italic;
    padding: 20px;
    text-align: center;
}

/* Loading and Error States */
.loading, .error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    font-size: 14px;
}

.error {
    color: var(--accent-red);
}

/* Abstract Text (legacy) */
.result-abstract {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Keywords row in preview cards */
.result-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.result-keyword {
    background-color: rgba(161, 66, 244, 0.08);
    color: var(--accent-purple);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.result-keyword-overflow {
    background-color: var(--surface-hover);
    color: var(--text-secondary);
}

/* Detail panel meta bar */
.detail-meta-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background-color: var(--bg-color);
    border-radius: 8px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.detail-meta-bar .meta-separator {
    color: var(--text-tertiary);
}

/* Result Header Layout */
.result-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Status Badges (Urgency & Thread Status) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-high {
    background-color: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.badge-open {
    background-color: #ffedd5;
    color: #ea580c;
    border: 1px solid #fed7aa;
}

/* Result Bottom Row */
.result-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-top: 10px;
}

.result-bottom-row .result-keywords {
    margin-top: 0;
    flex: 1;
}

/* Tech/Problem Indicators */
.result-indicators {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.indicator {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface-hover);
}

.indicator-tech {
    color: #059669;
}

.indicator-problem {
    color: #d97706;
}

/* Detail Header Badges */
.detail-header-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Collapsible Sections */
.additional-insights {
    margin-top: 24px;
}

.collapsible-section {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.collapsible-header:hover {
    background-color: var(--surface-hover);
}

.chevron {
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
}

.collapsible-section.expanded .chevron {
    transform: rotate(90deg);
}

.collapsible-title {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-section.expanded .collapsible-content {
    max-height: 1000px;
}

.collapsible-content .subsection {
    padding: 0 20px 16px 20px;
    border-top: 1px solid var(--border-light);
}

.collapsible-content .subsection:first-child {
    padding-top: 16px;
}

.collapsible-content h5 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
}

/* Pills */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 6px;
    margin-bottom: 6px;
}

.pill-tech {
    background-color: rgba(5, 150, 105, 0.1);
    color: #059669;
}

.pill-topic {
    background-color: rgba(26, 115, 232, 0.1);
    color: var(--accent-blue);
}

.tech-pills, .topic-pills {
    display: flex;
    flex-wrap: wrap;
}

/* Code References */
.code-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.code-ref {
    font-family: var(--font-mono);
    font-size: 12px;
    background-color: var(--surface-hover);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--accent-purple);
}

/* Error Messages */
.error-list {
    margin: 0;
    padding-left: 20px;
}

.error-item {
    color: #dc2626;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 6px;
}

.error-item:last-child {
    margin-bottom: 0;
}

/* Problems List */
.problems-list {
    margin: 0;
    padding-left: 20px;
}

.problems-list li {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 6px;
    color: var(--text-primary);
}

/* Entities */
.entities {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.8;
}

.entity {
    color: var(--accent-purple);
    font-weight: 500;
}

/* Search Suggestions */
.search-suggestions {
    margin: 0;
    padding-left: 20px;
    list-style-type: none;
}

.search-suggestions li {
    margin-bottom: 8px;
}

.search-suggestions li::before {
    content: "→ ";
    color: var(--text-tertiary);
}

.search-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 13px;
}

.search-link:hover {
    text-decoration: underline;
}

/* Key Phrases */
.key-phrases {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.phrase {
    color: var(--text-primary);
    font-style: italic;
}

/* Detail Footer */
.detail-footer {
    margin-top: 24px;
    padding: 16px 20px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-tertiary);
    font-size: 12px;
    text-align: center;
}
