/* --- theme: variables --- */
:root,
html[data-theme="light"] {
    color-scheme: light;
    --bg-page: #e8eaef;
    --bg-elevated: #ffffff;
    --bg-chat: #f4f5f8;
    --border-subtle: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.08);
    --text-primary: #1a1d26;
    --text-secondary: #5c6370;
    --text-muted: #8b919d;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --bubble-user: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --bubble-user-text: #fff;
    --bubble-bot: #ffffff;
    --bubble-bot-border: rgba(0, 0, 0, 0.06);
    --composer-bg: rgba(255, 255, 255, 0.92);
    --input-bg: #fff;
    --key-btn-bg: #d6dae2;
    --key-btn-bg-hover: #cbd1db;
    --key-btn-border: rgba(0, 0, 0, 0.12);
    --reply-dock-bg: rgba(239, 246, 255, 0.95);
    --code-bg: rgba(0, 0, 0, 0.05);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg-page: #0c0e12;
    --bg-elevated: #151922;
    --bg-chat: #10141c;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.45);
    --text-primary: #e8eaef;
    --text-secondary: #a8b0bd;
    --text-muted: #7a8494;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --bubble-user: linear-gradient(135deg, #3d6cad 0%, #2563eb 100%);
    --bubble-user-text: #f8fafc;
    --bubble-bot: #1a2230;
    --bubble-bot-border: rgba(255, 255, 255, 0.07);
    --composer-bg: rgba(21, 25, 34, 0.92);
    --input-bg: #1a2230;
    --key-btn-bg: #313b4b;
    --key-btn-bg-hover: #3a4658;
    --key-btn-border: rgba(255, 255, 255, 0.12);
    --reply-dock-bg: rgba(21, 28, 42, 0.95);
    --code-bg: rgba(255, 255, 255, 0.08);
}

html {
    height: 100%;
}

html,
body {
    margin: 0;
    min-height: 100dvh;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
}

body {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.shell-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    box-sizing: border-box;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: var(--bg-chat);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
}

html[data-theme="light"] .theme-icon-sun,
html[data-theme="dark"] .theme-icon-moon {
    display: none;
}

/* --- chat --- */
.playground {
    max-width: 40rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
}

.playground-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.playground-header-main {
    flex: 1;
    min-width: 0;
}

.playground-header .theme-toggle {
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.playground-header h1 {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.muted {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin: 0;
}

.muted code {
    font-size: 0.8em;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: var(--code-bg);
    color: var(--text-secondary);
}

.session-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.session-id-btn {
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    color: inherit;
    background: transparent;
    cursor: pointer;
    text-align: inherit;
}

.session-id-btn code {
    text-decoration: none;
}

.session-id-btn:hover code,
.session-id-btn:focus-visible code {
    color: var(--accent, CanvasText);
}

.session-renew-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--input-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.session-renew-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.session-renew-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.session-renew-icon {
    display: flex;
    line-height: 0;
    pointer-events: none;
}

.playground-drop-target {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.playground-drop-target--drop-active {
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
    border-radius: 16px;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.chat-log {
    position: relative;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    padding: 1rem;
    background: var(--bg-chat);
    box-shadow: var(--shadow-md);
    transition: outline-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 16px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    background: color-mix(in srgb, var(--bg-page) 58%, transparent);
    backdrop-filter: blur(3px);
}

.playground-drop-target--drop-active .chat-drop-overlay {
    opacity: 1;
    visibility: visible;
}

.chat-drop-overlay-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    max-width: 16rem;
    padding: 1.1rem 1.35rem;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border-subtle));
    background: var(--composer-bg);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.chat-drop-overlay-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.15rem;
    border-radius: 999px;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.chat-drop-overlay-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-drop-overlay-hint {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--text-muted);
}

.chat-block {
    margin-bottom: 0.85rem;
}

.chat-line {
    margin-bottom: 0.15rem;
    padding: 0.55rem 0.75rem;
    border-radius: 14px;
    max-width: 92%;
}

.chat-line.user {
    margin-left: auto;
    background: var(--bubble-user);
    color: var(--bubble-user-text);
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-line.bot {
    margin-right: auto;
    background: var(--bubble-bot);
    border: 1px solid var(--bubble-bot-border);
    border-bottom-left-radius: 4px;
}

.chat-meta {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    opacity: 0.95;
}

.chat-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.chat-meta-row .chat-meta {
    margin-bottom: 0;
}

.metadata-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

.metadata-btn:hover,
.metadata-btn:focus-visible {
    background: var(--bg-chat);
    color: var(--accent);
    border-color: var(--accent);
    outline: none;
}

.chat-line.user .chat-meta {
    color: rgba(255, 255, 255, 0.75);
}

.chat-meta .msg-id {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-secondary);
}

.chat-meta .msg-edited {
    margin-left: 0.35rem;
    font-style: italic;
}

.chat-line.user .chat-meta .msg-id {
    color: rgba(255, 255, 255, 0.85);
}

.chat-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9375rem;
    line-height: 1.45;
}

