* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8faff;
    --border: #e5eaf2;
    --border-strong: #d8dfeb;

    --text: #111827;
    --text-soft: #344054;
    --muted: #667085;
    --muted-light: #98a2b3;

    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-soft: #eef2ff;

    --sidebar: #0b1020;
    --sidebar-soft: #11182a;
    --sidebar-border: #202a40;
    --sidebar-text: #c5cede;

    --success: #16a34a;
    --danger: #dc2626;

    --shadow-sm:
        0 1px 2px rgba(16, 24, 40, .04),
        0 2px 8px rgba(16, 24, 40, .03);

    --shadow-md:
        0 10px 30px rgba(16, 24, 40, .08);

    --radius: 16px;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background:
        radial-gradient(
            circle at 70% -10%,
            rgba(79, 70, 229, .08),
            transparent 32%
        ),
        var(--bg);

    color: var(--text);

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
textarea,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .65;
}

.app {
    min-height: 100vh;
    display: flex;
}


/* =========================================
   SIDEBAR
========================================= */

.sidebar {
    width: 280px;
    flex: 0 0 280px;

    min-height: 100vh;

    display: flex;
    flex-direction: column;

    padding: 22px 16px;

    background:
        radial-gradient(
            circle at 20% 0%,
            rgba(79, 70, 229, .18),
            transparent 28%
        ),
        var(--sidebar);

    color: white;

    border-right: 1px solid rgba(255,255,255,.04);

    position: sticky;
    top: 0;

    height: 100vh;

    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;

    gap: 12px;

    padding: 5px 8px 27px;
}

.brand-mark {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    border-radius: 13px;

    background:
        linear-gradient(
            135deg,
            #6366f1,
            #4338ca
        );

    box-shadow:
        0 8px 22px rgba(79, 70, 229, .35);

    font-size: 19px;
    font-weight: 850;

    letter-spacing: -.04em;
}

.brand-copy {
    min-width: 0;
}

.brand-copy strong {
    display: block;

    font-size: 16px;
    line-height: 1.1;

    letter-spacing: -.02em;
}

.brand-copy span {
    display: block;

    margin-top: 4px;

    color: #8f9bb1;

    font-size: 11px;

    letter-spacing: .01em;
}


/* New project */

.new-project {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    padding: 12px 14px;

    border: 1px solid #303b55;

    border-radius: 11px;

    background:
        linear-gradient(
            180deg,
            #18223a,
            #141d31
        );

    color: white;

    font-weight: 650;
    font-size: 13px;

    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);

    transition:
        transform .18s ease,
        background .18s ease,
        border-color .18s ease;
}

.new-project span:first-child {
    font-size: 18px;
    line-height: 1;
}

.new-project:hover {
    transform: translateY(-1px);

    background: #1d2943;

    border-color: #3e4d70;
}


/* Navigation */

.sidebar-label,
.tools-label {
    font-size: 9px;
    font-weight: 800;

    letter-spacing: 1.5px;

    color: #69758b;
}

.sidebar-label {
    padding: 22px 10px 8px;
}

.stage-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stage {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 10px;

    border: 0;

    border-radius: 9px;

    background: transparent;

    color: var(--sidebar-text);

    text-align: left;

    padding: 10px 10px;

    font-size: 12.5px;

    transition:
        background .18s ease,
        color .18s ease,
        transform .18s ease;
}

.stage:hover {
    background: rgba(255,255,255,.055);
    color: white;
}

.stage.active {
    background:
        linear-gradient(
            90deg,
            rgba(79,70,229,.26),
            rgba(79,70,229,.10)
        );

    color: white;

    box-shadow:
        inset 3px 0 0 #6366f1;
}

.stage-number {
    width: 28px;

    color: #65728a;

    font-size: 10px;
    font-weight: 800;

    letter-spacing: .04em;
}

.stage.active .stage-number {
    color: #9da9ff;
}


/* Sidebar footer */

.sidebar-footer {
    margin-top: auto;

    padding: 16px 4px 0;

    border-top: 1px solid var(--sidebar-border);
}

.connection {
    display: flex;
    align-items: center;

    gap: 9px;

    padding: 0 7px 13px;
}

.status-dot,
.save-dot {
    display: inline-block;

    width: 8px;
    height: 8px;

    flex: 0 0 auto;

    border-radius: 50%;

    background: #22c55e;

    box-shadow:
        0 0 0 3px rgba(34,197,94,.11);
}

.connection strong {
    display: block;

    color: #d8deea;

    font-size: 11px;
}

.connection small {
    display: block;

    margin-top: 2px;

    color: #707d94;

    font-size: 10px;
}

.account-button {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 9px;

    border: 1px solid transparent;

    border-radius: 10px;

    padding: 8px;

    background: transparent;

    color: white;

    text-align: left;

    transition:
        background .18s ease,
        border-color .18s ease;
}

.account-button:hover {
    background: rgba(255,255,255,.055);
    border-color: rgba(255,255,255,.06);
}

.avatar {
    width: 32px;
    height: 32px;

    display: grid;
    place-items: center;

    border-radius: 9px;

    background:
        linear-gradient(
            135deg,
            #667eea,
            #764ba2
        );

    font-size: 12px;
    font-weight: 800;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-info strong {
    display: block;

    font-size: 11px;
}

.account-info span {
    display: block;

    margin-top: 2px;

    color: #79869b;

    font-size: 10px;
}

.account-arrow {
    color: #67748a;
    font-size: 18px;
}


/* =========================================
   MAIN
========================================= */

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    height: 86px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 34px;

    background:
        rgba(255,255,255,.88);

    backdrop-filter: blur(14px);

    border-bottom: 1px solid var(--border);

    position: sticky;
    top: 0;

    z-index: 30;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
}

.topbar-left {
    gap: 13px;
}

.topbar-right {
    gap: 14px;
}

.eyebrow {
    margin: 0 0 4px;

    color: var(--muted);

    font-size: 9px;
    font-weight: 850;

    letter-spacing: 1.7px;
}

.topbar h1 {
    margin: 0;

    font-size: 22px;
    line-height: 1.1;

    letter-spacing: -.035em;
}

.save-state {
    display: flex;
    align-items: center;

    gap: 7px;

    color: var(--muted);

    font-size: 11px;
}

.save-dot {
    width: 6px;
    height: 6px;

    box-shadow: none;
}

.save-button {
    border: 1px solid var(--border-strong);

    background: white;

    color: var(--text-soft);

    padding: 9px 15px;

    border-radius: 9px;

    font-size: 12px;
    font-weight: 650;

    box-shadow: var(--shadow-sm);

    transition:
        border-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.save-button:hover {
    transform: translateY(-1px);

    border-color: #c5cedc;

    box-shadow: var(--shadow-md);
}


/* =========================================
   WORKSPACE
========================================= */

.workspace {
    width: 100%;
    max-width: 1480px;

    margin: 0 auto;

    padding: 30px;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        340px;

    gap: 24px;
}

.paper-panel,
.copilot-panel {
    background: rgba(255,255,255,.94);

    border: 1px solid var(--border);

    border-radius: var(--radius);

    box-shadow: var(--shadow-sm);
}

.paper-panel {
    padding: 30px;
}


/* Progress */

.progress-area {
    margin-bottom: 34px;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 8px;

    color: var(--muted);

    font-size: 10px;
}

.progress-meta strong {
    color: var(--text-soft);

    font-size: 10px;
}

.progress-track {
    width: 100%;
    height: 5px;

    overflow: hidden;

    border-radius: 99px;

    background: #edf0f5;
}

#progressBar {
    height: 100%;
    width: 11%;

    border-radius: inherit;

    background:
        linear-gradient(
            90deg,
            #4f46e5,
            #6366f1
        );

    box-shadow:
        0 0 12px rgba(79,70,229,.22);

    transition: width .3s ease;
}


/* Section heading */

