/* ACTION / FEED */
.status-bar {
    width: 60%;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    /* Center justified as requested */
    padding-left: 0;
    margin-bottom: 0;
    /* Bring text down / Shrink gap */
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

#statusText {
    background: transparent !important;
    border: none !important;
    padding: 0;
    margin: 0;
    display: inline-block;
    max-width: 100%;
    font-weight: 800;
    /* Fairly bold */
    font-size: clamp(1rem, 3vw, 1.5rem);
    /* Significant size */
    color: var(--success);
    letter-spacing: clamp(0.03em, 0.18vw, 1px);
    text-shadow: var(--status-glow-success);
    /* Green glow */
    font-family: 'Inter', sans-serif;
    /* Ensure clean font */
    white-space: nowrap;
    text-align: center;
}

.action-phase-text {
    width: min(640px, 88%);
    margin: 0.6rem auto 0.2rem auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    min-height: 1.1rem;
}

.action-phase-text.is-flashing {
    animation: summary-pulse 1.2s ease-in-out infinite;
}

.progress-container {
    height: 12px;
    width: 60%;
    margin: 0 auto;
    position: relative;
    /* For absolute children */
    background: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
    display: none;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background-color: var(--success);
    width: 0%;
    transition: width 0.3s ease;
    z-index: 10;
    /* On top of scanner */
    position: absolute;
    top: 0;
    left: 0;
    /* ... rest of gradient ... */
    background-image: linear-gradient(45deg,
            rgba(255, 255, 255, 0.15) 25%,
            transparent 25%,
            transparent 50%,
            rgba(255, 255, 255, 0.15) 50%,
            rgba(255, 255, 255, 0.15) 75%,
            transparent 75%,
            transparent);
    background-size: 20px 20px;
    animation: progress-stripes 1s linear infinite;
}



@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feed {
    display: grid;
    gap: 1.75rem;
    margin-top: 1rem;
    /* max-height removed for full card size */
    padding-right: 0.5rem;
}

.question-card {
    background: var(--bg-card-gradient);
    border: 1px solid var(--border-card);
    border-radius: 0.75rem;
    padding: 1.75rem;
    box-shadow: var(--shadow-card);
    animation: slideIn 0.35s ease-out;
    animation-fill-mode: both;
    position: relative;
    overflow: hidden;
    transition: border-color 0.24s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
}

.question-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--border-alpha-medium);
}

.q-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.q-header {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.q-number {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--accent);
}

.q-guidance {
    font-style: italic;
    opacity: 0.85;
    color: var(--accent);
    text-transform: capitalize;
}

.q-source {
    margin-left: auto;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.q-text {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.option {
    background: linear-gradient(180deg, var(--bg-overlay-heavy), var(--bg-overlay));
    padding: 1rem 1.15rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-alpha);
    transition: background 0.24s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.24s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.24s cubic-bezier(0.4, 0, 0.2, 1), transform 0.14s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.option:hover {
    background: linear-gradient(180deg, var(--bg-surface-alt-heavy), var(--accent-alpha-subtle));
    border-color: var(--border-alpha-medium);
    box-shadow: var(--shadow-card);
}

.option:active {
    transform: scale(0.985);
}

.option.option-correct,
.option.option-correct:hover,
.option.option-correct:active,
.option.option-correct:focus-visible {
    background: var(--feedback-correct-bg);
    border-color: var(--feedback-correct-border);
}

.option.option-wrong,
.option.option-wrong:hover,
.option.option-wrong:active,
.option.option-wrong:focus-visible {
    background: var(--feedback-wrong-bg);
    border-color: var(--feedback-wrong-border);
}

.answer-reveal {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
    color: var(--success);
    font-size: 0.9rem;
    font-weight: 600;
    display: none;
}

.question-card:hover .answer-reveal {
    display: block;
}

/* --- AGENT PANE --- */
.action-grid {
    width: 100%;
    display: block;
    margin-top: 1rem;
}

#scoreboard.scoreboard {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 2rem;
}

.main-action-wrap {
    text-align: center;
    margin-top: 2rem;
}

#btnMainAction {
    width: auto;
}

