/* =========================================================================
   chat.dk – stylesheet
   ========================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap");

:root {
    --primary-50:   #ecf4fd;
    --primary-100:  #e0ecf6;
    --primary-200:  #c7dced;
    --primary-300:  #b6d0e4;
    --primary-400:  #92b1d0;
    --primary-500:  #678ab3;
    --primary-600:  #4b6d9b;
    --primary-700:  #395784;
    --primary-800:  #204172;
    --primary-900:  #0f3062;
    --primary-950:  #0a214f;

    --surface-0:    #ffffff;
    --surface-50:   #fafafa;
    --surface-100:  #f4f4f5;
    --surface-200:  #e4e4e7;
    --surface-300:  #d4d4d8;
    --surface-400:  #a1a1aa;
    --surface-500:  #71717a;
    --surface-600:  #52525b;
    --surface-700:  #3f3f46;
    --surface-800:  #27272a;
    --surface-900:  #18181b;

    --bg-app:       #ffffff;
    --bg-panel:     #ffffff;
    --bg-input:     #ffffff;
    --bg-user-msg:  #eef3fa;
    --bg-icon-btn:  #f1f3f5;
    --bg-icon-btn-h:#e7eaee;

    --text:         #1f2630;
    --text-strong:  #0f1620;
    --text-muted:   #7a8290;
    --text-primary: #1f4f8b;
    --text-heading: #2b568f;

    --border:       #e6e8ec;
    --border-strong:#d9dde3;

    --radius-pill:  9999px;
    --radius-lg:    14px;
    --radius-md:    10px;
    --radius-sm:    6px;

    --shadow-sm:    0 1px 2px rgba(15, 48, 98, .05);
    --shadow-md:    0 4px 14px rgba(15, 48, 98, .08);
    --shadow-lg:    0 12px 32px rgba(15, 48, 98, .12);

    --font-sans:    "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
                    Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono:    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
                    "Liberation Mono", monospace;

    --content-max:  900px;
    --composer-max: 880px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-app:       #15181d;
        --bg-panel:     #1c1f25;
        --bg-input:     #1c1f25;
        --bg-user-msg:  #1f2a3f;
        --bg-icon-btn:  #262b33;
        --bg-icon-btn-h:#2f353f;

        --text:         #e4e7ec;
        --text-strong:  #f5f7fa;
        --text-muted:   #8b94a3;
        --text-heading: #9ec1eb;
        --text-primary: #9ec1eb;

        --border:       #2a2f38;
        --border-strong:#363c48;
    }
}

[data-theme="dark"] {
    --bg-app:       #15181d;
    --bg-panel:     #1c1f25;
    --bg-input:     #1c1f25;
    --bg-user-msg:  #1f2a3f;
    --bg-icon-btn:  #262b33;
    --bg-icon-btn-h:#2f353f;
    --text:         #e4e7ec;
    --text-strong:  #f5f7fa;
    --text-muted:   #8b94a3;
    --text-heading: #9ec1eb;
    --text-primary: #9ec1eb;
    --border:       #2a2f38;
    --border-strong:#363c48;
}

/* -------------------------------------------------------------------------
   Reset
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0; height: 100%;
    background: var(--bg-app);
    color: var(--text);
}
body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--text-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -------------------------------------------------------------------------
   App layout
   ------------------------------------------------------------------------- */
.app {
    display: flex; flex-direction: column;
    height: 100vh; height: 100dvh;
    width: 100%;
    background: var(--bg-app);
    position: relative;
}

/* -------------------------------------------------------------------------
   Topbar
   ------------------------------------------------------------------------- */
.topbar {
    flex: 0 0 auto;
    display: flex; align-items: center;
    padding: 14px 20px 0;
    gap: 8px;
    z-index: 20;
}
.topbar__left  { display: flex; gap: 8px; }
.topbar__right { display: flex; gap: 8px; margin-left: auto; }

.icon-btn {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-icon-btn);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: background .15s;
    position: relative;
}
.icon-btn:hover { background: var(--bg-icon-btn-h); }
.icon-btn svg  { width: 22px; height: 22px; }
.icon-btn img  { width: 26px; height: 26px; object-fit: contain; display: block; }
.icon-btn--logo { padding: 4px; }
.icon-btn--ghost { background: transparent; color: var(--text-primary); }
.icon-btn--ghost:hover { background: var(--bg-icon-btn); }

.icon-btn[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute; top: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    background: #1f2630; color: #fff;
    font-size: 12px; padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    z-index: 50;
    pointer-events: none;
}

/* -------------------------------------------------------------------------
   Help dropdown
   ------------------------------------------------------------------------- */
