/* ==========================================================================
   Java Learn Tutor — yalnız chat, açıq tema, yumşaq rəngli vurğular
   ========================================================================== */

:root {
    --bg: #ffffff;
    --bg-soft: #f7f7f8;
    --bubble: #f4f4f5;
    --code-bg: #0f1115;
    --code-bar: #171a21;

    --line: #ececed;
    --line-2: #e3e3e6;
    --line-focus: #d3d3d8;

    --text: #0d0d0d;
    --text-2: #3d3d42;
    --muted: #6d6d76;
    --muted-2: #9b9ba3;

    --accent: #171717;

    /* yumşaq rənglər */
    --blue: #3d6ed0;
    --blue-tint: #eef3fd;
    --blue-line: #cfdffa;
    --violet: #6b5bb5;
    --violet-tint: #f2effc;
    --green: #1a7f4b;
    --green-tint: #edf7f1;
    --green-line: #cfe9da;
    --amber: #9a6b12;
    --amber-tint: #fdf6e7;
    --amber-line: #eee0bd;
    --red: #b0392f;
    --red-tint: #fdefee;
    --red-line: #f2d3d0;

    --radius: 24px;
    --shadow-focus: 0 2px 10px rgba(13, 13, 13, .05);

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

::selection { background: var(--blue-tint); }

*::-webkit-scrollbar { width: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: transparent; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*:hover::-webkit-scrollbar-thumb { background: #d6d6da; background-clip: content-box; }

/* -------------------------------- chat -------------------------------- */
.chat { height: 100dvh; display: flex; flex-direction: column; }

.thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.thread-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 26px 18px 36px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* ------------------------------- hero --------------------------------- */
.hero {
    position: relative;
    display: none;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 18px;
    padding-top: 4vh;
    text-align: center;
    isolation: isolate;
}

body.empty .hero { display: block; }
body.empty .thread { display: flex; align-items: center; }

.hero-orbs { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
.hero-orbs i { position: absolute; display: block; border-radius: 50%; filter: blur(52px); opacity: .5; }
.hero-orbs i:nth-child(1) { width: 260px; height: 260px; left: 6%;  top: 2%;  background: var(--blue-tint); }
.hero-orbs i:nth-child(2) { width: 220px; height: 220px; right: 8%; top: 12%; background: var(--violet-tint); }
.hero-orbs i:nth-child(3) { width: 200px; height: 200px; left: 42%; bottom: 4%; background: var(--green-tint); }

.hero-mark {
    width: 52px;
    height: 52px;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(155deg, #ffffff 0%, #f3f6fc 60%, #eef1f8 100%);
    border: 1px solid var(--blue-line);
    box-shadow: 0 6px 22px rgba(61, 110, 208, .10), inset 0 1px 0 #fff;
    font-size: 25px;
}

.hero h1 {
    margin: 0 0 10px;
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -.8px;
    background: linear-gradient(92deg, #0d0d0d 20%, #3d6ed0 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero p { margin: 0 0 32px; color: var(--muted); font-size: 15px; }
.hero p b { color: var(--text-2); font-weight: 500; }

.hero-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; text-align: left; }

.hero-cards button {
    position: relative;
    font: inherit;
    cursor: pointer;
    background: var(--bg);
    border: 1px solid var(--line-2);
    border-radius: 15px;
    padding: 15px 38px 15px 16px;
    font-size: 13.5px;
    color: var(--text-2);
    line-height: 1.45;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.hero-cards button:hover {
    background: var(--bg-soft);
    border-color: var(--blue-line);
    box-shadow: 0 4px 16px rgba(13, 13, 13, .05);
}
.hero-cards button:active { transform: scale(.99); }

.hero-cards button span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--blue);
    margin-bottom: 5px;
}
.hero-cards button svg {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-2);
    opacity: 0;
    transition: opacity .15s, transform .15s;
}
.hero-cards button:hover svg { opacity: 1; transform: translate(2px, -50%); }

/* hero altı: tələbə + səviyyə + yeni chat */
.hero-meta {
    margin-top: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mini-field { display: inline-flex; align-items: center; gap: 7px; }
.mini-field span { font-size: 11.5px; color: var(--muted-2); }
.mini-field input {
    width: 96px;
    padding: 4px 10px;
    font: inherit;
    font-size: 12.5px;
    color: var(--text-2);
    background: var(--bg-soft);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.mini-field input:focus { background: var(--bg); border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-tint); }

.level-pill {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    background: var(--bg-soft);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    padding: 4px 12px;
    white-space: nowrap;
    transition: color .2s, border-color .2s, background .2s;
}
.level-pill.ok  { color: var(--green); border-color: var(--green-line); background: var(--green-tint); }
.level-pill.mid { color: var(--amber); border-color: var(--amber-line); background: var(--amber-tint); }

.link-btn {
    font: inherit;
    font-size: 12.5px;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 1px solid var(--line-2);
    border-radius: 0;
    padding: 2px 0;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.link-btn:hover { color: var(--text); border-bottom-color: var(--line-focus); }

/* ----------------------------- messages ------------------------------- */
.turn { display: flex; flex-direction: column; gap: 5px; }
.turn.user { align-items: flex-end; }

.turn .content {
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 16px;
}

/* istifadəçi balonu — yumşaq qradiyent */
.turn.user .content {
    max-width: 86%;
    background: linear-gradient(135deg, var(--blue-tint) 0%, #f6f4fd 100%);
    border: 1px solid var(--blue-line);
    border-radius: 22px;
    padding: 11px 17px;
    border-bottom-right-radius: 7px;
}

/* tutor sətri: avatar + ad */
.turn.assistant .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.avatar {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: linear-gradient(150deg, #f4f7fd, #eef1f8);
    border: 1px solid var(--blue-line);
    font-size: 11px;
}
.turn.assistant .head b { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.turn.assistant .head em { font-style: normal; font-size: 11.5px; color: var(--muted-2); }

.turn .foot {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px 0;
    margin-top: 3px;
    font-size: 11.5px;
    color: var(--muted-2);
    opacity: 0;
    transition: opacity .18s;
}
.turn:hover .foot { opacity: 1; }
.turn .foot .grow { flex: 1; }
.turn .foot .topic-tag { font-weight: 500; color: var(--text-2); }

.turn .foot button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font: inherit;
    font-size: 11.5px;
    color: var(--muted);
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 3px 8px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.turn .foot button:hover { background: var(--bg-soft); color: var(--text); border-color: var(--line-2); }
.turn .foot button.done { color: var(--green); border-color: var(--green-line); background: var(--green-tint); }

.turn.quota .content {
    background: var(--amber-tint);
    border: 1px solid var(--amber-line);
    color: #7d5610;
    border-radius: 15px;
    padding: 13px 16px;
}
.turn.error .content {
    background: var(--red-tint);
    border: 1px solid var(--red-line);
    color: #8d2c25;
    border-radius: 15px;
    padding: 13px 16px;
}

.cursor {
    display: inline-block;
    width: 2px;
    height: 17px;
    background: var(--text);
    vertical-align: -3px;
    margin-left: 2px;
    animation: blink 1.05s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* --------------------------- markdown / kod --------------------------- */
.content strong { font-weight: 600; }
.content em { font-style: italic; color: var(--text-2); }

.content code {
    font-family: var(--mono);
    font-size: 13.5px;
    background: var(--bubble);
    border-radius: 5px;
    padding: 1.5px 5px;
    word-break: break-word;
}

.content hr { border: none; border-top: 1px solid var(--line-2); margin: 18px 0; }

.code-block {
    margin: 13px 0;
    border-radius: 13px;
    overflow: hidden;
    border: 1px solid #1e222b;
    background: var(--code-bg);
}
.code-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: var(--code-bar);
    border-bottom: 1px solid #1e222b;
}
.code-dots { display: flex; gap: 5px; }
.code-dots i { width: 8px; height: 8px; border-radius: 50%; background: #2c313b; }
.code-dots i:nth-child(1) { background: #3a3f4b; }
.code-dots i:nth-child(2) { background: #343945; }
.code-dots i:nth-child(3) { background: #2e333d; }
.code-bar button {
    font: inherit;
    font-size: 11px;
    color: #9aa1ad;
    background: none;
    border: none;
    border-radius: 6px;
    padding: 2px 7px;
    cursor: pointer;
    transition: color .15s, background .15s;
}
.code-bar button:hover { color: #e6e6e6; background: rgba(255, 255, 255, .07); }

.content pre { margin: 0; padding: 14px 16px; background: var(--code-bg); overflow-x: auto; }
.content pre code {
    background: none;
    padding: 0;
    color: #e6e6e6;
    font-size: 13px;
    line-height: 1.7;
    word-break: normal;
}

/* ------------------------------ composer ------------------------------ */
.composer-area {
    flex: none;
    padding: 0 18px 14px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--bg) 24%);
}

.composer-wrap { max-width: 900px; margin: 0 auto; }

.quick-actions {
    display: flex;
    gap: 7px;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 11px;
}
.quick-actions::-webkit-scrollbar { display: none; }

.quick-actions button {
    flex: none;
    font: inherit;
    font-size: 12.5px;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    padding: 5px 13px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.quick-actions button:hover { background: var(--blue-tint); color: var(--blue); border-color: var(--blue-line); }

.composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    padding: 9px 9px 9px 19px;
    box-shadow: var(--shadow-focus);
    transition: border-color .18s, box-shadow .18s;
}
.composer:focus-within { border-color: var(--blue-line); box-shadow: 0 4px 22px rgba(61, 110, 208, .12); }

.composer textarea {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    background: none;
    font: inherit;
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    max-height: 260px;
    padding: 9px 0;
    scrollbar-width: thin;
}
.composer textarea::placeholder { color: var(--muted-2); }

.send-btn {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: opacity .15s, transform .1s, background .15s;
}
.send-btn:hover { background: #303034; }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .25; cursor: not-allowed; transform: none; }

.disclaimer { margin: 10px 0 0; text-align: center; font-size: 11.5px; color: var(--muted-2); }

/* ----------------------------- responsive ----------------------------- */
@media (max-width: 760px) {
    .hero h1 { font-size: 24px; }
    .hero-cards { grid-template-columns: 1fr; }
    .turn.user .content { max-width: 92%; }
    .thread-inner { padding: 20px 14px 30px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* ============================ ensemble panel ========================== */
.turn.assistant .head { flex-wrap: wrap; }

.stage {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--blue);
    background: var(--blue-tint);
    border: 1px solid var(--blue-line);
    border-radius: 999px;
    padding: 2px 10px;
    animation: fade-in .2s ease;
}
.stage::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--blue);
    animation: blink 1s steps(2, start) infinite;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(-2px); } }

.panel-box { margin-top: 10px; max-width: 620px; }

.panel-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 11px;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.panel-toggle:hover { color: var(--text-2); border-color: var(--line-2); }
.panel-toggle svg { transition: transform .2s; }

.panel-body {
    display: none;
    margin-top: 8px;
    padding: 11px 13px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 11px;
}
.panel-box.open .panel-body { display: block; animation: fade-in .2s ease; }

.verdicts { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.verdicts li { display: flex; align-items: baseline; gap: 7px; font-size: 11.5px; }
.verdicts i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.verdicts .good i { background: var(--green); }
.verdicts .bad  i { background: var(--red); }
.verdicts b { font-weight: 600; color: var(--text-2); }
.verdicts span { color: var(--muted); }

.cands-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted-2);
    margin: 10px 0 6px;
}

.cand { border-top: 1px solid var(--line); padding: 6px 0 0; margin-top: 6px; }
.cand summary {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 11.5px;
    color: var(--text-2);
    list-style: none;
}
.cand summary::-webkit-details-marker { display: none; }
.cand summary i { width: 6px; height: 6px; border-radius: 50%; }
.cand summary i.ok { background: var(--blue); }
.cand summary i.no { background: var(--red); }
.cand summary em { font-style: normal; margin-left: auto; font-size: 10.5px; color: var(--muted-2); }
.cand pre {
    margin: 7px 0 2px;
    padding: 10px 12px;
    background: var(--code-bg);
    color: #d6d9de;
    border-radius: 9px;
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow: auto;
}

/* ============================== login gate ============================== */
.is-hidden { display: none !important; }

.login-gate {
    position: relative;
    max-width: 380px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: 18px;
    padding: 30px 26px 24px;
    box-shadow: 0 6px 26px rgba(13, 13, 13, .06);
}

.login-mark {
    width: 46px;
    height: 46px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--blue-tint);
    border: 1px solid var(--blue-line);
    font-size: 20px;
}

.login-gate h1 { margin: 0 0 6px; font-size: 19px; font-weight: 600; text-align: center; letter-spacing: -.3px; }
.login-gate > p { margin: 0 0 20px; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.55; }

.login-form { display: flex; flex-direction: column; gap: 11px; }
.lg-field { display: flex; flex-direction: column; gap: 5px; }
.lg-field span { font-size: 11.5px; color: var(--muted); }
.lg-field input {
    font: inherit;
    font-size: 14.5px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.lg-field input:focus { background: var(--surface); border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-tint); }
#loginCode { letter-spacing: 6px; font-family: var(--mono); text-align: center; font-size: 17px; }

.lg-btn {
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: var(--blue);
    border: 1px solid var(--blue);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background .15s;
}
.lg-btn:hover { background: #3360bd; }

.lg-link {
    font: inherit;
    font-size: 12.5px;
    color: var(--muted);
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.lg-link:hover { color: var(--text); }

.lg-msg { margin: 0; font-size: 12.5px; color: var(--muted); min-height: 18px; text-align: center; }
.lg-msg.bad { color: var(--red); }
.hidden { display: none !important; }

/* profil çubuğu (yalnız giriş etmişlər) */
.who-bar {
    flex: none;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 7px 18px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--muted-2);
}
body:not(.has-user) .who-bar { display: none; }
.who-name { font-weight: 500; color: var(--text-2); }
