:root {
    color-scheme: light;
    font-family: system-ui, "Segoe UI", sans-serif;
    color: #0d1b33;
    background: #fff;
    --border: #d5deeb;
    --panel: #f1f5f9;
    --action: #254771;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.top { background: #0d1b33; color: white; min-height: 3.5rem; display: flex; align-items: center; gap: 1.25rem; padding: .75rem max(1rem, calc((100vw - 72rem) / 2)); }
.top a { color: inherit; font-size: 1.3rem; font-weight: 700; text-decoration: none; }
main { max-width: 74rem; margin: 0 auto; padding: 1.5rem 1rem; }
h1 { margin: 0 0 .75rem; font-size: clamp(1.45rem, 2.5vw, 2rem); }
#reference, .hint, footer { color: #405775; }
#status { max-width: 55rem; min-height: 1.5rem; }
#status.error { color: #a31e28; }
.workspace { display: grid; grid-template-columns: minmax(13rem, 21rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
nav, form { border: 1px solid var(--border); }
nav { background: var(--panel); }
nav ul { list-style: none; padding: .4rem; margin: 0; }
button { font: inherit; cursor: pointer; }
nav button { width: 100%; min-height: 2.75rem; text-align: start; border: 0; padding: .65rem .8rem; background: transparent; color: inherit; }
nav button[aria-current="true"] { background: #dee9f8; font-weight: 650; }
.field { padding: 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
.hint { margin: 0 0 1rem; }
label { font-weight: 650; display: block; margin-bottom: .4rem; }
input, textarea, select { display: block; width: 100%; max-width: 34rem; border: 1px solid #8396ad; border-radius: 3px; padding: .65rem; font: inherit; background: white; color: inherit; }
textarea { resize: vertical; }
.actions { background: var(--panel); padding: 1rem; display: flex; justify-content: end; gap: .5rem; flex-wrap: wrap; }
.actions button { border: 1px solid var(--action); border-radius: 4px; padding: .65rem 1rem; background: var(--action); color: white; }
.actions button:disabled { opacity: .65; cursor: default; }
.actions #answer-refresh { color: var(--action); background: white; }
:focus-visible { outline: 3px solid #1864ab; outline-offset: 2px; }
footer { margin-top: 1.25rem; }
.portal-nav { display: flex; background: var(--panel); gap: .25rem; padding: .35rem; margin-bottom: 1rem; }
.portal-nav button { width: auto; flex: 0 1 auto; }
#chat-view { max-width: 57rem; }
#chat-status.error { color: #a31e28; }
.primary, .chat-bar button { border: 1px solid var(--action); border-radius: 4px; padding: .65rem 1rem; background: var(--action); color: white; }
.secondary { border: 1px solid var(--action); border-radius: 4px; padding: .65rem 1rem; background: white; color: var(--action); }
.chat-verify { padding: 1rem; margin-top: .75rem; }
.password-help { margin: 1rem 0 .5rem; }
.chat-verify input { max-width: 12rem; margin-bottom: .65rem; }
.chat-verify input[type="password"] { max-width: 24rem; }
.chat-bar { display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
#chat-logout { margin-left: auto; background: white; color: var(--action); }
.messages { display: flex; flex-direction: column; gap: .6rem; min-height: 12rem; max-height: 53vh; overflow: auto; background: var(--panel); padding: 1rem; list-style: none; border: 1px solid var(--border); }
.messages li { align-self: flex-start; max-width: min(90%, 40rem); padding: .65rem .85rem; background: white; border: 1px solid var(--border); border-radius: 5px; }
.messages li.mine { align-self: flex-end; background: #dee9f8; }
.messages p { margin: .35rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-send label, .chat-send textarea { margin: .75rem; }
.chat-send textarea { width: calc(100% - 1.5rem); max-width: none; }
.chat-send textarea:disabled { opacity: .65; }

@media (max-width: 38rem) {
    .workspace { grid-template-columns: 1fr; gap: .75rem; }
    .field + .field { border-top: 1px solid var(--border); }
    .actions button { width: 100%; }
    #chat-login button { min-height: 2.75rem; }
}