.help-dropdown {
    position: absolute;
    top: 60px; right: 20px;
    width: 240px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    z-index: 100;
    display: none;
}
.help-dropdown[data-open="true"] { display: block; }
.help-dropdown__item {
    display: block; width: 100%; text-align: left;
    padding: 10px 16px;
    color: var(--text);
    font-size: 15px;
    border-radius: 0;
}
.help-dropdown__item:hover { background: var(--bg-icon-btn); text-decoration: none; }
.help-dropdown__divider {
    height: 1px; background: var(--border);
    margin: 8px 12px;
}
.help-dropdown__lang {
    display: flex; align-items: center; gap: 8px;
    margin: 4px 12px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    cursor: pointer;
    font-size: 14px;
}
.help-dropdown__lang:hover { background: var(--bg-icon-btn); }
.help-dropdown__lang-flag { font-size: 18px; line-height: 1; }
.help-dropdown__lang-chevron { margin-left: auto; color: var(--text-muted); }

.help-dropdown__themes {
    display: flex; gap: 6px;
    margin: 8px 12px 4px;
}
.theme-btn {
    flex: 1;
    height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-icon-btn);
    color: var(--text);
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.theme-btn:hover { background: var(--bg-icon-btn-h); }
.theme-btn--active {
    background: var(--primary-100);
    color: var(--primary-900);
}
[data-theme="dark"] .theme-btn--active,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-btn--active {
        background: var(--primary-800); color: white;
    }
}
.theme-btn svg { width: 18px; height: 18px; }

.lang-menu {
    position: fixed;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    padding: 4px 0;
    z-index: 260;
    display: none;
}
.lang-menu[data-open="true"] { display: block; }
.lang-menu__item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; width: 100%; text-align: left;
    font-size: 14px;
}
.lang-menu__item:hover { background: var(--bg-icon-btn); }
.lang-menu__flag { font-size: 18px; line-height: 1; }

/* -------------------------------------------------------------------------
   Stage = the main content area
   ------------------------------------------------------------------------- */
.stage {
    flex: 1 1 auto;
    display: flex; flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.app--welcome .stage {
    justify-content: center;
    align-items: center;
}
.app--welcome .messages { display: none; }
.app--chat    .welcome  { display: none; }

/* -------------------------------------------------------------------------
   Welcome screen
   ------------------------------------------------------------------------- */
.welcome {
    width: 100%;
    max-width: var(--content-max);
    padding: 0 20px;
    margin: 0 auto;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    gap: 36px;
    margin-top: -8vh;
}
.welcome__title {
    font-size: clamp(22px, 2.6vw, 30px);
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
    letter-spacing: -.01em;
}
.welcome__composer-host { width: 100%; }
.welcome__map {
    margin-top: 8px;
    width: 220px;
    opacity: .9;
}
.welcome__map img,
.welcome__map svg {
    width: 100%;
    height: auto;
    display: block;
}
.welcome__caption {
    color: var(--text-muted);
    font-size: 15px;
    margin-top: -8px;
}

/* -------------------------------------------------------------------------
   Messages
   ------------------------------------------------------------------------- */
.messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 24px 20px 16px;
    width: 100%;
}
.messages__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex; flex-direction: column;
    gap: 8px;
}
/* Spacer der sikrer at brugerens seneste besked altid kan scrolles til toppen
   uanset hvor kort modellens svar er. Højden sættes dynamisk i JS til
   container'ens clientHeight. */
.messages__spacer {
    flex: 0 0 auto;
}

.msg-row { display: flex; width: 100%; }
.msg-row--user { justify-content: flex-end; }
.msg-row--asst { justify-content: flex-start; flex-direction: column; }

