:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.status-badge {
    font-size: 0.875rem;
    color: var(--success-color);
    background: #ecfdf5;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-badge.offline {
    color: #ef4444; /* Red-500 */
    background: #fef2f2; /* Red-50 */
}

/* Main Layout */
.main-container {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.grid-layout {
    display: grid;
    grid-template-columns: minmax(420px, 520px) 1fr;
    gap: 2rem;
    height: 100%;
    min-height: 600px;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Panels */
.panel {
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    margin-left: 1.75rem;
}

/* Input Panel */
.input-panel {
    height: fit-content;
}

.input-requirements {
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.requirements-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.requirements-example-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.requirements-example-img {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    display: block;
    cursor: pointer;
}

.requirements-example-img:hover {
    border-color: #cbd5e1;
}

.requirements-example-hint {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

#inferenceForm {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

/* Drag & Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem 1rem;
    text-align: center;
    position: relative;
    transition: all 0.2s;
    background: #f8fafc;
    cursor: pointer;
}

#imageDropZone {
    min-height: 340px;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.file-name {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
    word-break: break-all;
}

/* Image Preview */
.image-preview-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: calc(var(--radius-md) - 2px);
    overflow: hidden;
}

.image-preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo .lab {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.logo .lab-sep {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
}

.logo .lab:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 30;
}

/* File Select Box */
.file-select-box {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    background: white;
}

.file-select-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    overflow: hidden;
}

.browse-btn {
    background: #e2e8f0;
    color: var(--text-main);
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Analyze Button */
.analyze-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.analyze-btn:hover {
    background: var(--primary-hover);
}

.analyze-btn:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
}

/* Result Panel */
.result-panel {
    position: relative;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    padding: 2rem;
    text-align: center;
}

.empty-state .illustration {
    font-size: 4rem;
    color: #e2e8f0;
    margin-bottom: 1.5rem;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.pulse-ring {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 4px solid var(--primary-color);
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Result Content */
.result-content {
    padding: 2rem;
    overflow-y: auto;
    height: 100%;
}

.report-meta {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    align-items: flex-start;
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-item .value {
    font-weight: 600;
    color: var(--text-main);
}

.section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.diagnosis-section {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.diagnosis-text {
    font-family: 'Inter', sans-serif;
    line-height: 1.7;
    color: var(--text-main);
    white-space: pre-wrap;
    background: #ecfdf5;
    padding: 0.85rem 1.25rem 1.25rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--success-color);
    font-size: 1.05rem;
}

.answer-section {
    margin-top: 0;
    margin-bottom: 2rem;
}

.answer-text {
    font-family: 'Inter', sans-serif;
    line-height: 1.7;
    color: var(--text-main);
    white-space: pre-wrap;
    background: #eff6ff;
    padding: 0.85rem 1.25rem 1.25rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    font-size: 1.05rem;
}

.reasoning-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: 1.5rem;
}

.section-header {
    width: 100%;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-header i {
    color: var(--secondary-color);
}

.panel-content {
    background: white;
}

.reasoning-text {
    padding: 0.85rem 1.25rem 1.25rem;
    white-space: pre-wrap;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    background-color: #fafafa;
}

.meta-item .value-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meta-item.request-id {
    flex-basis: 100%;
}

.toggle-btn {
    margin-left: auto;
}

.reasoning-section.collapsed .panel-content {
    display: none;
}

.reasoning-section.collapsed .toggle-btn i {
    transform: rotate(180deg);
}

.reasoning-text.streaming::after,
.diagnosis-text.streaming::after,
.answer-text.streaming::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 4px;
    vertical-align: -0.1em;
    background: var(--secondary-color);
    animation: blink 1s steps(1) infinite;
}

.diagnosis-text.streaming::after {
    background: var(--success-color);
}

.answer-text.streaming::after {
    background: var(--primary-color);
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}
.meta-item .value.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.85rem;
    font-weight: 600;
}

.copy-btn {
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 0.375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.copy-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.reasoning-text strong {
    color: var(--text-main);
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.arrow {
    transition: transform 0.2s;
}

.disclaimer {
    margin-top: 2rem;
    padding: 1rem;
    background: #fff7ed;
    border: 1px solid #ffedd5;
    border-radius: var(--radius-md);
    color: #c2410c;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Feedback Section */
.feedback-section {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.feedback-section p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.feedback-buttons {
    display: flex;
    gap: 1rem;
}

.feedback-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.feedback-btn:hover {
    background: #f8fafc;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.feedback-btn.active.like {
    background: #ecfdf5;
    color: var(--success-color);
    border-color: var(--success-color);
}

.feedback-btn.active.dislike {
    background: #fef2f2;
    color: #ef4444;
    border-color: #ef4444;
}

.feedback-message {
    font-size: 0.875rem;
    color: var(--success-color);
    font-weight: 500;
    animation: fadeIn 0.5s ease-out;
}

.feedback-detail {
    width: min(520px, 100%);
    border: 1px solid var(--border-color);
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.feedback-detail-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.feedback-detail-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.feedback-textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.65rem 0.75rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    background: white;
    color: var(--text-main);
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.feedback-submit {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.feedback-submit:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--primary-color);
}

.actions {
    display: flex;
    gap: 0.5rem;
}
