@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    color-scheme: dark;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Outfit', var(--font-body);
    --bg: #09120e;
    --surface: rgba(12, 28, 20, 0.72);
    --surface-strong: rgba(18, 39, 28, 0.94);
    --surface-soft: rgba(255, 255, 255, 0.035);
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.17);
    --text: #f3f6f4;
    --muted: #96a59d;
    --green: #20c785;
    --gold: #f5bf3f;
    --danger: #fb7185;
    --gradient: linear-gradient(135deg, var(--green) 0%, var(--gold) 100%);
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    font-family: var(--font-body);
    background:
        radial-gradient(circle at 4% 0%, rgba(32, 199, 133, 0.12), transparent 31rem),
        radial-gradient(circle at 96% 100%, rgba(245, 191, 63, 0.08), transparent 33rem),
        var(--bg);
}

button, input, select, textarea { font: inherit; }

a { color: inherit; }

.app-shell {
    width: min(1120px, calc(100% - 48px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 32px 0;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}

.dashboard-link {
    display: inline-flex;
    min-height: 36px;
    margin-bottom: 16px;
    padding: 7px 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.79rem;
    font-weight: 700;
    text-decoration: none;
    transition: 160ms ease;
}

.dashboard-link:hover,
.dashboard-link:focus-visible {
    border-color: var(--green);
    background: rgba(32, 199, 133, 0.09);
    outline: 3px solid rgba(32, 199, 133, 0.18);
    outline-offset: 2px;
}

h1, h2, p { margin-top: 0; }

h1 {
    margin-bottom: 6px;
    font-family: var(--font-heading);
    font-size: clamp(2.1rem, 5vw, 3.25rem);
    line-height: 1;
    letter-spacing: -0.045em;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.title-group > p {
    max-width: 650px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.91rem;
}

.engine-badge {
    min-width: 142px;
    padding: 10px 13px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(5, 14, 10, 0.7);
}

.engine-badge strong,
.engine-badge small { display: block; }

.engine-badge strong { font-size: 0.76rem; }
.engine-badge small { color: var(--muted); font-size: 0.68rem; }

.status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: #69756f;
}

.status-dot.checking { animation: pulse 1.3s ease-in-out infinite; }
.status-dot.online { background: var(--green); box-shadow: 0 0 13px rgba(32, 199, 133, 0.75); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 13px rgba(251, 113, 133, 0.55); }

.workspace {
    min-height: calc(100vh - 184px);
    padding-top: 24px;
    display: grid;
    grid-template-columns: minmax(220px, 0.72fr) minmax(0, 2fr);
    gap: 20px;
}

.source-panel,
.chat-panel {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.source-panel {
    padding: 22px;
    align-self: start;
}

.application-process-link {
    min-height: 48px;
    margin-bottom: 20px;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--gradient);
    box-shadow: 0 8px 24px rgba(32, 199, 133, 0.14);
    color: #07110c;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: transform 150ms ease, filter 150ms ease;
}

.application-process-link:hover {
    transform: translateY(-2px);
    filter: brightness(1.06);
}

.application-process-link:focus-visible {
    outline: 3px solid rgba(245, 191, 63, 0.38);
    outline-offset: 3px;
}

.source-panel h2,
.chat-panel h2 {
    margin-bottom: 6px;
    font-family: var(--font-heading);
    font-size: 1.18rem;
    letter-spacing: -0.02em;
}

.source-panel > div > p,
.chat-heading-row p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.55;
}

.source-list {
    margin: 20px 0;
    padding: 0;
    list-style: none;
    counter-reset: source;
}

.source-list li {
    counter-increment: source;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 9px;
    align-items: start;
    margin-bottom: 12px;
}

.source-list li::before {
    content: counter(source);
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(32, 199, 133, 0.28);
    border-radius: 50%;
    color: var(--green);
    font-size: 0.68rem;
    font-weight: 800;
}

.source-list a {
    padding-top: 2px;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
    text-decoration-color: rgba(32, 199, 133, 0.38);
    text-underline-offset: 3px;
}

.source-list a:hover,
.source-list a:focus-visible { color: var(--green); outline: none; }

.boundary-note {
    padding: 14px;
    border-left: 3px solid var(--gold);
    border-radius: 8px;
    background: rgba(245, 191, 63, 0.06);
}

.boundary-note strong { color: var(--gold); font-size: 0.75rem; }
.boundary-note p { margin: 5px 0 0; color: #c7cec9; font-size: 0.74rem; line-height: 1.5; }

.reference-only {
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
}

.reference-only a,
.reference-only small {
    display: block;
}

.reference-only a {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
    text-underline-offset: 3px;
}

.reference-only a:hover,
.reference-only a:focus-visible {
    color: var(--green);
    outline: none;
}

.reference-only small {
    margin-top: 4px;
    color: #718078;
    font-size: 0.64rem;
    line-height: 1.4;
}

.staff-admin-link {
    min-height: 38px;
    margin-top: 16px;
    padding: 8px 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: #d4ddd7;
    background: var(--surface-soft);
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
}

.staff-admin-link:hover,
.staff-admin-link:focus-visible {
    border-color: rgba(32, 199, 133, 0.55);
    color: var(--green);
    outline: 3px solid rgba(32, 199, 133, 0.16);
    outline-offset: 2px;
}

.chat-panel {
    min-height: 650px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-heading-row { padding: 22px 24px 15px; }

.starter-questions {
    padding: 0 24px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--line);
}

.starter-questions button {
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #d8dfdb;
    background: var(--surface-soft);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: 150ms ease;
}

.starter-questions button:hover,
.starter-questions button:focus-visible {
    border-color: rgba(32, 199, 133, 0.55);
    color: #fff;
    background: rgba(32, 199, 133, 0.09);
    outline: 2px solid rgba(32, 199, 133, 0.18);
    outline-offset: 2px;
}

.starter-questions button:disabled { opacity: 0.45; cursor: wait; }

.chat-history {
    min-height: 280px;
    flex: 1 1 auto;
    padding: 20px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 13px;
    overscroll-behavior: auto;
    touch-action: pan-y;
}

.message { max-width: 88%; }
.user-message { align-self: flex-end; }
.assistant-message { align-self: flex-start; }

.message-content {
    padding: 14px 16px;
    overflow-wrap: anywhere;
    border-radius: 12px;
    font-size: 0.86rem;
    line-height: 1.6;
}

.assistant-message .message-content {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 3px;
    background: var(--surface-strong);
}

.user-message .message-content {
    border-bottom-right-radius: 3px;
    color: #08110d;
    font-weight: 600;
    background: var(--gradient);
}

.welcome-message strong { color: var(--gold); }
.welcome-message p { margin: 8px 0 0; color: #c9d1cc; }

.assistant-message h1,
.assistant-message h2,
.assistant-message h3,
.assistant-message h4 {
    margin: 15px 0 7px;
    color: var(--gold);
    font-family: var(--font-heading);
    font-size: 1rem;
    line-height: 1.3;
}

.assistant-message h1:first-child,
.assistant-message h2:first-child,
.assistant-message h3:first-child { margin-top: 0; }

.assistant-message p { margin-bottom: 9px; }
.assistant-message p:last-child { margin-bottom: 0; }
.assistant-message ul,
.assistant-message ol { margin: 7px 0 10px; padding-left: 20px; }
.assistant-message li { margin-bottom: 5px; }

.assistant-message a {
    color: #77e0b6;
    font-weight: 650;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.assistant-message a:hover,
.assistant-message a:focus-visible { color: var(--gold); outline: 2px solid rgba(245, 191, 63, 0.25); outline-offset: 2px; }

.answer-feedback {
    margin-top: 7px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(4, 13, 9, 0.72);
}

.feedback-prompt {
    margin: 0 0 8px;
    color: #cbd4ce;
    font-size: 0.69rem;
    font-weight: 700;
}

.feedback-controls,
.feedback-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.feedback-button {
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #dbe4de;
    background: rgba(255, 255, 255, 0.045);
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
}

.feedback-button:hover:not(:disabled),
.feedback-button:focus-visible {
    border-color: var(--green);
    color: #fff;
    outline: 3px solid rgba(32, 199, 133, 0.16);
    outline-offset: 2px;
}

.feedback-button:disabled { opacity: 0.48; cursor: wait; }
.feedback-up { color: #80e2ba; }
.feedback-down { color: #f7c9d0; }
.feedback-submit { border-color: rgba(32, 199, 133, 0.48); color: #8be7c1; }

.feedback-form {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.feedback-form[hidden] { display: none; }

.feedback-form label {
    margin: 9px 0 5px;
    display: block;
    color: #d6dfd9;
    font-size: 0.68rem;
    font-weight: 700;
}

.feedback-form label:first-child { margin-top: 0; }

.feedback-form input,
.feedback-form textarea {
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
    font-size: 0.75rem;
    line-height: 1.45;
}

.feedback-form textarea { min-height: 92px; }
.feedback-form textarea[readonly] {
    color: #b8c4bd;
    background: rgba(255, 255, 255, 0.018);
    cursor: default;
}

.feedback-form input:focus-visible,
.feedback-form textarea:focus-visible {
    border-color: var(--green);
    outline: 3px solid rgba(32, 199, 133, 0.14);
}

.feedback-warning {
    margin: 8px 0 10px;
    color: #8f9d95;
    font-size: 0.62rem;
    line-height: 1.45;
}

.feedback-status {
    min-height: 1em;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.65rem;
    line-height: 1.45;
}

.feedback-success { color: #80e2ba; }
.feedback-error { color: #fda4af; }

.processing {
    margin: 0 24px 12px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(32, 199, 133, 0.26);
    border-radius: 9px;
    color: #dce5e0;
    background: rgba(32, 199, 133, 0.07);
    font-size: 0.76rem;
}

.processing[hidden] { display: none; }

.processing-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: var(--green);
    animation: processing 1.05s ease-in-out infinite;
}

.composer {
    padding: 16px 24px 18px;
    border-top: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.17);
}

.composer > label {
    display: block;
    margin-bottom: 7px;
    color: #d7dfda;
    font-size: 0.72rem;
    font-weight: 700;
}

.composer-row { display: flex; gap: 11px; }

textarea {
    min-width: 0;
    flex: 1 1 auto;
    min-height: 82px;
    padding: 13px 14px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
    font-size: 0.86rem;
    line-height: 1.5;
}

textarea::placeholder { color: #707d76; }
textarea:focus-visible { border-color: var(--green); outline: 3px solid rgba(32, 199, 133, 0.14); }

.send-button {
    min-width: 82px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    color: #08110d;
    background: var(--gradient);
    font-size: 0.86rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 150ms ease, filter 150ms ease;
}

.send-button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.06); }
.send-button:focus-visible { outline: 3px solid rgba(245, 191, 63, 0.35); outline-offset: 3px; }
.send-button:disabled { opacity: 0.45; cursor: wait; }

.privacy-note {
    margin: 8px 0 0;
    color: #79867f;
    font-size: 0.66rem;
    line-height: 1.45;
    text-align: center;
}

.app-footer {
    margin-top: 32px;
    padding: 20px 0 12px;
    border-top: 1px solid var(--line);
    text-align: center;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.84rem;
}

.footer-primary-link {
    color: var(--green);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 150ms ease;
}

.footer-primary-link:hover,
.footer-primary-link:focus-visible {
    color: var(--gold);
}

.footer-links a:not(.footer-primary-link) {
    color: var(--muted);
    text-decoration: none;
    transition: color 150ms ease;
}

.footer-links a:not(.footer-primary-link):hover,
.footer-links a:not(.footer-primary-link):focus-visible {
    color: var(--text);
    text-decoration: underline;
}

.footer-sep {
    color: var(--line-strong);
    user-select: none;
}

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes processing { 50% { transform: scale(0.72); opacity: 0.45; } }

@media (max-width: 820px) {
    html, body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .app-shell { width: min(100% - 32px, 720px); padding-top: 22px; }
    .workspace { grid-template-columns: 1fr; min-height: auto; }
    .source-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; width: 100%; }
    .source-list { margin: 0; }
    .boundary-note { grid-column: 1 / -1; }
    .staff-admin-link { grid-column: 1 / -1; }
    .reference-only { grid-column: 1 / -1; margin-top: 0; }
    .chat-panel { min-height: auto; }
    .chat-history { max-height: 450px; }
}

@media (max-width: 560px) {
    .app-shell { width: min(100% - 24px, 520px); padding: 16px 0 20px; }
    .app-header { align-items: flex-start; flex-direction: column; gap: 14px; padding-bottom: 18px; }
    .engine-badge { min-width: 132px; }
    .workspace { padding-top: 16px; gap: 14px; }
    .source-panel { padding: 17px; display: block; }
    .source-list { margin: 16px 0; }
    .chat-panel { min-height: auto; border-radius: 16px; }
    .chat-heading-row { padding: 18px 16px 13px; }
    .starter-questions { padding: 0 16px 14px; gap: 7px; }
    .starter-questions button { max-width: 100%; white-space: normal; text-align: left; }
    .chat-history { padding: 16px; max-height: 380px; }
    .message { max-width: 96%; }
    .message-content { padding: 12px 13px; font-size: 0.82rem; }
    .answer-feedback { margin-left: 0; margin-right: 0; }
    .feedback-controls .feedback-button,
    .feedback-form-actions .feedback-button { flex: 1 1 130px; }
    .processing { margin: 0 16px 10px; }
    .composer { padding: 14px 16px 16px; }
    .composer-row { flex-direction: column; }
    textarea { width: 100%; min-height: 88px; }
    .send-button { width: 100%; min-height: 46px; }
    .footer-links { flex-direction: column; gap: 8px; }
    .footer-sep { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
