/* =====================================================
   LUVO — ESTILOS DO CHAT
   Ecrã inicial (hero) com a orbe + headline + input grande,
   que dá lugar a um layout de conversa compacto assim que a
   primeira mensagem é enviada (classe .chat-started).
===================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    justify-content: center;
}

.app-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 600px;
    display: flex;
}

.chat-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    height: 100%;
    min-height: 600px;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #000;
}

/* ---------- Rail + sidebar de reflexões ---------- */

.rail {
    width: 64px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 0;
    background: #000;
    border-right: 1px solid #1c1c1c;
}

.rail-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #8b8496;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rail-btn:hover:not(:disabled) {
    background: rgba(180, 140, 255, .12);
    color: #f2f0f5;
}

.rail-btn.active {
    background: rgba(130, 90, 230, .22);
    color: #f2f0f5;
}

.rail-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px 16px;
    background: #07050c;
    border-right: 1px solid #1c1c1c;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
}

.sidebar-logo {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: .42em;
    color: #ece7fb;
    text-shadow: 0 0 22px rgba(196, 168, 255, .6);
}

.new-reflection-btn {
    width: 100%;
    border: 1px solid rgba(180, 140, 255, .32);
    border-radius: 12px;
    background: rgba(22, 15, 36, .55);
    color: #f2f0f5;
    font-size: 14px;
    font-family: inherit;
    padding: 11px 14px;
    cursor: pointer;
    text-align: left;
}

.new-reflection-btn:hover {
    background: rgba(22, 15, 36, .85);
}

.sidebar-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 10px;
}

.sidebar-view[hidden] {
    display: none;
}

.sidebar-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.sidebar-title {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #6f6a7d;
}

.sidebar-select-toggle {
    border: 0;
    background: transparent;
    color: #b79bf0;
    font-size: 11.5px;
    font-family: inherit;
    cursor: pointer;
    padding: 2px;
}

.sidebar-select-toggle:hover {
    color: #d9c6ff;
}

.sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-empty {
    margin: 8px 2px;
    font-size: 13px;
    color: #6f6a7d;
    line-height: 1.5;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}

.sidebar-group-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: #55506270;
    padding: 6px 8px 2px;
}

.sidebar-item-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-item-row.selected .sidebar-item {
    background: rgba(180, 140, 255, .14);
}

.sidebar-item-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 0 0 0 6px;
    accent-color: #8858e0;
    cursor: pointer;
}

.sidebar-item {
    flex: 1;
    min-width: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #f2f0f5;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    padding: 9px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-item:hover {
    background: rgba(180, 140, 255, .08);
}

.sidebar-item.active {
    background: rgba(130, 90, 230, .18);
}

.sidebar-item-delete {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    margin-right: 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #55506f;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-item-delete:hover {
    background: rgba(255, 90, 90, .12);
    color: #e88;
}

.sidebar-bulk-bar[hidden] {
    display: none;
}

.sidebar-bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid rgba(180, 140, 255, .32);
    border-radius: 12px;
    background: rgba(22, 15, 36, .75);
    font-size: 12.5px;
    color: #c7c2d1;
}

.sidebar-bulk-actions {
    display: flex;
    gap: 12px;
}

.sidebar-bulk-actions button {
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    padding: 0;
}

#sidebar-bulk-cancel {
    color: #8b8496;
}

#sidebar-bulk-cancel:hover {
    color: #f2f0f5;
}

#sidebar-bulk-delete {
    color: #e88;
    font-weight: 600;
}

#sidebar-bulk-delete:hover {
    color: #ffb0b0;
}

#sidebar-bulk-delete:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.sidebar-item-title {
    font-size: 13.5px;
    line-height: 1.35;
    color: #f2f0f5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sidebar-item-principle {
    font-size: 12px;
    color: #d9b876;
}

.sidebar-item-meta {
    font-size: 11.5px;
    color: #6f6a7d;
}

.sidebar-principle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    font-size: 13.5px;
    color: #f2f0f5;
}

.sidebar-principle-icon {
    font-size: 16px;
}

.sidebar-principle-label {
    flex: 1;
}

.sidebar-principle-count {
    color: #6f6a7d;
    font-size: 12.5px;
}

.sidebar-backdrop {
    display: none;
}

/* ---------- Cabeçalho ---------- */