.msg-user-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: min(620px, 90%);
}
.msg-user {
    padding: 14px 22px;
    background: var(--bg-user-msg);
    border-radius: 18px;
    color: var(--text);
    line-height: 1.55;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* Hover-actions under user-besked */
.msg-user-actions {
    display: flex; align-items: center; gap: 2px;
    margin-top: 6px;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity .12s;
}
.msg-row--user:hover .msg-user-actions,
.msg-row--user:focus-within .msg-user-actions {
    opacity: 1;
}

/* Redigér-editor (erstatter user-bobbel midlertidigt) */
.msg-user-editor {
    width: 100%;
    min-width: min(420px, 80vw);
    background: var(--bg-user-msg);
    border-radius: 18px;
    padding: 12px 16px;
    display: flex; flex-direction: column;
    gap: 10px;
}
.msg-user-editor__textarea {
    width: 100%;
    background: transparent;
    border: 0; outline: none; resize: none;
    color: var(--text);
    font: inherit; font-size: 15px;
    line-height: 1.55;
    min-height: 40px; max-height: 300px;
    overflow-y: auto;
}
.msg-user-editor__actions {
    display: flex; gap: 8px; justify-content: flex-end;
}
.msg-user-editor__btn {
    padding: 6px 16px;
    font-size: 14px; font-weight: 600;
    border-radius: var(--radius-pill);
    transition: background .15s, color .15s;
}
.msg-user-editor__btn--cancel {
    color: var(--text);
    background: transparent;
}
.msg-user-editor__btn--cancel:hover { background: rgba(0,0,0,.08); }
[data-theme="dark"] .msg-user-editor__btn--cancel:hover,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .msg-user-editor__btn--cancel:hover { background: rgba(255,255,255,.08); }
}
.msg-user-editor__btn--send {
    background: var(--primary-900);
    color: white;
}
.msg-user-editor__btn--send:hover { background: var(--primary-800); }

.msg-asst {
    width: 100%;
    color: var(--text);
}
.msg-asst .msg__body { line-height: 1.65; }
.msg-asst .msg__body p:first-child { margin-top: 0; }
.msg-asst .msg__body p:last-child  { margin-bottom: 0; }
.msg-asst .msg__body strong { color: var(--text-strong); font-weight: 700; }
.msg-asst .msg__body ul, .msg-asst .msg__body ol { padding-left: 22px; }
.msg-asst .msg__body li { margin: 4px 0; }
.msg-asst .msg__body pre {
    background: var(--bg-icon-btn);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    overflow-x: auto;
    font-family: var(--font-mono); font-size: 13px;
    position: relative;
}

/* Copy-knap der lægger sig oven på kode/tabel/math — vises ved hover */
.msg-asst .msg__body .table-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
}
.msg-asst .msg__body .katex-display {
    position: relative;
}
.msg-asst .msg__body .math-src {
    /* Wrapper for at bevare LaTeX-kilde — påvirker ikke layout */
    display: contents;
}
.copy-btn {
    position: absolute;
    top: 6px; right: 6px;
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(15, 48, 98, .08);
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity .15s, transform .15s, background .15s, color .15s;
    z-index: 5;
    cursor: pointer;
    padding: 0;
}
.msg-asst .msg__body pre:hover > .copy-btn,
.msg-asst .msg__body .table-wrap:hover > .copy-btn,
.msg-asst .msg__body .katex-display:hover > .copy-btn,
.copy-btn:focus-visible {
    opacity: 1;
    transform: translateY(0);
}
.copy-btn:hover {
    background: var(--bg-icon-btn);
    color: var(--text);
}
.copy-btn svg { width: 14px; height: 14px; }
.msg-asst .msg__body code:not(pre code) {
    background: var(--bg-icon-btn);
    padding: 1px 6px; border-radius: 4px;
    font-family: var(--font-mono); font-size: .92em;
}
.msg-asst .msg__body h1,
.msg-asst .msg__body h2,
.msg-asst .msg__body h3,
.msg-asst .msg__body h4,
.msg-asst .msg__body h5,
.msg-asst .msg__body h6 {
    color: var(--text-strong);
    font-weight: 700;
    margin: 18px 0 8px;
    line-height: 1.25;
}
.msg-asst .msg__body h1 { font-size: 1.55em; }
.msg-asst .msg__body h2 { font-size: 1.35em; }
.msg-asst .msg__body h3 { font-size: 1.18em; }
.msg-asst .msg__body h4 { font-size: 1.05em; }
.msg-asst .msg__body h5 { font-size: 0.95em; text-transform: uppercase; letter-spacing: .04em; }
.msg-asst .msg__body h6 { font-size: 0.9em;  color: var(--text-muted); }

.msg-asst .msg__body strong { color: var(--text-strong); font-weight: 700; }
.msg-asst .msg__body em     { font-style: italic; }
.msg-asst .msg__body del    { text-decoration: line-through; color: var(--text-muted); }

.msg-asst .msg__body hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

.msg-asst .msg__body blockquote {
    margin: 12px 0;
    padding: 6px 14px;
    border-left: 3px solid var(--primary-300);
    color: var(--text-muted);
    background: var(--bg-icon-btn);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ----- Math (KaTeX) ----------------------------------------------------
   KaTeX's eget stylesheet (katex.min.css) styler .katex og .katex-display.
   Vi tilføjer kun custom-touches: subtil baggrund på display-math og
   horisontal scroll på lange udtryk. */
.msg-asst .msg__body .katex { font-size: 1.05em; }
.msg-asst .msg__body .katex-display {
    margin: 16px 0;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--bg-icon-btn), transparent 50%);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    overflow-y: hidden;
}
.msg-asst .msg__body .katex-display > .katex {
    text-align: center;
    white-space: nowrap;
}
[data-theme="dark"] .msg-asst .msg__body .katex,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .msg-asst .msg__body .katex {
        color: var(--text);
    }
}