.section-heading {
    display: flex;

    gap: 15px;

    margin-bottom: 23px;
}

.section-number {
    width: 38px;
    height: 38px;

    flex: 0 0 auto;

    display: grid;
    place-items: center;

    border-radius: 11px;

    background: var(--primary-soft);

    color: var(--primary);

    font-size: 11px;
    font-weight: 850;
}

#stageNumber {
    padding: 0;
}

.section-heading h2 {
    margin: 1px 0 0;

    font-size: 25px;

    letter-spacing: -.035em;
}

.section-heading p {
    margin: 7px 0 0;

    color: var(--muted);

    font-size: 12px;

    line-height: 1.55;
}


/* Editor */

.editor-wrapper {
    overflow: hidden;

    border: 1px solid var(--border);

    border-radius: 13px;

    background: white;

    transition:
        border-color .18s ease,
        box-shadow .18s ease;
}

.editor-wrapper:focus-within {
    border-color: #aebaff;

    box-shadow:
        0 0 0 4px rgba(79,70,229,.07);
}

.editor-toolbar {
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 14px;

    background: #fafbfc;

    border-bottom: 1px solid var(--border);
}

.editor-label {
    color: var(--text-soft);

    font-size: 10px;
    font-weight: 700;
}

#wordCount {
    color: var(--muted-light);

    font-size: 10px;
}

#researchInput {
    width: 100%;

    min-height: 310px;

    resize: vertical;

    display: block;

    border: 0;
    outline: 0;

    padding: 20px;

    background: white;

    color: var(--text);

    font-size: 14px;

    line-height: 1.75;

    letter-spacing: .002em;
}

#researchInput::placeholder {
    color: #a5adba;
}

#researchInput:focus {
    outline: 0;
}


/* Actions */

.paper-actions {
    display: flex;

    align-items: center;

    gap: 9px;

    margin-top: 14px;
}

.primary,
.secondary {
    border-radius: 9px;

    padding: 10px 15px;

    font-size: 12px;
    font-weight: 700;

    transition:
        transform .18s ease,
        box-shadow .18s ease,
        background .18s ease;
}

.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 7px;

    border: 0;

    background:
        linear-gradient(
            135deg,
            #5b55ee,
            #4338ca
        );

    color: white;

    box-shadow:
        0 6px 18px rgba(79,70,229,.20);
}

.primary:hover {
    transform: translateY(-1px);

    box-shadow:
        0 9px 24px rgba(79,70,229,.27);
}

.secondary {
    border: 1px solid var(--border);

    background: white;

    color: var(--text-soft);
}

.secondary:hover {
    transform: translateY(-1px);

    background: #fafbfc;

    box-shadow: var(--shadow-sm);
}


/* =========================================
   OUTPUT
========================================= */

.output-section {
    margin-top: 30px;

    padding-top: 25px;

    border-top: 1px solid var(--border);
}

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 14px;
}

.output-title {
    font-size: 14px;
    font-weight: 750;

    letter-spacing: -.01em;
}

.output-subtitle {
    margin-top: 4px;

    color: var(--muted);

    font-size: 10px;
}

.copy-button {
    border: 1px solid var(--border);

    border-radius: 8px;

    padding: 7px 11px;

    background: white;

    color: var(--text-soft);

    font-size: 10px;
    font-weight: 700;
}

.copy-button:hover {
    background: #f8fafc;
}

.output {
    min-height: 190px;

    padding: 22px;

    border: 1px solid var(--border);

    border-radius: 12px;

    background:
        linear-gradient(
            180deg,
            #fcfdff,
            #f9fafc
        );

    color: var(--text-soft);

    white-space: pre-wrap;

    font-size: 13px;

    line-height: 1.75;
}

.output.empty {
    padding: 0;
}

.empty-output {
    min-height: 190px;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    padding: 30px;

    text-align: center;
}

.empty-icon {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    margin-bottom: 12px;

    border-radius: 12px;

    background: var(--primary-soft);

    color: var(--primary);

    font-size: 18px;
}

.empty-output strong {
    font-size: 12px;
}

.empty-output p {
    max-width: 330px;

    margin: 6px 0 0;

    color: var(--muted);

    font-size: 10px;

    line-height: 1.6;
}


/* =========================================
   COPILOT PANEL
========================================= */

.copilot-panel {
    position: sticky;
    top: 116px;

    align-self: start;

    overflow: hidden;
}

.copilot-header {
    display: flex;
    align-items: center;

    gap: 11px;

    padding: 20px;

    border-bottom: 1px solid var(--border);
}

.copilot-icon {
    width: 38px;
    height: 38px;

    display: grid;
    place-items: center;

    border-radius: 11px;

    background:
        linear-gradient(
            135deg,
            #eef2ff,
            #e7e9ff
        );

    color: var(--primary);

    font-size: 17px;
}

.copilot-header strong {
    display: block;

    font-size: 13px;
}

.copilot-header span {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 10px;
}

.copilot-content {
    padding: 18px;
}

.welcome-card {
    padding: 16px;

    border: 1px solid #e6e9ff;

    border-radius: 12px;

    background:
        linear-gradient(
            145deg,
            #f7f7ff,
            #fbfbfe
        );

    margin-bottom: 19px;
}

.welcome-icon {
    margin-bottom: 9px;

    color: var(--primary);

    font-size: 16px;
}

.welcome-card strong {
    display: block;

    font-size: 12px;
}

.welcome-card p {
    margin: 7px 0 0;

    color: var(--muted);

    font-size: 10px;

    line-height: 1.65;
}

.tools-label {
    margin-bottom: 8px;

    padding: 0 3px;
}

.quick-action {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 10px;

    margin-top: 5px;

    padding: 10px;

    border: 1px solid transparent;

    border-radius: 10px;

    background: transparent;

    text-align: left;

    color: var(--text);

    transition:
        background .18s ease,
        border-color .18s ease,
        transform .18s ease;
}

.quick-action:hover {
    transform: translateX(2px);

    background: #f8faff;

    border-color: var(--border);
}

.quick-icon {
    width: 31px;
    height: 31px;

    flex: 0 0 auto;

    display: grid;
    place-items: center;

    border-radius: 8px;

    background: #f1f3f8;

    color: #586174;

    font-size: 11px;
    font-weight: 800;
}

.quick-action:hover .quick-icon {
    background: var(--primary-soft);
    color: var(--primary);
}

.quick-action > span:nth-child(2) {
    flex: 1;
    min-width: 0;
}

.quick-action strong {
    display: block;

    font-size: 11px;
    font-weight: 700;
}

.quick-action small {
    display: block;

    margin-top: 3px;

    overflow: hidden;

    color: var(--muted);

    font-size: 9px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-arrow {
    color: #a2a9b5;

    font-size: 17px;
}

.copilot-footer {
    display: flex;
    align-items: center;

    gap: 8px;

    padding: 13px 18px;

    border-top: 1px solid var(--border);

    color: var(--muted);

    font-size: 9px;
}


/* =========================================
   ACCOUNT MODAL
========================================= */

.modal {
    position: fixed;

    inset: 0;

    z-index: 100;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background:
        rgba(8, 12, 24, .58);

    backdrop-filter: blur(7px);
}

.modal.hidden {
    display: none;
}

.modal-card {
    width: 100%;
    max-width: 420px;

    position: relative;

    padding: 34px;

    border: 1px solid rgba(255,255,255,.65);

    border-radius: 20px;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #fafbff
        );

    box-shadow:
        0 30px 80px rgba(0,0,0,.22);

    text-align: center;

    animation: modalIn .2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.98);
    }

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

.modal-close {
    position: absolute;

    top: 13px;
    right: 15px;

    width: 30px;
    height: 30px;

    border: 0;

    border-radius: 50%;

    background: #f3f4f7;

    color: #667085;

    font-size: 20px;
}

