/* ------------------------------------------------------------------ */
/* Custom Properties                                                   */
/* ------------------------------------------------------------------ */
:root {
    --color-bg: #0f1729;
    --color-bg-card: #1a2342;
    --color-bg-input: #0d1224;
    --color-border: #2a3a5c;
    --color-border-focus: #4a7dff;
    --color-primary: #4a7dff;
    --color-primary-hover: #6b95ff;
    --color-primary-active: #3a6ae0;
    --color-text: #e2e8f0;
    --color-text-muted: #8b97b0;
    --color-text-heading: #ffffff;
    --color-error-bg: #2d1b1b;
    --color-error-border: #6b2a2a;
    --color-error-text: #f87171;
    --color-success-bg: #1b2d1b;
    --color-success-border: #2a6b2a;
    --color-success-text: #4ade80;
    --color-assistant-bg: #1e2a4a;
    --color-user-bg: #2c4a8a;
    --color-citation-bg: rgba(74, 125, 255, 0.15);
    --color-citation-border: rgba(74, 125, 255, 0.4);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-input: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-message: 0 2px 8px rgba(0, 0, 0, 0.15);
    --transition: 0.2s ease;
    --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    --topbar-height: 60px;
    --input-bar-height: 80px;
}

/* ------------------------------------------------------------------ */
/* Reset & Base                                                        */
/* ------------------------------------------------------------------ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(74, 125, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(74, 125, 255, 0.04) 0%, transparent 50%);
}

body.chat-active {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

/* ------------------------------------------------------------------ */
/* LOGIN VIEW                                                          */
/* ------------------------------------------------------------------ */
.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem 2rem;
    box-shadow: var(--shadow-card);
}

.login-card__header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card__icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--color-primary), #6b5ce7);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.login-card__icon svg {
    width: 28px;
    height: 28px;
    stroke: #ffffff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.login-card__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-heading);
    letter-spacing: -0.01em;
}

.login-card__subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.35rem;
}

/* ------------------------------------------------------------------ */
/* Form Elements                                                       */
/* ------------------------------------------------------------------ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.4rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-input);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

.form-group input:focus {
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(74, 125, 255, 0.15);
}

/* ------------------------------------------------------------------ */
/* Submit Button                                                       */
/* ------------------------------------------------------------------ */
.btn-login {
    display: block;
    width: 100%;
    padding: 0.8rem 1.5rem;
    margin-top: 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--font-family);
    color: #ffffff;
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    letter-spacing: 0.01em;
}

.btn-login:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 14px rgba(74, 125, 255, 0.35);
}

.btn-login:active {
    background: var(--color-primary-active);
    transform: scale(0.985);
}

.btn-login:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ------------------------------------------------------------------ */
/* Messages (Error / Success)                                          */
/* ------------------------------------------------------------------ */
.message {
    display: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    line-height: 1.45;
}

.message--error {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error-text);
}

.message--success {
    background: var(--color-success-bg);
    border: 1px solid var(--color-success-border);
    color: var(--color-success-text);
}

.message--visible {
    display: block;
}

/* ------------------------------------------------------------------ */
/* Loading Spinner                                                     */
/* ------------------------------------------------------------------ */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}

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

/* ================================================================== */
/*                          CHAT VIEW                                  */
/* ================================================================== */

#chat-view {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* Top Bar                                                             */
/* ------------------------------------------------------------------ */
.chat-topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 10;
}

.chat-topbar__left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-topbar__icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-primary), #6b5ce7);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-topbar__icon svg {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-topbar__title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text-heading);
    letter-spacing: -0.01em;
}

.chat-topbar__right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-topbar {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: var(--font-family);
    color: var(--color-text);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-topbar:hover {
    background: rgba(74, 125, 255, 0.1);
    border-color: var(--color-primary);
    color: var(--color-text-heading);
}

.btn-topbar--danger:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--color-error-text);
    color: var(--color-error-text);
}

/* ------------------------------------------------------------------ */
/* Chat Messages Area                                                  */
/* ------------------------------------------------------------------ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Welcome screen */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    gap: 1rem;
    padding: 2rem;
    color: var(--color-text-muted);
}

.chat-welcome__icon {
    opacity: 0.4;
}

.chat-welcome__icon svg {
    stroke: var(--color-primary);
}

.chat-welcome h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text-heading);
}

