/* Literature Study Styles - Complete Rewrite */
/* 3-Panel Layout: Chat | Content | Questions */
/* Single scrollbar solution */

/* ========================================
   CSS VARIABLES
   ======================================== */

:root {
    /* Colors */
    --study-primary: #4f46e5;
    --study-primary-light: #6366f1;
    --study-primary-dark: #4338ca;
    --study-bg: #f8fafc;
    --study-card-bg: #ffffff;
    --study-border: #e2e8f0;
    --study-text: #1e293b;
    --study-text-muted: #64748b;
    --study-success: #10b981;
    --study-warning: #f59e0b;
    --study-error: #ef4444;
    --chat-user-bg: #e0e7ff;
    --chat-ai-bg: #f1f5f9;

    /* Layout */
    --header-height: 56px;
    --chat-width: 340px;
    --question-width: 380px;
    --bottom-nav-height: 64px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ========================================
   GLOBAL RESET - PREVENT DOUBLE SCROLLBARS
   ======================================== */

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

html {
    height: 100%;
    overflow: hidden;
}

body {
    height: 100%;
    overflow: hidden;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--study-text);
    background: var(--study-bg);
}

/* ========================================
   LOGIN PAGE STYLES
   ======================================== */

.study-container {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

.study-container .back-button {
    align-self: flex-start;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    margin-bottom: 40px;
    transition: background 0.2s;
}

.study-container .back-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 3em;
    display: block;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 1.75em;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--study-text-muted);
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--study-border);
    border-radius: 10px;
    font-size: 1em;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--study-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.story-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.story-option {
    cursor: pointer;
}

.story-option input[type="radio"] {
    display: none;
}

.story-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 2px solid var(--study-border);
    border-radius: 12px;
    transition: all 0.2s;
}

.story-option input:checked + .story-card {
    border-color: var(--study-primary);
    background: rgba(79, 70, 229, 0.05);
}

.story-card:hover {
    border-color: var(--study-primary-light);
}

.story-icon {
    font-size: 2em;
}

.story-info h3 {
    font-size: 1.1em;
    margin-bottom: 4px;
}

.story-info p {
    font-size: 0.9em;
    color: var(--study-text-muted);
}

.start-button {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(
        135deg,
        var(--study-primary) 0%,
        var(--study-primary-dark) 100%
    );
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition:
        transform 0.2s,
        box-shadow 0.2s;
}

.start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

/* ========================================
   STUDY PAGE - 3 PANEL LAYOUT
   ======================================== */

.study-page {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 1fr;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--study-bg);
}

/* ========================================
   CHAT PANEL (LEFT)
   ======================================== */

.chat-panel {
    width: var(--chat-width);
    background: var(--study-card-bg);
    border-right: 1px solid var(--study-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition:
        width 0.3s ease,
        margin-left 0.3s ease;
}

.chat-panel.collapsed {
    width: 0;
    margin-left: calc(var(--chat-width) * -1);
}

.chat-header {
    padding: 12px 16px;
    background: var(--study-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    flex-shrink: 0;
}

.chat-header h2 {
    font-size: 1em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.5;
    font-size: 0.95em;
    word-wrap: break-word;
    animation: messageIn 0.2s ease;
}

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

.message.user {
    align-self: flex-end;
    background: var(--chat-user-bg);
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--chat-ai-bg);
    border-bottom-left-radius: 4px;
}

.message.typing {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--study-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

.chat-input-area {
    padding: 12px;
    border-top: 1px solid var(--study-border);
    display: flex;
    gap: 10px;
    background: var(--study-card-bg);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--study-border);
    border-radius: 20px;
    font-size: 0.95em;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
    border-color: var(--study-primary);
}

.chat-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: var(--study-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send:hover {
    background: var(--study-primary-dark);
}
.chat-send:disabled {
    background: var(--study-text-muted);
    cursor: not-allowed;
}

/* ========================================
   CONTENT PANEL (CENTER)
   ======================================== */

.content-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0; /* Allow shrinking */
}

.content-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: var(--study-card-bg);
    border-bottom: 1px solid var(--study-border);
    min-height: var(--header-height);
    flex-shrink: 0;
}