.modal-logo {
    width: 48px;
    height: 48px;

    display: grid;
    place-items: center;

    margin: 0 auto 15px;

    border-radius: 14px;

    background:
        linear-gradient(
            135deg,
            #6366f1,
            #4338ca
        );

    color: white;

    font-weight: 850;

    box-shadow:
        0 10px 24px rgba(79,70,229,.25);
}

.modal-card h2 {
    margin: 0;

    font-size: 22px;

    letter-spacing: -.035em;
}

.modal-card > p {
    margin: 9px auto 23px;

    max-width: 320px;

    color: var(--muted);

    font-size: 11px;

    line-height: 1.6;
}

.google-button,
.email-button {
    width: 100%;

    height: 44px;

    border-radius: 9px;

    font-size: 12px;
    font-weight: 700;
}

.google-button {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 9px;

    border: 1px solid #d9dee8;

    background: white;

    color: #1f2937;

    box-shadow: var(--shadow-sm);
}

.google-button:hover {
    background: #fafbfc;
}

.google-g {
    font-size: 15px;
    font-weight: 850;
}

.email-button {
    border: 0;

    background:
        linear-gradient(
            135deg,
            #5b55ee,
            #4338ca
        );

    color: white;
}

.email-button:hover {
    filter: brightness(.98);
}

.divider {
    display: flex;
    align-items: center;

    gap: 10px;

    margin: 17px 0;

    color: #a0a7b4;

    font-size: 10px;
}

.divider::before,
.divider::after {
    content: "";

    flex: 1;

    height: 1px;

    background: var(--border);
}

.modal-note {
    display: block;

    margin-top: 17px;

    color: var(--muted-light);

    font-size: 9px;

    line-height: 1.5;
}


/* =========================================
   TOAST
========================================= */

.toast {
    position: fixed;

    left: 50%;
    bottom: 25px;

    z-index: 200;

    transform:
        translate(-50%, 20px);

    opacity: 0;

    pointer-events: none;

    padding: 10px 15px;

    border: 1px solid rgba(255,255,255,.18);

    border-radius: 10px;

    background: #111827;

    color: white;

    font-size: 11px;

    box-shadow:
        0 12px 30px rgba(0,0,0,.18);

    transition:
        opacity .2s ease,
        transform .2s ease;
}

.toast.show {
    opacity: 1;

    transform:
        translate(-50%, 0);
}


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

.mobile-only {
    display: none;
}

.sidebar-overlay {
    display: none;
}


/* Tablet */

@media (max-width: 1100px) {

    .workspace {
        grid-template-columns: minmax(0, 1fr) 290px;

        padding: 22px;

        gap: 18px;
    }

    .paper-panel {
        padding: 24px;
    }

    .sidebar {
        width: 245px;
        flex-basis: 245px;
    }

}


/* Mobile */

@media (max-width: 820px) {

    .mobile-only {
        display: grid;
    }

    .sidebar {
        position: fixed;

        left: 0;
        top: 0;
        bottom: 0;

        width: 285px;

        transform: translateX(-102%);

        transition:
            transform .25s ease;

        box-shadow:
            15px 0 40px rgba(0,0,0,.2);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;

        inset: 0;

        z-index: 40;

        background: rgba(8,12,24,.45);

        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .topbar {
        height: 72px;

        padding: 0 17px;
    }

    .topbar h1 {
        font-size: 18px;
    }

    .eyebrow {
        font-size: 8px;
    }

    .save-state {
        display: none;
    }

    .workspace {
        display: block;

        padding: 14px;
    }

    .paper-panel {
        padding: 19px;

        border-radius: 14px;
    }

    .copilot-panel {
        position: static;

        margin-top: 14px;
    }

    .section-heading h2 {
        font-size: 21px;
    }

    #researchInput {
        min-height: 270px;

        padding: 16px;

        font-size: 13px;
    }

    .paper-actions {
        display: grid;

        grid-template-columns: auto 1fr auto;
    }

    .primary {
        min-width: 0;
    }

}


/* Small phones */

@media (max-width: 480px) {

    .topbar {
        padding: 0 13px;
    }

    .topbar-right {
        gap: 5px;
    }

    .save-button {
        padding: 8px 11px;
    }

    .workspace {
        padding: 10px;
    }

    .paper-panel {
        padding: 15px;
    }

    .progress-area {
        margin-bottom: 25px;
    }

    .section-heading {
        gap: 11px;
    }

    .section-number {
        width: 34px;
        height: 34px;
    }

    .section-heading p {
        font-size: 11px;
    }

    .paper-actions {
        grid-template-columns: 1fr 1.4fr 1fr;
    }

    .primary,
    .secondary {
        padding: 10px 8px;

        font-size: 10px;
    }

    .output {
        padding: 16px;

        font-size: 12px;
    }

    .modal-card {
        padding: 28px 20px;
    }

}


/* Accessibility */

button:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(79,70,229,.22);

    outline-offset: 2px;
}


/* Reduced motion */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;

        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;

        transition-duration: .01ms !important;
    }

}

/* =========================================
   AUTH MODAL (email/password)
========================================= */
.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: #f3f4f7;
    padding: 4px;
    border-radius: 10px;
}
.auth-tab {
    flex: 1;
    padding: 8px 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #667085;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.auth-tab.active {
    background: white;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.auth-input {
    width: 100%;
    height: 44px;
    margin-bottom: 12px;
    padding: 0 14px;
    border: 1px solid #d9dee8;
    border-radius: 9px;
    font-size: 13px;
    background: white;
    color: #1f2937;
}
.auth-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.auth-input.hidden {
    display: none;
}
.auth-error {
    min-height: 18px;
    margin: -4px 0 10px;
    color: #dc2626;
    font-size: 11px;
    line-height: 1.4;
}
/* make sure the modal card is not too narrow */
.modal-card {
    width: 100%;
    max-width: 360px;
}

/* =========================================
   ENHANCED AUTH MODAL (override/refine)
========================================= */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(8,12,24,0.55);
    backdrop-filter: blur(4px);
    transition: opacity 0.2s ease;
}
.modal.hidden {
    display: none;
}
.modal-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: white;
    border-radius: 20px;
    padding: 32px 28px 28px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.25);
    animation: modalPop 0.25s ease;
}
@keyframes modalPop {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #f3f4f7;
    color: #667085;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}
.modal-close:hover {
    background: #e5e7eb;
}
.modal-logo {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    color: white;
    font-weight: 800;
    font-size: 24px;
    box-shadow: 0 12px 28px rgba(79,70,229,0.3);
}

.auth-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: #f3f4f7;
    padding: 5px;
    border-radius: 12px;
}
.auth-tab {
    flex: 1;
    padding: 9px 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #667085;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.auth-tab.active {
    background: white;
    color: #1f2937;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.modal-card h2 {
    margin: 0 0 6px;
    font-size: 22px;
    letter-spacing: -0.03em;
    color: #111827;
}
.modal-card > p {
    margin: 0 auto 20px;
    color: #6b7280;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    max-width: 300px;
}
.auth-input {
    width: 100%;
    height: 46px;
    margin-bottom: 12px;
    padding: 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: #1f2937;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.auth-input.hidden {
    display: none;
}
.auth-error {
    min-height: 20px;
    margin: -6px 0 10px;
    color: #dc2626;
    font-size: 12px;
    line-height: 1.4;
}
.email-button {
    width: 100%;
    height: 46px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #5b55ee, #4338ca);
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.2s;
}
.email-button:hover {
    filter: brightness(0.95);
}
.google-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    height: 46px;
    margin-top: 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: white;
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.google-button:hover {
    background: #f9fafb;
}
.google-g {
    font-size: 18px;
    font-weight: 800;
    color: #4285F4;
}
.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 10px;
    color: #9ca3af;
    font-size: 11px;
}
.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}
.modal-note {
    display: block;
    margin-top: 16px;
    color: #9ca3af;
    font-size: 10px;
    line-height: 1.5;
    text-align: center;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .modal-card {
        padding: 24px 18px;
    }
    .modal-card h2 {
        font-size: 20px;
    }
}

