:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #1d2330;
    --muted: #677085;
    --line: #e2e5ec;
    --accent: #2f6fed;
    --accent-text: #ffffff;
    --user: #e8effd;
    --danger: #c23b3b;
    --code: #f1f3f7;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161b;
        --panel: #1c1f26;
        --text: #e6e8ee;
        --muted: #9aa3b5;
        --line: #2c313b;
        --accent: #5b8ef5;
        --user: #233250;
        --danger: #ef6b6b;
        --code: #252a33;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, textarea { font: inherit; color: inherit; }

button {
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 8px;
    padding: 7px 12px;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--muted); font-size: 14px; }
button.link:hover:not(:disabled) { color: var(--accent); }

textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 12px;
    padding: 11px 12px;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.hint { color: var(--muted); font-size: 14px; }
[hidden] { display: none !important; }

/* ---------- Așezarea: chatul în stânga, fișa în dreapta ---------- */

.chat {
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 330px;
}

.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}
.topbar .title { flex: 1; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.topbar .menu { display: none; }
.badge { font-size: 13px; color: var(--muted); white-space: nowrap; }

.messages { flex: 1; overflow-y: auto; padding: 20px 16px 8px; }
.messages-inner { max-width: 780px; margin: 0 auto; }
.empty { text-align: center; color: var(--muted); margin-top: 18vh; font-size: 18px; }
.empty .hint { font-size: 15px; }

.msg { margin: 0 0 18px; display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg .bubble { max-width: 100%; overflow-wrap: anywhere; }
.msg.user .bubble {
    background: var(--user);
    border-radius: 16px 16px 4px 16px;
    padding: 9px 14px;
    max-width: 85%;
    white-space: pre-wrap;
}
.msg.assistant .bubble > :first-child { margin-top: 0; }
.msg.assistant .bubble > :last-child { margin-bottom: 0; }
.msg .tools { display: flex; gap: 2px; margin-top: 4px; margin-left: -6px; }
.msg .note { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 4px; }
.msg.error .bubble { color: var(--danger); }

.bubble pre { background: var(--code); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 14px; }
.bubble code { background: var(--code); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.bubble pre code { background: none; padding: 0; }
.bubble table { border-collapse: collapse; display: block; overflow-x: auto; margin: 10px 0; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.bubble th { background: var(--code); }
.bubble blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.bubble a { color: var(--accent); }

.typing::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }

.composer { padding: 10px 16px 14px; }
.composer-inner { max-width: 780px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 220px; min-height: 46px; }
.composer button { height: 46px; min-width: 92px; }
.composer-hint { max-width: 780px; margin: 6px auto 0; font-size: 12px; color: var(--muted); text-align: center; }
.banner { max-width: 780px; margin: 0 auto 8px; padding: 8px 12px; border-radius: 8px; background: var(--code); color: var(--danger); font-size: 14px; }

/* ---------- Exemplele din Fișa 4 ---------- */

.tasks {
    background: var(--panel);
    border-left: 1px solid var(--line);
    overflow-y: auto;
    min-height: 0;
}
.tasks-head { padding: 14px 16px 4px; }
.tasks-head h2 { margin: 0; font-size: 17px; }
.tasks-head .hint { margin: 4px 0 0; }
.task-list { margin: 0; padding: 4px 16px 16px 36px; }
.task-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.task-list li:last-child { border-bottom: 0; }
.task-list h3 { margin: 0 0 6px; font-size: 15px; }
.task-list .hint { margin: 6px 0 0; font-size: 13px; }
button.prompt {
    display: block;
    width: 100%;
    text-align: left;
    margin: 4px 0;
    padding: 6px 10px;
    font-size: 14px;
    background: var(--code);
    border-color: transparent;
}
button.prompt:hover { border-color: var(--accent); }

@media (max-width: 860px) {
    .chat { grid-template-columns: 1fr; }
    .tasks {
        position: fixed;
        inset: 0 0 0 auto;
        width: min(340px, 88vw);
        z-index: 10;
        transform: translateX(100%);
        transition: transform .2s;
        box-shadow: 0 0 30px rgba(0, 0, 0, .25);
    }
    .chat.show-tasks .tasks { transform: none; }
    .topbar { padding: 8px 10px; gap: 6px; }
    .topbar .menu { display: inline-block; }
    .topbar #new-chat { font-size: 14px; padding: 6px 8px; }
    .msg.user .bubble { max-width: 92%; }
    .composer { padding: 8px 10px 12px; }
    .composer button { min-width: 72px; }
}