/* Fallback-classes hvis KaTeX ikke kunne loade */
.msg-asst .msg__body .math {
    font-family: "Cambria Math", "STIX Two Math", Georgia, serif;
    font-style: italic;
}
.msg-asst .msg__body .math-display {
    display: block;
    margin: 16px 0;
    padding: 10px 14px;
    text-align: center;
    background: color-mix(in srgb, var(--bg-icon-btn), transparent 50%);
    border-radius: var(--radius-sm);
}
.msg-asst .msg__body .math sup,
.msg-asst .msg__body .math sub { font-size: .72em; line-height: 0; }
.msg-asst .msg__body .frac {
    display: inline-flex; flex-direction: column;
    vertical-align: -.45em; text-align: center; margin: 0 .15em;
    font-size: .88em; line-height: 1.15;
}
.msg-asst .msg__body .frac-num { border-bottom: 1px solid currentColor; padding: 0 .35em 1px; }
.msg-asst .msg__body .frac-den { padding: 1px .35em 0; }
.msg-asst .msg__body .sqrt { display: inline-block; padding-left: .1em; }
.msg-asst .msg__body .sqrt-arg { border-top: 1px solid currentColor; padding: 0 .15em; margin-left: .1em; }

/* Tabel-wrapper for horisontal scroll på små skærme uden at miste rounded corners */
.msg-asst .msg__body table {
    border-collapse: separate;
    border-spacing: 0;
    margin: 16px 0;
    font-size: 14px;
    width: max-content;
    max-width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 48, 98, .05), 0 8px 24px rgba(15, 48, 98, .04);
    overflow: hidden;
    display: table;
}

/* Wrapper omkring for at få scroll på snævre skærme */
.msg-asst .msg__body { /* så tabellen kan brede sig hvis der er plads */ }

.msg-asst .msg__body table thead {
    background: linear-gradient(180deg, var(--primary-50), color-mix(in srgb, var(--primary-100), transparent 30%));
}
[data-theme="dark"] .msg-asst .msg__body table thead,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .msg-asst .msg__body table thead {
        background: linear-gradient(180deg, color-mix(in srgb, var(--primary-700), transparent 70%), color-mix(in srgb, var(--primary-800), transparent 80%));
    }
}

.msg-asst .msg__body table th,
.msg-asst .msg__body table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    line-height: 1.45;
}
.msg-asst .msg__body table tbody tr:last-child td { border-bottom: 0; }

.msg-asst .msg__body table th {
    font-weight: 700;
    color: var(--primary-900);
    font-size: 13px;
    letter-spacing: .01em;
    border-bottom: 1px solid var(--primary-200);
    white-space: nowrap;
}
[data-theme="dark"] .msg-asst .msg__body table th,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .msg-asst .msg__body table th {
        color: var(--primary-200);
        border-bottom-color: color-mix(in srgb, var(--primary-700), transparent 60%);
    }
}

.msg-asst .msg__body table tbody tr {
    transition: background .12s;
}
.msg-asst .msg__body table tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--primary-50), transparent 60%);
}
[data-theme="dark"] .msg-asst .msg__body table tbody tr:nth-child(even),
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .msg-asst .msg__body table tbody tr:nth-child(even) {
        background: color-mix(in srgb, var(--surface-100), transparent 40%);
    }
}
.msg-asst .msg__body table tbody tr:hover {
    background: color-mix(in srgb, var(--primary-100), transparent 50%);
}
[data-theme="dark"] .msg-asst .msg__body table tbody tr:hover,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .msg-asst .msg__body table tbody tr:hover {
        background: color-mix(in srgb, var(--primary-700), transparent 70%);
    }
}

/* Tal-kolonner kunne være højrejusteret som default — bruger separator-aligns */
.msg-asst .msg__body table td code {
    background: color-mix(in srgb, var(--bg-icon-btn), transparent 30%);
}