.chat-welcome p {
    max-width: 500px;
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/* Message Bubbles                                                     */
/* ------------------------------------------------------------------ */
.chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 85%;
    animation: msgFadeIn 0.25s ease;
}

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

.chat-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg--assistant {
    align-self: flex-start;
}

.chat-msg--system {
    align-self: center;
    max-width: 90%;
}

.chat-msg__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.chat-msg--user .chat-msg__avatar {
    background: var(--color-primary);
}

.chat-msg--assistant .chat-msg__avatar {
    background: linear-gradient(135deg, #6b5ce7, var(--color-primary));
}

.chat-msg__bubble {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 0.9375rem;
    box-shadow: var(--shadow-message);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-msg--user .chat-msg__bubble {
    background: var(--color-user-bg);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-msg--assistant .chat-msg__bubble {
    background: var(--color-assistant-bg);
    color: var(--color-text);
    border-bottom-left-radius: 4px;
}

.chat-msg--system .chat-msg__bubble {
    background: rgba(74, 125, 255, 0.08);
    border: 1px solid rgba(74, 125, 255, 0.2);
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    text-align: center;
    border-radius: var(--radius);
}

.chat-msg--error .chat-msg__bubble {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error-text);
}

/* Markdown inside messages */
.chat-msg__bubble h1,
.chat-msg__bubble h2,
.chat-msg__bubble h3,
.chat-msg__bubble h4 {
    color: var(--color-text-heading);
    margin: 0.75rem 0 0.35rem;
    line-height: 1.3;
}

.chat-msg__bubble h1 { font-size: 1.2rem; }
.chat-msg__bubble h2 { font-size: 1.1rem; }
.chat-msg__bubble h3 { font-size: 1rem; }

.chat-msg__bubble p {
    margin: 0.35rem 0;
}

.chat-msg__bubble ul,
.chat-msg__bubble ol {
    margin: 0.35rem 0 0.35rem 1.25rem;
}

.chat-msg__bubble li {
    margin: 0.15rem 0;
}

.chat-msg__bubble code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'Fira Code', 'Consolas', monospace;
}

.chat-msg__bubble pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0.5rem 0;
}

.chat-msg__bubble pre code {
    background: none;
    padding: 0;
}

.chat-msg__bubble blockquote {
    border-left: 3px solid var(--color-primary);
    padding-left: 0.75rem;
    margin: 0.5rem 0;
    color: var(--color-text-muted);
}