.panel-toggle-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--study-border);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--study-text-muted);
    transition: all 0.2s;
}

.panel-toggle-btn:hover {
    background: var(--study-primary);
    color: white;
}

.panel-toggle-btn.active {
    background: var(--study-primary);
    color: white;
}

.exit-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--study-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--study-text-muted);
    transition: all 0.2s;
}

.exit-button:hover {
    background: #fecaca;
    color: #dc2626;
}

.content-header h1 {
    flex: 1;
    font-size: 1.1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.content-tabs {
    display: flex;
    gap: 6px;
}

.content-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--study-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.content-tab:hover {
    background: var(--study-bg);
    color: var(--study-text);
}

.content-tab.active {
    background: var(--study-primary);
    color: white;
}

/* CONTENT BODY - THE ONLY SCROLLABLE AREA */
.content-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
}

.content-section {
    display: none;
    max-width: 800px;
    margin: 0 auto;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========================================
   QUESTION PANEL (RIGHT)
   ======================================== */

.question-panel {
    width: var(--question-width);
    background: var(--study-card-bg);
    border-left: 1px solid var(--study-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition:
        width 0.3s ease,
        margin-right 0.3s ease;
}

.question-panel.collapsed {
    width: 0;
    margin-right: calc(var(--question-width) * -1);
}

.question-header {
    padding: 12px 16px;
    background: var(--study-success);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    flex-shrink: 0;
}

.question-header h2 {
    font-size: 1em;
    font-weight: 600;
}

.question-progress {
    display: flex;
    gap: 6px;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.2s;
}

.progress-dot.completed {
    background: white;
}

.progress-dot.current {
    background: white;
    transform: scale(1.2);
}

.progress-dot.insufficient {
    background: var(--study-warning);
}

.question-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.question-card {
    background: var(--study-bg);
    border-radius: 12px;
    padding: 20px;
}

.question-label {
    font-size: 0.8em;
    color: var(--study-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.question-text {
    font-size: 1.05em;
    line-height: 1.6;
    color: var(--study-text);
}

.question-hint {
    background: #fef3c7;
    border-left: 3px solid var(--study-warning);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 0.9em;
    color: #92400e;
    display: none;
}

.question-hint.visible {
    display: block;
}

.answer-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-textarea {
    width: 100%;
    min-height: 120px;
    padding: 14px;
    border: 2px solid var(--study-border);
    border-radius: 10px;
    font-size: 0.95em;
    font-family: inherit;
    resize: vertical;
    line-height: 1.5;
}

.answer-textarea:focus {
    outline: none;
    border-color: var(--study-primary);
}

.answer-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--study-primary-dark);
}
.btn-primary:disabled {
    background: var(--study-text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--study-border);
    color: var(--study-text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

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

.btn-success:hover {
    background: #059669;
}

/* Grading feedback */
.grading-feedback {
    padding: 16px;
    border-radius: 10px;
    display: none;
}

.grading-feedback.visible {
    display: block;
}

.grading-feedback.sufficient {
    background: #d1fae5;
    border: 1px solid var(--study-success);
    color: #065f46;
}

.grading-feedback.insufficient {
    background: #fef3c7;
    border: 1px solid var(--study-warning);
    color: #92400e;
}

.grading-feedback h4 {
    font-size: 0.95em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grading-feedback p {
    font-size: 0.9em;
    line-height: 1.5;
}

.feedback-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}

/* ========================================
   REFLECTION SECTION
   ======================================== */

.reflection-section {
    display: none;
}

.reflection-section.active {
    display: block;
}

.reflection-intro {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--study-border);
}

.reflection-intro h2 {
    font-size: 1.4em;
    margin-bottom: 8px;
}

.reflection-intro p {
    color: var(--study-text-muted);
}

.reflection-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.reflection-block {
    background: var(--study-card-bg);
    border: 1px solid var(--study-border);
    border-radius: 12px;
    padding: 20px;
}

.reflection-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--study-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 10px;
}

.reflection-question {
    font-size: 1em;
    line-height: 1.5;
    margin-bottom: 12px;
}

.reflection-input {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 2px solid var(--study-border);
    border-radius: 8px;
    font-size: 0.95em;
    font-family: inherit;
    resize: vertical;
}

.reflection-input:focus {
    outline: none;
    border-color: var(--study-primary);
}

.submit-section {
    text-align: center;
    padding: 24px 0;
}

.submit-button {
    padding: 14px 40px;
    background: var(--study-success);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
}

.submit-button:hover {
    background: #059669;
}
.submit-button:disabled {
    background: var(--study-text-muted);
    cursor: not-allowed;
}

.submit-note {
    margin-top: 12px;
    color: var(--study-text-muted);
    font-size: 0.9em;
}

/* ========================================
   STORY & THEORY CONTENT STYLES
   ======================================== */

.story-title {
    text-align: center;
    margin-bottom: 28px;
}

.story-title h2 {
    font-size: 1.6em;
    margin-bottom: 6px;
}

.story-title .author {
    color: var(--study-text-muted);
    font-style: italic;
}

.story-text {
    font-size: 1.05em;
    line-height: 1.85;
}

.story-text p {
    margin-bottom: 1.4em;
    text-indent: 2em;
}

.story-text p:first-of-type {
    text-indent: 0;
}

.theory-content h2 {
    font-size: 1.4em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--study-primary);
}

.theory-section {
    margin-bottom: 28px;
    padding: 20px;
    background: var(--study-card-bg);
    border-radius: 12px;
    border: 1px solid var(--study-border);
}

.theory-section h2 {
    font-size: 1.2em;
    color: var(--study-primary);
    margin-bottom: 14px;
    border-bottom: none;
    padding-bottom: 0;
}

.theory-section h3 {
    font-size: 1.05em;
    margin: 18px 0 10px;
}

.theory-section p {
    line-height: 1.65;
    margin-bottom: 10px;
}

.theory-section ul {
    margin: 10px 0;
    padding-left: 20px;
}

.theory-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* ========================================
   MOBILE BOTTOM NAVIGATION
   ======================================== */

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: var(--study-card-bg);
    border-top: 1px solid var(--study-border);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--study-text-muted);
    cursor: pointer;
    padding: 8px;
    position: relative;
    min-height: 44px;
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
}