.msg__attachments {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 10px; justify-content: flex-end;
}
.msg__attachment {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: var(--bg-icon-btn);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.msg__attachment img {
    max-width: 200px; max-height: 140px;
    border-radius: var(--radius-sm);
    display: block;
}
.msg__attachment video {
    max-width: 320px; max-height: 240px;
    border-radius: var(--radius-sm);
    display: block;
    background: #000;
}

/* Activity indicator */
.activity {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--text-muted);
    font-size: 14px; font-style: italic;
    padding: 4px 0;
}
.activity__icon {
    width: 18px; height: 18px;
    color: var(--primary-700);
}
.activity__icon svg { width: 100%; height: 100%; }
.activity--running .activity__icon { animation: spinSlow 1.4s linear infinite; }
@keyframes spinSlow {
    to { transform: rotate(360deg); }
}

/* Message actions row */
.msg-actions {
    display: flex; align-items: center; gap: 4px;
    margin-top: 14px;
    color: var(--text-muted);
}
.msg-action {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
    position: relative;
}
.msg-action:hover { background: var(--bg-icon-btn); color: var(--text); }
.msg-action svg { width: 18px; height: 18px; }
.msg-action--active { color: var(--primary-700); }
[data-theme="dark"] .msg-action--active,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .msg-action--active { color: var(--primary-300); }
}
@keyframes msgActionSpin { to { transform: rotate(360deg); } }
.msg-action--loading svg { animation: msgActionSpin .9s linear infinite; }
.msg-action[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute; top: calc(100% + 6px); left: 50%;
    transform: translateX(-50%);
    background: #1f2630; color: #fff;
    font-size: 12px; padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    z-index: 30;
    pointer-events: none;
}

.sources-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    background: #fff7c2;
    color: #6b5b00;
    border-radius: var(--radius-pill);
    font-size: 13px;
    margin-left: 6px;
    border: 0;
    cursor: pointer;
}
.sources-pill__icons { display: inline-flex; gap: 1px; opacity: .55; font-weight: 700; }
.sources-pill:hover { filter: brightness(.97); }

/* Streaming caret */
.streaming::after {
    content: "▍";
    display: inline-block;
    margin-left: 2px;
    color: var(--primary-700);
    animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* -------------------------------------------------------------------------
   Composer (pill)
   ------------------------------------------------------------------------- */
.composer-wrap {
    width: 100%;
    display: flex; justify-content: center;
    padding: 0 20px;
}
.app--chat .composer-wrap {
    padding: 8px 20px 14px;
    flex: 0 0 auto;
}

.composer {
    width: 100%;
    max-width: var(--composer-max);
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: 30px;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
    display: flex; flex-direction: column;
}
.composer:focus-within {
    border-color: var(--primary-400);
    box-shadow: var(--shadow-md);
}

.composer__attachments {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 10px 18px 0;
}
.composer__attachments:empty { display: none; }

.attachment-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 4px;
    background: var(--bg-icon-btn);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
}
.attachment-chip img { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; }
.attachment-chip__icon {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-100); color: var(--primary-900);
    border-radius: 4px;
}
.attachment-chip__icon--office {
    font-size: 10px; font-weight: 700;
    letter-spacing: .04em;
    background: #1d6f42;  /* Excel-grøn / Office-look */
    color: #fff;
}
.attachment-chip__name {
    max-width: 160px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attachment-chip__remove {
    width: 20px; height: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted); border-radius: 4px;
}
.attachment-chip__remove:hover { background: var(--bg-icon-btn-h); color: var(--text); }

.composer__row {
    display: flex; align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 8px;
    min-height: 56px;
}

.composer__btn {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-50);
    color: var(--primary-900);
    border-radius: 50%;
    transition: background .15s, color .15s;
    flex: 0 0 auto;
}
.composer__btn:hover { background: var(--primary-100); }
.composer__btn svg  { width: 20px; height: 20px; }
.composer__btn--active { background: var(--primary-100); }

.composer__input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0; outline: none;
    background: transparent;
    resize: none;
    padding: 8px 8px;
    font-size: 16px;
    line-height: 1.4;
    color: var(--text);
    min-height: 28px;
    max-height: 200px;
    overflow-y: hidden;  /* JS slår 'auto' til når indholdet overstiger max-height */
}
.composer__input::placeholder { color: var(--text-muted); }

.mode-select {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 6px 6px 12px;
    border-radius: var(--radius-pill);
    color: var(--text-heading);
    font-weight: 600;
    font-size: 15px;
    background: transparent;
    transition: background .15s;
    cursor: pointer;
}
.mode-select:hover { background: var(--bg-icon-btn); }
.mode-select svg { width: 16px; height: 16px; }