.chat-msg__bubble a {
    color: var(--color-primary-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-msg__bubble a:hover {
    color: #ffffff;
}

.chat-msg__bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

.chat-msg__bubble th,
.chat-msg__bubble td {
    border: 1px solid var(--color-border);
    padding: 0.4rem 0.65rem;
    text-align: left;
}

.chat-msg__bubble th {
    background: rgba(0, 0, 0, 0.2);
    color: var(--color-text-heading);
    font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Citations                                                           */
/* ------------------------------------------------------------------ */
.chat-msg__sources {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-msg__sources-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

.chat-msg__sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.citation {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    background: var(--color-citation-bg);
    border: 1px solid var(--color-citation-border);
    color: var(--color-text);
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: default;
    transition: all var(--transition);
    line-height: 1.35;
}

.citation__ref {
    color: var(--color-primary-hover);
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.citation__text {
    color: var(--color-text);
    font-weight: 400;
}

.citation:hover {
    background: rgba(74, 125, 255, 0.25);
}

/* ------------------------------------------------------------------ */
/* Typing Indicator                                                    */
/* ------------------------------------------------------------------ */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.85rem 1.1rem;
    background: var(--color-assistant-bg);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-message);
    width: fit-content;
}

.typing-indicator__dot {
    width: 8px;
    height: 8px;
    background: var(--color-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

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

/* ------------------------------------------------------------------ */
/* Input Bar                                                           */
/* ------------------------------------------------------------------ */
.chat-input-bar {
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border);
    padding: 0.75rem 1.25rem;
    z-index: 10;
}

.chat-input-bar__inner {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.chat-input-bar__actions-left {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    padding-bottom: 0.25rem;
}

.btn-attach {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-attach:hover {
    background: rgba(74, 125, 255, 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary-hover);
}

.chat-input {
    flex: 1;
    min-height: 42px;
    max-height: 150px;
    padding: 0.6rem 1rem;
    font-size: 0.9375rem;
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    outline: none;
    resize: none;
    line-height: 1.5;
    transition: border-color var(--transition), box-shadow var(--transition);
    overflow-y: auto;
}

.chat-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

.chat-input:focus {
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(74, 125, 255, 0.15);
}

.btn-send {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius);
    color: #ffffff;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 14px rgba(74, 125, 255, 0.35);
}

.btn-send:active {
    background: var(--color-primary-active);
    transform: scale(0.95);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Upload status */
.upload-status {
    display: none;
    max-width: 900px;
    margin: 0.5rem auto 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    animation: msgFadeIn 0.2s ease;
}

.upload-status--visible {
    display: block;
}

.upload-status--info {
    background: rgba(74, 125, 255, 0.1);
    border: 1px solid rgba(74, 125, 255, 0.25);
    color: var(--color-primary-hover);
}

.upload-status--success {
    background: var(--color-success-bg);
    border: 1px solid var(--color-success-border);
    color: var(--color-success-text);
}

.upload-status--error {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error-text);
}

/* ------------------------------------------------------------------ */
/* Sources Panel (overlay slide-in from right)                         */
/* ------------------------------------------------------------------ */
.sources-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sources-overlay--open {
    opacity: 1;
    visibility: visible;
}

.sources-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100%;
    background: var(--color-bg-card);
    border-left: 1px solid var(--color-border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.sources-overlay--open .sources-panel {
    transform: translateX(0);
}

.sources-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.sources-panel__header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text-heading);
}

.btn-close-panel {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-close-panel:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--color-error-text);
    color: var(--color-error-text);
}

/* Sources List */
.sources-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sources-list::-webkit-scrollbar {
    width: 5px;
}

.sources-list::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.sources-empty {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    padding: 3rem 1rem;
}

.source-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    transition: border-color var(--transition);
}

.source-item:hover {
    border-color: rgba(74, 125, 255, 0.3);
}

.source-item__info {
    flex: 1;
    min-width: 0;
}

.source-item__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-item__meta {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.source-item__badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    font-size: 0.675rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.source-item__badge--pdf {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.source-item__badge--web {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.btn-delete-source {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-delete-source:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--color-error-text);
    color: var(--color-error-text);
}

/* ------------------------------------------------------------------ */
/* URL Modal                                                           */
/* ------------------------------------------------------------------ */
.url-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    padding: 1rem;
}

.url-modal-overlay--open {
    opacity: 1;
    visibility: visible;
}

.url-modal {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-card);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.url-modal-overlay--open .url-modal {
    transform: scale(1);
}

.url-modal h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-heading);
    margin-bottom: 0.5rem;
}

.url-modal p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.url-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.url-input:focus {
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(74, 125, 255, 0.15);
}

.url-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

.url-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.btn-modal {
    padding: 0.55rem 1.15rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--color-border);
}

.btn-modal--cancel {
    background: transparent;
    color: var(--color-text-muted);
}

.btn-modal--cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
}

.btn-modal--confirm {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #ffffff;
}

.btn-modal--confirm:hover {
    background: var(--color-primary-hover);
}

.btn-modal--confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ------------------------------------------------------------------ */
/* PDF Viewer Overlay                                                  */
/* ------------------------------------------------------------------ */
.pdf-viewer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: stretch;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pdf-viewer-overlay--open {
    opacity: 1;
    visibility: visible;
}

.pdf-viewer-panel {
    width: 90%;
    max-width: 1100px;
    margin: 1.5rem;
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pdf-viewer-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.pdf-viewer-panel__header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.pdf-viewer-panel__actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.pdf-viewer-frame {
    flex: 1;
    border: none;
    background: #2a2a2a;
}

/* Make citation clickable */
.citation--clickable {
    cursor: pointer;
}

.citation--clickable:hover {
    background: rgba(74, 125, 255, 0.35);
    border-color: var(--color-primary);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 480px) {
    .login-card {
        padding: 2rem 1.25rem 1.5rem;
    }

    .login-card__title {
        font-size: 1.3rem;
    }

    .chat-topbar {
        padding: 0 0.75rem;
    }

    .btn-topbar span {
        display: none;
    }

    .chat-messages {
        padding: 1rem;
    }

    .chat-msg {
        max-width: 95%;
    }

    .chat-input-bar {
        padding: 0.5rem 0.75rem;
    }

    .sources-panel {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .chat-msg {
        max-width: 92%;
    }
}
