:root {
    --brand-primary: #2563eb;
    --brand-primary-dark: #1d4ed8;
    --brand-accent: #22c55e;
    --background: #07101f;
    --surface: rgba(15, 27, 47, 0.94);
    --surface-light: rgba(24, 39, 65, 0.92);
    --border: rgba(148, 163, 184, 0.16);
    --text: #f8fafc;
    --muted: #9fb0c6;
    --danger: #fb7185;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background:
        radial-gradient(circle at 12% 18%, rgba(37, 99, 235, 0.22), transparent 34rem),
        radial-gradient(circle at 88% 82%, rgba(34, 197, 94, 0.12), transparent 32rem),
        var(--background);
}

button,
input,
textarea {
    font: inherit;
}

button,
a {
    transition:
        transform 150ms ease,
        opacity 150ms ease,
        background-color 150ms ease;
}

button:hover,
a:hover {
    opacity: 0.92;
}

button:active {
    transform: translateY(1px);
}

.login-page {
    display: grid;
    min-height: 100vh;
    padding: 24px;
    place-items: center;
}

.login-card {
    width: min(460px, 100%);
    padding: 44px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
}

.brand-mark {
    display: grid;
    width: 64px;
    height: 64px;
    margin-bottom: 28px;
    color: white;
    font-size: 30px;
    font-weight: 800;
    border-radius: 20px;
    place-items: center;
    background: linear-gradient(135deg, var(--brand-primary), #60a5fa);
    box-shadow: 0 16px 40px rgba(37, 99, 235, 0.32);
}

.brand-mark-small {
    width: 44px;
    height: 44px;
    margin: 0;
    font-size: 21px;
    border-radius: 14px;
}

.eyebrow {
    margin: 0 0 8px;
    color: #7dd3fc;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(30px, 4vw, 46px);
    line-height: 1.05;
}

.login-intro {
    margin-bottom: 28px;
    color: var(--muted);
    line-height: 1.65;
}

.login-form {
    display: grid;
    gap: 18px;
}

.login-form label {
    display: grid;
    gap: 8px;
    color: #d7e2f0;
    font-size: 14px;
    font-weight: 700;
}

.login-form input,
.composer textarea {
    width: 100%;
    color: var(--text);
    border: 1px solid var(--border);
    outline: none;
    background: rgba(4, 12, 26, 0.74);
}

.login-form input {
    height: 52px;
    padding: 0 16px;
    border-radius: 14px;
}

.login-form input:focus,
.composer textarea:focus {
    border-color: rgba(96, 165, 250, 0.76);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.login-form button,
.composer button {
    color: white;
    border: 0;
    cursor: pointer;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
}

.login-form button {
    height: 52px;
    margin-top: 4px;
    border-radius: 14px;
}

.alert,
.chat-error {
    color: #fecdd3;
    border: 1px solid rgba(251, 113, 133, 0.25);
    background: rgba(159, 18, 57, 0.22);
}

.alert {
    margin-bottom: 20px;
    padding: 13px 15px;
    border-radius: 12px;
}

.local-note {
    margin: 24px 0 0;
    color: #718198;
    font-size: 12px;
    text-align: center;
}

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

.topbar {
    display: flex;
    min-height: 76px;
    padding: 14px clamp(20px, 4vw, 52px);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    background: rgba(5, 13, 27, 0.74);
    backdrop-filter: blur(20px);
}

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

.brand strong,
.brand span {
    display: block;
}

.brand span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.account {
    display: flex;
    gap: 16px;
    align-items: center;
    color: var(--muted);
    font-size: 14px;
}

.account a {
    color: white;
    font-weight: 700;
    text-decoration: none;
}

.workspace {
    display: grid;
    width: min(1500px, calc(100% - 40px));
    min-height: calc(100vh - 116px);
    margin: 20px auto;
    gap: 20px;
    grid-template-columns: minmax(0, 1fr) 370px;
}

.chat-panel,
.monitor-panel {
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}

.chat-panel {
    display: flex;
    min-height: 760px;
    padding: clamp(22px, 4vw, 42px);
    flex-direction: column;
}

.chat-heading {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: space-between;
}

.chat-heading h1 {
    margin-bottom: 8px;
}

.chat-heading > div > p:last-child {
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    padding: 10px 13px;
    gap: 8px;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 999px;
    align-items: center;
    color: var(--muted);
    background: rgba(4, 12, 26, 0.6);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #64748b;
}

.status-pill.online .status-dot {
    background: var(--brand-accent);
    box-shadow: 0 0 14px rgba(34, 197, 94, 0.9);
}

.status-pill.online {
    color: #bbf7d0;
}

.messages {
    display: flex;
    overflow-y: auto;
    min-height: 320px;
    max-height: 52vh;
    padding: 30px 4px;
    gap: 18px;
    flex: 1;
    flex-direction: column;
}

.message {
    display: flex;
    max-width: 82%;
    gap: 12px;
    align-items: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    color: white;
    border-radius: 12px;
    place-items: center;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-primary), #60a5fa);
}

.message.user .avatar {
    background: #334155;
}

.message-content {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 6px 18px 18px;
    background: var(--surface-light);
}

.message.user .message-content {
    border-radius: 18px 6px 18px 18px;
    background: rgba(37, 99, 235, 0.24);
}

.message-content strong {
    display: block;
    margin-bottom: 6px;
    color: #bfdbfe;
    font-size: 12px;
}

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



.composer {
    display: grid;
    padding: 9px;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(4, 12, 26, 0.72);
    grid-template-columns: minmax(0, 1fr) auto;
}

.composer textarea {
    min-height: 54px;
    max-height: 160px;
    padding: 15px;
    border: 0;
    resize: none;
    background: transparent;
}

.composer button {
    min-width: 106px;
    border-radius: 13px;
}

.composer button:disabled {
    cursor: wait;
    opacity: 0.55;
}

.chat-error {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
}

.monitor-panel {
    position: sticky;
    top: 20px;
    height: fit-content;
    padding: 26px;
}

.monitor-header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    justify-content: space-between;
}