/* Links inside message bubbles */
.chat-text .chat-link {
    color: var(--chat-link-color, #2e86de);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s ease, opacity 0.15s ease;
    word-break: break-all;
}

.chat-text .chat-link:hover {
    text-decoration-color: var(--chat-link-color, #2e86de);
    opacity: 0.85;
}

/* User bubble: white links on colored background */
.chat-line.user .chat-text .chat-link {
    --chat-link-color: rgba(255, 255, 255, 0.92);
}

.chat-line.user .chat-text .chat-link:hover {
    --chat-link-color: rgba(255, 255, 255, 0.92);
}

.msg-attachment-strip {
    margin-top: 0.15rem;
}

.msg-attachment-strip--separated {
    margin-top: 0.45rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--msg-attachment-divider, var(--border-subtle));
}

.chat-line.user .msg-attachment-strip--separated {
    --msg-attachment-divider: rgba(255, 255, 255, 0.22);
}

.msg-attachment-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0.42rem 0.5rem;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    border: 1px solid transparent;
    min-width: 0;
}

.msg-attachment-link--bot {
    color: var(--text-primary);
    background: var(--code-bg);
}

.msg-attachment-link--bot:hover {
    background: var(--key-btn-bg-hover);
    border-color: var(--border-subtle);
}

.msg-attachment-link--user {
    color: rgba(255, 255, 255, 0.96);
    background: rgba(255, 255, 255, 0.12);
}

.msg-attachment-link--user:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.28);
}

.msg-attachment-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.msg-attachment-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.msg-attachment-link--user .msg-attachment-icon {
    color: rgba(255, 255, 255, 0.82);
}

.msg-attachment-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.keyboard.inline-attached {
    margin: 0.4rem 0 0 0.25rem;
    padding-top: 0.25rem;
}

.reply-dock {
    flex-shrink: 0;
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 1rem;
    background: var(--reply-dock-bg);
    backdrop-filter: blur(8px);
}

.reply-dock-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.keyboard {
    margin-bottom: 0.5rem;
}

.keyboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.key-btn {
    padding: 0.45rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--key-btn-border);
    background: var(--key-btn-bg);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.12s ease, transform 0.1s ease;
}

.key-btn:hover {
    background: var(--key-btn-bg-hover);
    transform: translateY(-1px);
}

a.key-link {
    text-decoration: none;
    display: inline-block;
    box-sizing: border-box;
    position: relative;
    padding-top: 0.5rem;
    padding-right: 1.15rem;
}

/* Telegram-style external-link glyph in the button corner */
a.key-link .key-link-external {
    position: absolute;
    top: 0.12rem;
    right: 0.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 0.65rem;
    height: 0.65rem;
    opacity: 0.85;
    pointer-events: none;
    color: var(--text-muted);
}