.bottom-nav-item span {
    font-size: 0.7em;
    font-weight: 500;
}

.bottom-nav-item.active {
    color: var(--study-primary);
}

.nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    min-width: 16px;
    height: 16px;
    background: var(--study-error);
    color: white;
    font-size: 0.6em;
    font-weight: 700;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.nav-badge.visible {
    display: flex;
}

/* ========================================
   MOBILE OVERLAYS
   ======================================== */

.overlay-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.overlay-backdrop.visible {
    display: block;
    opacity: 1;
}

/* Mobile chat overlay */
.mobile-chat-overlay,
.mobile-question-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--study-card-bg);
    z-index: 200;
    display: none;
    flex-direction: column;
}

.mobile-chat-overlay.open,
.mobile-question-overlay.open {
    display: flex;
}

.mobile-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--study-primary);
    color: white;
    min-height: var(--header-height);
}

.mobile-question-overlay .mobile-overlay-header {
    background: var(--study-success);
}

.mobile-overlay-header h2 {
    font-size: 1em;
}

.mobile-overlay-close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1.3em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-overlay-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Desktop: Full 3-panel layout */
@media (min-width: 1024px) {
    .bottom-nav {
        display: none !important;
    }
    .mobile-chat-overlay,
    .mobile-question-overlay {
        display: none !important;
    }
    .overlay-backdrop {
        display: none !important;
    }
}

/* Tablet: Collapsible panels */
@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --chat-width: 300px;
        --question-width: 320px;
    }

    .bottom-nav {
        display: none;
    }

    .content-header h1 {
        font-size: 1em;
    }

    .content-tab {
        padding: 6px 12px;
        font-size: 0.85em;
    }
}