.monitor-header h2 {
    margin: 0;
    font-size: 20px;
}

.working-badge {
    padding: 7px 10px;
    color: #bbf7d0;
    font-size: 12px;
    font-weight: 800;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.12);
}

.working-badge.working {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.16);
}

.gpu-name {
    margin: 28px 0 24px;
    color: #dbeafe;
    font-size: 18px;
    font-weight: 800;
}

.metric {
    margin-bottom: 20px;
}

.metric-line {
    display: flex;
    margin-bottom: 9px;
    justify-content: space-between;
    color: var(--muted);
    font-size: 13px;
}

.metric-line strong {
    color: white;
}

.progress {
    overflow: hidden;
    height: 9px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
}

.progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #38bdf8);
    transition: width 350ms ease;
}

.progress.memory span {
    background: linear-gradient(90deg, #16a34a, #4ade80);
}

.system-grid {
    display: grid;
    margin-top: 26px;
    gap: 12px;
    grid-template-columns: 1fr 1fr;
}

.system-grid > div {
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(4, 12, 26, 0.48);
}

.system-grid span,
.system-grid strong {
    display: block;
}

.system-grid span {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 11px;
}

.system-grid strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-chart {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.chart-heading {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 11px;
}

.activity-bars {
    display: flex;
    height: 76px;
    gap: 3px;
    align-items: flex-end;
}

.activity-bars span {
    flex: 1;
    min-width: 2px;
    border-radius: 4px 4px 1px 1px;
    background: linear-gradient(180deg, #38bdf8, #2563eb);
    transition: height 250ms ease;
}

.privacy-note {
    margin: 20px 0 0;
    color: #718198;
    font-size: 11px;
    line-height: 1.55;
}

@media (max-width: 980px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .monitor-panel {
        position: static;
        order: -1;
    }

    .chat-panel {
        min-height: 680px;
    }
}

@media (max-width: 620px) {
    .workspace {
        width: min(100% - 20px, 1500px);
        margin: 10px auto;
    }

    .topbar {
        padding: 12px 14px;
    }

    .account span {
        display: none;
    }

    .chat-heading {
        flex-direction: column;
    }

    .message {
        max-width: 94%;
    }

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

    .composer button {
        min-height: 46px;
    }

    .login-card {
        padding: 30px 24px;
    }
}

.processing-status {
    display: flex;
    width: fit-content;
    margin: 18px 0 2px;
    padding: 11px 14px;
    gap: 12px;
    align-items: center;
    color: #dbeafe;
    border: 1px solid rgba(56, 189, 248, 0.24);
    border-radius: 14px;
    background: rgba(14, 116, 144, 0.10);
}

.processing-status[hidden] {
    display: none;
}

.processing-status strong,
.processing-status span {
    display: block;
}

.processing-status strong {
    margin-bottom: 2px;
    font-size: 13px;
}

.processing-status span {
    color: var(--muted);
    font-size: 11px;
}

.processing-spinner {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 2px solid rgba(125, 211, 252, 0.20);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: paul-spin 0.75s linear infinite;
}

@keyframes paul-spin {
    to {
        transform: rotate(360deg);
    }
}

.working-badge.working {
    position: relative;
    padding-left: 23px;
}

.working-badge.working::before {
    content: "";
    position: absolute;
    left: 9px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    transform: translateY(-50%);
    background: #fbbf24;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.9);
    animation: paul-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes paul-pulse {
    from {
        opacity: 0.35;
    }

    to {
        opacity: 1;
    }
}

/* =========================================================
   Paul Frontend - finales generisches Chatlayout
   ========================================================= */

/* Branding oben links */

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

.brand-logo-wrap {
    display: flex;
    width: 52px;
    height: 44px;
    flex: 0 0 52px;
    align-items: center;
    justify-content: center;
}

.brand-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.brand-copy strong {
    color: #f8fafc;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.1;
}

.brand-copy span {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.2;
}

/* Gesamtlayout */

.workspace {
    height: calc(100vh - 116px);
    min-height: 680px;
    align-items: stretch;
}

.chat-panel {
    display: flex;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 30px 34px 22px;
    flex-direction: column;
}

/* Chatkopf */

.chat-heading {
    flex: 0 0 auto;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.chat-heading h1 {
    margin: 0 0 4px;
    font-size: 34px;
    line-height: 1;
}

.chat-heading > div > p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* Verarbeitungshinweis */

.processing-status {
    flex: 0 0 auto;
    margin: 14px 0 0;
}

/* Nur Nachrichten scrollen */

.messages {
    display: flex;
    overflow-y: auto;
    min-height: 0;
    max-height: none;
    margin: 0 -4px;
    padding: 22px 8px;
    flex: 1 1 auto;
    gap: 18px;
    flex-direction: column;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}

.messages::-webkit-scrollbar {
    width: 7px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #334155;
}

/* Keine Schnellaktionen im generischen Paul-Frontend */

.suggestions {
    display: none !important;
}

/* Eingabe bleibt ganz unten */

.composer {
    position: relative;
    display: grid;
    flex: 0 0 auto;
    min-height: 66px;
    margin-top: 10px;
    padding: 8px;
    gap: 10px;
    border: 1px solid rgba(96, 165, 250, 0.22);
    border-radius: 18px;
    background: #050d1c;
    grid-template-columns: minmax(0, 1fr) auto;
    box-shadow: 0 -12px 34px rgba(2, 8, 23, 0.16);
}

.composer textarea {
    min-height: 48px;
    max-height: 140px;
    padding: 14px 16px;
    border: 0;
    line-height: 1.45;
    resize: none;
    background: transparent;
}

.composer button {
    min-width: 110px;
    min-height: 48px;
    border-radius: 13px;
}

/* Systemmonitor bleibt kompakt oben */

.monitor-panel {
    align-self: start;
    max-height: calc(100vh - 116px);
}

/* Mobile */

@media (max-width: 980px) {
    .workspace {
        height: auto;
        min-height: 0;
    }

    .chat-panel {
        height: 75vh;
        min-height: 620px;
    }

    .monitor-panel {
        max-height: none;
    }
}

@media (max-width: 620px) {
    .brand-copy span {
        display: none;
    }

    .brand-logo-wrap {
        width: 42px;
        height: 38px;
        flex-basis: 42px;
    }

    .chat-panel {
        padding: 22px 18px 16px;
    }
}

.message-content .paul-link {
    color: #60a5fa;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid rgba(96, 165, 250, 0.45);
    overflow-wrap: anywhere;
}

.message-content .paul-link:hover {
    color: #93c5fd;
    border-bottom-color: #93c5fd;
}

.message-content strong {
    color: #f8fafc;
}
