:root {
    --violet: #8b5cf6;
    --amber: #c084fc;
    --ink: #0f172a;
    --black: #020617;
    --panel: rgba(15, 23, 42, .68);
    --line: rgba(255, 255, 255, .12);
    --text: #f8fafc;
    --muted: #94a3b8;
    --danger: #fb7185;
    --success: #34d399;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--black);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

.landing-body,
.auth-body,
.app-body {
    background:
        radial-gradient(circle at 18% 8%, rgba(192, 132, 252, .22), transparent 34%),
        radial-gradient(circle at 82% 12%, rgba(139, 92, 246, .18), transparent 28%),
        linear-gradient(135deg, #020617 0%, #0f172a 48%, #111827 100%);
}

.glass {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .36);
    backdrop-filter: blur(22px);
}

.topbar,
.chat-header,
.sidebar-head,
.sidebar-foot,
.hero-actions,
.nav-actions {
    display: flex;
    align-items: center;
}

.landing {
    min-height: 100vh;
    padding: 28px clamp(18px, 4vw, 64px);
}

.topbar {
    justify-content: space-between;
    max-width: 1180px;
    margin: 0 auto;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 22px;
    font-weight: 800;
}

.brand span {
    color: var(--amber);
}

.brand.center {
    justify-content: center;
}

.nav-actions,
.hero-actions {
    gap: 12px;
}

.primary-link,
.ghost-link,
.primary-button {
    border-radius: 8px;
    padding: 11px 16px;
    border: 1px solid var(--line);
    transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.primary-link,
.primary-button {
    color: white;
    background: linear-gradient(135deg, var(--violet), var(--amber));
    border: 0;
    cursor: pointer;
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.ghost-link {
    background: rgba(255, 255, 255, .05);
}

.large {
    padding: 14px 20px;
}

.primary-link:hover,
.ghost-link:hover,
.primary-button:hover,
.new-chat:hover,
.send-button:hover,
.icon-button:hover {
    transform: translateY(-1px);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
    gap: clamp(32px, 6vw, 84px);
    align-items: center;
    max-width: 1180px;
    min-height: calc(100vh - 96px);
    margin: 0 auto;
    padding-bottom: 7vh;
}

.eyebrow {
    color: var(--amber);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
}

.hero h1 {
    margin: 0;
    font-size: clamp(56px, 10vw, 128px);
    line-height: .88;
    letter-spacing: 0;
}

.lead {
    max-width: 680px;
    color: #dbeafe;
    font-size: clamp(18px, 2vw, 22px);
    line-height: 1.65;
}

.hero-panel {
    min-width: 0;
}

.editor-window {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(2, 6, 23, .78);
    box-shadow: 0 28px 90px rgba(0, 0, 0, .45);
}

.window-dots {
    display: flex;
    gap: 8px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
}

.window-dots i {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: var(--amber);
}

pre {
    margin: 0;
    overflow: auto;
    white-space: pre-wrap;
}

code {
    font-family: "JetBrains Mono", Consolas, monospace;
}

.editor-window pre {
    padding: 22px;
    color: #c4b5fd;
    line-height: 1.7;
}

.auth-shell {
    width: min(440px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    align-content: center;
    gap: 20px;
}

.auth-shell.wide {
    width: min(560px, calc(100% - 32px));
}

.auth-card,
.debug-shell {
    border-radius: 8px;
    padding: 28px;
}

.auth-card h1,
.debug-shell h1 {
    margin: 0 0 22px;
}

.auth-card label {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: #dbeafe;
    font-size: 14px;
}

.auth-card input,
.composer textarea,
.composer select {
    width: 100%;
    color: var(--text);
    background: rgba(2, 6, 23, .54);
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: 0;
}

.auth-card input {
    padding: 13px 14px;
}

.primary-button {
    width: 100%;
    padding: 13px 16px;
    font-weight: 700;
}

.auth-card p {
    color: var(--muted);
    text-align: center;
}

.auth-card a,
.debug-shell a {
    color: var(--amber);
}

.alert {
    margin-bottom: 16px;
    border-radius: 8px;
    padding: 12px 14px;
}

.alert.error {
    color: #fecdd3;
    background: rgba(251, 113, 133, .14);
}

.alert.success {
    color: #bbf7d0;
    background: rgba(52, 211, 153, .14);
}

.app-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    min-height: 560px;
    overflow: hidden;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-width: 0 1px 0 0;
    padding: 18px;
}

.sidebar-head,
.sidebar-foot,
.chat-header {
    justify-content: space-between;
    gap: 12px;
}

.new-chat {
    margin: 22px 0 16px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    color: white;
    background: rgba(255, 255, 255, .07);
    cursor: pointer;
    text-align: left;
}

.chat-list {
    display: grid;
    gap: 8px;
    overflow: auto;
    flex: 1;
    padding-right: 4px;
}

.chat-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px;
    color: #dbeafe;
    background: transparent;
}

.chat-item.active,
.chat-item:hover {
    background: rgba(255, 255, 255, .07);
    border-color: var(--line);
}

.chat-title {
    min-width: 0;
    border: 0;
    padding: 0;
    color: inherit;
    background: transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    text-align: left;
}

.mini-button,
.icon-button {
    border: 1px solid var(--line);
    color: #e2e8f0;
    background: rgba(255, 255, 255, .06);
    border-radius: 8px;
    cursor: pointer;
}

.mini-button {
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    font-size: 12px;
}

.icon-button {
    width: 38px;
    height: 38px;
}

.sidebar-foot {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    color: var(--muted);
    font-size: 14px;
}

.chat-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    height: 100vh;
    height: 100dvh;
}

.chat-header {
    padding: 18px clamp(16px, 3vw, 34px);
    border-bottom: 1px solid var(--line);
}

.chat-header span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.settings-link {
    color: var(--amber);
}

.messages {
    overflow-y: auto;
    padding: 28px clamp(16px, 4vw, 72px);
    scroll-behavior: smooth;
    min-height: 0;
}

.welcome {
    max-width: 760px;
    margin: 8vh auto;
    border-radius: 8px;
    padding: 34px;
    text-align: center;
}

.welcome h1 {
    margin: 0 0 12px;
    font-size: clamp(38px, 7vw, 76px);
}

.welcome p {
    color: #dbeafe;
    line-height: 1.7;
}

.message {
    max-width: 940px;
    margin: 0 auto 22px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 14px;
    animation: rise .24s ease both;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(192, 132, 252, .16);
    border: 1px solid var(--line);
    color: var(--amber);
    font-weight: 800;
}

.bubble {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px 18px;
    background: rgba(15, 23, 42, .58);
    line-height: 1.65;
}

.message.user .bubble {
    background: rgba(139, 92, 246, .14);
}

.bubble p {
    margin: 0 0 12px;
}

.bubble pre {
    position: relative;
    margin: 14px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(2, 6, 23, .78);
}

.bubble pre code {
    display: block;
    padding: 18px;
    line-height: 1.65;
    color: #e2e8f0;
}

.copy-code {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #e2e8f0;
    background: rgba(15, 23, 42, .92);
    cursor: pointer;
    padding: 6px 9px;
    font-size: 12px;
}

.hidden {
    display: none !important;
}

.composer {
    display: grid;
    grid-template-columns: minmax(132px, 180px) auto auto minmax(0, 1fr) 46px;
    align-items: end;
    gap: 12px;
    margin: 0 clamp(16px, 4vw, 72px) 22px;
    padding: 12px;
    border-radius: 8px;
}

.composer textarea,
.composer select {
    min-height: 46px;
    padding: 12px 14px;
    line-height: 1.5;
}

.image-upload {
    min-height: 46px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 13px;
    color: #e2e8f0;
    background: rgba(255, 255, 255, .06);
    cursor: pointer;
}

.image-upload input {
    display: none;
}

.image-file {
    max-width: 160px;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer textarea {
    max-height: 180px;
    resize: none;
}

.composer select {
    appearance: none;
    cursor: pointer;
    padding-right: 34px;
    background-image:
        linear-gradient(45deg, transparent 50%, #cbd5e1 50%),
        linear-gradient(135deg, #cbd5e1 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 20px,
        calc(100% - 12px) 20px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.send-button {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 8px;
    color: white;
    background: linear-gradient(135deg, var(--violet), var(--amber));
    cursor: pointer;
    font-size: 22px;
}

.message-image {
    display: block;
    max-width: min(100%, 720px);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.loader {
    display: inline-flex;
    gap: 6px;
}

.loader i {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--amber);
    animation: pulse 1s ease-in-out infinite;
}

.loader i:nth-child(2) {
    animation-delay: .16s;
}

.loader i:nth-child(3) {
    animation-delay: .32s;
}

.debug-shell {
    width: min(760px, calc(100% - 32px));
    margin: 8vh auto;
}

.legal-page {
    min-height: 100vh;
    padding: 28px clamp(18px, 4vw, 64px) 56px;
}

.legal-topbar {
    margin-bottom: clamp(28px, 5vw, 56px);
}

.legal-shell {
    width: min(860px, calc(100% - 32px));
    margin: 0 auto;
    border-radius: 8px;
    padding: clamp(24px, 4vw, 44px);
}

.legal-shell h1 {
    margin: 28px 0 18px;
    font-size: clamp(34px, 6vw, 58px);
}

.legal-shell h2 {
    margin: 26px 0 8px;
    color: var(--amber);
}

.legal-shell p {
    color: #dbeafe;
    line-height: 1.75;
}

.admin-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-nav {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    border-radius: 0;
    border-width: 0 1px 0 0;
    padding: 20px;
}

.admin-nav nav {
    display: grid;
    gap: 8px;
}

.admin-nav nav a {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px 14px;
    color: #dbeafe;
}

.admin-nav nav a.active,
.admin-nav nav a:hover {
    border-color: var(--line);
    background: rgba(255, 255, 255, .07);
}

.admin-nav .ghost-link {
    margin-top: auto;
    text-align: center;
}

.admin-content {
    min-width: 0;
    padding: clamp(18px, 4vw, 44px);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.admin-header h1 {
    margin: 0;
    font-size: clamp(34px, 5vw, 56px);
}

.admin-header span {
    color: var(--muted);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card {
    border-radius: 8px;
    padding: 22px;
}

.stat-card span {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 42px;
}

.admin-panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
    gap: 16px;
    margin-top: 16px;
}

.admin-panel,
.admin-form {
    border-radius: 8px;
    padding: 22px;
}

.admin-panel h2,
.admin-form h2 {
    margin: 0 0 16px;
    font-size: 22px;
}

.system-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 18px;
    color: var(--muted);
}

.system-list strong {
    color: #e2e8f0;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-form {
    width: min(780px, 100%);
}

.admin-form label {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: #dbeafe;
    font-size: 14px;
}

.admin-form input[type="password"],
.admin-form input[type="number"] {
    width: 100%;
    color: var(--text);
    background: rgba(2, 6, 23, .54);
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: 0;
    padding: 13px 14px;
}

.form-help {
    margin: -4px 0 18px;
    color: var(--muted);
    line-height: 1.6;
}

.toggle-row {
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
}

.toggle-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--violet);
}

.admin-table-wrap {
    overflow: auto;
    border-radius: 8px;
}

.admin-table {
    width: 100%;
    min-width: 820px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.admin-table td span {
    color: var(--muted);
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-actions button {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    color: #e2e8f0;
    background: rgba(255, 255, 255, .06);
    cursor: pointer;
}

.inline-actions button:hover {
    background: rgba(255, 255, 255, .1);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    color: #dbeafe;
    background: rgba(148, 163, 184, .16);
    font-size: 12px;
}

.status-pill.suspect,
.status-pill.pending {
    color: #fde68a;
    background: rgba(245, 158, 11, .18);
}

.status-pill.banned,
.status-pill.deleted {
    color: #fecdd3;
    background: rgba(251, 113, 133, .18);
}

.status-pill.normal,
.status-pill.approved {
    color: #bbf7d0;
    background: rgba(52, 211, 153, .16);
}

.moderation-list {
    display: grid;
    gap: 16px;
}

.moderation-card {
    border-radius: 8px;
    padding: 18px;
}

.moderation-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.moderation-head span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.moderation-card p {
    color: #dbeafe;
    line-height: 1.65;
    white-space: pre-wrap;
}

.risk-score {
    min-width: 76px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(251, 113, 133, .35);
    border-radius: 8px;
    color: #fecdd3;
    background: rgba(251, 113, 133, .12);
    font-weight: 800;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.tag-row span {
    border-radius: 999px;
    padding: 5px 9px;
    color: #dbeafe;
    background: rgba(139, 92, 246, .16);
    font-size: 12px;
}

.debug-row {
    display: grid;
    gap: 6px;
    margin: 12px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.debug-row.ok {
    border-color: rgba(52, 211, 153, .45);
}

.debug-row.ko {
    border-color: rgba(251, 113, 133, .55);
}

.debug-row span {
    color: var(--muted);
}

.mobile-only {
    display: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: .35;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

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

@media (max-width: 920px) {
    .hero,
    .app-layout,
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .app-layout {
        min-height: 100vh;
        min-height: 100dvh;
    }

    .hero {
        padding-top: 64px;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        width: min(86vw, 320px);
        transform: translateX(-105%);
        transition: transform .22s ease;
    }

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

    .mobile-only {
        display: inline-grid;
        place-items: center;
    }

    .admin-nav {
        position: static;
        height: auto;
        border-width: 0 0 1px;
    }

    .admin-nav .ghost-link {
        margin-top: 0;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-panel-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .landing {
        padding: 18px;
    }

    .topbar,
    .hero-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .nav-actions {
        gap: 8px;
    }

    .auth-card,
    .debug-shell,
    .welcome {
        padding: 22px;
    }

    .message {
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 10px;
    }

    .avatar {
        width: 34px;
        height: 34px;
    }

    .composer {
        margin-inline: 12px;
        grid-template-columns: minmax(0, 1fr) 46px;
    }

    .composer select {
        grid-column: 1 / -1;
    }

    .image-upload,
    .image-file {
        grid-column: 1 / -1;
    }

    .admin-header,
    .moderation-head {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .admin-content {
        padding: 16px;
    }
}
