﻿
        * { margin: 0; padding: 0; box-sizing: border-box; }
        .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;
        }
        :root {
            --ocp-brand: #1DA13D;
            --ocp-green: #1DA13D;
            --ocp-green-hover: #159035;
            --ocp-accent-light: rgba(34, 197, 94, 0.18);
            --bg-page: #052e16;
            --surface: #14532d;
            --surface-chat: #0a3d22;
            --border: #166534;
            --border-soft: #15803d;
            --text: #ecfdf5;
            --text-secondary: #bbf7d0;
            --text-muted: #86efac;
            --user-msg: #166534;
            --user-msg-border: #22c55e;
            --assistant-msg: #14532d;
            --assistant-border: #15803d;
            --radius: 12px;
            --radius-sm: 8px;
            --shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 12px 40px rgba(0, 0, 0, 0.35);
            --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
            --font-ar: "Noto Sans Arabic", "Inter", system-ui, sans-serif;
        }
        html[lang="ar"] body, .chat-container[dir="rtl"] { font-family: var(--font-ar); }
        body {
            font-family: var(--font);
            background: linear-gradient(165deg, #022c22 0%, var(--bg-page) 45%, #14532d 100%);
            color: var(--text);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: stretch;
            padding: clamp(12px, 2vw, 28px);
            line-height: 1.5;
        }
        .app-shell {
            width: 100%;
            max-width: 820px;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            min-height: min(92vh, 900px);
        }
        .chat-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--surface);
            border-radius: var(--radius);
            border: 1px solid var(--border-soft);
            box-shadow: var(--shadow);
            overflow: hidden;
            min-height: 0;
        }
        .app-header {
            flex-shrink: 0;
            border-bottom: none;
            background: var(--ocp-brand);
        }
        .app-header__row {
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 12px 18px;
        }
        .header-logo {
            flex-shrink: 0;
            width: auto;
            max-width: min(260px, 56vw);
            height: 48px;
            background: transparent;
            border: none;
            border-radius: 0;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            padding: 0;
        }
        .header-logo__img {
            height: 100%;
            width: auto;
            max-width: 100%;
            object-fit: contain;
            object-position: left center;
            display: block;
        }
        .chat-container[dir="rtl"] .header-logo__img { object-position: right center; }
        .header-text { flex: 1; min-width: 0; }
        .header-text h1 {
            color: #ffffff;
            font-size: 1.125rem;
            font-weight: 600;
            letter-spacing: -0.02em;
            line-height: 1.3;
        }
        .header-text p {
            color: rgba(255, 255, 255, 0.92);
            font-size: 0.8125rem;
            margin-top: 2px;
        }
        .header-status { flex-shrink: 0; }
        .status-pill {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            background: rgba(255, 255, 255, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.35);
            border-radius: 999px;
            font-size: 0.75rem;
            font-weight: 500;
            color: #ffffff;
        }
        .status-dot {
            width: 8px;
            height: 8px;
            background: #ffffff;
            border-radius: 50%;
            box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
        }
        .app-toolbar {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 8px;
            padding: 10px 16px 14px;
            background: var(--surface);
            border-top: 1px solid rgba(29, 161, 61, 0.25);
        }
        .app-toolbar__group {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 6px;
        }
        .app-toolbar__group--end { margin-inline-start: auto; }
        .chat-container[dir="rtl"] .app-toolbar__group--end {
            margin-inline-start: 0;
            margin-inline-end: auto;
        }
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 7px 12px;
            font-size: 0.8125rem;
            font-weight: 500;
            font-family: inherit;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
            background: var(--surface);
            color: var(--text);
            cursor: pointer;
            transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
        }
        .btn:hover { background: var(--surface-chat); border-color: #94a3b8; }
        .btn:focus-visible { outline: 2px solid var(--ocp-green); outline-offset: 2px; }
        .btn--ghost { background: transparent; border-color: transparent; }
        .btn--ghost:hover { background: rgba(34, 197, 94, 0.15); border-color: transparent; color: #bbf7d0; }
        .btn.muted, .btn.off { opacity: 0.65; }
        .select-lang {
            font-family: inherit;
            font-size: 0.8125rem;
            padding: 7px 32px 7px 10px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
            background: var(--surface);
            color: var(--text);
            cursor: pointer;
            min-width: 128px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23bbf7d0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 10px center;
            appearance: none;
        }
        .select-lang:focus-visible { outline: 2px solid var(--ocp-green); outline-offset: 2px; }
        .chat-messages {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 16px 18px;
            display: flex;
            flex-direction: column;
            gap: 14px;
            background: var(--surface-chat);
            scroll-behavior: smooth;
        }
        .message {
            max-width: min(100%, 640px);
            padding: 12px 14px;
            border-radius: var(--radius-sm);
            line-height: 1.65;
            font-size: 0.9375rem;
            animation: fadeIn 0.22s ease-out;
            position: relative;
            border: 1px solid transparent;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(6px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .message.user {
            align-self: flex-end;
            background: var(--user-msg);
            border-color: var(--user-msg-border);
            color: var(--text);
            border-bottom-right-radius: 4px;
        }
        .message.assistant {
            align-self: flex-start;
            background: var(--assistant-msg);
            border-color: var(--assistant-border);
            color: var(--text);
            border-bottom-left-radius: 4px;
            box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
        }
        .chat-container[dir="rtl"] .message.user {
            border-bottom-right-radius: var(--radius-sm);
            border-bottom-left-radius: 4px;
        }
        .chat-container[dir="rtl"] .message.assistant {
            border-bottom-left-radius: var(--radius-sm);
            border-bottom-right-radius: 4px;
        }
        .message-header {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 8px;
            font-weight: 600;
            font-size: 0.75rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }
        .message-time { margin-inline-start: auto; font-size: 0.6875rem; font-weight: 500; opacity: 0.85; }
        .qa-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 22px;
            height: 20px;
            padding: 0 6px;
            border-radius: 4px;
            font-size: 0.65rem;
            font-weight: 700;
        }
        .qa-badge--q { background: var(--ocp-green); color: #fff; }
        .qa-badge--a { background: #15803d; color: #ecfdf5; }
        .message-content {
            white-space: normal;
            word-break: break-word;
            font-size: 0.9375rem;
            color: var(--text);
            text-rendering: optimizeLegibility;
        }
        .message-content p { margin: 0 0 10px; }
        .message-content p:last-child { margin-bottom: 0; }
        .message-content .section-title {
            margin-top: 12px;
            margin-bottom: 8px;
            color: var(--ocp-green);
            font-weight: 700;
            font-size: 0.9em;
            text-transform: none;
            letter-spacing: 0;
        }
        .message-content .section-title--alert {
            color: #9a3412;
            border-inline-start: 3px solid #ea580c;
            padding-inline-start: 10px;
        }
        .message-content .actions-box {
            margin: 8px 0 10px;
            padding: 10px 12px;
            border-radius: var(--radius-sm);
            border: 1px solid #fde68a;
            background: #fffbeb;
            color: var(--text);
        }
        .message-content ul, .message-content ol { margin: 6px 0 10px; padding-inline-start: 22px; }
        .message-content li { margin: 4px 0; }
        .message-content strong { color: var(--text); font-weight: 600; }
        .quick-actions {
            display: flex;
            gap: 8px;
            padding: 0 18px 10px;
            flex-wrap: wrap;
            background: var(--surface-chat);
        }
        .quick-btn {
            background: var(--surface);
            border: 1px solid var(--border);
            color: var(--text-secondary);
            padding: 7px 12px;
            border-radius: 999px;
            cursor: pointer;
            font-size: 0.75rem;
            font-weight: 500;
            font-family: inherit;
            transition: border-color 0.15s, color 0.15s, background 0.15s;
            white-space: nowrap;
        }
        .quick-btn:hover {
            border-color: var(--ocp-green);
            color: var(--ocp-green);
            background: var(--ocp-accent-light);
        }
        .quick-btn:focus-visible { outline: 2px solid var(--ocp-green); outline-offset: 2px; }
        .input-area {
            padding: 12px 16px 14px;
            background: var(--surface);
            border-top: 1px solid var(--border-soft);
        }
        .input-wrapper {
            display: flex;
            gap: 10px;
            background: var(--surface-chat);
            border-radius: var(--radius-sm);
            padding: 6px 8px 6px 12px;
            border: 1px solid var(--border);
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }
        .input-wrapper:focus-within {
            border-color: var(--ocp-green);
            box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
        }
        .chat-messages::-webkit-scrollbar { width: 8px; }
        .chat-messages::-webkit-scrollbar-thumb { background: #22c55e; border-radius: 8px; }
        #userInput {
            flex: 1;
            background: transparent;
            border: none;
            padding: 8px 4px;
            color: var(--text);
            font-size: 0.9375rem;
            font-family: inherit;
            outline: none;
        }
        #userInput::placeholder { color: #6ee7b7; }
        .send-btn {
            background: var(--ocp-green);
            border: none;
            width: 42px;
            height: 42px;
            border-radius: var(--radius-sm);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s ease, transform 0.1s ease;
            flex-shrink: 0;
        }
        .send-btn:hover { background: var(--ocp-green-hover); }
        .send-btn:active { transform: scale(0.97); }
        .send-btn:focus-visible { outline: 2px solid var(--ocp-green); outline-offset: 2px; }
        .mic-btn {
            flex-shrink: 0;
            width: 42px;
            height: 42px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
            background: var(--surface);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: border-color 0.15s, color 0.15s, background 0.15s;
        }
        .mic-btn:hover:not(:disabled) {
            border-color: var(--ocp-green);
            color: var(--ocp-green);
            background: var(--ocp-accent-light);
        }
        .mic-btn:disabled { opacity: 0.4; cursor: not-allowed; }
        .mic-btn.listening {
            border-color: var(--ocp-green);
            background: var(--ocp-accent-light);
            color: var(--ocp-green);
        }
        .mic-btn:focus-visible { outline: 2px solid var(--ocp-green); outline-offset: 2px; }
        .typing-indicator {
            display: none;
            align-self: flex-start;
            margin-inline-start: 18px;
            margin-bottom: 4px;
            background: var(--surface);
            padding: 12px 16px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border-soft);
        }
        .typing-indicator.active { display: flex; align-items: center; gap: 5px; }
        .typing-dot {
            width: 6px;
            height: 6px;
            background: #4ade80;
            border-radius: 50%;
            animation: typing 1.2s infinite ease-in-out;
        }
        .typing-dot:nth-child(2) { animation-delay: 0.15s; }
        .typing-dot:nth-child(3) { animation-delay: 0.3s; }
        @keyframes typing {
            0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
            30% { opacity: 1; transform: translateY(-4px); }
        }
        .safety-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: #fff7ed;
            color: #9a3412;
            padding: 6px 10px;
            border-radius: var(--radius-sm);
            font-size: 0.8125rem;
            font-weight: 500;
            margin-top: 12px;
            border: 1px solid #fed7aa;
        }
        .skip-link {
            position: absolute;
            top: -100px;
            left: 12px;
            z-index: 10000;
            padding: 10px 16px;
            background: var(--ocp-green);
            color: #fff;
            font-weight: 600;
            border-radius: var(--radius-sm);
            text-decoration: none;
            transition: top 0.2s ease;
        }
        .skip-link:focus { top: 12px; outline: 2px solid var(--text); outline-offset: 2px; }
        .composer-hint {
            margin-top: 8px;
            padding: 0 4px;
            font-size: 0.6875rem;
            color: var(--text-muted);
            text-align: center;
        }
        .app-footer {
            flex-shrink: 0;
            padding: 10px 18px 12px;
            border-top: 1px solid var(--border-soft);
            background: var(--surface);
        }
        .app-footer__inner {
            max-width: 900px;
            margin: 0 auto;
            font-size: 0.6875rem;
            line-height: 1.55;
            color: var(--text-muted);
            text-align: center;
        }
        .app-footer__brand { color: var(--text-secondary); font-weight: 600; }
        .app-footer__sep { margin: 0 0.35em; opacity: 0.5; }
        .toast {
            position: fixed;
            bottom: 24px;
            left: 50%;
            transform: translateX(-50%) translateY(120%);
            max-width: min(90vw, 420px);
            padding: 12px 18px;
            background: var(--text);
            border-radius: var(--radius-sm);
            color: #fff;
            font-size: 0.875rem;
            box-shadow: var(--shadow);
            z-index: 9999;
            opacity: 0;
            pointer-events: none;
            transition: transform 0.3s ease, opacity 0.3s ease;
        }
        .toast.toast--visible { transform: translateX(-50%) translateY(0); opacity: 1; }
        .modal {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 10001;
            background: rgba(15, 23, 42, 0.45);
            -webkit-backdrop-filter: blur(4px);
            backdrop-filter: blur(4px);
            align-items: center;
            justify-content: center;
            padding: 20px;
        }
        .modal.modal--open { display: flex; }
        body.modal-open { overflow: hidden; }
        .modal__panel {
            background: var(--surface);
            border: 1px solid var(--border-soft);
            border-radius: var(--radius);
            padding: 22px 24px;
            max-width: 440px;
            width: 100%;
            box-shadow: var(--shadow);
            max-height: 90vh;
            overflow-y: auto;
        }
        .modal__panel--wide { max-width: min(96vw, 560px); }
        .modal__title {
            color: var(--text);
            font-size: 1.125rem;
            font-weight: 600;
            margin-bottom: 12px;
            letter-spacing: -0.02em;
        }
        .modal__body { color: var(--text-secondary); font-size: 0.875rem; line-height: 1.6; }
        .modal__body .about-p { margin-bottom: 10px; }
        .modal__body .about-p:last-child { margin-bottom: 0; }
        .modal__btn {
            margin-top: 12px;
            width: 100%;
            padding: 10px 16px;
            border-radius: var(--radius-sm);
            border: none;
            cursor: pointer;
            font-weight: 600;
            font-family: inherit;
            font-size: 0.875rem;
            background: var(--ocp-green);
            color: #fff;
            transition: background 0.15s ease;
        }
        .modal__btn:hover { background: var(--ocp-green-hover); }
        .modal__btn:focus-visible { outline: 2px solid var(--ocp-green); outline-offset: 2px; }
        .modal__btn--secondary {
            background: var(--surface-chat);
            color: var(--text);
            border: 1px solid var(--border);
        }
        .modal__btn--secondary:hover { background: #166534; }
        .qa-upload-textarea {
            width: 100%;
            min-height: 140px;
            margin-top: 8px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
            background: var(--surface-chat);
            color: var(--text);
            padding: 10px 12px;
            resize: vertical;
            font-family: ui-monospace, Consolas, monospace;
            font-size: 0.75rem;
            line-height: 1.45;
        }
        .qa-upload-token { min-height: 0; height: 42px; }
        .qa-manage-list { min-height: 100px; max-height: 200px; overflow: auto; }
        .qa-manage-item {
            margin-bottom: 10px;
            padding-bottom: 10px;
            border-bottom: 1px solid var(--border-soft);
            font-size: 0.8125rem;
        }
        .qa-edit-panel {
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 12px;
            margin-top: 10px;
            background: var(--surface-chat);
        }
        .lang-select {
            font-family: inherit;
            font-size: 0.8125rem;
            padding: 8px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
            width: 100%;
            margin-top: 8px;
        }
        .lang-select:focus-visible { outline: 2px solid var(--ocp-green); outline-offset: 2px; }
        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }
        body.dynamic-off, body.dynamic-off * { animation: none !important; }
        body.ui-normal .app-shell { max-width: 920px; }
        body.ui-normal .chat-container { min-height: min(88vh, 920px); }
        body.ui-normal .message { font-size: 1rem; padding: 14px 16px; }
        body.ui-normal .quick-btn { padding: 8px 14px; font-size: 0.8125rem; }
        body.ui-normal #userInput { font-size: 1rem; padding: 10px 6px; }
        body.ui-normal .send-btn, body.ui-normal .mic-btn { width: 46px; height: 46px; }
        @media (max-width: 600px) {
            .chat-container { border-radius: 0; }
            .app-header__row { flex-wrap: nowrap; }
            .message { max-width: 100%; }
        }
    