.chat-header {
    width: 100%;
    padding: 22px 28px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    border-bottom: 1px solid #1c1c1c;
    flex-shrink: 0;
}

.user-area {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    border-radius: 10px;
    font-family: inherit;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
    background: rgba(255, 255, 255, .06);
}

#user-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #222;
}

#user-name {
    font-size: 14px;
    color: #ddd;
}

.user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #141118;
    border: 1px solid #262230;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .4);
    z-index: 30;
}

.user-menu[hidden] {
    display: none;
}

.user-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: #ddd;
    font-size: 13.5px;
    font-family: inherit;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.user-menu-item:hover {
    background: rgba(255, 255, 255, .06);
}

/* Discreto por omissão — só sinaliza "perigoso" ao passar o rato,
   nunca como um botão vermelho permanente e chamativo. */
.user-menu-item-danger {
    color: #a89bb5;
}

.user-menu-item-danger:hover {
    color: #e08b8b;
    background: rgba(224, 139, 139, .08);
}

/* ---------- Modais (A minha conta / Eliminar conta) ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-panel {
    width: 100%;
    max-width: 380px;
    background: #141118;
    border: 1px solid #262230;
    border-radius: 16px;
    padding: 26px;
}

.modal-panel h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    font-size: 20px;
    color: #f2f0f5;
    margin: 0 0 18px;
}

.modal-panel p {
    font-size: 14px;
    line-height: 1.6;
    color: #c7c2d1;
    margin: 0 0 12px;
}

.modal-panel ul {
    margin: 0 0 12px;
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.7;
    color: #c7c2d1;
}

.modal-danger-emphasis {
    color: #e08b8b;
    font-weight: 600;
}

.modal-actions[hidden] {
    display: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-secondary-btn {
    border: 1px solid #333;
    background: transparent;
    color: #ccc;
    font-family: inherit;
    font-size: 13.5px;
    padding: 13px 16px;
    border-radius: 8px;
    cursor: pointer;
}

.modal-secondary-btn:hover {
    background: rgba(255, 255, 255, .05);
}

.modal-danger-btn {
    border: 0;
    background: #7a2f2f;
    color: #fff;
    font-family: inherit;
    font-size: 13.5px;
    padding: 13px 16px;
    border-radius: 8px;
    cursor: pointer;
}

.modal-danger-btn:hover {
    background: #8f3737;
}

.modal-danger-btn:disabled {
    opacity: .6;
    cursor: default;
}

.account-modal-photo-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 4px;
}

.account-modal-photo-row img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #222;
}

.account-modal-name {
    font-size: 15px;
    color: #f2f0f5;
}

.account-modal-email {
    font-size: 13px;
    color: #8b8496;
}

/* ---------- Acesso de avaliação terminado ---------- */
/* Cobre a app inteira, sem forma de fechar — por isso um fundo
   opaco em vez do translúcido dos outros modais (não é um diálogo
   sobre o chat, é um estado que substitui o chat). */

.access-expired-overlay {
    background: #000;
}

.access-expired-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 28px;
    max-width: 360px;
}

.access-expired-orb {
    margin-bottom: 0;
}

.account-deletion-status-message {
    margin: -14px 0 0;
    font-size: 13px;
    line-height: 1.55;
    color: #9891ab;
    max-width: 320px;
}

#account-deletion-status-actions {
    justify-content: center;
}

.access-expired-panel h2 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    font-size: clamp(16px, 5.6vw, 22px);
    line-height: 1.4;
    color: #f2f0f5;
    margin: 0;
    white-space: nowrap;
}

/* ---------- Corpo ---------- */

.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow-y: auto;
    padding: 40px 24px;
}

/* ---------- Hero (orbe + título) ---------- */

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 620px;
    flex-shrink: 0;
}

.orb-wrap {
    position: relative;
    width: min(190px, 40vw);
    aspect-ratio: 1 / 1;
    margin-bottom: 26px;
}

.orb-glow {
    position: absolute;
    inset: -22%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(130, 90, 230, .38) 0%, rgba(130, 90, 230, 0) 70%);
    filter: blur(6px);
    pointer-events: none;
}

.orb {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%, #2a2049 0%, #170f2c 42%, #060410 74%, #000 100%);
    box-shadow:
        inset 0 0 50px rgba(0, 0, 0, .7),
        inset 0 0 2px rgba(255, 255, 255, .06);
}

