/* =========================================================================
   KORMORAN Vitorlás Szabály-tutor — chat UI
   A kormoranmarine.hu "műszerfal" palettájához igazítva (sötét tengerészkék).
   ========================================================================= */
:root {
    --bg:       #0a1622;
    --bg-2:     #0d1c2b;
    --panel:    #102233;
    --panel-2:  #14293d;
    --line:     #1e3a52;
    --text:     #e6eef5;
    --muted:    #8fa6b8;
    --accent:   #2fa3ac;
    --accent-2: #3fc9d4;
    --user:     #14324a;
    --radius:   12px;
    --maxw:     820px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font); background: var(--bg); color: var(--text);
    line-height: 1.6; -webkit-font-smoothing: antialiased;
    display: flex; flex-direction: column;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; width: 100%; }

/* ---------- Header ---------- */
.site-header {
    background: rgba(10,22,34,.92); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.nav { display: flex; align-items: center; gap: 16px; height: 62px; }
.brand { display: flex; flex-direction: column; line-height: 1; color: inherit; text-decoration: none; }
.brand b { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.brand span { font-size: 9px; letter-spacing: 2px; color: var(--muted); margin-top: 3px; }
.status { margin-left: auto; font-size: 12px; color: var(--muted); }
.status.ok { color: var(--accent-2); }
.status.err { color: #ef6a6a; }

/* ---------- Layout ---------- */
.chat-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; padding-top: 16px; padding-bottom: 16px; }

/* ---------- Controls ---------- */
.controls { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent-2); font-weight: 700; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
    background: var(--panel); color: var(--muted); border: none; cursor: pointer;
    padding: 7px 13px; font-size: 13px; font-weight: 600; font-family: inherit;
    border-right: 1px solid var(--line); transition: .12s;
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent); color: #041016; }
.btn-reset {
    margin-left: auto; background: #16283a; color: var(--muted); border: 1px solid var(--line);
    border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn-reset:hover { color: var(--text); }

/* ---------- Messages ---------- */
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 8px 2px; }
.msg { max-width: 88%; padding: 12px 15px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); border: 1px solid var(--line); }
.msg.bot  { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.bot.streaming::after { content: "▍"; color: var(--accent-2); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Hint / examples ---------- */
.hint { color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.hint b { color: var(--text); }
.hint p { margin: 8px 0 12px; }
.examples { display: flex; flex-direction: column; gap: 8px; }
.examples button {
    text-align: left; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
    border-radius: 8px; padding: 9px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.examples button:hover { border-color: var(--accent); }

/* ---------- Composer ---------- */
.composer { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.composer textarea {
    flex: 1; resize: none; background: var(--panel); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
    font-family: inherit; font-size: 15px; line-height: 1.5; max-height: 180px;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
#send {
    background: var(--accent); color: #041016; border: none; border-radius: var(--radius);
    width: 48px; height: 48px; font-size: 18px; cursor: pointer; flex-shrink: 0;
}
#send:hover { background: var(--accent-2); }
#send:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Belépés (fejléc + kapu) ---------- */
.btn-login {
    display: inline-block; background: var(--accent); color: #041016; text-decoration: none;
    border: none; border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 700;
    cursor: pointer; font-family: inherit;
}
.btn-login:hover { background: var(--accent-2); }
#authArea { margin-left: 4px; display: inline-flex; align-items: center; gap: 8px; }
#authArea .kmr-user { color: var(--text); }

.gate {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.gate-txt { color: var(--muted); font-size: 14px; flex: 1; min-width: 220px; }
.gate-txt b { color: var(--text); }

/* ---------- Renderelt Markdown a bot-buborékban ---------- */
.msg.bot { white-space: normal; }
.msg.bot > :first-child { margin-top: 0; }
.msg.bot > :last-child { margin-bottom: 0; }
.msg.bot h1, .msg.bot h2, .msg.bot h3, .msg.bot h4 {
    color: var(--accent-2); line-height: 1.3; margin: 14px 0 6px; font-weight: 700;
}
.msg.bot h1 { font-size: 1.25rem; } .msg.bot h2 { font-size: 1.12rem; }
.msg.bot h3 { font-size: 1.02rem; } .msg.bot h4 { font-size: .95rem; }
.msg.bot p { margin: 8px 0; }
.msg.bot ul, .msg.bot ol { margin: 8px 0 8px 22px; }
.msg.bot li { margin: 3px 0; }
.msg.bot strong { color: #fff; }
.msg.bot code {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px;
    padding: 1px 5px; font-size: .88em; font-family: "Consolas", monospace;
}
.msg.bot pre {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
    padding: 12px; overflow-x: auto; margin: 10px 0;
}
.msg.bot pre code { background: none; border: none; padding: 0; }
.msg.bot blockquote {
    border-left: 3px solid var(--accent); margin: 10px 0; padding: 4px 12px; color: var(--muted);
}
.msg.bot hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.msg.bot table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
.msg.bot th, .msg.bot td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.msg.bot th { background: var(--panel-2); color: var(--accent-2); }