#actionStage:not(.action-complete) #btnMainAction {
    padding: 0.5rem 2rem;
}

#actionStage.action-complete #btnMainAction {
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
}

#actionStage.action-waiting .action-grid {
    margin-top: 0.5rem;
}

#actionStage.action-waiting .main-action-wrap {
    margin-top: 0.75rem;
}

#actionStage.action-waiting #scoreboard {
    margin-bottom: 1rem;
}

#actionStage.action-complete .main-action-wrap {
    position: absolute;
    top: 0.5rem;
    left: 0;
    margin-top: 0;
    text-align: left;
    z-index: 5;
}

@media (max-width: 900px) {
    .status-bar {
        width: 100%;
        padding: 0 0.75rem;
        box-sizing: border-box;
    }

    #statusText {
        font-size: clamp(0.98rem, 4.3vw, 1.18rem);
        letter-spacing: 0.03em;
    }
}

@media (max-width: 640px) {
    .status-bar {
        padding: 0 0.35rem;
    }

    #statusText {
        font-size: clamp(0.92rem, 4.6vw, 1.04rem);
        letter-spacing: 0.02em;
    }
}

.action-grid.agent-open {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.5rem;
    align-items: stretch;
}

.action-grid.agent-open .feed {
    margin-top: 0;
}

.agent-pane {
    background: linear-gradient(180deg, var(--bg-overlay-heavy), var(--bg-overlay));
    border: 1px solid var(--border-card);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    min-height: 420px;
    align-self: stretch;
    height: 100%;
    box-shadow: var(--shadow-card);
}

.agent-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
}

.agent-title {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
}

.agent-explain {
    display: flex;
    justify-content: flex-start;
}

.agent-transcript {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    overflow-y: auto;
    max-height: 420px;
    display: flex;
    flex-direction: column;
}

.agent-message {
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    margin-bottom: 0.5rem;
    max-width: 85%;
    width: fit-content;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.agent-message.user {
    background: var(--indigo-500);
    color: #fff;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

.agent-message.agent {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    color: var(--text-secondary);
}

.agent-typing {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    width: fit-content;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    border-bottom-left-radius: 2px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-style: italic;
    animation: agent-pulse 1.2s ease-in-out infinite;
}

@keyframes agent-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

.agent-input {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.agent-minimize {
    padding: 0.3rem 0.6rem;
    font-size: 1rem;
    line-height: 1;
}

.agent-input-box {
    flex: 1;
    min-height: 64px;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    resize: vertical;
    font-size: 0.95rem;
}

.agent-dock {
    margin-top: 1rem;
    align-self: flex-end;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
}

.agent-dock-wrap {
    display: flex;
    justify-content: flex-end;
}

.agent-trigger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--border-alpha-strong);
    background: var(--bg-overlay-heavy);
    color: var(--accent);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
    position: relative;
    box-shadow: inset 0 0 0 1px var(--border-white-subtle);
}

.agent-trigger-icon:hover {
    transform: translateY(-1px);
    border-color: var(--border-alpha-strong);
    background: var(--bg-surface-alt-heavy);
}

.agent-trigger-icon::before {
    content: "✧";
    position: absolute;
    top: 6px;
    right: 7px;
    font-size: 0.55rem;
    color: var(--accent);
    pointer-events: none;
}

.agent-trigger-icon::after {
    content: "✧";
    position: absolute;
    bottom: 7px;
    left: 8px;
    font-size: 0.5rem;
    color: var(--accent-alpha-medium);
    pointer-events: none;
}

.material-summary-btn.agent-trigger-icon {
    position: absolute;
    left: 0.72rem;
    bottom: 1.08rem;
    width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 999px;
    z-index: 2;
}

.material-summary-btn.agent-trigger-icon::before {
    top: 7px;
    right: 8px;
}

.material-summary-btn.agent-trigger-icon::after {
    bottom: 8px;
    left: 9px;
}

@media (max-width: 1100px) {
    .action-grid.agent-open {
        grid-template-columns: 1fr;
    }
}

/* MINI ITEM (Streaming) */
.q-mini-content {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
    font-family: var(--font-body);
}

.q-label {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--accent);
    margin-right: 0.5rem;
}

