:root {
    --bg: #0f1216;
    --surface: #171c22;
    --surface-2: #1f252d;
    --text: #f5f7fb;
    --muted: #9fa9b8;
    --border: rgba(255, 255, 255, 0.08);
    --brand: #ff7a2f;
    --brand-strong: #ff8d4d;
    --brand-soft: rgba(255, 122, 47, 0.16);
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

[ng-cloak] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(255, 122, 47, 0.14), transparent 30%),
        var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
}

a,
button {
    -webkit-tap-highlight-color: transparent;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: 12px;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--brand);
    color: #111;
    transform: translateY(-200%);
    transition: transform 0.2s ease;
    z-index: 1000;
}

.skip-link:focus {
    transform: translateY(0);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(13, 16, 20, 0.94);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    min-width: 0;
}

.app-brand__mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--brand-soft), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--brand-strong);
    font-weight: 800;
}

.app-brand__copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-brand__name {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.1;
}

.app-brand__tagline {
    font-size: 0.82rem;
    color: var(--muted);
}

.app-header__nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.app-header__form {
    margin: 0;
}

.app-header__link,
.app-header__account,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    text-decoration: none;
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.app-header__link {
    color: var(--muted);
}

.app-header__link:hover,
.app-header__link:focus-visible,
.button:hover,
.button:focus-visible {
    transform: translateY(-1px);
    text-decoration: none;
}

.app-header__account {
    background: var(--brand-soft);
    border-color: rgba(255, 122, 47, 0.22);
    color: var(--text);
    font-weight: 700;
}

.page-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 32px auto 64px;
    display: grid;
    gap: 18px;
}

.chat-page {
    width: min(1280px, calc(100% - 32px));
}

.auth-page {
    width: min(1080px, calc(100% - 32px));
}

.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.auth-panel,
.auth-hero,
.auth-message {
    min-width: 0;
}

.auth-message--error {
    border-color: rgba(255, 122, 47, 0.3);
    background: rgba(255, 122, 47, 0.08);
}

.auth-form {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.field {
    display: grid;
    gap: 8px;
}

.field__label {
    font-weight: 700;
}

.field__input {
    width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font: inherit;
}

.field__input:focus-visible {
    outline: 2px solid var(--brand-strong);
    outline-offset: 2px;
}

.auth-actions {
    display: flex;
    justify-content: flex-start;
}

.chat-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.chat-sidebar,
.chat-main {
    min-width: 0;
}

.chat-sidebar__header,
.chat-main__header,
.chat-composer__actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.chat-sidebar__header h2,
.chat-main__header h2 {
    margin: 0;
}

.chat-sidebar__status,
.chat-sidebar__empty,
.chat-status,
.chat-empty {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    margin-top: 14px;
}

.chat-status--error {
    border-color: rgba(255, 122, 47, 0.3);
    background: rgba(255, 122, 47, 0.08);
    color: var(--text);
}

.chat-conversation-list {
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
    display: grid;
    gap: 10px;
}

.chat-conversation-list__button {
    width: 100%;
    text-align: left;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

.chat-conversation-list__button.is-active {
    border-color: rgba(255, 122, 47, 0.45);
    background: rgba(255, 122, 47, 0.12);
}

.chat-conversation-list__title {
    display: block;
    font-weight: 700;
}

.chat-conversation-list__meta {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

.chat-message-list {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    max-height: min(54vh, 680px);
    overflow: auto;
    padding-right: 4px;
}

.chat-message {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.chat-message--assistant {
    background: rgba(255, 122, 47, 0.08);
    border-color: rgba(255, 122, 47, 0.18);
}

.chat-message--user {
    background: rgba(255, 255, 255, 0.025);
}

.chat-message__meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.chat-message__role {
    color: var(--brand-strong);
    font-weight: 700;
}

.chat-message__content {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-composer {
    margin-top: 18px;
    display: grid;
    gap: 10px;
}

.chat-composer__label {
    font-weight: 700;
}

.chat-composer__input {
    width: 100%;
    resize: vertical;
    min-height: 130px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font: inherit;
}

.chat-composer__input:focus-visible,
.chat-conversation-list__button:focus-visible,
.button:focus-visible {
    outline: 2px solid var(--brand-strong);
    outline-offset: 2px;
}

.chat-composer__hint {
    margin: 0;
}

.card {
    padding: 24px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.hero h1,
.card h2 {
    margin-top: 0;
    line-height: 1.1;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.8rem);
    margin-bottom: 16px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    color: var(--brand-strong);
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.muted {
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.button {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
    font-weight: 700;
}

.button--primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    color: #1a120d;
    border-color: transparent;
}

.button--secondary {
    background: rgba(255, 255, 255, 0.03);
}

code {
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

main:focus {
    outline: none;
}

@media (max-width: 760px) {
    .app-header {
        padding: 12px 16px;
    }

    .app-brand__tagline {
        display: none;
    }

    .page-shell {
        width: min(100% - 24px, 1080px);
        margin-top: 18px;
    }

    .card {
        padding: 20px;
    }

    .chat-layout {
        grid-template-columns: 1fr;
    }

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

    .chat-message-list {
        max-height: none;
    }

    .chat-sidebar__header,
    .chat-main__header,
    .chat-composer__actions {
        flex-direction: column;
        align-items: stretch;
    }
}
