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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: url('./assets/Background@2x.png') center center / cover no-repeat fixed;
    color: #000;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    height: 100vh;
    padding: 30px 54px;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: left;
    margin-bottom: 30px;
}

h1 {
    font-size: 36px;
    font-weight: 300;
    letter-spacing: 0;
    line-height: 1.21;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 12px;
    font-weight: 300;
    color: rgba(0, 0, 0, 0.6);
    line-height: 1.21;
}

/* Main Content Layout */
.content {
    display: grid;
    grid-template-columns: 1fr 339px;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 50px;
    flex: 1;
    min-height: 0;
}

/* Header positioned in grid */
header {
    grid-column: 1;
    grid-row: 1;
}

/* Video Section */
.video-section {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.video-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 38px;
    align-items: flex-end;
}

.video-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
    background: transparent;
}

.video-card:hover {
    opacity: 0.8;
}

.video-card.main-video {
    flex-basis: 100%;
}

.video-card:not(.main-video) {
    flex-basis: calc((100% - 38px) / 2);
    max-width: 221px;
}

.video-container {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.video-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    background: #000;
}

.video-card-title {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.21;
    color: rgba(0, 0, 0, 0.6);
}

.video-card.main-video .video-card-title {
    font-size: 16px;
    font-weight: 500;
    color: #000;
}

/* Chat Section */
.chat-section {
    grid-column: 2;
    grid-row: 2;
    width: 339px;
    margin-top: 40px;
    border: 1px solid #E2E8F0;
    border-radius: 5px;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.chat-section:not(.empty) {
    overflow: visible;
}

/* Empty State - Centered Input */
.chat-section.empty .chat-history {
    display: none;
}

.chat-section.empty .chat-bottom-container {
    display: none;
}

.chat-section.empty .chat-intro-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 15px;
    flex: 1;
    padding: 20px 20px 20px 16px;
}

/* Active State - Normal Chat */
.chat-section:not(.empty) .chat-intro-container {
    display: none;
}

.chat-section:not(.empty) .chat-history {
    display: flex;
    flex-direction: column;
    gap: 19px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px;
    min-height: 0;
}

.chat-section:not(.empty) .chat-bottom-container {
    display: block;
    padding: 18px;
    border-top: 1px solid #E2E8F0;
    flex-shrink: 0;
}

/* Chat Intro Text */
.chat-intro-text {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.21;
    color: rgba(0, 0, 0, 0.6);
    text-align: left;
}

/* Messages */
.message {
    padding: 12px;
    border-radius: 3.6px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.21;
    background: #fff;
    color: rgba(0, 0, 0, 0.6);
    width: 100%;
}

.message.user {
    background: #fff;
    color: rgba(0, 0, 0, 0.6);
}

.message.assistant {
    background: #fff;
    color: rgba(0, 0, 0, 0.6);
}

.message.error {
    background: #fee;
    color: #c00;
}

.message.system {
    background: #E3F2FD;
    color: #1565C0;
    font-size: 11px;
    padding: 8px 12px;
    text-align: center;
}

/* Citations */
.message-text + .message-text {
    margin-top: 10px;
}

.message-list {
    margin: 8px 0 0 16px;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message-list-item {
    line-height: 1.45;
    color: rgba(0, 0, 0, 0.75);
}

.message-text strong,
.message-list-item strong {
    font-weight: 600;
    color: #000;
}

.message-text em,
.message-list-item em {
    font-style: italic;
    color: rgba(0, 0, 0, 0.8);
}

.message-text code,
.message-list-item code {
    font-family: 'Source Code Pro', Menlo, monospace;
    background: rgba(15, 23, 42, 0.06);
    border-radius: 4px;
    padding: 0 4px;
    font-size: 11px;
    color: #111827;
}

.citation-badge {
    border: none;
    background: #444444;
    color: #fff;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 4px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    vertical-align: text-top;
}

.citation-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(17, 24, 39, 0.25);
}

.citation-badge:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.4);
    outline-offset: 2px;
}

/* Chat Input */
.chat-input-container {
    position: relative;
    width: 100%;
}

#queryInput,
#queryInputBottom {
    width: 100%;
    padding: 12px 45px 12px 12px;
    border: 1px solid #E5E5E5;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 300;
    line-height: 1.21;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    outline: none;
    background: #fff;
}

#queryInput:focus,
#queryInputBottom:focus {
    border-color: #ccc;
}

#queryInput::placeholder,
#queryInputBottom::placeholder {
    color: rgba(0, 0, 0, 0.6);
    font-weight: 300;
}

#sendBtn,
#sendBtnBottom {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    width: 17px;
    height: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    padding: 0;
}

#sendBtn:hover,
#sendBtnBottom:hover {
    opacity: 0.7;
}

#sendBtn:active,
#sendBtnBottom:active {
    transform: translateY(-50%) scale(0.95);
}

#sendBtn:disabled,
#sendBtnBottom:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#sendBtn img,
#sendBtnBottom img {
    width: 100%;
    height: 100%;
}

/* Detailed Analysis Toggle */

.chat-bottom-container {
    padding: 18px;
    border-top: 1px solid #E2E8F0;
    flex-shrink: 0;
}

.detailed-analysis-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 10px;
}

.analysis-mode-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.chat-info-button {
    position: absolute;
    left: 18px;
    bottom: 18px;
    font-size: 10px;
    text-decoration: underline;
    color: #00000060;
    background: transparent;
    border: none;
    cursor: pointer;
}

.chat-section:not(.empty) .chat-info-button {
    display: none;
}

.analysis-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 300;
    line-height: 1.21;
    color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    user-select: none;
}

.analysis-label input[type="checkbox"] {
    cursor: pointer;
    width: 10px;
    height: 10px;
    margin: 0;
}

.analysis-label .toggle-text {
    font-weight: 300;
}

.analysis-tooltip-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.analysis-tooltip-trigger {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: #fff;
    color: rgba(0, 0, 0, 0.6);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.analysis-tooltip-trigger:hover,
.analysis-tooltip-trigger:focus-visible {
    background: rgba(15, 23, 42, 0.08);
    color: #000;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.1);
}

.analysis-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translate(-50%, -6px);
    width: 260px;
    background: #fff;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
    border-radius: 3px;
    padding: 18px 20px;
    color: rgba(15, 23, 42, 0.75);
    font-size: 12px;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.analysis-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #fff;
    box-shadow: -3px -3px 6px rgba(15, 23, 42, 0.05);
}

.analysis-tooltip-wrapper:hover .analysis-tooltip,
.analysis-tooltip-wrapper:focus-within .analysis-tooltip {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.analysis-tooltip-title {
    font-size: 13px;
    font-weight: 600;
    color: #0F172A;
    margin-bottom: 8px;
}

.analysis-tooltip p {
    margin: 0 0 8px;
}

.analysis-tooltip p:last-child {
    margin-bottom: 0;
}

/* Loading */
.loading {
    text-align: center;
    padding: 12px;
    color: rgba(0, 0, 0, 0.6);
    font-size: 12px;
    font-weight: 400;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Processing state */
.video-card.processing .video-thumbnail {
    filter: blur(2px) brightness(0.7);
}

.video-card.processing::after {
    content: 'PROCESSING...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
    color: #fff;
    background: #000;
    padding: 4px 8px;
    letter-spacing: 1px;
    font-weight: 400;
}
.message-text {
    margin: 0;
    white-space: pre-wrap;
}