.q-preview-text {
    color: var(--text-primary);
}

/* --- QUESTION FEED MINI ITEMS --- */
.q-mini-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    margin-bottom: 0.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

.q-label-accent {
    font-weight: 700;
    color: var(--accent);
    margin-right: 0.4rem;
}

.q-mini-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-weight: 500;
}

/* --- PDF ACTION AREA --- */
.pdf-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
    padding: 0.35rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.view-toggle {
    display: flex;
    background: var(--bg-primary);
    padding: 2px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.toggle-option {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.35rem 0.8rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.toggle-option:hover {
    color: var(--text-primary);
}

.toggle-option.active {
    background: var(--indigo-500);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#btnBackToBuilder {
    font-weight: 500;
    color: var(--text-primary);
    border-color: var(--border-alpha-strong);
    background: var(--bg-surface-alt);
    border-radius: 0.65rem;
    box-shadow: var(--shadow-card);
}

#btnBackToBuilder:hover {
    color: var(--text-primary);
    border-color: var(--border-alpha-strong);
    background: var(--bg-surface-alt-heavy);
    box-shadow: var(--shadow-card-hover);
}

.download-group {
    display: flex;
    gap: 0.5rem;
}

.btn-mini {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.5rem 0.85rem;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.24s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: var(--min-touch);
}

.btn-mini:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: var(--border-white-subtle);
}

.btn-notability-export {
    white-space: nowrap;
}

.btn-notability-export:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Updated Container for Preview */
.pdf-preview-container {
    height: 80vh;
    /* Much Taller */
    min-height: 700px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #525659;
    /* PDF Viewer Grey */
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.pdf-frame {
    width: 100%;
    height: 100%;
    display: block;
}

/* Hide feed when reviewing */
.feed.hidden {
    display: none !important;

}

/* --- History Drawer (Slide-Over) --- */
.history-drawer {
    position: fixed;
    top: 0;
    right: -400px;
    width: 350px;
    height: 100vh;
    background: var(--bg-overlay-heavy);
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 30px var(--bg-scrim-heavy);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
}

.history-drawer.active {
    right: 0;
}

.drawer-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-overlay-heavy);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Close Button */
.btn-close-drawer {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-close-drawer:hover {
    background: var(--border-white-subtle);
    color: var(--accent);
    transform: rotate(90deg);
}

/* History Items */
.history-item {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.8rem;
    cursor: pointer;
    background: var(--bg-primary);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.history-item:hover {
    border-color: var(--accent);
    background: linear-gradient(90deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    transform: translateX(4px);
    box-shadow: var(--shadow-card);
}

.btn-delete-history {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.4;
    transition: all 0.2s;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
}

.btn-delete-history:hover {
    opacity: 1;
    transform: scale(1.1);
    background: rgba(239, 68, 68, 0.15);
}


/* Backdrop */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: var(--bg-scrim);
    backdrop-filter: blur(4px);
    z-index: 1500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Floating Trigger Button */
.btn-history-float {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: var(--bg-overlay-light);
    color: var(--text-primary);
    border: 1px solid var(--border-alpha-medium);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    z-index: 10;
    font-weight: 500;
}

.btn-history-float:hover {
    background: var(--bg-secondary);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-alpha-subtle);
}

/* SCROLLBAR UTILS */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* WEIGHTED SCANNNER ANIMATION */
.weighted-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 30%;
    height: 100%;
    background: var(--cyan-400);
    box-shadow: 0 0 10px var(--cyan-400);
    opacity: 0.8;
    border-radius: 4px;
    animation: weighted-scan 1.5s ease-in-out infinite alternate;
    z-index: 5;
    will-change: left, width;
}

@keyframes weighted-scan {
    0% {
        left: 0;
        width: 15%;
    }

    50% {
        width: 40%;
    }

    100% {
        left: 85%;
        width: 15%;
    }
}