/* Academic integrity review */
.integrity-shortcut {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 13px 2px 0;
    padding: 11px 10px;
    border: 1px solid rgba(111, 224, 179, .2);
    border-radius: 11px;
    background: rgba(31, 147, 106, .1);
    color: #c7eee0;
    font-size: 11px;
    font-weight: 750;
    text-decoration: none;
}

.integrity-shortcut span {
    display: grid;
    width: 21px;
    height: 21px;
    place-items: center;
    border-radius: 7px;
    background: rgba(60, 211, 143, .18);
    color: #8af0bb;
    font-size: 12px;
}

.integrity-shortcut:hover {
    border-color: rgba(111, 224, 179, .4);
    background: rgba(31, 147, 106, .18);
}

.integrity-panel {
    margin-top: 25px;
    padding: 21px;
    border: 1px solid #c6e4d7;
    border-radius: 16px;
    background:
        radial-gradient(circle at 100% 0%, rgba(45, 140, 255, .1), transparent 10rem),
        linear-gradient(135deg, #f2fcf7, #f9fffc);
}

.integrity-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
}

.integrity-header .section-kicker {
    margin-bottom: 5px;
    color: #087b61;
}

.integrity-header h3 {
    margin: 0;
    color: var(--afriva-ink);
    font-size: 18px;
    letter-spacing: -.025em;
}

.integrity-status {
    flex: 0 0 auto;
    padding: 5px 8px;
    border: 1px solid #cbded8;
    border-radius: 999px;
    background: #fff;
    color: #607a78;
    font-size: 9px;
    font-weight: 750;
}

.integrity-status.review-recommended {
    border-color: #eed69f;
    background: #fff9e7;
    color: #89651e;
}

.integrity-status.all-clear {
    border-color: #b7e8cf;
    background: #effbf5;
    color: #087b61;
}

.integrity-description {
    max-width: 710px;
    margin: 12px 0 0;
    color: #45696a;
    font-size: 12px;
    line-height: 1.6;
}

.integrity-disclaimer {
    margin: 10px 0 15px;
    color: #66807e;
    font-size: 10px;
    font-style: italic;
    line-height: 1.5;
}

