:root {
    color-scheme: light;
    --bg: #f4f5f7;
    --ink: #101114;
    --muted: #6c727f;
    --line: #e6e8ee;
    --panel: #ffffff;
    --dark: #101114;
    --lime: #e8ff5a;
    --cyan: #00d1ff;
    --soft: #f8f9fb;
    --danger: #d92d20;
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.conversation-app {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(232, 255, 90, .16), transparent 34%),
        linear-gradient(315deg, rgba(0, 209, 255, .12), transparent 38%),
        var(--bg);
}

.aurora-line {
    position: fixed;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--lime), var(--cyan), #ffffff);
    z-index: 2;
}

.loading-card,
.login-view,
.chat-layout {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
}

.loading-card {
    min-height: 100vh;
    display: grid;
    place-items: center;
    gap: 14px;
    color: var(--muted);
}

.loading-card img {
    width: 64px;
    height: 64px;
}

.login-view {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
    gap: 48px;
    align-items: center;
    padding: 48px 0;
}

.brand {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.brand img {
    width: 72px;
    height: 72px;
    flex: 0 0 auto;
}

.brand p,
.chat-header span,
.pulse-card span {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.brand h1 {
    max-width: 720px;
    margin: 0;
    font-size: clamp(2.8rem, 6vw, 5.8rem);
    line-height: .96;
}

.brand.compact {
    align-items: center;
}

.brand.compact img {
    width: 48px;
    height: 48px;
}

.brand.compact h1 {
    font-size: 1.45rem;
    line-height: 1.1;
}

.login-panel,
.side-panel,
.chat-panel {
    background: rgba(255, 255, 255, .86);
    border: 1px solid rgba(230, 232, 238, .9);
    box-shadow: 0 24px 80px rgba(16, 17, 20, .08);
    backdrop-filter: blur(18px);
}

.login-panel {
    display: grid;
    gap: 14px;
    padding: 28px;
    border-radius: 8px;
}

.login-panel label {
    font-weight: 800;
}

.login-panel input,
.composer textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--soft);
    color: var(--ink);
    outline: none;
    border-radius: 8px;
}

.login-panel input {
    min-height: 54px;
    padding: 0 16px;
}

.login-panel input:focus,
.composer textarea:focus {
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(232, 255, 90, .45);
}

.primary-action,
.send-button,
.ghost-action,
.icon-button,
.load-more {
    border: 0;
    border-radius: 8px;
    min-height: 46px;
    font-weight: 900;
}

.primary-action,
.send-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 18px;
    background: var(--dark);
    color: white;
}

.primary-action:disabled,
.send-button:disabled,
.icon-button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.form-error {
    color: var(--danger);
    font-weight: 700;
}

.chat-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    padding: 24px 0;
}

.side-panel,
.chat-panel {
    border-radius: 8px;
}

.side-panel {
    min-height: calc(100vh - 48px);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.mode-switch button {
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-weight: 900;
}

.mode-switch button.active {
    background: var(--dark);
    color: white;
}

.pulse-card {
    padding: 18px;
    background: linear-gradient(135deg, var(--dark), #292c33);
    color: white;
    border-radius: 8px;
}

.pulse-card strong {
    display: block;
    font-size: 1.35rem;
    line-height: 1.12;
}

.ghost-action {
    margin-top: auto;
    background: var(--soft);
    color: var(--ink);
}

.chat-panel {
    min-height: calc(100vh - 48px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.chat-header {
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-header h2 {
    margin: 0;
    font-size: 1.55rem;
}

.icon-button {
    width: 46px;
    background: var(--soft);
}

.messages {
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px;
    scroll-behavior: smooth;
}

.message {
    width: min(76%, 720px);
    padding: 14px 16px;
    border: 1px solid var(--line);
    background: var(--soft);
    border-radius: 8px;
}

.message.mine {
    align-self: flex-end;
    background: var(--dark);
    border-color: var(--dark);
    color: white;
}

.message.ai {
    background: #effcff;
    border-color: #b9f1ff;
    color: var(--ink);
}

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-size: .78rem;
    font-weight: 900;
    color: var(--muted);
}

.message.mine .message-meta {
    color: rgba(255, 255, 255, .68);
}

.message p {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.55;
}

.message details {
    margin-top: 12px;
    color: rgba(255, 255, 255, .72);
}

.message details span {
    display: block;
    margin-top: 8px;
    line-height: 1.45;
}

.load-more {
    align-self: center;
    padding: 0 16px;
    background: white;
    border: 1px solid var(--line);
}

.empty-state {
    margin: auto;
    max-width: 420px;
    text-align: center;
    color: var(--muted);
}

.empty-state strong {
    display: block;
    margin-bottom: 8px;
    color: var(--ink);
    font-size: 1.4rem;
}

.composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--line);
    background: white;
}

.composer textarea {
    min-height: 54px;
    max-height: 160px;
    resize: vertical;
    padding: 14px 16px;
}

.not-found {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.not-found a {
    color: var(--ink);
    font-weight: 900;
}

#blazor-error-ui {
    background: #fff4d6;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none;
    left: 0;
    padding: .8rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
}

@media (max-width: 860px) {
    .login-view,
    .chat-layout {
        grid-template-columns: 1fr;
    }

    .login-view {
        align-content: center;
        gap: 28px;
    }

    .brand {
        display: grid;
    }

    .brand h1 {
        font-size: 3rem;
    }

    .side-panel {
        min-height: auto;
    }

    .chat-panel {
        min-height: 72vh;
    }

    .composer {
        grid-template-columns: 1fr;
    }

    .message {
        width: 92%;
    }
}