.mode-menu {
    position: fixed;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 220px;
    display: none;
    z-index: 250;
}
.mode-menu[data-open="true"] { display: block; }
.mode-menu__item {
    display: flex; flex-direction: column; gap: 2px;
    width: 100%; text-align: left;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
}
.mode-menu__item:hover { background: var(--bg-icon-btn); }
.mode-menu__item--active { background: var(--primary-50); color: var(--primary-900); }
.mode-menu__item-label  { font-weight: 600; }
.mode-menu__item-hint   { font-size: 12px; color: var(--text-muted); }
.mode-menu__item--active .mode-menu__item-hint { color: var(--primary-700); }

.mic-btn {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-900);
    color: white;
    border-radius: 50%;
}
.mic-btn:hover { background: var(--primary-800); }
.mic-btn svg { width: 18px; height: 18px; }
.mic-btn--recording { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
    50% { box-shadow: 0 0 0 6px rgba(15, 48, 98, .15); }
}

.send-btn {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-icon-btn);
    color: var(--text-muted);
    border-radius: 50%;
    transition: background .15s, color .15s;
}
.send-btn:not(:disabled) {
    background: var(--primary-900);
    color: white;
}
.send-btn:not(:disabled):hover { background: var(--primary-800); }
.send-btn:disabled { cursor: not-allowed; }
.send-btn svg { width: 18px; height: 18px; }
.send-btn--stop {
    background: var(--primary-900) !important;
    color: white !important;
}

/* Tools popover */
.popover-host { position: relative; }
.tools-popover {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 6px;
    z-index: 90;
    display: none;
}
.tools-popover[data-open="true"] { display: block; }
.tools-popover__item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text); text-align: left;
}
.tools-popover__item:hover { background: var(--bg-icon-btn); }
.tools-popover__item svg { width: 18px; height: 18px; color: var(--text-muted); }

/* -------------------------------------------------------------------------
   Sources panel (right slide-in)
   ------------------------------------------------------------------------- */
.sources-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(360px, 92vw);
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform .25s ease;
    z-index: 200;
    display: flex; flex-direction: column;
}
.sources-panel[data-open="true"] { transform: translateX(0); }
.sources-panel__header {
    display: flex; align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}
.sources-panel__title { font-size: 16px; font-weight: 600; flex: 1; }
.sources-panel__close {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted); border-radius: var(--radius-sm);
}
.sources-panel__close:hover { background: var(--bg-icon-btn); color: var(--text); }
.sources-panel__list {
    flex: 1; overflow-y: auto;
    padding: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-content: start;
}
.source-card {
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px;
    background: var(--bg-icon-btn);
    border-radius: var(--radius-md);
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
}
.source-card:hover { background: var(--bg-icon-btn-h); text-decoration: none; }
.source-card__icon {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.source-card__icon svg { width: 24px; height: 24px; }
.source-card__url {
    font-size: 12px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 100%;
}
.scrim {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
    z-index: 190;
}
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

/* -------------------------------------------------------------------------
   Sidebar (left slide-in for chat list)
   ------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 86vw);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
    display: flex; flex-direction: column;
    padding: 14px 12px;
}
.sidebar[data-open="true"] { transform: translateX(0); }
.sidebar__head {
    display: flex; align-items: center; gap: 8px;
    padding: 0 4px 12px;
}
.sidebar__new {
    flex: 1;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--bg-icon-btn);
    color: var(--text);
    border-radius: var(--radius-md);
    font-weight: 600;
}
.sidebar__new:hover { background: var(--bg-icon-btn-h); }
.sidebar__section {
    font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-muted); font-weight: 700;
    padding: 14px 12px 6px;
}
.chat-list { flex: 1; overflow-y: auto; padding: 0 4px; }
/* Diskret note i samtalelisten (anonym: 'Log ind for at gemme…' / tom liste) */
.chat-list__note {
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: default;
    user-select: none;
}

.chat-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: var(--radius-md);
    cursor: pointer; color: var(--text);
    font-size: 14px;
}
.chat-item:hover { background: var(--bg-icon-btn); }
.chat-item--active { background: var(--primary-50); color: var(--primary-900); }
.chat-item__title {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-item__del {
    opacity: 0;
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    border-radius: 4px;
}
.chat-item:hover .chat-item__del { opacity: 1; }
.chat-item__del:hover { background: var(--bg-icon-btn-h); color: var(--text); }

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */
.footer {
    flex: 0 0 auto;
    padding: 14px 20px 16px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}
.footer__powered {
    display: block;
    font-style: italic;
    font-size: 12px;
    margin-top: 4px;
    color: var(--text-muted);
}
.app--chat .footer__welcome,
.app--welcome .footer__chat { display: none; }

/* -------------------------------------------------------------------------
   About page
   ------------------------------------------------------------------------- */
.about {
    display: none;
    flex: 1; overflow-y: auto;
    padding: 18px 24px 80px;
    color: var(--text);
}
.app--about .about        { display: block; }
.app--about .stage        { display: none; }
.app--about .composer-wrap{ display: none; }
.app--about .footer       { display: none; }
.app--about .topbar       { display: none; }
.about__back {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    background: var(--primary-500);
    color: white;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 14px; font-weight: 500;
}
.about__back:hover { background: var(--primary-600); text-decoration: none; }
.about__content {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 4px 48px;
}
.about__content h1 {
    font-size: clamp(28px, 4vw, 38px);
    color: var(--text-strong);
    margin: 0 0 4px;
    font-weight: 700;
    letter-spacing: -.02em;
}
.about__content h1 .accent { color: var(--text-primary); }

.about__tagline {
    font-size: 17px;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0 0 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.about__content h2 {
    font-size: 20px;
    color: var(--text-strong);
    margin: 32px 0 10px;
    font-weight: 700;
    letter-spacing: -.01em;
}
.about__content p {
    margin: 0 0 14px;
    line-height: 1.7;
    font-size: 15.5px;
    color: var(--text);
}
.about__content strong { color: var(--text-strong); font-weight: 700; }

.about__closing {
    margin-top: 28px !important;
    padding: 14px 18px;
    background: color-mix(in srgb, var(--primary-50), transparent 30%);
    border-left: 3px solid var(--primary-500);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--text-primary);
    font-weight: 600;
}
[data-theme="dark"] .about__closing,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .about__closing {
        background: color-mix(in srgb, var(--primary-800), transparent 70%);
    }
}

