/* ============================================================================
   Font Face
   ============================================================================ */

@font-face {
    font-family: 'ZCOOL KuaiLe';
    src: url('/static/fonts/ZCOOLKuaiLe.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ============================================================================
   Base Styles
   ============================================================================ */

:root {
    /* Primary - Soft Purple (warm & curious) */
    --primary: #9f69e1;
    --primary-dark: #8b5cf6;

    /* Secondary - Curiosity-inspiring Teal */
    --secondary: #2dd4bf;
    --secondary-dark: #14b8a6;

    /* Accent - Playful Gold */
    --accent: #fbbf24;

    /* Status Colors */
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;

    /* Warm Gray Palette */
    --gray-50: #fdfcfb;
    --gray-100: #f7f5f3;
    --gray-200: #ede9e5;
    --gray-300: #ddd6cf;
    --gray-400: #b8aea4;
    --gray-500: #8c8279;
    --gray-600: #5f574f;
    --gray-700: #433d37;
    --gray-800: #2d2924;
    --gray-900: #1c1917;

    /* Fun Accents */
    --lavender: #c4b5fd;
    --pink: #fda4af;

    --radius: 8px;
    --shadow: 0 1px 3px rgba(44, 41, 36, 0.1), 0 1px 2px rgba(44, 41, 36, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(44, 41, 36, 0.1), 0 4px 6px -2px rgba(44, 41, 36, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ============================================================================
   Site Header
   ============================================================================ */

.site-header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0.75rem 0;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo:hover {
    color: var(--primary);
}

.logo-img {
    height: 32px;
    width: auto;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-greeting {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* ============================================================================
   Auth Styles
   ============================================================================ */

.auth-container {
    min-height: calc(100vh - 100px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: white;
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
    text-align: center;
    margin-bottom: 2rem;
}

.auth-form {
    margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn:hover {
    background: var(--gray-200);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-100);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #10b981;
}

.btn-warning {
    background: var(--warning);
    color: var(--gray-800);
}

.btn-warning:hover {
    background: #f59e0b;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #ef4444;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-full {
    width: 100%;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
}

/* ============================================================================
   Forms
   ============================================================================ */

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* ============================================================================
   Status Badges
   ============================================================================ */

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    text-transform: uppercase;
}

.status-published {
    background: #d1fae5;
    color: #065f46;
}

.status-hidden {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ============================================================================
   Admin Styles
   ============================================================================ */

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.admin-header h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
}

.admin-nav {
    display: flex;
    gap: 0.75rem;
}

.questionnaire-list {
    display: grid;
    gap: 1rem;
}

.questionnaire-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.questionnaire-card .card-cover {
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
}

.questionnaire-card .card-cover img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.questionnaire-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.questionnaire-card h3 {
    font-size: 1.125rem;
    color: var(--gray-900);
}

.questionnaire-card .card-description {
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.questionnaire-card .card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
}

.questionnaire-card .card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Generate Form */
.generate-section {
    max-width: 600px;
}

.section-intro {
    color: var(--gray-600);
    margin-bottom: 2rem;
}

.generate-form {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.loading-container {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: block;
}

.htmx-request.htmx-indicator {
    display: block;
}

/* Review Page */
.review-section {
    max-width: 800px;
}

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

.review-actions {
    display: flex;
    gap: 0.5rem;
}

.info-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.info-card h3 {
    font-size: 1rem;
    color: var(--gray-900);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-100);
}

.info-card p {
    margin-bottom: 0.5rem;
    color: var(--gray-600);
}

.questions-list {
    display: grid;
    gap: 0.75rem;
}

.question-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.question-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    background: var(--gray-50);
}

.question-header:hover {
    background: var(--gray-100);
}

.question-number {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.question-content {
    flex: 1;
    font-size: 0.875rem;
}

.toggle-icon {
    color: var(--gray-400);
    font-size: 1.25rem;
}

.question-options {
    padding: 0.75rem 1rem;
    background: white;
}

.option-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-100);
}

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

.option-content {
    color: var(--gray-700);
}

.option-scores {
    color: var(--gray-400);
    font-family: monospace;
    font-size: 0.75rem;
}

.results-list {
    display: grid;
    gap: 1rem;
}

.result-item {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.result-item h4 {
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.result-item p {
    font-size: 0.875rem;
}

.result-vector {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
}

/* List Table */
.questionnaire-table {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-header,
.table-row {
    display: grid;
    grid-template-columns: 60px 2fr 1fr 1fr 1fr 1fr 1fr;
    padding: 1rem;
    align-items: center;
    gap: 1rem;
}

.col-thumb {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-image {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.table-header {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.table-row {
    border-top: 1px solid var(--gray-100);
    font-size: 0.875rem;
}

.table-row:hover {
    background: var(--gray-50);
}

/* ============================================================================
   User Styles
   ============================================================================ */

.user-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.user-header .header-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.user-header .header-text {
    text-align: left;
}

.user-header h1 {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 3rem;
    -webkit-background-clip: text;
    background-clip: text;
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
    text-shadow: 2px 2px 4px rgba(102, 126, 234, 0.2);
}

.user-header .subtitle {
    font-family: 'ZCOOL KuaiLe', cursive;
    color: var(--gray-500);
    font-size: 1.125rem;
}

.user-nav {
    margin-top: 1rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

.empty-hint {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.test-card {
    display: block;
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.test-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.test-cover {
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
}

.test-cover img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.test-title {
    font-size: 1.25rem;
    color: var(--gray-900);
    margin-bottom: 0.75rem;
}

.test-description {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.test-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.test-action {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.875rem;
}

/* Test Detail Page */
.test-detail-page {
    max-width: 600px;
    margin: 0 auto;
}

.back-link {
    display: inline-block;
    color: var(--gray-500);
    text-decoration: none;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.back-link:hover {
    color: var(--gray-700);
}

.test-detail-card {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.test-cover-large {
    margin: -2rem -2rem 1.5rem -2rem;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
}

.test-cover-large img {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
}

.test-detail-card h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.test-detail-card .test-description {
    font-size: 1rem;
    margin-bottom: 2rem;
}

.test-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-top: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
}

.info-item {
    text-align: center;
}

.info-label {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.info-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* Question Page */
.question-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
}

.progress-bar {
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.progress-text {
    text-align: center;
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.question-card {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.question-card .question-content {
    font-size: 1.25rem;
    color: var(--gray-900);
    margin-bottom: 2rem;
    text-align: center;
    line-height: 1.6;
}

.options-list {
    display: grid;
    gap: 0.75rem;
}

.option-button {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    text-align: left;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--gray-800);
}

.option-button:hover {
    border-color: var(--primary);
    background: white;
}

.option-loading {
    color: var(--gray-400);
}

/* Narrative Box */
.narrative-box {
    background: linear-gradient(135deg, #fefcfb 0%, #fef7f4 100%);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.narrative-text {
    font-style: italic;
    color: var(--gray-700);
    line-height: 1.8;
    font-size: 1rem;
}

/* Narrative Animation Styles */
.narrative-container {
    display: flex;
    flex-direction: column;
    min-height: 60vh;
    justify-content: center;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.narrative-container.centered {
    justify-content: center;
}

.narrative-container.at-top {
    justify-content: flex-start;
    min-height: auto;
}

.narrative-box.animated {
    opacity: 0;
    transform: scale(0.95);
    animation: narrativeFadeIn 0.6s ease-out forwards;
}

@keyframes narrativeFadeIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Typewriter cursor */
.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--primary);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: cursorBlink 0.8s infinite;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Question content fade in */
.question-content-wrapper {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-content-wrapper.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Progress bar animation delay */
.progress-wrapper {
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

.progress-wrapper.visible {
    opacity: 1;
}

/* Option Narrative in Admin */
.option-narrative {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-50);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--gray-600);
    border-left: 2px solid var(--primary);
}

.option-narrative em {
    font-style: italic;
}

/* Result Page */
.result-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
}

.result-card {
    background: white;
    border-radius: var(--radius);
    padding: 3rem 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.result-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.result-card .result-image {
    margin-bottom: 1.5rem;
}

.result-card .result-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.result-title {
    font-size: 2rem;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.result-description {
    color: var(--gray-600);
    line-height: 1.8;
    margin-bottom: 2rem;
}

.result-from {
    font-size: 0.875rem;
    color: var(--gray-400);
    margin-bottom: 2rem;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

/* Error Message */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}

/* Error Page */
.error-page {
    max-width: 500px;
    margin: 4rem auto;
    text-align: center;
    padding: 2rem;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.error-page h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.error-description {
    color: var(--gray-600);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.error-actions .btn {
    min-width: 120px;
}

/* Stream Output */
.stream-output {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--gray-800);
    color: var(--secondary);
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ============================================================================
   Result Editing Styles
   ============================================================================ */

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

.result-header h4 {
    margin: 0;
}

.result-thumbnail {
    max-width: 200px;
    height: auto;
    border-radius: var(--radius);
    margin: 0.75rem 0;
    box-shadow: var(--shadow);
}

.image-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.image-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.image-section.disabled {
    opacity: 0.6;
}

.current-image {
    margin-bottom: 1rem;
}

.result-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.share-image-preview {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px dashed var(--gray-300);
}

.share-image-preview h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--gray-600);
}

.share-image-thumbnail {
    max-height: 300px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.no-share-image {
    color: var(--gray-500);
    font-style: italic;
    margin: 0.5rem 0;
}

.share-image-form {
    margin-top: 0.75rem;
}

.image-controls {
    margin-bottom: 1rem;
}

.prompt-loading-indicator {
    margin-left: 1rem;
    color: var(--gray-500);
}

.prompt-form {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    margin-bottom: 1rem;
}

.prompt-textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.prompt-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.image-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.success-message {
    color: #065f46;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.info-message {
    color: var(--gray-500);
    font-style: italic;
}

/* Image Library */
.image-library {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    margin-top: 1rem;
}

.image-library h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--gray-700);
}

.image-library .empty-message {
    color: var(--gray-500);
    font-style: italic;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.library-image-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-50);
}

.library-image-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.library-image-item .image-info {
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.library-image-item form {
    padding: 0.5rem;
    padding-top: 0;
}

.library-image-item .btn-small {
    width: 100%;
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
}

.library-loading-indicator {
    margin-left: 1rem;
    color: var(--gray-500);
}

.form-static {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--gray-600);
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: var(--radius);
}

/* ============================================================================
   Inventory - RPG Collection Bag
   ============================================================================ */

/* Warm color palette for inventory */
:root {
    --inventory-bg: #fef7ed;
    --inventory-border: #d4a574;
    --inventory-slot-bg: #fff8f0;
    --inventory-slot-border: #e8c9a8;
    --inventory-slot-empty: #f5e6d3;
    --inventory-shadow: 0 4px 12px rgba(180, 140, 100, 0.15);
    --inventory-glow: 0 0 8px rgba(255, 200, 100, 0.4);
}

.inventory-section {
    background: var(--inventory-bg);
    border: 3px solid var(--inventory-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--inventory-shadow);
}

.inventory-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #f0c36d;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(240, 195, 109, 0.2);
}

.inventory-warning .warning-icon {
    font-size: 1.2rem;
}

.inventory-warning .warning-text {
    color: #856404;
    font-size: 0.9rem;
}

.inventory-warning .warning-text a {
    color: #704b00;
    font-weight: 600;
    text-decoration: underline;
}

.inventory-warning .warning-text a:hover {
    color: #503500;
}

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

.inventory-title {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 1.25rem;
    color: #8b5a2b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inventory-title::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #d4a574 0%, #8b5a2b 100%);
    border-radius: 4px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.inventory-expand-btn {
    background: transparent;
    border: 2px solid var(--inventory-border);
    border-radius: 8px;
    padding: 0.25rem 0.75rem;
    color: #8b5a2b;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.inventory-expand-btn:hover {
    background: var(--inventory-border);
    color: white;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.inventory-grid.expanded {
    max-height: 400px;
    overflow-y: auto;
}

.inventory-slot {
    aspect-ratio: 1;
    background: var(--inventory-slot-bg);
    border: 2px solid var(--inventory-slot-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    position: relative;
}

.inventory-slot:hover:not(.empty) {
    border-color: var(--inventory-border);
    box-shadow: var(--inventory-glow);
    transform: scale(1.05);
}

.inventory-slot.empty {
    background: var(--inventory-slot-empty);
    border-style: dashed;
    cursor: default;
}

.inventory-slot.empty:hover {
    transform: none;
    box-shadow: none;
}

.inventory-item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.inventory-item-placeholder {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 1.5rem;
    color: var(--inventory-border);
    text-align: center;
    padding: 0.25rem;
    word-break: break-all;
}

/* Inventory Modal */
.inventory-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.inventory-modal {
    background: white;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: modal-appear 0.2s ease-out;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--gray-100);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    color: var(--gray-500);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* Inventory Item Detail */
.inventory-detail {
    padding: 1.5rem;
    text-align: center;
}

.detail-image {
    margin-bottom: 1rem;
}

.detail-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.detail-test-name {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

.detail-result-title {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 1.5rem;
    color: var(--gray-900);
    margin: 0 0 0.75rem 0;
}

.detail-description {
    color: var(--gray-600);
    line-height: 1.6;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.detail-date {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-bottom: 1.5rem;
}

.detail-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* Retake Warning */
.retake-warning {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
}

.retake-warning .warning-icon {
    background: #f97316;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.retake-warning p {
    margin: 0;
    color: #9a3412;
    font-size: 0.875rem;
}

/* Guest Signup Prompt */
.guest-signup-prompt {
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #fef7f4 0%, #fef0eb 100%);
    border: 2px solid var(--pink);
    border-radius: var(--radius);
    text-align: center;
}

.guest-signup-prompt p {
    color: var(--gray-700);
    font-weight: 500;
    margin-bottom: 1rem;
}

/* Empty Inventory State */
.inventory-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #8b5a2b;
}

.inventory-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.inventory-empty-text {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 1rem;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .question-page {
        padding: 1rem 0.75rem;
    }

    .question-card {
        padding: 1.5rem 1rem;
    }

    .question-card .question-content {
        font-size: 1.125rem;
    }

    .narrative-box {
        padding: 1rem 1.25rem;
    }

    .result-page {
        padding: 1rem 0.75rem;
    }

    .result-card {
        padding: 2rem 1.25rem;
    }

    .admin-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .admin-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .table-header,
    .table-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .table-header {
        display: none;
    }

    .table-row {
        padding: 1rem;
    }

    .test-grid {
        grid-template-columns: 1fr;
    }

    .test-info {
        flex-direction: column;
        gap: 1rem;
    }

    .result-actions {
        flex-direction: column;
        align-items: center;
    }

    /* Inventory responsive */
    .inventory-grid {
        grid-template-columns: repeat(4, 1fr);
        max-height: 180px;
    }

    .inventory-grid.expanded {
        max-height: 400px;
    }

    .inventory-section {
        padding: 1rem;
    }

    .inventory-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .inventory-grid {
        grid-template-columns: repeat(3, 1fr);
        max-height: 160px;
    }
}

/* ============================================================================
   Share Feature Styles
   ============================================================================ */

.btn-share {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
}

.btn-share:hover {
    background: linear-gradient(135deg, #6d4a84, #3a7a84);
    transform: translateY(-1px);
}

.share-loading {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.share-result {
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.share-image-preview {
    max-width: 100%;
    max-height: 60vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.share-actions {
    margin-top: 1rem;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.share-hint {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Share Modal */
.share-modal {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    background: white;
    /* Center the dialog */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.share-modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.share-modal-content {
    padding: 1.5rem;
    text-align: center;
}

.share-modal-content p {
    margin-bottom: 1rem;
    color: var(--gray-600);
}

.share-modal .share-image {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius);
    margin: 0 auto 1rem auto;
}

.share-modal .btn {
    margin-top: 0.5rem;
}

/* Form hint for admin */
.form-hint {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Result sharing text in admin review */
.result-sharing-text {
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, rgba(139, 92, 166, 0.1), rgba(66, 135, 145, 0.1));
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.9rem;
    color: var(--gray-700);
}
