:root {
    --bg: #ffffff;
    --hero: #081e43;
    --hero-soft: #102a58;
    --hero-line: rgba(255, 255, 255, 0.1);
    --card: #ffffff;
    --widget: #ffffff;
    --widget-soft: #f3f6fb;
    --widget-line: rgba(9, 30, 66, 0.1);
    --text: #0f1728;
    --muted: #60708f;
    --muted-strong: #4c5d7a;
    --user: #0f6fff;
    --user-soft: #eaf2ff;
    --assistant: #edf3fb;
    --accent: #1d76ff;
    --accent-strong: #0f5de2;
    --success: #5aec73;
    --shadow: 0 24px 90px rgba(7, 20, 48, 0.18);
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: "Segoe UI Variable", "Segoe UI", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app-shell {
    min-height: 100vh;
}

h1,
h2,
p {
    margin: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
}

/* Pagina de demonstracao por tras do widget. */
.preview-page {
    min-height: 100vh;
}

.preview-hero {
    position: relative;
    min-height: 520px;
    padding: 26px 32px 48px;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.14), transparent 22%),
        linear-gradient(180deg, #061938 0%, #08204a 100%);
    overflow: hidden;
}

.preview-nav,
.preview-copy,
.preview-content {
    position: relative;
    z-index: 1;
}

.preview-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    color: #ffffff;
}

.preview-logo {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.preview-links {
    display: flex;
    gap: 28px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
}

.preview-copy {
    max-width: 620px;
    padding-top: 72px;
    color: #ffffff;
}

.preview-copy h1 {
    font-size: clamp(2.8rem, 5vw, 4.8rem);
    line-height: 0.95;
    letter-spacing: -0.06em;
}

.preview-copy p {
    margin-top: 28px;
    max-width: 520px;
    font-size: 1.35rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.86);
}

.preview-grid {
    position: absolute;
    top: -20px;
    right: -40px;
    width: 620px;
    height: 420px;
    transform: rotate(10deg);
    display: grid;
    grid-template-columns: repeat(3, 120px);
    gap: 26px;
    opacity: 0.88;
}

.preview-grid span {
    border: 1px solid var(--hero-line);
    border-radius: 30px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.preview-grid .is-accent {
    background: linear-gradient(180deg, #1b73ff 0%, #0a55da 100%);
}

.preview-grid .is-soft {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.08));
}

.preview-content {
    padding: 26px 32px 120px;
}

.preview-tabs {
    display: flex;
    gap: 34px;
    align-items: center;
    min-height: 76px;
    color: var(--muted-strong);
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(15, 23, 40, 0.08);
}

.preview-tabs .is-active {
    color: var(--text);
    font-weight: 700;
}

.preview-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
    padding-top: 34px;
}

.preview-card {
    min-height: 200px;
    padding: 28px;
    border-radius: 24px;
    background: var(--card);
    border: 1px solid rgba(15, 23, 40, 0.06);
    box-shadow: 0 10px 34px rgba(10, 20, 40, 0.06);
}

.preview-card h2 {
    font-size: 1.32rem;
    letter-spacing: -0.03em;
}

.preview-card p {
    margin-top: 16px;
    color: var(--muted-strong);
    line-height: 1.65;
}

/* Widget flutuante. */
.chat-widget {
    position: fixed;
    top: 24px;
    right: 24px;
    bottom: 24px;
    width: min(380px, calc(100vw - 48px));
    height: auto;
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    background: var(--widget);
    border: 1px solid var(--widget-line);
    box-shadow: var(--shadow);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px) scale(0.98);
    transform-origin: bottom right;
    transition: transform 180ms ease, opacity 180ms ease;
    z-index: 30;
}

.app-shell.widget-open .chat-widget {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--widget-line);
    background: linear-gradient(180deg, #ffffff 0%, #fafcff 100%);
}

.widget-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.widget-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #1d76ff 0%, #0f5de2 100%);
    color: #ffffff;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.widget-brand-copy {
    display: grid;
    gap: 2px;
}

.widget-brand-copy strong {
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.widget-brand-copy span {
    color: var(--muted);
    font-size: 0.88rem;
}

.widget-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 1.55rem;
    cursor: pointer;
}

.widget-body {
    flex: 1;
    padding: 18px 16px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    overflow-y: auto;
}

.welcome-state {
    display: grid;
    gap: 10px;
}

.app-shell.has-conversation .welcome-state {
    display: none;
}

.welcome-bubble {
    max-width: 82%;
    padding: 13px 15px;
    border-radius: 18px;
    background: var(--assistant);
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 40, 0.04);
}

.welcome-bubble.is-muted {
    max-width: 70%;
}

.quick-actions {
    display: grid;
    gap: 10px;
    padding-top: 8px;
}

