* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #14151a;
    color: #e6e6e6;
    margin: 0;
    padding: 0;
}

.auth-box {
    max-width: 320px;
    margin: 15vh auto;
    padding: 2rem;
    background: #1e1f26;
    border-radius: 12px;
    text-align: center;
}

.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

input, textarea, button {
    font: inherit;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    border: 1px solid #33343d;
    background: #14151a;
    color: #e6e6e6;
}

button {
    background: #4a7dff;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

button:hover { background: #3a68e0; }

.error { color: #ff6b6b; }
.loading { color: #999; }

/* Pevný "app shell" - stránka jako celek nescrolluje, jen `main` uvnitř
   (transcript). Postranní panel a hlavička tak zůstávají na místě i při
   scrollování dlouhé konverzace. */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
    background: #1a1b21;
    border-right: 1px solid #26272f;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: margin-left 0.15s ease;
}

.app-layout.sidebar-hidden .sidebar {
    margin-left: -240px;
}

.sidebar #new-chat-btn {
    width: 100%;
}

#chat-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.chat-list-item {
    background: none;
    border: none;
    color: #b7b8c0;
    font-weight: 400;
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.chat-list-item:hover { background: #23242c; }
.chat-list-item.active { background: #26324a; color: #e6e6e6; }

.main-area {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid #26272f;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#sidebar-toggle {
    background: none;
    border: 1px solid #33343d;
    padding: 0.3rem 0.6rem;
    font-size: 1rem;
    line-height: 1;
}

#sidebar-toggle:hover { background: #23242c; }

header a { color: #999; text-decoration: none; }

main {
    flex: 1;
    overflow-y: auto;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem 0;
}

#prompt-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: sticky;
    bottom: 0;
    padding: 1rem 0 1.5rem;
    background: linear-gradient(#14151a00, #14151a 20%);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

.agent-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #999;
}

.agent-row select {
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
}

#transcript {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 1rem;
}

.turn {
    padding: 0.9rem 1.1rem;
    border-radius: 12px;
    line-height: 1.5;
}

.turn p {
    margin: 0;
    white-space: pre-wrap;
}

.turn-user {
    background: #23324f;
    align-self: flex-end;
    max-width: 80%;
}

.turn-assistant {
    background: #1e1f26;
}

.turn-agent-switch {
    align-self: center;
    background: none;
    padding: 0.2rem 0;
    font-size: 0.78rem;
    color: #6b6c76;
    text-align: center;
}

.turn-content.loading { color: #999; }
.turn-content.error { color: #ff6b6b; }

/* Markdown obsah v odpovědi asistenta */
.turn-content :first-child { margin-top: 0; }
.turn-content :last-child { margin-bottom: 0; }
.turn-content p { margin: 0.6rem 0; }
.turn-content ul, .turn-content ol { margin: 0.6rem 0; padding-left: 1.4rem; }
.turn-content li { margin: 0.2rem 0; }
.turn-content a { color: #6fa0ff; }
.turn-content strong { color: #f2f2f2; }
.turn-content code {
    background: #14151a;
    border: 1px solid #2c2d36;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.9em;
}
.turn-content pre {
    background: #14151a;
    border: 1px solid #2c2d36;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    overflow-x: auto;
}
.turn-content pre code {
    background: none;
    border: none;
    padding: 0;
}
.turn-content blockquote {
    margin: 0.6rem 0;
    padding-left: 0.8rem;
    border-left: 3px solid #33343d;
    color: #a9a9b2;
}
.turn-content table { border-collapse: collapse; }
.turn-content th, .turn-content td {
    border: 1px solid #2c2d36;
    padding: 0.3rem 0.6rem;
}

.version-badge {
    position: fixed;
    right: 0.75rem;
    bottom: 0.5rem;
    font-size: 0.75rem;
    color: #55565f;
    user-select: none;
    pointer-events: none;
}