a.key-link .key-link-external svg {
    width: 100%;
    height: 100%;
    display: block;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.composer {
    flex-shrink: 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 0.85rem;
    border-radius: 14px;
    background: var(--composer-bg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
    min-width: 0;
}

.composer-tools {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
    max-width: 40%;
    min-width: 0;
}

.composer-attach {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--input-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.composer-attach:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.composer-attach:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.composer-file-input-native {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}

.composer-attach-icon {
    display: flex;
    pointer-events: none;
}

.composer-cmd {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--input-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.composer-cmd:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.composer-cmd:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.composer-cmd-icon {
    display: flex;
    line-height: 0;
    pointer-events: none;
}

.composer-input-wrap {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.composer-input-wrap .text-input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.command-palette {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    margin-bottom: 0.35rem;
    max-height: min(14rem, 40vh);
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--composer-bg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    z-index: 5;
}

.command-palette-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.1s ease;
}

.command-palette-item:last-child {
    border-bottom: none;
}

.command-palette-item:hover,
.command-palette-item.active {
    background: var(--bg-chat);
}

.command-palette-trigger {
    font-weight: 600;
    font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
    font-size: 0.8125rem;
}

.command-palette-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.25;
}

.command-palette-empty {
    padding: 0.55rem 0.65rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.text-input {
    min-width: 0;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.text-input::placeholder {
    color: var(--text-muted);
}

.text-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
}

.send-btn-icon {
    display: flex;
    line-height: 0;
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.send-btn:disabled:hover {
    background: var(--accent);
}

.send-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.file-picked {
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An unhandled error has occurred.";
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* --- session modal --- */
.metadata-modal.session-modal {
    width: min(calc(100vw - 2rem), max(22rem, calc(36ch + 2.5rem)));
    height: auto;
    max-height: min(90dvh, 90vh);
    flex: 0 0 auto;
}

.metadata-modal.session-modal .metadata-modal-body {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
    padding: 0.65rem 0.85rem 0.85rem;
}

.metadata-modal.session-modal .metadata-modal-header {
    flex-shrink: 0;
}

.session-modal-header {
    justify-content: space-between;
    gap: 0.75rem;
}

.session-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
}

.session-modal-field {
    width: 100%;
    box-sizing: border-box;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.session-modal-field:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.session-modal-field--error {
    border-color: #e50000;
    outline: 2px solid #e50000;
    outline-offset: 1px;
}

.session-modal-field--error:focus {
    outline: 2px solid #e50000;
    outline-offset: 1px;
}

.session-modal-error-msg {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    color: #e50000;
    line-height: 1.35;
}

.session-modal-actions {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.85rem;
}

.session-modal-btn {
    box-sizing: border-box;
    width: 7.5rem;
    min-height: 2.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.session-modal-btn-primary {
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
}

.session-modal-btn-primary:hover:not(:disabled),
.session-modal-btn-primary:focus-visible:not(:disabled) {
    background: var(--accent-hover);
}

.session-modal-btn-primary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.session-modal-btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* --- message metadata debug modal --- */
.metadata-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 50;
}

.metadata-modal {
    display: flex;
    flex-direction: column;
    width: 80vw;
    height: 80dvh;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.metadata-modal-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--composer-bg);
}

.metadata-modal-key select {
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 10rem;
}

.metadata-modal-search {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.4rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.metadata-modal-search::placeholder {
    color: var(--text-muted);
}

.metadata-modal-close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.metadata-modal-close:hover,
.metadata-modal-close:focus-visible {
    background: var(--bg-chat);
    color: var(--text-primary);
    outline: none;
}

.metadata-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0.75rem 0.85rem;
}

.metadata-modal-pre {
    margin: 0;
    font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
    font-size: 0.8125rem;
    line-height: 1.45;
    white-space: pre;
    color: var(--text-primary);
}

.metadata-hit {
    background: rgba(250, 204, 21, 0.45);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

html[data-theme="dark"] .metadata-hit {
    background: rgba(250, 204, 21, 0.35);
}

.metadata-modal-footer {
    padding: 0.4rem 0.85rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--composer-bg);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* MainLayout (was scoped): no bundle.scp.css when hosted from another assembly */
#blazor-error-ui {
    color-scheme: light only;
    background: #422006;
    color: #fffbeb;
    bottom: 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.65rem 1.25rem 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 0.9rem;
}

#blazor-error-ui .reload {
    color: #fde68a;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.55rem;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0.85;
}