.orb-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 1.5px;
    background: conic-gradient(from 0deg at 50% 50%,
        transparent 0deg,
        rgba(178, 140, 255, .5) 22deg,
        rgba(232, 217, 255, .95) 48deg,
        rgba(178, 140, 255, .55) 78deg,
        transparent 135deg,
        transparent 360deg);
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    filter: blur(.5px);
}

.orb-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(26px, 7vw, 38px);
    font-weight: 500;
    letter-spacing: .42em;
    color: #ece7fb;
    text-shadow: 0 0 22px rgba(196, 168, 255, .6);
    padding-left: .42em;
}

.hero-title {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    font-size: clamp(24px, 4.4vw, 34px);
    line-height: 1.32;
    color: #f2f0f5;
}

.hero-title em {
    font-style: italic;
    color: #d9b876;
}

/* ---------- Saudação de entrada (uma vez, ao chegar — ecrã inteiro) ---------- */

.entry-greeting-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    /* Fundo sólido, sem transparência nenhuma — o brilho roxo vem só
       de .entry-greeting-glow por cima, nunca deixando o conteúdo de
       trás (ex: o "LUVO" do hero) transparecer e confundir o texto. */
    background: #07050f;
    opacity: 0;
    pointer-events: none;
    transition: opacity .9s ease;
}

.entry-greeting-overlay.is-visible {
    opacity: 1;
}

.entry-greeting-overlay.is-hiding {
    opacity: 0;
    transition: opacity 1.1s ease;
}

.entry-greeting-glow {
    position: absolute;
    width: min(560px, 92vw);
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(178, 140, 255, .38) 0%, rgba(139, 92, 230, 0) 70%);
    filter: blur(10px);
    opacity: 0;
    transform: scale(.6);
    transition: opacity 1.2s ease, transform 1.6s cubic-bezier(.22, 1, .36, 1);
}

.entry-greeting-overlay.is-visible .entry-greeting-glow {
    opacity: 1;
    transform: scale(1);
}

.entry-greeting-text {
    position: relative;
    margin: 0;
    padding: 0 24px;
    max-width: 720px;
    text-align: center;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    font-size: clamp(30px, 7.6vw, 56px);
    line-height: 1.25;
    color: #f2f0f5;
    text-shadow: 0 0 44px rgba(178, 140, 255, .55);
    opacity: 0;
    filter: blur(6px);
    transform: scale(.85) translateY(10px);
    transition: opacity .9s ease, filter .9s ease, transform 1.1s cubic-bezier(.22, 1, .36, 1);
}

.entry-greeting-overlay.is-visible .entry-greeting-text {
    opacity: 1;
    filter: blur(0);
    transform: scale(1) translateY(0);
}

/* ---------- Encorajamento (após a primeira mensagem) ---------- */
/* Explosão de faíscas roxas à volta de um "botão" com a mensagem —
   ver renderEncouragementMessage em ui-engine.js. */

.encouragement-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* "Sai" da coluna estreita das mensagens e usa a largura do ecrã
       inteiro — só assim há espaço para caber em 2 linhas com uma
       letra maior (a coluna normal das mensagens, com padding, é
       tipicamente estreita demais para isto num telemóvel). */
    width: 100vw;
    margin: 6px calc(50% - 50vw) 24px;
}

.firework-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
}

.firework-particle {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: var(--spark-color, #b79bf0);
    box-shadow: 0 0 6px 1px var(--spark-color, #b79bf0);
    opacity: 0;
}

.encouragement-wrapper.is-visible .firework-particle {
    animation: firework-spark .9s ease-out forwards;
}

@keyframes firework-spark {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) scale(.3);
    }
}

.encouragement-badge {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    max-width: min(420px, calc(100vw - 24px));
    border: 1px solid rgba(180, 140, 255, .45);
    border-radius: 18px;
    background: rgba(139, 92, 230, .16);
    box-shadow: 0 0 34px rgba(139, 92, 230, .38);
    color: #ece7fb;
    font-size: 16.5px;
    font-weight: 500;
    line-height: 1.5;
    padding: 12px 16px;
    text-align: center;
    white-space: pre-line;
    opacity: 0;
    transform: scale(.82);
    transition: opacity .5s ease, transform .5s cubic-bezier(.34, 1.56, .64, 1);
}

.encouragement-wrapper.is-visible .encouragement-badge {
    opacity: 1;
    transform: scale(1);
}

