* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Utility class for hiding elements */
.hidden {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #e8e9eb;
    min-height: 100vh;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #6BA4D6 0%, #5B9BD5 100%);
    color: white;
    padding: 28px;
    text-align: center;
}

header h1 {
    font-size: 2.125em;
    margin-bottom: 8px;
}

header p {
    font-size: 1.02em;
    opacity: 0.95;
}

/* Progress Message */
.progress-message {
    display: none;
    padding: 16px 40px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

.progress-message.visible {
    display: block;
}

.progress-message-text {
    color: #666666;
    font-size: 15px;
}

#progressMessageReady {
    display: block;
    text-align: center;
    color: #5B9BD5;
    font-weight: 600;
    animation: pulse-ready 1.5s ease-in-out infinite;
}

.progress-message-icon {
    font-size: 16px;
    margin-left: 6px;
    vertical-align: text-bottom;
    animation: pulse-info 2s ease-in-out infinite;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
    user-select: none;
}

.progress-message-icon:hover {
    opacity: 1;
    transform: scale(1.15);
}

.progress-message-icon.active {
    opacity: 1;
    animation: none;
    filter: brightness(1.2);
}

@keyframes pulse-info {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes pulse-ready {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Horizontal Stepper */
.horizontal-stepper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 40px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.stepper-track {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 0 0 auto;
    min-width: 80px;
}

.stepper-node {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    z-index: 1;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stepper-node.pending {
    background: #e5e7eb;
    color: #6b7280;
}

.stepper-node.active {
    background: #5B9BD5;
    color: white;
    animation: stepper-pulse 1.5s ease-in-out infinite;
}

.stepper-node.completed {
    background: #22c55e;
    color: white;
}

.stepper-node.failed {
    background: #ef4444;
    color: white;
    animation: failed-attention 1.5s ease-in-out infinite;
}

.stepper-label {
    font-size: 14px;
    margin-top: 8px;
    text-align: center;
    max-width: 90px;
    color: #6b7280;
    line-height: 1.3;
    font-weight: 500;
}

.stepper-label.active {
    color: #5B9BD5;
    font-weight: 600;
}

.stepper-label.completed {
    color: #22c55e;
}

.stepper-label.failed {
    color: #ef4444;
}

.stepper-connector {
    flex: 1;
    height: 3px;
    background: #e5e7eb;
    margin: 0 8px;
    position: relative;
    top: 20px;
    z-index: 0;
    min-width: 20px;
}

.stepper-connector.completed {
    background: #22c55e;
}

@keyframes stepper-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 120, 212, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(0, 120, 212, 0); }
}

@keyframes failed-attention {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Substep Display - Inside Stepper */
.substep-display {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px 25px;
    margin-top: 25px;
    text-align: center;
    display: none;
    width: 33%;
    min-width: 300px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.substep-display.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.substep-text {
    font-size: 14px;
    color: #5B9BD5;
    font-weight: 600;
    display: inline;
}

.substep-dots {
    display: inline-flex;
    align-items: center;
    height: 8px;
    margin-left: 4px;
    vertical-align: middle;
    white-space: nowrap;
}

.substep-dot {
    width: 3px;
    height: 3px;
    margin: 0 2px;
    background-color: #5B9BD5;
    border-radius: 50%;
    opacity: 0.4;
    animation: dotPulse 1.5s infinite ease-in-out;
}

.substep-dot:nth-child(1) { animation-delay: 0s; }
.substep-dot:nth-child(2) { animation-delay: 0.2s; }
.substep-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 100% { transform: scale(0.8); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* Error Context Container - Short error above input */
.error-context-outer {
    display: none;
    padding: 10px 10px;
    background: #f8f9fa;
}

.error-context-outer.visible {
    display: block;
}

.error-context {
    display: none;
    background: #f8f9fa;
    border: 2px solid #fca5a5;
    border-radius: 8px;
    padding: 16px 16px;
    margin: 0 40px 0px 40px;
}

.error-context.visible {
    display: block;
}

.error-context-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.error-context-icon {
    color: #dc2626;
    font-size: 20px;
}

.error-context-title {
    font-weight: 600;
    color: #dc2626;
    font-size: 1em;
}

.error-context-message {
    color: #991b1b;
    line-height: 1.5;
    font-size: 0.95em;
}

/* Judge Feedback Container - Detailed feedback after analysis */
.judge-feedback {
    display: none;
    background: #fef3c7;
    border: 2px solid #fbbf24;
    border-radius: 8px;
    padding: 24px;
}

.judge-feedback.full-width {
    grid-column: 1 / -1;
}

.judge-feedback.visible {
    display: block;
}

.judge-feedback-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.judge-feedback-icon {
    color: #d97706;
    font-size: 24px;
}

.judge-feedback-title {
    font-weight: 600;
    color: #92400e;
    font-size: 1.1em;
}

.judge-feedback-content {
    color: #78350f;
    line-height: 1.6;
}

.judge-feedback-tip {
    background: #fef3c7;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #fbbf24;
    margin-top: 15px;
}

.judge-feedback-issue {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.judge-feedback-issue-title {
    font-weight: 600;
    color: #d97706;
    margin-bottom: 8px;
}

.judge-feedback-issue-reason {
    margin-bottom: 10px;
    color: #78350f;
}

.judge-feedback-suggestions {
    margin: 10px 0;
    padding-left: 25px;
}

.judge-feedback-suggestions li {
    margin: 5px 0;
    color: #78350f;
}

.judge-feedback-content-wrapper {
    background: white;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
}


.input-section {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
    font-size: 1.1em;
}

textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.3s, background-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #5B9BD5;
    box-shadow: 0 0 0 3px rgba(91, 155, 213, 0.15);
}

textarea:disabled {
    background-color: #f8f9fa;
    cursor: not-allowed;
    opacity: 0.7;
}

/* File Upload Section */
.file-upload-section {
    margin-top: 0;
}

.file-upload-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s;
    user-select: none;
}

.file-upload-toggle:hover {
    color: #4b5563;
}

.file-upload-toggle-icon {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.file-upload-toggle-icon.expanded {
    transform: rotate(90deg);
}

.file-upload-toggle-text {
    font-size: 12px;
}

.file-upload-toggle-hint {
    font-size: 13px;
    color: #9ca3af;
    font-weight: 400;
}

.file-upload-toggle-hint.has-files {
    color: #6b7280;
}

.file-upload-collapsible {
    max-height: 0;
    width: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, width 0s 0.3s, margin-top 0.3s ease-out;
    margin-top: 0;
}

.file-upload-collapsible.expanded {
    max-height: 400px;
    width: 100%;
    flex: 1 1 100%;
    min-width: 0;
    margin-top: 8px;
    transition: max-height 0.3s ease-out, width 0s, margin-top 0.3s ease-out;
}

.file-upload-area {
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    transition: all 0.3s;
    background: white;
}

.file-upload-area.drag-over {
    border-color: #5B9BD5;
    background: rgba(91, 155, 213, 0.05);
}

.file-upload-placeholder {
    cursor: pointer;
    padding: 8px;
}

.file-upload-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 6px;
}

.file-upload-text {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 4px;
}

.file-upload-hint {
    color: #9ca3af;
    font-size: 12px;
    margin: 0;
}

.file-list {
    margin-top: 10px;
    text-align: left;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 4px;
    border: 1px solid #e5e7eb;
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.file-item-icon {
    font-size: 18px;
}

.file-item-details {
    flex: 1;
}

.file-item-name {
    font-weight: 500;
    font-size: 13px;
    color: #374151;
    word-break: break-all;
}

.file-item-size {
    font-size: 11px;
    color: #6b7280;
    margin-top: 1px;
}

.file-item-remove {
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
}

.file-item-remove:hover {
    background: #4b5563;
}

.file-remove-all-container {
    text-align: right;
    margin-top: 8px;
}

.file-remove-all-btn {
    padding: 6px 12px;
}

.button-container {
    text-align: center;
    margin-top: 10px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.analyze-btn {
    background: linear-gradient(135deg, #6BA4D6 0%, #5B9BD5 100%);
    color: white;
    border: none;
    padding: 10px 28px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-block;
}

.analyze-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(91, 155, 213, 0.4);
}

.analyze-btn:active {
    transform: translateY(0);
}

.analyze-btn:disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

.analyze-btn-secondary {
    background: white;
    color: #5B9BD5;
    border: 2px solid #5B9BD5;
}

.analyze-btn-secondary:hover:not(:disabled) {
    background: #f0f7ff;
    box-shadow: 0 8px 20px rgba(91, 155, 213, 0.2);
}

.analyze-btn-secondary:disabled {
    background: #e8e8e8;
    color: #999;
    border-color: #ccc;
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

.results-section {
    display: none;
    padding: 40px;
}

.results-section.active {
    display: block;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.result-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 25px;
    border: 2px solid #e0e0e0;
    transition: box-shadow 0.3s;
}

.result-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.result-card h2 {
    color: #5B9BD5;
    margin-bottom: 15px;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-card.full-width {
    grid-column: 1 / -1;
}

.section-explanation {
    font-size: 0.9em;
    color: #64748b;
    font-style: italic;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: #f1f5f9;
    border-radius: 4px;
    line-height: 1.5;
}

.diagram-image {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
}

.analysis-content {
    background: white;
    padding: 20px;
    border-radius: 6px;
    line-height: 1.8;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.analysis-content h3 {
    color: #5B9BD5;
    margin: 15px 0 10px 0;
    font-size: 1.1em;
}

/* List styling for markdown content */
.analysis-content ul,
.analysis-content ol {
    margin-left: 0;
    margin-bottom: 10px;
    padding-left: 0;
    list-style-position: inside;
}

.analysis-content li {
    margin: 4px 0;
    padding-left: 4px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Reduce paragraph spacing for inline markdown rendering */
.analysis-content p,
.sub-section p,
.sub-section div > p,
.resource-item p,
.improvement-item p,
.improvement-suggestion p,
.improvement-impact p {
    margin: 0;
    display: inline;
}

/* Block-level paragraphs for standalone content (not inline) */
.analysis-content > p,
.sub-section > div > p:first-child {
    display: block;
    margin-bottom: 8px;
}

/* Fix list items appearing inline */
.analysis-content li,
.sub-section li {
    display: list-item;
    margin: 4px 0;
    padding-left: 4px;
}

/* Ensure proper list display */
.sub-section ul,
.sub-section ol,
.sub-section div ul,
.sub-section div ol {
    margin-left: 0;
    margin-bottom: 10px;
    margin-top: 0;
    padding-left: 0;
    display: block;
    list-style-position: inside;
}

/* Remove extra top margin from first element after heading */
.sub-section h4 + div,
.sub-section h4 + p,
.sub-section h4 + ol,
.sub-section h4 + ul,
.sub-section h4 + div > p:first-child,
.sub-section h4 + div > ol:first-child,
.sub-section h4 + div > ul:first-child {
    margin-top: 0;
}

/* Block for array items rendered as markdown */
.list-item-block {
    margin-bottom: 4px;
}

.list-item-block:last-child {
    margin-bottom: 0;
}

.resource-item {
    background: white;
    padding: 12px;
    margin: 10px 0;
    border-radius: 6px;
    border-left: 4px solid #5B9BD5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.resource-name {
    font-weight: bold;
    color: #333;
    font-size: 1.05em;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.resource-details {
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.cost-total {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 20px;
}

.cost-total .amount {
    font-size: 2.5em;
    font-weight: bold;
    margin: 10px 0;
}

.improvement-item {
    background: white;
    padding: 15px;
    margin: 10px 0;
    border-radius: 6px;
    border-left: 4px solid #ffc107;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.improvement-category {
    display: inline-block;
    background: #ffc107;
    color: #000;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
    margin-bottom: 8px;
}

.improvement-suggestion {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.improvement-impact {
    color: #666;
    font-size: 0.9em;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure inline rendering for improvement suggestion/impact content */
.improvement-suggestion > *,
.improvement-impact > * {
    display: inline;
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 9px 22px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, #6BA4D6 0%, #5B9BD5 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.info-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.sub-section {
    background: white;
    padding: 15px;
    margin: 10px 0;
    border-radius: 6px;
    border-left: 4px solid #6c5ce7;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.sub-section h4 {
    margin: 0 0 10px 0;
    color: #6c5ce7;
    font-size: 1em;
}

.sub-section h5 {
    margin: 0 0 10px 0;
    font-size: 1em;
}

.sub-section p {
    margin: 0;
    color: #555;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.sub-section table th,
.sub-section table td {
    text-align: left;
    vertical-align: top;
    padding: 6px 12px;
}

.sub-section table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
}

.sub-section-table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
}

/* Mobile cards for sub-section tables */
.mobile-cards {
    display: none;
}

.mobile-card {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    border-left: 3px solid #6c5ce7;
}

.mobile-card-title {
    font-weight: 600;
    font-size: 0.95em;
    color: #2d3436;
    margin-bottom: 8px;
}

.mobile-card-field {
    font-size: 0.9em;
    color: #555;
    margin: 4px 0;
    line-height: 1.5;
}

.mobile-card-field strong {
    color: #333;
}

.sub-section.uncertainty-section {
    border-left-color: #fdcb6e;
    background: #fffef5;
}

.sub-section.uncertainty-section h4 {
    color: #d68910;
}

.assumption-resource {
    padding: 10px;
    margin: 8px 0;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.95em;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-disclaimer-short {
    background: #fff9e6;
    border: 1px solid #ffd966;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 10px 0 15px 0;
    font-size: 0.85em;
    color: #856404;
    line-height: 1.4;
}

.ai-disclaimer-short.full-width {
    grid-column: 1 / -1;
}

.ai-disclaimer-long {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 30px 0 20px 0;
    font-size: 0.9em;
    color: #495057;
    line-height: 1.6;
}

.ai-disclaimer-long h3 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #212529;
    font-size: 1.1em;
}

.ai-disclaimer-long p {
    margin: 0 0 10px 0;
}

.ai-disclaimer-long p:last-child {
    margin-bottom: 0;
}

.alternative-text {
    color: #888;
    font-size: 0.9em;
    font-style: italic;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.no-diagram-message {
    color: #666;
    font-style: italic;
    padding: 20px;
    text-align: center;
}

.confidence-bar {
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.5s ease;
}

.confidence-fill.high {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.confidence-fill.medium {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
}

.confidence-fill.low {
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
}

.confidence-text {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    color: #333;
    font-size: 0.9em;
}

/* Utility classes for JS-generated content (CSP-safe replacements for inline styles) */
.sub-section-detail {
    margin-top: 8px;
    color: #555;
}

.cost-total-title {
    font-size: 1.1em;
}

.cost-total-note {
    font-size: 0.9em;
    opacity: 0.9;
}

.resource-error {
    color: #dc3545;
}

.cost-disclaimer {
    margin-top: 15px;
    font-size: 0.9em;
    color: #666;
}

/* Progressive result card states */
.result-card.pending {
    opacity: 0.5;
    position: relative;
    background: linear-gradient(90deg, #f8f9fa 25%, #e9ecef 50%, #f8f9fa 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.result-card.pending::after {
    content: "Waiting for data...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-style: italic;
    background: rgba(248, 249, 250, 0.9);
    padding: 10px 20px;
    border-radius: 4px;
}

.result-card.pending > *:not(h2) {
    visibility: hidden;
}

.result-card.ready {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Collapsible Section Styles */
.section-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-toggle {
    transition: transform 0.3s ease;
    font-size: 0.8em;
}

.section-toggle.collapsed {
    transform: rotate(-90deg);
}

.section-content {
    transition: opacity 0.3s ease, padding 0.3s ease;
    opacity: 1;
}

.section-content.collapsed {
    overflow: hidden;
    opacity: 0;
    padding: 0;
    /* max-height is controlled exclusively by inline style (set by toggleSection) */
}

/* Quick Links Navigation */
.quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
}

.quick-links-label {
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    margin-right: 5px;
}

.quick-link {
    color: #5B9BD5;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 4px;
    background: white;
    border: 1px solid #ddd;
    transition: all 0.2s;
}

.quick-link:hover {
    background: #5B9BD5;
    color: white;
    border-color: #5B9BD5;
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #5B9BD5;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.2s;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    transform: translateY(-4px);
    background: #4a8ac4;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Spinning animation for export loading */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Security Analysis severity badges */
.severity-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
    display: inline-block;
    white-space: nowrap;
    width: fit-content;
}

.severity-critical {
    background-color: #dc3545;
    color: white;
}

.severity-high {
    background-color: #fd7e14;
    color: white;
}

.severity-medium {
    background-color: #ffc107;
    color: #000;
}

.severity-low {
    background-color: #28a745;
    color: white;
}

/* Site Footer */
.site-footer {
    text-align: center;
    padding: 16px 20px;
    font-size: 0.85em;
    color: #6c757d;
    border-top: 1px solid #e0e0e0;
}

.site-footer a {
    color: #5B9BD5;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

.footer-separator {
    margin: 0 8px;
    color: #adb5bd;
}

.footer-copyright {
    color: #adb5bd;
}

.help-page .container {
    max-width: 900px;
}

/* Legal Pages */
.legal-content {
    padding: 40px;
    line-height: 1.7;
    color: #333;
}

.legal-content h1 {
    font-size: 1.8em;
    margin-bottom: 8px;
    color: #212529;
}

.legal-content h2 {
    font-size: 1.3em;
    margin-top: 28px;
    margin-bottom: 12px;
    color: #212529;
}

.legal-content h3 {
    font-size: 1.1em;
    margin-top: 20px;
    margin-bottom: 8px;
    color: #333;
}

.legal-content p {
    margin-bottom: 12px;
}

.legal-content ul {
    margin: 0 0 12px 24px;
}

.legal-content li {
    margin-bottom: 6px;
}

.legal-effective-date {
    color: #6c757d;
    margin-bottom: 20px;
}

.legal-back-link {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.legal-back-link a {
    color: #5B9BD5;
    text-decoration: none;
}

.legal-back-link a:hover {
    text-decoration: underline;
}

.header-back-link {
    color: white;
    text-decoration: none;
    opacity: 0.9;
}

.header-back-link:hover {
    opacity: 1;
    text-decoration: underline;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.95em;
}

.legal-table th,
.legal-table td {
    border: 1px solid #dee2e6;
    padding: 10px 14px;
    text-align: left;
}

.legal-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #212529;
}

.legal-table td {
    color: #333;
}

.legal-content a {
    color: #5B9BD5;
    text-decoration: none;
}

.legal-content a:hover {
    text-decoration: underline;
}

/* ===== Model Selector ===== */

/* Row that holds file-upload toggle and model selector */
.input-extras-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-top: 5px;
    gap: 0.5rem 2rem;
    flex-wrap: wrap;
}

.file-upload-section, .model-selector-container {
    flex: 0 0 auto;
}

.model-selector-container {
    position: relative;
    text-align: right;
    margin-left: auto;
}

.model-selector-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #6b7280;
    padding: 4px 0;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    user-select: none;
    font-weight: 500;
}

.model-selector-summary:hover {
    color: #4b5563;
}

.model-selector-label {
    color: #9ca3af;
}

.model-selector-current {
    font-weight: 500;
    color: #6b7280;
}

.model-selector-summary:hover .model-selector-current {
    color: #4b5563;
}

.model-selector-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    background: rgba(91, 155, 213, 0.12);
    color: #5B9BD5;
    font-weight: 600;
}

.model-selector-toggle {
    font-size: 12px;
    transition: transform 0.3s ease;
    order: -1;
}

.model-selector-toggle.expanded {
    transform: rotate(90deg);
}

.model-selector-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, margin-top 0.3s ease-out;
    margin-top: 0;
}

.model-selector-collapsible.expanded {
    max-height: 800px;
    margin-top: 0.3rem;
    transition: max-height 0.3s ease-out, margin-top 0.3s ease-out;
}

.model-selector-list {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.4rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 320px;
    max-width: 500px;
    text-align: left;
    margin-left: auto;
}

.model-selector-provider {
    padding: 0.2rem 0;
}

.model-selector-provider-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    padding: 0.3rem 0.6rem 0.15rem;
    font-weight: 600;
}

.model-selector-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #4b5563;
    transition: background 0.15s;
}

.model-selector-option:hover {
    background: rgba(91, 155, 213, 0.1);
}

.model-selector-option.selected {
    background: rgba(91, 155, 213, 0.15);
    color: #5B9BD5;
}

.model-selector-option-name-container {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-grow: 1;
}

.model-selector-option-name {
    font-weight: 500;
}

.model-selector-option-default {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #5B9BD5;
    opacity: 0.8;
}

/* Responsive: Tablet */
@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .result-card.full-width {
        grid-column: 1;
    }
    
    .horizontal-stepper {
        padding: 20px;
    }
    
    .stepper-node {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }
    
    .stepper-label {
        font-size: 11px;
        max-width: 70px;
    }
    
    .stepper-connector {
        top: 18px;
        min-width: 10px;
    }
}

/* Responsive: Mobile */
@media (max-width: 768px) {
    .substep-display {
        width: auto;
        min-width: 0;
        margin: 20px 20px 5px 20px;
        text-align: left;
    }
    
    .horizontal-stepper {
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
        gap: 0;
    }
    
    .stepper-track {
        flex-direction: column;
        width: 100%;
    }

    .stepper-step {
        flex-direction: row;
        min-width: auto;
        padding: 8px 0;
    }
    
    .stepper-node {
        width: 32px;
        height: 32px;
        font-size: 12px;
        flex-shrink: 0;
    }
    
    .stepper-label {
        margin-top: 0;
        margin-left: 12px;
        text-align: left;
        max-width: none;
        font-size: 13px;
    }
    
    .stepper-connector {
        display: none;
    }
    
    .input-section {
        padding: 10px 20px;
    }

    .model-selector-list {
        margin-left: 0;
        min-width: 100%;
    }

    .error-context {
        margin: 0 20px 20px;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    header p {
        font-size: 1em;
    }
    
    .button-container {
        text-align: center;
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }
    
    .analyze-btn {
        width: 100%;
        max-width: 300px;
    }
    
    /* Mobile: Adjusted textarea height */
    textarea {
        min-height: 140px;
    }
    
    /* Mobile: Smaller section headings */
    .result-card h2 {
        font-size: 1.2em;
    }
    
    /* Mobile: Reduced margins and padding */
    .results-section {
        padding: 15px;
    }
    
    .result-card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .analysis-content {
        padding: 12px;
    }
    
    body {
        padding: 10px;
    }
    
    /* Mobile: Show cards, hide tables in sub-sections */
    .sub-section .mobile-cards {
        display: block;
    }

    .sub-section table {
        display: none;
    }

    /* Mobile: Thinner colorful border lines */
    .sub-section {
        border-left-width: 3px;
        padding: 10px;
    }
    
    .resource-item {
        border-left-width: 3px;
        padding: 10px;
    }
    
    /* Mobile: Smaller export buttons */
    .btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .action-buttons {
        gap: 10px;
    }
    
    /* Mobile: Adjust scroll to top button */
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    /* Mobile: Adjust quick links */
    .quick-links {
        padding: 10px;
        gap: 8px;
    }
    
    .quick-link {
        font-size: 12px;
        padding: 5px 10px;
    }
    
    /* Mobile: Text wrapping fixes to prevent overflow */
    .container {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .analysis-content,
    .sub-section,
    .sub-section p,
    .resource-item,
    .resource-details,
    .improvement-item,
    .improvement-suggestion,
    .improvement-impact,
    .judge-feedback-content,
    .error-context-message,
    .alternative-text,
    .assumption-resource {
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
        hyphens: auto;
    }
    
    .resource-name,
    .file-item-name {
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    /* Prevent horizontal scroll on mobile - rely on .container { overflow: hidden } */
    
    /* Ensure cost section text wraps properly */
    .cost-total,
    .cost-total .amount {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

@media (max-width: 500px) {

    .progress-message {
        padding: 16px 20px;
        text-align: left;
    }

    .model-selector-container {
        flex: 1 0 100%;
        text-align: left;
        margin-left: 0;
    }
}