/* Mobile: Overlay-based panels */
@media (max-width: 767px) {
    .study-page {
        grid-template-columns: 1fr;
    }

    /* Hide desktop panels on mobile */
    .chat-panel,
    .question-panel {
        display: none !important;
    }

    /* Show bottom nav */
    .bottom-nav {
        display: flex;
    }

    /* Adjust content for bottom nav */
    .content-body {
        padding-bottom: calc(
            var(--bottom-nav-height) + var(--safe-area-bottom) + 16px
        );
    }

    /* Hide panel toggle buttons in header on mobile */
    .panel-toggle-btn {
        display: none;
    }

    .content-header {
        padding: 10px 16px;
    }

    .content-header h1 {
        font-size: 1em;
    }

    .content-tabs {
        display: none;
    }

    .content-body {
        padding: 16px;
    }

    /* Story/Theory adjustments */
    .story-title h2 {
        font-size: 1.3em;
    }

    .story-text {
        font-size: 1em;
    }

    .theory-section {
        padding: 16px;
    }
}

/* Small mobile */
@media (max-width: 380px) {
    .login-card {
        padding: 20px 16px;
    }

    .content-header {
        gap: 8px;
        padding: 8px 12px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

:focus-visible {
    outline: 2px solid var(--study-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   READING COMPLETE BANNER
   ======================================== */

.reading-complete-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid var(--study-primary);
    padding: 16px 24px;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.reading-complete-banner p {
    margin: 0;
    color: var(--study-text-muted);
    font-size: 0.95rem;
}

.reading-complete-btn {
    background: var(--study-primary);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

@media (max-width: 768px) {
    .reading-complete-banner {
        bottom: var(--bottom-nav-height);
        padding: 12px 16px;
    }
}

/* ========================================
   PRE-TASK OVERLAY
   ======================================== */

.pre-task-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.4s ease;
    padding: 1rem;
}

.pre-task-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.pre-task-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.pre-task-card h2 {
    margin: 0 0 0.5rem;
    color: var(--study-primary);
    font-size: 1.4em;
}

.pre-task-card > p {
    color: var(--study-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.pre-task-prompt {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--study-text);
    margin-bottom: 1rem;
    font-weight: 500;
}

.pre-task-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--study-border);
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
    min-height: 120px;
    box-sizing: border-box;
}

.pre-task-input:focus {
    outline: none;
    border-color: var(--study-primary);
}

.pre-task-word-count {
    font-size: 0.85rem;
    color: var(--study-text-muted);
    margin-top: 0.5rem;
}

.pre-task-word-count.met {
    color: var(--study-success);
}

.pre-task-submit {
    margin-top: 1rem;
    width: 100%;
    padding: 12px;
    font-size: 1.05rem;
    background: var(--study-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.pre-task-submit:hover:not(:disabled) {
    background: var(--study-primary-dark);
}

.pre-task-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   CHAT REQUIREMENT NOTICE
   ======================================== */

.chat-requirement-notice {
    font-size: 0.88rem;
    color: var(--study-warning);
    background: #fef9e7;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 500;
}

.chat-requirement-notice.met {
    color: var(--study-success);
    background: #ecfdf5;
    border-color: #a7f3d0;
}

/* ========================================
   RUBRIC SCORE BADGE
   ======================================== */

.rubric-score {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    margin-left: 8px;
}

.rubric-score.score-5 {
    background: #d1fae5;
    color: #065f46;
}

.rubric-score.score-4 {
    background: #d1fae5;
    color: #065f46;
}

.rubric-score.score-3 {
    background: #e0f2fe;
    color: #0c4a6e;
}

.rubric-score.score-2 {
    background: #fef3c7;
    color: #92400e;
}

.rubric-score.score-1 {
    background: #fee2e2;
    color: #991b1b;
}

.grading-strengths {
    margin-top: 8px;
    font-size: 0.88em;
    color: #065f46;
}

.grading-strengths strong {
    font-weight: 600;
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .btn,
    .content-tab,
    .bottom-nav-item,
    .panel-toggle-btn,
    .exit-button,
    .chat-send,
    .chat-close-btn,
    .mobile-overlay-close {
        min-height: 44px;
        min-width: 44px;
    }
}