.encouragement-wrapper.is-hiding {
    transition: opacity .6s ease;
    opacity: 0;
}

.encouragement-wrapper.is-hiding .encouragement-badge {
    transform: scale(.94);
    transition: opacity .6s ease, transform .6s ease;
}

/* ---------- Mensagens ---------- */

#messages {
    display: none;
    width: 100%;
    max-width: 620px;
    padding: 8px 4px 24px;
}

.chat-container.chat-started #messages {
    display: block;
}

.message {
    margin-bottom: 20px;
    line-height: 1.6;
    font-size: 16px;
}

.message.user {
    text-align: right;
}

.message.user .message-content {
    display: inline-block;
    background: #fff;
    color: #000;
    padding: 11px 16px;
    border-radius: 18px;
    max-width: 80%;
    text-align: left;
}

.message.assistant .message-content {
    display: block;
    color: #ece9f2;
    max-width: 100%;
    line-height: 1.7;
    font-size: 15.5px;
}

.message.assistant .message-content > *:first-child {
    margin-top: 0;
}

.message.assistant .message-content > *:last-child {
    margin-bottom: 0;
}

.message.assistant .message-content p {
    margin: 0 0 14px;
}

.message.assistant .message-content strong {
    color: #fff;
    font-weight: 600;
}

.message.assistant .message-content em {
    font-style: italic;
    color: #d9b876;
}

.message.assistant .message-content ul,
.message.assistant .message-content ol {
    margin: 0 0 14px;
    padding-left: 22px;
}

.message.assistant .message-content li {
    margin-bottom: 6px;
}

.message.assistant .message-content li:last-child {
    margin-bottom: 0;
}

.message.assistant .message-content blockquote {
    margin: 4px 0 14px;
    padding: 2px 0 2px 16px;
    border-left: 2px solid rgba(217, 184, 118, .5);
    color: #cfc9da;
    font-style: italic;
}

.message.assistant .message-content.loading-message {
    color: #a99fc2;
    font-style: italic;
    opacity: 1;
    transition: opacity .35s ease;
}

.message.assistant .message-content.loading-message.is-fading {
    opacity: 0;
}

/* ---------- Input, exemplo, confiança ---------- */

.chat-input-area {
    width: 100%;
    max-width: 620px;
    flex-shrink: 0;
    margin-top: 32px;
}

.chat-form {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    border: 1px solid rgba(180, 140, 255, .32);
    border-radius: 26px;
    background: rgba(22, 15, 36, .55);
    box-shadow: 0 0 40px rgba(130, 90, 230, .14), inset 0 0 30px rgba(90, 60, 160, .07);
    padding: 17px 18px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

/* #message tem outline:none — sem isto, focar o campo não dava
   nenhum sinal visual. */
.chat-form:focus-within {
    border-color: rgba(200, 170, 255, .75);
    box-shadow: 0 0 55px rgba(130, 90, 230, .3), inset 0 0 30px rgba(90, 60, 160, .12);
}

/* Pulso neon suave ao começar "Nova reflexão" — chama a atenção para
   a caixa de texto sem ser abrupto (fade in/out lento, não um piscar). */
@keyframes neon-attention-pulse {
    0% {
        border-color: rgba(180, 140, 255, .32);
        box-shadow: 0 0 40px rgba(130, 90, 230, .14), inset 0 0 30px rgba(90, 60, 160, .07);
    }
    45% {
        border-color: rgba(216, 180, 255, .95);
        box-shadow: 0 0 75px rgba(180, 120, 255, .6), inset 0 0 40px rgba(130, 90, 230, .28);
    }
    100% {
        border-color: rgba(180, 140, 255, .32);
        box-shadow: 0 0 40px rgba(130, 90, 230, .14), inset 0 0 30px rgba(90, 60, 160, .07);
    }
}

.chat-form.neon-attention {
    animation: neon-attention-pulse 1.6s ease-in-out;
}

.chat-form-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #b79bf0;
    opacity: .85;
}

.chat-container:not(.chat-started) #message {
    min-height: 46px;
}

#message {
    flex: 1;
    min-height: 24px;
    max-height: 220px;
    resize: none;
    overflow-y: auto;
    border: 0;
    background: transparent;
    outline: none;
    color: #f2f0f5;
    padding: 0;
    font-size: 15.5px;
    line-height: 1.5;
    font-family: inherit;
}