.about__footnote {
    margin-top: 36px !important;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px !important;
    line-height: 1.6 !important;
}
.about__footnote a { color: var(--text-primary); }

/* -------------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------------- */
.toast-host {
    position: fixed; bottom: 64px; left: 50%; transform: translateX(-50%);
    z-index: 300;
    display: flex; flex-direction: column; gap: 8px; align-items: center;
    pointer-events: none;
}
.toast {
    padding: 10px 14px;
    background: #1f2630; color: white;
    border-radius: var(--radius-sm);
    font-size: 13px; box-shadow: var(--shadow-lg);
    opacity: 0; transform: translateY(8px);
    transition: opacity .2s, transform .2s;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--err { background: #7f1d1d; }

/* -------------------------------------------------------------------------
   Auth (login-knap, konto-menu, modaler)
   ------------------------------------------------------------------------- */
#auth-slot { display: flex; align-items: center; }
#auth-slot:empty { display: none; }

/* Login-knap: pille-formet som de øvrige topbar-elementer */
.auth-btn {
    height: 40px;
    padding: 0 18px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-icon-btn);
    color: var(--text-primary);
    border-radius: var(--radius-pill);
    font-weight: 600; font-size: 14px;
    transition: background .15s;
}
.auth-btn:hover { background: var(--bg-icon-btn-h); }

/* Rund knap med brugerens initial */
.auth-avatar {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-900);
    color: #fff;
    border-radius: 50%;
    font-weight: 700; font-size: 16px;
    transition: background .15s;
}
.auth-avatar:hover { background: var(--primary-800); }

/* Konto-dropdown (genbruger help-dropdown-mønstret, blot placeret under
   auth-knappen som sidder til venstre for hjælp-knappen) */
.help-dropdown--auth {
    right: 68px;
    width: 260px;
}
.auth-identity {
    padding: 8px 16px 6px;
    color: var(--text-muted);
    font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Generisk modal: scrim + centreret kort */
.modal-scrim {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .4);
    display: none;
    align-items: center; justify-content: center;
    padding: 20px;
    z-index: 400;
}
.modal-scrim[data-open="true"] { display: flex; }
.modal-card {
    width: min(400px, 100%);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-card__title {
    margin: 0 0 14px;
    font-size: 19px; font-weight: 700;
    color: var(--text-strong);
}
.modal-card__text {
    margin: 0 0 16px;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.55;
}
.modal-card__footer { margin-top: 18px; }

/* Login-modal */
.auth-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    outline: none;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 10px;
}
.auth-input:focus { border-color: var(--primary-400); }
.auth-input--code {
    text-align: center;
    font-size: 22px;
    letter-spacing: .4em;
    font-family: var(--font-mono);
}
.auth-submit {
    width: 100%;
    padding: 11px 14px;
    background: var(--primary-900);
    color: #fff;
    border-radius: var(--radius-md);
    font-weight: 600; font-size: 15px;
    transition: background .15s;
}
.auth-submit:hover:not(:disabled) { background: var(--primary-800); }
.auth-submit:disabled { opacity: .6; cursor: not-allowed; }
.auth-secondary {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-icon-btn);
    color: var(--text);
    border-radius: var(--radius-md);
    font-weight: 600; font-size: 15px;
    transition: background .15s;
}
.auth-secondary:hover { background: var(--bg-icon-btn-h); }