.integrity-check-button {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid rgba(25, 169, 116, .55);
    border-radius: 10px;
    background: linear-gradient(135deg, #159b6b, #087b61);
    color: #fff;
    font-size: 11px;
    font-weight: 750;
    box-shadow: 0 8px 17px rgba(8, 105, 88, .15);
}

.integrity-check-button:hover {
    background: linear-gradient(135deg, #1bae77, #0b8e6d);
}

.integrity-results {
    margin-top: 16px;
}

.integrity-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.integrity-metric {
    min-height: 67px;
    padding: 10px;
    border: 1px solid #d5e8df;
    border-radius: 10px;
    background: rgba(255, 255, 255, .76);
}

.integrity-metric strong,
.integrity-metric span {
    display: block;
}

.integrity-metric strong {
    color: #123f43;
    font-size: 17px;
}

.integrity-metric span {
    margin-top: 4px;
    color: #66807e;
    font-size: 9px;
    line-height: 1.25;
}

.integrity-issues {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.integrity-issue {
    padding: 12px;
    border: 1px solid #d7e5df;
    border-left: 3px solid #d5a437;
    border-radius: 10px;
    background: #fff;
}

.integrity-issue.high {
    border-left-color: #ba6945;
}

.integrity-issue strong,
.integrity-issue p {
    display: block;
    margin: 0;
}

.integrity-issue strong {
    color: #294e50;
    font-size: 11px;
}

.integrity-issue p {
    margin-top: 5px;
    color: #607a78;
    font-size: 10px;
    line-height: 1.5;
}

.integrity-issue-actions {
    display: flex;
    gap: 7px;
    margin-top: 9px;
}

.integrity-issue-actions button {
    min-height: 30px;
    padding: 0 9px;
    border: 1px solid #cbded8;
    border-radius: 8px;
    background: #fafffc;
    color: #155c52;
    font-size: 9px;
    font-weight: 700;
}

.integrity-empty {
    margin: 12px 0 0;
    color: #446a63;
    font-size: 11px;
}

@media (max-width: 480px) {
    .integrity-panel {
        padding: 17px;
    }

    .integrity-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .integrity-check-button {
        width: 100%;
    }
}

/* Credits and usage transparency */
.wallet-button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border: 1px solid #b9dfcf;
    border-radius: 10px;
    background: #effbf5;
    color: #087b61;
    font-size: 11px;
    font-weight: 750;
}

.wallet-menu {
    position: relative;
}

.wallet-dropdown {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    z-index: 60;
    width: 240px;
    padding: 14px;
    border: 1px solid #c9e4d8;
    border-radius: 13px;
    background: rgba(252, 255, 253, .98);
    box-shadow: 0 18px 38px rgba(7, 49, 55, .17);
}

.wallet-dropdown > strong,
.wallet-dropdown > span {
    display: block;
}

.wallet-dropdown > strong {
    color: #087b61;
    font-size: 9px;
    letter-spacing: .12em;
}

.wallet-dropdown > span {
    margin-top: 7px;
    color: #123f43;
    font-size: 16px;
    font-weight: 800;
}

.wallet-dropdown p {
    margin: 7px 0 11px;
    color: #607a78;
    font-size: 10px;
    line-height: 1.45;
}

.wallet-dropdown button {
    width: 100%;
    min-height: 35px;
    border: 1px solid #c9ddd8;
    border-radius: 8px;
    background: #fff;
    color: #155c52;
    font-size: 10px;
    font-weight: 750;
}

.wallet-button:hover {
    background: #e2f8ec;
}

.operation-cost {
    margin: 9px 0 0;
    color: #66807e;
    font-size: 10px;
}

.wallet-panel {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #cce6da;
    border-radius: 16px;
    background: linear-gradient(135deg, #f2fcf7, #f6fbff);
}

.knowledge-graph-panel {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #c8ddea;
    border-radius: 16px;
    background: linear-gradient(135deg, #f2fbf8, #f1f8ff);
}

.knowledge-graph-actions,
.knowledge-graph-form {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.knowledge-graph-form input {
    min-width: 0;
    flex: 1;
    min-height: 39px;
    padding: 0 10px;
    border: 1px solid #cbded9;
    border-radius: 9px;
}

.knowledge-graph-form button {
    min-height: 39px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    background: #0a7b73;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.knowledge-graph-content {
    margin-top: 13px;
    color: #4d7070;
    font-size: 11px;
}

.knowledge-graph-content p { margin: 0; }
.knowledge-graph-content ul { margin: 8px 0 0; padding-left: 17px; }

.wallet-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.wallet-panel h3,
.wallet-content h4 {
    margin: 0;
    color: var(--afriva-ink);
}

.wallet-plan {
    padding: 5px 8px;
    border-radius: 999px;
    background: #e3f7ec;
    color: #087b61;
    font-size: 9px;
    font-weight: 750;
}

.wallet-content {
    margin-top: 13px;
    color: #557572;
    font-size: 11px;
    line-height: 1.55;
}

.wallet-amount {
    display: block;
    color: #103f42;
    font-size: 23px;
    letter-spacing: -.03em;
}

.wallet-content p {
    margin: 5px 0 0;
}

.wallet-note {
    color: #65807c;
    font-size: 10px;
}

.wallet-content h4 {
    margin-top: 14px;
    font-size: 11px;
}

.wallet-content ul {
    display: grid;
    gap: 5px;
    margin: 7px 0 0;
    padding: 0;
    list-style: none;
}

.wallet-content li {
    padding: 7px 0;
    border-top: 1px solid #dcece5;
    font-size: 10px;
}

@media (max-width: 480px) {
    .wallet-button span:last-child {
        display: none;
    }

    .wallet-button {
        width: 38px;
        justify-content: center;
        padding: 0;
    }
}

/* Mobile drawer brand and research-journey refinement */
.sidebar {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(141, 224, 193, .38) transparent;
    scrollbar-width: thin;
}

.brand-banner {
    position: relative;
    display: block;
    min-height: 166px;
    margin: -9px -7px 19px;
    padding: 22px 20px 17px;
    overflow: hidden;
    border: 1px solid rgba(128, 224, 184, .22);
    border-radius: 17px;
    background:
        radial-gradient(circle at 85% 10%, rgba(45, 140, 255, .46), transparent 7rem),
        radial-gradient(circle at 15% 100%, rgba(25, 169, 116, .38), transparent 10rem),
        linear-gradient(135deg, #062635, #084653 58%, #063d3b);
    box-shadow: inset 0 1px rgba(229, 255, 246, .12), 0 16px 27px rgba(0, 0, 0, .16);
}

.brand-banner::before,
.brand-banner::after {
    position: absolute;
    border: 1px solid rgba(166, 247, 215, .19);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.brand-banner::before {
    top: -85px;
    right: -38px;
    width: 180px;
    height: 180px;
    box-shadow: 0 0 0 24px rgba(25, 169, 116, .06), 0 0 0 49px rgba(45, 140, 255, .045);
}

.brand-banner::after {
    bottom: -88px;
    left: -40px;
    width: 150px;
    height: 150px;
    border-color: rgba(242, 182, 68, .22);
}

.brand-banner .brand-mark,
.brand-banner .brand-copy {
    position: relative;
    z-index: 1;
}

.brand-banner .brand-mark {
    width: min(100%, 218px);
    margin: 3px 0 11px;
}

.brand-banner .brand-logo {
    mix-blend-mode: screen;
}

.brand-banner .brand-copy span {
    color: #e8fff5;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .15em;
}

.brand-banner .brand-copy small {
    display: block;
    margin-top: 7px;
    color: #b2d5cf;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .1em;
    line-height: 1.45;
    text-transform: uppercase;
}

.brand-banner .icon-button {
    position: absolute;
    z-index: 2;
    top: 13px;
    right: 13px;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: 14px;
    background: rgba(248, 255, 252, .92);
    color: #0d3741;
    box-shadow: 0 7px 18px rgba(0, 17, 24, .22);
    font-size: 26px;
    line-height: 1;
}

.new-project {
    position: relative;
    justify-content: flex-start;
    min-height: 54px;
    padding: 12px 15px;
    border-color: rgba(122, 243, 190, .56);
    background: linear-gradient(105deg, #14a670, #167fb8);
    box-shadow: 0 11px 24px rgba(2, 18, 24, .26), inset 0 1px rgba(255, 255, 255, .22);
}

.new-project-plus {
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, .17);
    font-size: 18px !important;
}

.new-project-arrow {
    margin-left: auto;
    color: #dbfff0;
    font-size: 20px;
}

.new-project:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 7px rgba(0, 0, 0, .17);
}

.new-project:focus-visible,
.brand-banner .icon-button:focus-visible {
    outline: 3px solid rgba(142, 247, 198, .82);
    outline-offset: 3px;
}

.sidebar-label {
    padding: 22px 10px 10px;
    color: #90b9b3;
    font-size: 9px;
    letter-spacing: .17em;
}

.stage-nav {
    gap: 6px;
}

.stage {
    min-height: 50px;
    gap: 9px;
    padding: 9px 9px;
    border-radius: 13px;
}

.stage-number {
    width: 25px;
    flex: 0 0 25px;
    font-size: 9px;
}

.stage-icon {
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(190, 236, 222, .1);
    border-radius: 9px;
    background: rgba(255, 255, 255, .055);
    color: #9fbbb8;
}

.stage-icon svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.stage-copy {
    min-width: 0;
}

.stage-copy strong,
.stage-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stage-copy strong {
    color: inherit;
    font-size: 12px;
    font-weight: 700;
}

.stage-copy small {
    display: none;
    margin-top: 3px;
    color: #8ba7a5;
    font-size: 9px;
}

.stage.active {
    border-color: rgba(95, 235, 168, .34);
    background:
        radial-gradient(circle at 100% 50%, rgba(45, 140, 255, .14), transparent 7rem),
        linear-gradient(90deg, rgba(20, 166, 112, .31), rgba(10, 91, 95, .14));
    box-shadow: inset 3px 0 var(--afriva-green), 0 7px 18px rgba(0, 12, 17, .12);
}

.stage.active .stage-icon {
    border-color: rgba(155, 255, 208, .34);
    background: rgba(54, 213, 144, .17);
    color: #8df0bd;
}

.stage.active .stage-copy strong {
    color: #f2fff9;
}

.sidebar-footer {
    padding: 17px 4px 0;
}

.connection {
    padding: 11px 10px;
    border: 1px solid rgba(184, 235, 220, .1);
    border-radius: 12px;
    background: rgba(255, 255, 255, .035);
}

.connection .status-dot {
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .12), 0 0 11px rgba(57, 207, 141, .48);
}

.brand-statement {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 15px 7px 3px;
    color: #8eadaa;
}

.brand-statement > span {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 1px solid rgba(86, 218, 153, .25);
    border-radius: 9px;
    color: #65dba1;
    font-size: 17px;
}

.brand-statement p {
    margin: 0;
    font-size: 8px;
    font-weight: 750;
    letter-spacing: .1em;
    line-height: 1.55;
}

.brand-statement strong {
    color: #d2ebe3;
}

@media (min-width: 821px) {
    .brand-banner {
        min-height: 148px;
        margin-bottom: 17px;
    }

    .brand-banner .brand-mark {
        width: min(100%, 200px);
    }
}

@media (max-width: 820px) {
    .sidebar {
        width: min(92vw, 360px);
        padding: 18px 14px 18px;
    }

    .brand-banner {
        min-height: 174px;
        margin: -3px -2px 18px;
    }

    .stage {
        min-height: 61px;
    }

    .stage-copy small {
        display: block;
    }
}

@media (max-width: 374px) {
    .sidebar {
        width: calc(100vw - 14px);
        padding: 15px 11px;
    }

    .brand-banner {
        min-height: 164px;
        padding: 19px 17px 15px;
    }

    .brand-banner .brand-mark {
        width: 194px;
    }

    .stage {
        gap: 7px;
        padding-right: 7px;
    }

    .stage-number {
        width: 22px;
        flex-basis: 22px;
    }
}

/* AFRIVA hero brand lockup */
.workspace-intro {
    min-height: 238px;
}

.hero-brand-lockup {
    position: relative;
    z-index: 1;
    width: min(100%, 238px);
    margin: 0 0 16px;
    padding: 10px 13px 9px;
    border: 1px solid rgba(196, 255, 225, .2);
    border-radius: 13px;
    background: rgba(0, 26, 34, .19);
    box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 9px 22px rgba(0, 22, 27, .14);
}

.hero-brand-logo {
    display: block;
    width: 100%;
    height: auto;
    mix-blend-mode: screen;
}

.hero-brand-lockup span {
    display: block;
    margin-top: 4px;
    color: #c1f5d9;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.workspace-intro .section-kicker,
.workspace-intro h2,
.workspace-intro p:not(.section-kicker) {
    position: relative;
    z-index: 1;
}

@media (min-width: 821px) {
    .workspace-intro {
        min-height: 252px;
        padding-top: 29px;
        padding-bottom: 29px;
    }

    .hero-brand-lockup {
        width: 272px;
        margin-bottom: 14px;
    }
}

@media (max-width: 820px) {
    .workspace-intro {
        min-height: 0;
    }

    .hero-brand-lockup {
        width: min(100%, 230px);
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .hero-brand-lockup {
        width: min(100%, 211px);
        padding: 8px 11px 8px;
    }
}

/* Zotero source workspace */
.zotero-panel {
    padding: 18px;
    border-top: 1px solid #dce9e5;
}

.zotero-panel-header {
    display: flex;
    align-items: center;
    gap: 9px;
}

.zotero-mark {
    width: 31px;
    height: 31px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 9px;
    background: linear-gradient(135deg, #e0f8ed, #e1f0ff);
    color: #087b61;
}

.zotero-mark svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.zotero-panel-header > div:nth-child(2) {
    min-width: 0;
    flex: 1;
}

.zotero-panel .tools-label {
    margin: 0 0 3px;
}

.zotero-panel h3 {
    margin: 0;
    color: var(--afriva-ink);
    font-size: 13px;
}

.zotero-status {
    padding: 4px 7px;
    border: 1px solid #d5e4e0;
    border-radius: 999px;
    background: #f5f9f8;
    color: #667d7a;
    font-size: 9px;
    font-weight: 750;
    white-space: nowrap;
}

.zotero-status.connected {
    border-color: #afe5ca;
    background: #eafaf1;
    color: #087b61;
}

.zotero-message {
    margin: 11px 0 13px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
}

.zotero-connect,
.zotero-subtle-button,
.zotero-page-button,
.zotero-source-controls button,
.zotero-source-controls a {
    min-height: 36px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 750;
}

.zotero-connect {
    width: 100%;
    border: 1px solid rgba(91, 219, 159, .58);
    background: linear-gradient(105deg, #129968, #167fba);
    color: #fff;
    box-shadow: 0 8px 17px rgba(8, 105, 88, .16);
}

.zotero-connect:hover {
    background: linear-gradient(105deg, #18ad76, #218dd0);
}

.zotero-library {
    padding-top: 2px;
}

.zotero-toolbar {
    display: grid;
    gap: 8px;
}

.zotero-toolbar input,
.zotero-toolbar select {
    width: 100%;
    min-height: 37px;
    border: 1px solid #cddfd9;
    border-radius: 9px;
    background: #fbfffd;
    color: var(--afriva-ink);
    font-size: 11px;
}

.zotero-toolbar input {
    padding: 0 11px;
}

.zotero-toolbar select {
    padding: 0 8px;
}

.zotero-library-actions,
.zotero-pagination {
    display: flex;
    gap: 7px;
    margin-top: 9px;
}

.zotero-subtle-button,
.zotero-page-button,
.zotero-source-controls button {
    border: 1px solid #c9ddd8;
    background: #fff;
    color: #17434a;
}

.zotero-subtle-button {
    flex: 1;
    padding: 0 8px;
}

.zotero-page-button {
    flex: 1;
}

.zotero-subtle-button:hover,
.zotero-page-button:hover,
.zotero-source-controls button:hover {
    border-color: #8dbfb0;
    background: #f0faf5;
}

.zotero-results-status {
    min-height: 17px;
    margin: 12px 0 5px;
    color: #607a78;
    font-size: 10px;
}

.zotero-results {
    display: grid;
    gap: 7px;
}

.zotero-source-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
    border: 1px solid #d5e5df;
    border-radius: 11px;
    background: #fcfffd;
}

.zotero-source-card > input {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: #109b6b;
}

.zotero-source-details strong,
.zotero-source-details span {
    display: block;
}

.zotero-source-details strong {
    color: var(--afriva-ink);
    font-size: 11px;
    line-height: 1.35;
}

.zotero-source-details span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.4;
}

.zotero-source-controls {
    display: flex;
    grid-column: 2;
    flex-wrap: wrap;
    gap: 6px;
}

.zotero-source-controls button,
.zotero-source-controls a {
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    text-decoration: none;
}

.zotero-source-controls a {
    color: #087b61;
}

.zotero-source-card details {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.zotero-source-card summary {
    cursor: pointer;
    color: #087b61;
    font-weight: 700;
}

.zotero-source-card details p {
    margin: 7px 0 0;
}

.zotero-tags {
    color: #3c7970;
}

.zotero-empty {
    margin: 0;
    padding: 12px;
    border: 1px dashed #cddfd9;
    border-radius: 10px;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
}

.zotero-disconnect {
    width: 100%;
    min-height: 34px;
    margin-top: 11px;
    border: 0;
    background: transparent;
    color: #a33c3c;
    font-size: 10px;
    font-weight: 700;
}

.source-attribution {
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid #cce9dc;
    border-radius: 12px;
    background: #effbf5;
    color: #245e54;
    font-size: 11px;
    line-height: 1.5;
}

.source-attribution strong {
    display: block;
    color: #087b61;
}

.source-attribution ul {
    margin: 6px 0 0;
    padding-left: 17px;
}

@media (max-width: 820px) {
    .zotero-panel {
        padding: 17px;
    }

    .zotero-connect,
    .zotero-subtle-button,
    .zotero-page-button {
        min-height: 42px;
    }
}

/* =========================================
   PRODUCT EXPERIENCE REFINEMENTS
========================================= */

:root {
    --primary: #315f72;
    --primary-dark: #1d4354;
    --primary-soft: #e7f1f0;
    --accent: #d99a3e;
    --ink: #14232a;
    --canvas: #f5f7f3;
    --surface: #ffffff;
    --border: #dce5e1;
    --muted: #5f6f73;
    --radius: 18px;
}

body {
    background:
        radial-gradient(circle at 88% 0%, rgba(217, 154, 62, .13), transparent 28rem),
        radial-gradient(circle at 53% 35%, rgba(49, 95, 114, .08), transparent 34rem),
        var(--canvas);
    color: var(--ink);
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 300;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    transform: translateY(-160%);
    transition: transform .2s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar {
    background:
        radial-gradient(circle at 22% 0%, rgba(217, 154, 62, .2), transparent 23%),
        linear-gradient(180deg, #142d38, #10232c);
}

.brand-mark,
.modal-logo {
    background: linear-gradient(135deg, #d9a34d, #b86d2d);
    box-shadow: 0 10px 26px rgba(184, 109, 45, .28);
}

.new-project {
    min-height: 48px;
    border-color: rgba(255, 255, 255, .16);
    background: rgba(255, 255, 255, .08);
}

.new-project:hover {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .28);
}

.stage {
    min-height: 42px;
}

.stage.active {
    background: linear-gradient(90deg, rgba(217, 154, 62, .22), rgba(217, 154, 62, .04));
    box-shadow: inset 3px 0 0 var(--accent);
}

.stage.active .stage-number {
    color: #f3c875;
}

.topbar {
    height: 82px;
    background: rgba(255, 255, 255, .78);
}

.topbar h1 {
    color: var(--ink);
}

.save-button,
.copy-button,
.secondary {
    min-height: 42px;
    border-color: var(--border);
}

.workspace-intro {
    width: min(1420px, calc(100% - 60px));
    margin: 30px auto 0;
    padding: 28px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    border: 1px solid rgba(49, 95, 114, .14);
    border-radius: 22px;
    background:
        linear-gradient(120deg, rgba(255, 255, 255, .94), rgba(245, 250, 248, .9)),
        var(--surface);
    box-shadow: 0 14px 38px rgba(20, 35, 42, .06);
}

.section-kicker {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .14em;
}

.workspace-intro h2 {
    max-width: 680px;
    margin: 0;
    color: var(--ink);
    font-size: clamp(25px, 3.2vw, 39px);
    line-height: 1.08;
    letter-spacing: -.045em;
}

.workspace-intro p:not(.section-kicker) {
    max-width: 650px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.intro-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 15px;
}

.intro-primary,
.primary {
    min-height: 46px;
    border: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, #315f72, #1d4354);
    color: #fff;
    box-shadow: 0 8px 18px rgba(29, 67, 84, .2);
}

.intro-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 750;
}

.intro-primary:hover,
.primary:hover {
    background: linear-gradient(135deg, #397088, #1d4354);
}

.intro-link {
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
}

.intro-link:hover {
    text-decoration: underline;
}

.workspace {
    max-width: 1480px;
    padding-top: 22px;
}

.paper-panel,
.copilot-panel {
    border-color: var(--border);
    box-shadow: 0 10px 30px rgba(20, 35, 42, .05);
}

.paper-panel {
    padding: clamp(20px, 3vw, 34px);
}

.progress-track {
    height: 6px;
    background: #e5ece8;
}

#progressBar {
    background: linear-gradient(90deg, #d99a3e, #315f72);
}

.section-number,
.empty-icon {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.section-heading p,
.output-subtitle {
    font-size: 12px;
}

.editor-wrapper:focus-within {
    border-color: rgba(49, 95, 114, .65);
    box-shadow: 0 0 0 4px rgba(49, 95, 114, .12);
}

#researchInput {
    min-height: 330px;
    font-size: 15px;
    line-height: 1.72;
}

.output {
    border-color: var(--border);
    background: linear-gradient(160deg, #fff, #f7faf8);
}

.copilot-header {
    background: linear-gradient(145deg, #fbfdfc, #f2f7f5);
}

.copilot-icon,
.quick-action:hover .quick-icon {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.quick-action {
    min-height: 58px;
}

.quick-action:hover {
    background: #f4f8f6;
    border-color: #d8e6e0;
}

.entity-panel {
    padding: 4px 18px 18px;
    border-top: 1px solid var(--border);
}

.entity-panel-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 0 10px;
}

.entity-panel .tools-label {
    margin: 0 0 4px;
}

.entity-panel h3 {
    margin: 0;
    color: var(--ink);
    font-size: 13px;
}

.entity-count {
    min-width: 24px;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.entity-list {
    display: grid;
    gap: 7px;
}

.entity-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfdfc;
}

.entity-item strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entity-item span {
    color: var(--muted);
    font-size: 10px;
    text-transform: capitalize;
}

.entity-state {
    margin: 0;
    padding: 10px;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

.entity-error {
    color: var(--danger);
}

.site-footer {
    width: min(1420px, calc(100% - 60px));
    margin: 0 auto;
    padding: 22px 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    color: var(--muted);
    font-size: 11px;
}

.site-footer strong {
    color: var(--ink);
    font-size: 13px;
}

.site-footer span {
    margin-left: 8px;
}

.site-footer p {
    margin: 0;
    text-align: right;
}

.auth-provider-note {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 11px;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(217, 154, 62, .55);
    outline-offset: 3px;
}

@media (max-width: 820px) {
    .workspace-intro,
    .site-footer {
        width: calc(100% - 28px);
    }

    .workspace-intro {
        margin-top: 16px;
        padding: 23px 20px;
        display: block;
    }

    .workspace-intro h2 {
        font-size: 28px;
    }

    .intro-actions {
        margin-top: 19px;
    }

    .topbar {
        height: 70px;
    }

    .icon-button {
        width: 42px;
        height: 42px;
        place-items: center;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: #fff;
        color: var(--ink);
    }

    .site-footer {
        display: block;
        padding: 20px 0 28px;
    }

    .site-footer span {
        display: block;
        margin: 4px 0 0;
    }

    .site-footer p {
        margin-top: 12px;
        text-align: left;
    }

    .footer-brand {
        flex-wrap: wrap;
    }

    .footer-brand span {
        flex-basis: 100%;
    }
}

@media (max-width: 480px) {
    .workspace-intro,
    .site-footer {
        width: calc(100% - 20px);
    }

    .workspace-intro h2 {
        font-size: 25px;
    }

    .workspace-intro p:not(.section-kicker) {
        font-size: 13px;
    }

    .intro-actions {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .intro-primary {
        justify-content: center;
    }

    .intro-link {
        padding: 8px;
        text-align: center;
    }

    #researchInput {
        min-height: 250px;
        font-size: 14px;
    }

    .entity-panel {
        padding-right: 14px;
        padding-left: 14px;
    }
}

.brand-mark,
.modal-logo {
    background: transparent;
    box-shadow: none;
}

.brand-logo,
.modal-brand-logo,
.footer-logo {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.brand-mark {
    width: clamp(80px, 8vw, 126px);
    height: auto;
    flex: 0 0 auto;
    border-radius: 0;
}

.modal-logo {
    width: clamp(128px, 28vw, 180px);
    height: auto;
    margin: 0 auto 18px;
    border-radius: 0;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-logo {
    width: clamp(64px, 8vw, 96px);
    flex: 0 0 auto;
}

.site-footer span {
    margin-left: 0;
}

@media (max-width: 820px) {
    .footer-brand {
        flex-wrap: wrap;
    }

    .footer-brand span {
        flex-basis: 100%;
    }
}

/* AFRIVA workspace visual system */
:root {
    --afriva-navy: #071f2b;
    --afriva-deep: #041721;
    --afriva-teal: #0a4353;
    --afriva-emerald: #19a974;
    --afriva-green: #39cf8d;
    --afriva-blue: #2d8cff;
    --afriva-gold: #f2b644;
    --afriva-canvas: #edf5f3;
    --afriva-ink: #102b34;
    --afriva-muted: #60757b;
    --afriva-line: #d6e4e0;
    --primary: var(--afriva-emerald);
    --primary-dark: #087551;
    --primary-soft: #dff7eb;
    --ink: var(--afriva-ink);
    --canvas: var(--afriva-canvas);
    --border: var(--afriva-line);
    --muted: var(--afriva-muted);
    --radius: 20px;
}

body {
    background:
        radial-gradient(circle at 94% 2%, rgba(45, 140, 255, .14), transparent 25rem),
        radial-gradient(circle at 55% 18%, rgba(25, 169, 116, .1), transparent 32rem),
        var(--afriva-canvas);
}

.sidebar {
    width: 292px;
    flex-basis: 292px;
    padding: 24px 15px 18px;
    background:
        radial-gradient(circle at 10% 4%, rgba(57, 207, 141, .19), transparent 20rem),
        radial-gradient(circle at 88% 22%, rgba(45, 140, 255, .16), transparent 18rem),
        linear-gradient(180deg, #092c39 0%, var(--afriva-deep) 100%);
    border-right-color: rgba(180, 233, 220, .1);
}

.brand {
    gap: 10px;
    padding: 1px 7px 26px;
}

.brand-mark {
    width: 126px;
}

.brand-copy strong {
    color: #fff;
    font-size: 17px;
}

.brand-copy span {
    color: #9fc2bd;
    font-size: 10px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.new-project {
    min-height: 50px;
    border-color: rgba(83, 224, 163, .38);
    border-radius: 13px;
    background: linear-gradient(135deg, #159766, #087b62);
    box-shadow: 0 12px 25px rgba(0, 0, 0, .2), inset 0 1px rgba(255, 255, 255, .18);
}

.new-project:hover {
    background: linear-gradient(135deg, #1bb47b, #0a8e70);
    border-color: rgba(114, 245, 190, .56);
}

.sidebar-label,
.tools-label {
    color: #8aada8;
}

.sidebar-label {
    padding-top: 25px;
}

.stage {
    min-height: 43px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: #b5cac7;
}

.stage:hover {
    background: rgba(255, 255, 255, .07);
}

.stage.active {
    border-color: rgba(55, 211, 143, .15);
    background: linear-gradient(90deg, rgba(25, 169, 116, .29), rgba(25, 169, 116, .04));
    box-shadow: inset 3px 0 0 var(--afriva-green);
}

.stage.active .stage-number {
    color: #7de7b3;
}

.stage-number {
    color: #7c9a9d;
}

.sidebar-footer {
    border-top-color: rgba(180, 233, 220, .12);
}

.connection strong {
    color: #d8f0e9;
}

.connection small,
.account-info span,
.account-arrow {
    color: #8eadaa;
}

.account-button:hover {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(180, 233, 220, .12);
}

.avatar {
    border-radius: 11px;
    background: linear-gradient(135deg, var(--afriva-blue), #1555a5);
}

.topbar {
    height: 84px;
    padding: 0 clamp(20px, 3vw, 42px);
    background: rgba(248, 253, 251, .82);
    border-bottom-color: rgba(143, 183, 175, .35);
    box-shadow: 0 5px 24px rgba(12, 48, 52, .035);
}

.eyebrow,
.section-kicker {
    color: #087b61;
}

.topbar h1 {
    color: var(--afriva-ink);
    font-size: 24px;
}

.save-state {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(25, 169, 116, .08);
    color: #337067;
}

.save-button,
.copy-button,
.secondary {
    border-color: #c9ddd8;
    background: rgba(255, 255, 255, .9);
    color: #17434a;
    box-shadow: none;
}

.save-button:hover,
.copy-button:hover,
.secondary:hover {
    border-color: #8abdaf;
    background: #fff;
    box-shadow: 0 8px 18px rgba(8, 71, 67, .08);
}

.workspace-intro {
    position: relative;
    overflow: hidden;
    width: min(1420px, calc(100% - 60px));
    min-height: 196px;
    padding: 34px 38px;
    border: 1px solid rgba(126, 201, 177, .27);
    border-radius: 24px;
    background:
        radial-gradient(circle at 93% 5%, rgba(56, 207, 143, .24), transparent 13rem),
        radial-gradient(circle at 82% 120%, rgba(45, 140, 255, .2), transparent 20rem),
        linear-gradient(118deg, #073342 0%, #0a4954 59%, #0b5a58 100%);
    box-shadow: 0 20px 46px rgba(7, 49, 55, .16);
}

.workspace-intro::after {
    position: absolute;
    right: -68px;
    bottom: -92px;
    width: 265px;
    height: 265px;
    border: 1px solid rgba(214, 255, 236, .2);
    border-radius: 50%;
    box-shadow: 0 0 0 26px rgba(214, 255, 236, .05), 0 0 0 53px rgba(214, 255, 236, .04);
    content: "";
    pointer-events: none;
}

.section-kicker {
    color: #80eeb8;
}

.workspace-intro h2 {
    max-width: 690px;
    color: #f7fffc;
    font-size: clamp(29px, 3.3vw, 43px);
}

.workspace-intro p:not(.section-kicker) {
    color: #c6e1da;
    font-size: 14px;
}

.intro-actions {
    position: relative;
    z-index: 1;
}

.intro-primary,
.primary {
    background: linear-gradient(135deg, #29c780, #109c6e);
    box-shadow: 0 12px 24px rgba(0, 19, 23, .25);
}

.intro-primary:hover,
.primary:hover {
    background: linear-gradient(135deg, #44dc98, #15ad79);
}

.intro-link {
    color: #dcfff0;
}

.workspace {
    max-width: 1480px;
    grid-template-columns: minmax(0, 1fr) 355px;
    gap: 25px;
    padding-top: 24px;
}

.paper-panel,
.copilot-panel {
    border-color: rgba(153, 190, 182, .5);
    background: rgba(255, 255, 255, .87);
    box-shadow: 0 16px 38px rgba(9, 54, 54, .07);
}

.paper-panel {
    padding: clamp(24px, 3vw, 36px);
}

.progress-track {
    background: #dcebe7;
}

#progressBar {
    background: linear-gradient(90deg, var(--afriva-emerald), var(--afriva-blue));
    box-shadow: 0 0 14px rgba(25, 169, 116, .28);
}

.progress-meta strong,
.section-heading h2,
.output-title {
    color: var(--afriva-ink);
}

.section-number,
.empty-icon {
    background: linear-gradient(135deg, #dff9ed, #d9edff);
    color: #087b61;
}

.editor-wrapper {
    border-color: #cbded9;
    border-radius: 15px;
    background: #fff;
}

.editor-wrapper:focus-within {
    border-color: rgba(25, 169, 116, .76);
    box-shadow: 0 0 0 4px rgba(25, 169, 116, .12);
}

.editor-toolbar {
    background: #f5faf8;
    border-bottom-color: #dce9e5;
}

#researchInput {
    min-height: 340px;
    color: #163840;
}

.output-section {
    border-top-color: #dce9e5;
}

.output {
    border-color: #d3e4df;
    background: linear-gradient(140deg, #fcfffd, #f4fbf8);
}

.copilot-panel {
    top: 108px;
    border-radius: 20px;
}

.copilot-header {
    padding: 21px;
    border-bottom-color: rgba(159, 205, 192, .4);
    background:
        radial-gradient(circle at 90% 0%, rgba(45, 140, 255, .15), transparent 8rem),
        linear-gradient(135deg, #eafbf3, #edf7ff);
}

.copilot-icon {
    background: linear-gradient(135deg, #0ca370, #127ccd);
    color: #fff;
    box-shadow: 0 8px 20px rgba(17, 127, 111, .2);
}

.copilot-header strong {
    color: var(--afriva-ink);
}

.welcome-card {
    border-color: #cce9dc;
    background:
        radial-gradient(circle at 100% 0%, rgba(45, 140, 255, .1), transparent 8rem),
        linear-gradient(140deg, #effbf5, #f8fffb);
}

.welcome-icon {
    color: #079568;
}

.quick-action {
    border-radius: 12px;
}

.quick-action:hover {
    background: #f0faf5;
    border-color: #c9e9da;
}

.quick-icon,
.quick-action:hover .quick-icon {
    background: #e2f6ed;
    color: #087b61;
}

.entity-panel {
    border-top-color: #dce9e5;
}

.entity-count {
    background: #e2f6ed;
    color: #087b61;
}

.entity-item {
    border-color: #d7e7e2;
    background: #fcfffd;
}

.entity-item strong,
.entity-panel h3 {
    color: var(--afriva-ink);
}

.copilot-footer {
    border-top-color: #dce9e5;
}

.site-footer {
    color: #658087;
}

.site-footer strong {
    color: var(--afriva-ink);
}

.modal {
    background: rgba(3, 25, 33, .73);
}

.modal-card {
    border-color: rgba(173, 230, 210, .55);
    background: linear-gradient(155deg, #fff, #f0faf6);
}

.auth-tab.active {
    color: #087b61;
}

.auth-input:focus {
    border-color: var(--afriva-emerald);
    box-shadow: 0 0 0 3px rgba(25, 169, 116, .13);
}

.email-button {
    background: linear-gradient(135deg, #159b6b, #087b61);
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
a:focus-visible {
    outline-color: rgba(25, 169, 116, .68);
}

@media (max-width: 1100px) {
    .sidebar {
        width: 254px;
        flex-basis: 254px;
    }

    .brand-mark {
        width: 96px;
    }

    .workspace {
        grid-template-columns: minmax(0, 1fr) 300px;
    }
}

@media (max-width: 820px) {
    .sidebar {
        width: 290px;
    }

    .workspace-intro {
        min-height: 0;
        background:
            radial-gradient(circle at 100% 0%, rgba(57, 207, 141, .2), transparent 11rem),
            linear-gradient(135deg, #073342, #0a5357);
    }

    .workspace-intro::after {
        opacity: .55;
    }

    .topbar {
        background: rgba(248, 253, 251, .94);
    }

    .icon-button {
        border-color: #c9ddd8;
        color: var(--afriva-ink);
    }
}

@media (max-width: 480px) {
    .workspace-intro {
        padding: 26px 21px;
        border-radius: 19px;
    }

    .workspace-intro h2 {
        font-size: 28px;
    }

    .topbar h1 {
        font-size: 19px;
    }

    .paper-panel,
    .copilot-panel {
        border-radius: 16px;
    }
}