#message::placeholder {
    color: #8b8496;
}

#message:disabled {
    opacity: .6;
}

#send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 1px solid rgba(210, 180, 255, .4);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #2a2049, #120c22);
    color: #e7d9b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send svg {
    width: 17px;
    height: 17px;
}

#send:hover {
    opacity: .9;
}

#send:disabled {
    opacity: .4;
    cursor: not-allowed;
}

#message::-webkit-scrollbar {
    width: 6px;
}

#message::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 20px;
}

.example-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 20px auto 0;
    border: 0;
    background: transparent;
    color: #b79bf0;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
}

.example-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.example-btn:hover {
    color: #d9c6ff;
}

.example-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* Marcador sem estilo, colocado logo antes de .trust-rows: o
   IntersectionObserver observa este span, nunca o .trust-rows
   diretamente — um alvo com clip-path aplicado a si próprio é
   silenciosamente tratado como "nunca a intersetar" pelo browser
   (testado localmente: intersectionRatio fica sempre 0), por isso
   precisa de um sentinela vizinho, sem clip-path, à mesma posição. */
.trust-rows-sentinel {
    display: block;
    height: 1px;
}

.trust-rows {
    /* Fica escondido debaixo da área de input, como um tapete a tapar
       o chão — clip-path (não opacity) para parecer que desliza de
       trás da área de acima, em vez de simplesmente aparecer. Só sai
       de baixo com um scroll real (ver initTrustRowsReveal em
       ui-engine.js — nunca revela só por já calhar visível no
       arranque, senão perde-se o efeito de "puxar o tapete"). */
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 480px;
    margin: 160px auto 0;
    padding-top: 28px;
    border-top: 1px solid rgba(255, 255, 255, .05);
    background: linear-gradient(180deg, rgba(24, 16, 38, .5) 0%, rgba(24, 16, 38, 0) 65%);
    clip-path: inset(0 0 100% 0);
    transform: translateY(-18px);
    transition: clip-path .9s cubic-bezier(.22, 1, .36, 1), transform .9s cubic-bezier(.22, 1, .36, 1);
}

.trust-rows::before {
    content: "";
    position: absolute;
    top: 0;
    left: -24px;
    right: -24px;
    height: 36px;
    background: linear-gradient(180deg, rgba(0, 0, 0, .6) 0%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
}

.trust-rows.is-revealed {
    clip-path: inset(0 0 0% 0);
    transform: translateY(0);
}

.trust-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    text-align: left;
    font-size: 12.5px;
    line-height: 1.5;
    color: #8b8594;
}

.trust-row svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
    color: #7d72a3;
}

.trust-row em {
    font-style: italic;
    color: #d9b876;
}

.trust-row a {
    color: inherit;
    text-decoration: none;
}

.trust-row a:hover em {
    color: #e8c98e;
}

/* ---------- Estado: conversa iniciada ---------- */

.chat-container.chat-started .chat-content {
    justify-content: flex-start;
    padding-bottom: 20px;
}

.chat-container.chat-started .hero,
.chat-container.chat-started .example-btn,
.chat-container.chat-started .trust-rows {
    display: none;
}

.chat-container.chat-started .chat-input-area {
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: #000;
    padding-top: 10px;
}

/* ---------- Responsivo ---------- */

@media (max-width: 600px) {

    .chat-header {
        padding: 16px 18px;
    }

    .chat-content {
        padding: 28px 18px;
    }

    .hero-title {
        font-size: clamp(21px, 5.6vw, 28px);
    }

    .trust-rows {
        margin-top: 100px;
    }

    #user-name {
        display: none;
    }

    /* Alvos de toque um pouco maiores em mobile (mínimo recomendado
       ~44px), sem alterar o visual em ecrãs largos. */
    .rail-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    /* Sidebar vira um overlay: fica fora de ecrã até .sidebar.open;
       o rail de ícones mantém-se sempre visível e é quem a abre. */

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 64px;
        width: min(280px, calc(100vw - 64px));
        z-index: 20;
        /* -100% só desloca pela própria largura — falta também o
           left:64px de onde parte, senão fica uma fatia visível
           por cima do rail. */
        transform: translateX(calc(-100% - 64px));
        transition: transform .25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.open ~ .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0 0 0 calc(64px + min(280px, calc(100vw - 64px)));
        background: rgba(0, 0, 0, .45);
        z-index: 19;
    }

}