.auth-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 16px 0;
    color: var(--text-muted); font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
    content: ""; flex: 1; height: 1px;
    background: var(--border);
}

.auth-oauth-btn {
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 10px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-weight: 600; font-size: 14.5px;
    color: var(--text);
    margin-bottom: 8px;
    transition: background .15s;
}
.auth-oauth-btn:hover { background: var(--bg-icon-btn); }
.auth-oauth-btn svg { flex: 0 0 auto; }

.auth-remember {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin-top: 14px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.auth-remember input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--primary-900);
    cursor: pointer;
}
[data-theme="dark"] .auth-remember input[type="checkbox"],
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .auth-remember input[type="checkbox"] {
        accent-color: var(--primary-300);
    }
}

.auth-note {
    margin: 14px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
    text-align: center;
}

.auth-code-actions {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 12px;
}
.auth-link-btn {
    color: var(--text-primary);
    font-size: 13.5px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
}
.auth-link-btn:hover:not(:disabled) { background: var(--bg-icon-btn); }
.auth-link-btn:disabled { color: var(--text-muted); cursor: default; }

/* Hukommelses-modal */
.memory-choices { display: flex; flex-direction: column; gap: 8px; }

/* Indstillings-modal */
.settings-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 10px 0;
    font-size: 15px;
    cursor: pointer;
}
.switch {
    position: relative;
    width: 44px; height: 24px;
    flex: 0 0 auto;
    display: inline-block;
}
.switch input {
    position: absolute;
    opacity: 0;
    width: 100%; height: 100%;
    margin: 0;
    cursor: pointer;
}
.switch__slider {
    position: absolute; inset: 0;
    background: var(--border-strong);
    border-radius: var(--radius-pill);
    transition: background .15s;
    pointer-events: none;
}
.switch__slider::before {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform .15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.switch input:checked + .switch__slider { background: var(--primary-700); }
.switch input:checked + .switch__slider::before { transform: translateX(20px); }

.auth-danger-btn {
    width: 100%;
    padding: 10px 14px;
    margin-top: 16px;
    background: transparent;
    border: 1px solid #b91c1c;
    color: #b91c1c;
    border-radius: var(--radius-md);
    font-weight: 600; font-size: 14px;
    transition: background .15s, color .15s;
}
.auth-danger-btn:hover { background: #b91c1c; color: #fff; }
[data-theme="dark"] .auth-danger-btn {
    border-color: #ef4444; color: #ef4444;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .auth-danger-btn {
        border-color: #ef4444; color: #ef4444;
    }
}
[data-theme="dark"] .auth-danger-btn:hover {
    background: #ef4444; color: #15181d;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .auth-danger-btn:hover {
        background: #ef4444; color: #15181d;
    }
}

/* Totrinsbekræftelse (TOTP) */
.settings-status {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--text-muted);
}
.totp-qr {
    display: block;
    width: fit-content;
    margin: 0 auto 14px;
    padding: 12px;
    background: #fff;   /* QR-koden SKAL stå på hvid baggrund — også i dark mode */
    border-radius: var(--radius-md);
}
.totp-qr svg { display: block; }
.totp-secret {
    font-family: var(--font-mono);
    font-size: 15px;
    letter-spacing: .08em;
    word-break: break-all;
    text-align: center;
    color: var(--text-strong);
    margin: 0 0 16px;
    user-select: all;
}
.recovery-codes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    font-family: var(--font-mono);
    font-size: 14px;
    text-align: center;
    background: var(--bg-icon-btn);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin: 0 0 12px;
    user-select: all;
}

/* -------------------------------------------------------------------------
   Utility
   ------------------------------------------------------------------------- */
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); padding: 0; border: 0;
}
.hidden { display: none !important; }

@media (max-width: 640px) {
    .welcome { gap: 24px; margin-top: 0; padding: 0 16px; }
    .welcome__title { font-size: 20px; }
    .topbar { padding: 10px 12px 0; }
    .help-dropdown--auth { right: 60px; }
    .composer-wrap { padding: 0 12px; }
    .app--chat .composer-wrap { padding: 8px 12px 12px; }
    .sources-panel__list { grid-template-columns: 1fr; }
}