.quick-action {
    min-height: 46px;
    padding: 0 16px;
    border-radius: 16px;
    border: 1px solid rgba(29, 118, 255, 0.22);
    background: #ffffff;
    color: var(--accent-strong);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.quick-action:hover {
    background: var(--user-soft);
}

.messages {
    display: none;
    gap: 18px;
}

.app-shell.has-conversation .messages {
    display: grid;
}

.message {
    width: 100%;
    animation: rise-in 180ms ease-out both;
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .message-body {
    max-width: 86%;
    padding: 12px 14px;
    border-radius: 18px 18px 6px 18px;
    background: var(--user);
    color: #ffffff;
}

.message-user .markdown-body :not(pre) > code,
.message-user .message-inline-code {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.message-assistant .message-body {
    max-width: 92%;
    padding: 12px 14px;
    border-radius: 18px 18px 18px 6px;
    background: var(--assistant);
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 40, 0.04);
}

.message-error .message-body {
    max-width: 92%;
    padding: 12px 14px;
    border-radius: 18px;
    background: #fff1ef;
    color: #9f2b1d;
    border: 1px solid rgba(204, 72, 49, 0.2);
}

.message-body {
    display: grid;
    gap: 12px;
    font-size: 0.97rem;
    line-height: 1.68;
}

.message-body strong {
    font-weight: 700;
}

.message-body em {
    font-style: italic;
}

.message-paragraph {
    margin: 0;
}

.message-heading {
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.message-divider {
    width: 100%;
    height: 1px;
    margin: 2px 0;
    border: 0;
    background: rgba(15, 23, 40, 0.08);
}

.message-list {
    margin: 0;
    padding-left: 22px;
    display: grid;
    gap: 4px;
}

.message-list li {
    line-height: 1.6;
}

.message-inline-code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9em;
    background: rgba(15, 23, 40, 0.06);
    border: 1px solid rgba(15, 23, 40, 0.06);
    border-radius: 8px;
    padding: 2px 6px;
}

.message-math-inline {
    display: inline-block;
    max-width: 100%;
}

.message-math-block {
    width: 100%;
    overflow-x: auto;
    padding: 4px 0;
}

.message-math-block mjx-container,
.message-math-inline mjx-container {
    color: currentColor;
}

.markdown-body > :first-child {
    margin-top: 0;
}

.markdown-body > :last-child {
    margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.03em;
}

.markdown-body h1 {
    font-size: 1.32rem;
}

.markdown-body h2 {
    font-size: 1.16rem;
}

.markdown-body h3,
.markdown-body h4 {
    font-size: 1.03rem;
}

.markdown-body p {
    margin: 0;
}

.markdown-body ul,
.markdown-body ol {
    margin: 0;
    padding-left: 22px;
    display: grid;
    gap: 4px;
}

.markdown-body blockquote {
    margin: 0;
    padding: 4px 0 4px 12px;
    border-left: 3px solid rgba(15, 23, 40, 0.12);
    color: var(--muted-strong);
}

.markdown-body a {
    color: var(--accent-strong);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.markdown-body hr {
    width: 100%;
    height: 1px;
    margin: 2px 0;
    border: 0;
    background: rgba(15, 23, 40, 0.08);
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    border: 1px solid rgba(15, 23, 40, 0.08);
    border-radius: 12px;
    overflow: hidden;
    display: block;
    overflow-x: auto;
}

.markdown-body thead {
    background: rgba(15, 23, 40, 0.04);
}

.markdown-body th,
.markdown-body td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(15, 23, 40, 0.08);
    border-right: 1px solid rgba(15, 23, 40, 0.08);
    text-align: left;
    vertical-align: top;
}

.markdown-body th:last-child,
.markdown-body td:last-child {
    border-right: 0;
}

.markdown-body tr:last-child td {
    border-bottom: 0;
}

.markdown-body pre,
.message-code {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 40, 0.08);
    background: #0f1728;
}

.markdown-body pre code,
.message-code code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9rem;
    white-space: pre;
    color: #f7f9fc;
}

.markdown-body :not(pre) > code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9em;
    background: rgba(15, 23, 40, 0.06);
    border: 1px solid rgba(15, 23, 40, 0.06);
    border-radius: 8px;
    padding: 2px 6px;
}

.markdown-body mjx-container {
    color: currentColor;
}

.message-code-block {
    display: grid;
    gap: 8px;
}

.message-code-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.composer {
    padding: 14px 16px 16px;
    border-top: 1px solid var(--widget-line);
    background: #ffffff;
}

.composer-shell {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-height: 58px;
    padding: 10px 10px 10px 14px;
    border-radius: 18px;
    background: var(--widget-soft);
    border: 1px solid rgba(15, 23, 40, 0.06);
}

textarea {
    width: 100%;
    min-height: 28px;
    max-height: 180px;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.96rem;
    line-height: 1.5;
    resize: none;
    overflow-y: auto;
    padding: 4px 0;
}

textarea::placeholder {
    color: var(--muted);
}

textarea:focus {
    outline: none;
}

.send-button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    flex: 0 0 auto;
    background: var(--accent);
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.send-button:hover {
    transform: translateY(-1px);
    background: var(--accent-strong);
}

.send-button:disabled {
    opacity: 0.45;
    cursor: wait;
    transform: none;
}

.widget-launcher {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 66px;
    height: 66px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #1d76ff 0%, #0f5de2 100%);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 18px 40px rgba(15, 93, 226, 0.34);
    z-index: 31;
    transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

.launcher-ring {
    position: absolute;
    inset: 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.launcher-icon {
    position: relative;
    font-size: 1.28rem;
}

.app-shell.widget-open .widget-launcher {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.88);
    background: linear-gradient(180deg, #174eb5 0%, #103d8f 100%);
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 900px) {
    .preview-links {
        display: none;
    }

    .preview-copy {
        padding-top: 52px;
    }

    .preview-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .chat-widget {
        right: 12px;
        top: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
        height: auto;
    }

    .widget-launcher {
        right: 12px;
        bottom: 18px;
        width: 60px;
        height: 60px;
    }
}
