:root,
.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-sidebar: #f9fafb;
    --bg-bubble-user: #e5e7eb;
    --bg-bubble-assistant: #f3f4f6;
    --text-bubble-user: var(--text-primary);
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-on-primary: #ffffff;
    --border-color: #e5e7eb;
    --accent-color: #2563eb;
    --error-color: #dc2626;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.theme-dark {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-sidebar: #0f172a;
    --bg-bubble-user: #374151;
    --bg-bubble-assistant: #1f2937;
    --text-bubble-user: var(--text-primary);
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-on-primary: #ffffff;
    --border-color: #374151;
    --accent-color: #3b82f6;
    --error-color: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/*
 * Telerik/Kendo components derive their colors from Meridian design tokens at
 * :root. Overriding the core tokens on <body> when dark mode is active flips
 * the AppBar, Splitter, buttons, dropdowns and dialogs to dark. The token
 * overrides must live on an ancestor of every component (including popups
 * appended to <body>), hence the body.theme-dark scope.
 */
body.theme-dark {
    color-scheme: dark;
    --kendo-color-app-surface: #111827;
    --kendo-color-on-app-surface: #f9fafb;
    --kendo-color-surface: #1f2937;
    --kendo-color-surface-alt: #243042;
    --kendo-color-base: #1f2937;
    --kendo-color-base-hover: #2a3647;
    --kendo-color-base-active: #313f54;
    --kendo-color-on-base: #f9fafb;
    --kendo-color-base-on-surface: #f9fafb;
    --kendo-color-border: rgba(255, 255, 255, 0.12);
    --kendo-color-border-alt: rgba(255, 255, 255, 0.22);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* Lock the outer shell; only the message list scrolls. Prevents the page
       from scrolling the app bar away when the mobile keyboard opens. */
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

#app {
    height: 100%;
}

.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 1rem;
    color: var(--text-secondary);
}

.app-loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.app-shell {
    height: 100vh;
}

.chat-page {
    --appbar-height: 56px;
    --tab-switcher-height: 48px;
    --mobile-model-bar-height: 0px;
    --mobile-chrome-top: calc(var(--appbar-height) + var(--tab-switcher-height) + var(--mobile-model-bar-height));
    display: flex;
    flex-direction: column;
    /* Pin the shell to the viewport so iOS can't scroll the app bar away when
       the keyboard opens. Height/offset are driven by the VisualViewport API
       (see chatInterop.initViewportHeight) so the layout shrinks to the visible
       area, keeping the composer above the on-screen keyboard. */
    position: fixed;
    top: var(--app-offset-top, 0px);
    left: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.chat-appbar {
    min-height: var(--appbar-height);
}

.chat-appbar .k-appbar {
    display: flex;
    width: 100%;
}

.chat-appbar .k-appbar-section.chat-appbar-start {
    flex: 0 0 auto;
}

.chat-appbar .k-appbar-section:last-child {
    margin-left: auto;
    flex: 0 0 auto;
}

.chat-appbar-end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.chat-appbar-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-left: 0.5rem;
}

.chat-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.chatgpt-panel {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    position: relative;
}

.chatgpt-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-sidebar {
    width: 280px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
}

.sidebar-header {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-project-icon {
    margin-right: 0.25rem;
}

.project-dialog-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.project-member-picker {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.project-member-search-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.project-member-results {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 12rem;
    overflow-y: auto;
}

.project-member-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-member-error {
    color: var(--error-color, #c62828);
    margin: 0;
}

.project-member-selected-count {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted, #666);
}

.sidebar-search {
    width: 100%;
}

.conversation-sidebar-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.sidebar-list {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0.5rem;
}

.sidebar-group {
    margin-bottom: 0.75rem;
}

.sidebar-group:last-child {
    margin-bottom: 0;
}

.sidebar-group-label {
    margin: 0.25rem 0.5rem 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.sidebar-empty {
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    min-width: 0;
}

.sidebar-item.active {
    background: var(--bg-secondary);
}

.sidebar-item-button {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-align: left;
    background: none;
    border: none;
    padding: 0.625rem 0.5rem 0.625rem 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
}

.sidebar-item-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-pin-icon {
    margin-right: 0.25rem;
    font-size: 0.75rem;
}

.sidebar-item.pinned .sidebar-item-title {
    font-weight: 600;
}

.profile-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.profile-panel-title {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
}

.profile-panel-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.profile-panel-saved {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.profile-panel-loading {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.profile-editor-toolbar {
    margin-bottom: 0.75rem;
}

.profile-editor-toolbar .k-toolbar-button {
    min-width: 2.25rem;
    font-weight: 600;
}

.profile-editor-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: stretch;
}

.profile-editor-pane-label {
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.profile-editor-textarea textarea,
.profile-editor-textarea .k-input-inner {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92rem;
    line-height: 1.45;
}

.profile-editor-preview {
    min-height: 320px;
    max-height: 520px;
    overflow: auto;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color, rgba(128, 128, 128, 0.35));
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--surface-color, #fff) 92%, transparent);
}

.profile-editor-preview-empty {
    margin: 0;
    color: var(--text-secondary);
    font-style: italic;
}

.profile-panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-top: 0.75rem;
}

.profile-panel-footer-start {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    min-width: 0;
}

.profile-panel-counter {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.profile-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.profile-panel-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.profile-panel-success {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--success-color, #22c55e) 15%, transparent);
    color: var(--success-color, #22c55e);
}

.sidebar-menu-btn {
    flex-shrink: 0;
}

.sidebar-item-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--bg-primary);
}

.chat-error-banner {
    flex-shrink: 0;
    background: color-mix(in srgb, var(--error-color) 15%, transparent);
    color: var(--error-color);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.chat-message-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1.5rem 1rem;
    scroll-behavior: smooth;
}

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
}

.chat-message {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.25rem;
    max-width: 820px;
    width: 100%;
}

.chat-message.user {
    margin-left: auto;
    align-items: flex-end;
}

.chat-message.assistant,
.chat-message.system {
    margin-right: auto;
    align-items: flex-start;
}

.chat-bubble {
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    line-height: 1.6;
    word-break: break-word;
}

.chat-message.user .chat-bubble {
    background: var(--bg-bubble-user);
    color: var(--text-bubble-user);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 0.25rem;
}

.chat-message.assistant .chat-bubble,
.chat-message.system .chat-bubble {
    background: var(--bg-bubble-assistant);
    color: var(--text-primary);
    border: 1px solid transparent;
    border-bottom-left-radius: 0.25rem;
}

.chat-bubble.error {
    border: 1px solid var(--error-color);
}

.chat-citations {
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border-color);
}

.chat-citations-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    text-align: left;
}

.chat-citations-toggle:hover {
    color: var(--text-primary);
}

.chat-citations-chevron {
    display: inline-block;
    font-size: 0.95rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

.chat-citations-chevron.expanded {
    transform: rotate(90deg);
}

.chat-citations-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.chat-citations-list {
    margin: 0.35rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    line-height: 1.45;
}

.chat-citations-list--scrollable {
    max-height: 9rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.chat-citations-list a {
    color: var(--accent-color, #3b82f6);
    text-decoration: none;
}

.chat-citations-list a:hover {
    text-decoration: underline;
}

.chat-message-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.chat-message:hover .chat-message-actions {
    opacity: 1;
}

.feedback-thumb-icon {
    font-size: 1rem;
    line-height: 1;
}

.feedback-thumb.feedback-thumb-active {
    background: color-mix(in srgb, var(--accent-color, #3b82f6) 18%, transparent);
    border-radius: 0.375rem;
}

.feedback-dialog-hint {
    margin: 0 0 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Touch devices have no hover, so keep message actions visible. */
@media (hover: none) {
    .chat-message-actions {
        opacity: 1;
    }
}

.markdown-content pre {
    background: #0d1117;
    color: #e6edf3;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.markdown-content code {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.875em;
}

.markdown-content p {
    margin: 0 0 0.75rem;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.streaming-cursor {
    display: inline-block;
    width: 0.5rem;
    height: 1rem;
    background: var(--accent-color);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    50% { opacity: 0; }
}

.typing-indicator {
    display: flex;
    gap: 0.35rem;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-composer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/*
 * iOS Safari shifts the whole document when an input is focused near the bottom
 * of the page (a long-standing WebKit bug). Attaching a near-invisible animation
 * to :focus suppresses that focus-scroll, so our VisualViewport-driven layout
 * stays pinned and the composer remains above the keyboard.
 */
@keyframes ios-focus-fix {
    from { opacity: 0.999; }
    to { opacity: 1; }
}

textarea:focus,
input:focus,
[contenteditable]:focus {
    animation: ios-focus-fix 0.01s forwards;
}

.chat-composer-actions {
    display: flex;
    justify-content: flex-end;
}

.chat-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#blazor-error-ui {
    display: none;
    background: #b32121;
    color: white;
    padding: 0.75rem 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.chat-splitter {
    flex: 1;
    min-height: 0;
    height: 100%;
    border: none;
}

.chat-splitter.k-splitter,
.chat-splitter > .k-splitter {
    height: 100% !important;
    min-height: 0;
}

.chat-sidebar-pane,
.chat-main-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-sidebar-pane .k-pane-content,
.chat-main-pane .k-pane-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.chat-main-pane > .chat-main,
.chat-main-pane .chat-main {
    flex: 1;
    min-height: 0;
    height: 100%;
}

.chat-drawer-backdrop {
    position: fixed;
    inset: var(--mobile-chrome-top, var(--appbar-height)) 0 0 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
}

.chat-sidebar-mobile {
    position: fixed;
    top: var(--mobile-chrome-top, var(--appbar-height));
    left: 0;
    bottom: 0;
    z-index: 100;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.chat-sidebar-mobile.open {
    transform: translateX(0);
}

.confirm-dialog-message {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.5;
}

.confirm-dialog-extra {
    margin-top: 1rem;
}

.confirm-dialog-version {
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border-subtle, rgba(128, 128, 128, 0.35));
    border-radius: 0.5rem;
    background: var(--surface-subtle, rgba(128, 128, 128, 0.08));
}

.confirm-dialog-version-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.75;
    margin-bottom: 0.5rem;
}

.confirm-dialog-version-list {
    margin: 0;
    display: grid;
    gap: 0.65rem;
}

.confirm-dialog-version-list dt {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.75;
    margin: 0;
}

.confirm-dialog-version-list dd {
    margin: 0.1rem 0 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
}

.confirm-dialog-version-build {
    font-family: inherit !important;
    font-size: 0.8rem !important;
    opacity: 0.85;
}

.confirm-dialog-version-warning {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--warning-text, #b45309);
    line-height: 1.4;
}

.sidebar-new-btn {
    width: 100%;
}

.model-selector {
    min-width: 180px;
}

.model-selector-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.75;
    margin-right: 0.5rem;
}

.profile-toggle-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.75;
    margin-right: 0.35rem;
    white-space: nowrap;
}

.chat-appbar-profile-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.25rem;
}

@media (max-width: 768px) {
    .chat-page-mobile {
        --tab-switcher-height: 44px;
    }

    .chat-message {
        max-width: 100%;
    }

    .chat-appbar-title {
        display: none;
    }

    .chat-appbar .k-appbar {
        padding-inline: 0.35rem;
    }

    .model-selector-label {
        display: none;
    }

    .model-selector {
        width: 42vw !important;
        min-width: 0 !important;
        max-width: 200px;
    }

    .main-view-switcher {
        padding: 0.35rem 0.5rem;
    }

    .main-view-switcher-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }

    .main-view-switcher-scroll::-webkit-scrollbar {
        display: none;
    }

    .main-segmented-control--mobile {
        width: max-content;
        min-width: 100%;
    }

    .main-segmented-control--mobile .k-segmented-control {
        flex-wrap: nowrap;
    }

    .mobile-model-bar {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.4rem 0.75rem;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-secondary);
    }

    .mobile-model-bar-label {
        flex: 0 0 auto;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-secondary);
    }

    .mobile-model-selector {
        flex: 1;
        min-width: 0;
        width: 100% !important;
    }

    .mobile-model-bar-end {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        flex: 0 0 auto;
        margin-left: auto;
    }

    .mobile-session-toggles {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        flex: 0 0 auto;
    }

    .mobile-session-toggles .mobile-profile-toggle {
        margin-left: 0;
    }

    .mobile-app-actions {
        display: flex;
        align-items: center;
        gap: 0.15rem;
        flex: 0 0 auto;
    }

    .mobile-profile-toggle {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        flex: 0 0 auto;
        margin-left: auto;
    }

    .mobile-profile-toggle-label {
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-secondary);
        white-space: nowrap;
    }

    .chat-message-list {
        padding: 1rem 0.75rem;
    }

    .chat-composer {
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }

    .chat-input textarea,
    .chat-input .k-input-inner,
    .k-textarea .k-input-inner,
    .k-textbox .k-input-inner {
        font-size: 16px;
    }

    .tool-tab-content {
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }

    .tool-panel {
        gap: 0.75rem;
    }

    .tool-panel-actions {
        justify-content: stretch;
    }

    .tool-panel-actions .k-button {
        width: 100%;
    }

    .tool-panel-response-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .translation-settings-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .translation-setting {
        width: 100%;
    }

    .translation-setting .tool-dropdown,
    .translation-setting .k-dropdownlist,
    .translation-setting .k-picker {
        width: 100% !important;
        max-width: none !important;
    }

    .translation-file-row {
        flex-direction: column;
        align-items: stretch;
    }

    .translation-file-name {
        word-break: break-word;
    }

    .profile-panel-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .profile-panel-saved {
        white-space: normal;
    }

    .profile-panel-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .profile-panel-actions .k-button {
        width: 100%;
    }

    .profile-editor-preview {
        min-height: 220px;
    }
}

.pwa-update-banner {
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: calc(100vw - 2rem);
    padding: 0.6rem 0.75rem 0.6rem 1rem;
    border-radius: 0.75rem;
    background: #1f2937;
    color: #f9fafb;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    animation: pwa-update-in 0.25s ease-out;
}

.pwa-update-icon {
    display: inline-flex;
    align-items: center;
    color: #818cf8;
}

.pwa-update-text {
    font-size: 0.9rem;
    white-space: nowrap;
}

.pwa-update-dismiss {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.6;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.pwa-update-dismiss:hover {
    opacity: 1;
}

@keyframes pwa-update-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(1rem);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@media (max-width: 768px) {
    .pwa-update-text {
        white-space: normal;
    }
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.login-card h1 {
    margin: 0 0 0.25rem;
    font-size: 1.75rem;
}

.login-subtitle {
    margin: 0 0 1.5rem;
    color: var(--text-secondary);
}

.login-error {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--error-color) 15%, transparent);
    color: var(--error-color);
    font-size: 0.9rem;
}

.login-submit {
    width: 100%;
    margin-top: 0.5rem;
}

.login-password-field {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
}

.login-password-field .k-textbox {
    flex: 1;
    min-width: 0;
}

.login-password-toggle {
    flex-shrink: 0;
    align-self: center;
    color: var(--text-secondary);
}

.login-password-toggle.k-button:hover,
.login-password-toggle.k-button:focus-visible {
    color: var(--text-primary);
}

.login-page .login-password-toggle.k-button .k-button-icon,
.login-page .login-password-toggle.k-button .k-svg-icon,
.login-page .login-password-toggle.k-button .k-svg-icon > svg,
.login-page .login-password-toggle.k-button .k-svg-icon path,
.login-page .login-password-toggle-icon,
.login-page .login-password-toggle-icon > svg,
.login-page .login-password-toggle-icon path {
    color: var(--text-secondary) !important;
    fill: var(--text-secondary) !important;
}

.login-page .login-password-toggle.k-button:hover .k-button-icon,
.login-page .login-password-toggle.k-button:hover .k-svg-icon,
.login-page .login-password-toggle.k-button:hover .k-svg-icon > svg,
.login-page .login-password-toggle.k-button:hover .k-svg-icon path,
.login-page .login-password-toggle.k-button:hover .login-password-toggle-icon,
.login-page .login-password-toggle.k-button:hover .login-password-toggle-icon > svg,
.login-page .login-password-toggle.k-button:hover .login-password-toggle-icon path,
.login-page .login-password-toggle.k-button:focus-visible .k-button-icon,
.login-page .login-password-toggle.k-button:focus-visible .k-svg-icon,
.login-page .login-password-toggle.k-button:focus-visible .k-svg-icon > svg,
.login-page .login-password-toggle.k-button:focus-visible .k-svg-icon path,
.login-page .login-password-toggle.k-button:focus-visible .login-password-toggle-icon,
.login-page .login-password-toggle.k-button:focus-visible .login-password-toggle-icon > svg,
.login-password-toggle.k-button:focus-visible .login-password-toggle-icon path {
    color: var(--text-primary) !important;
    fill: var(--text-primary) !important;
}

.main-view-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.main-view-switcher {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color, var(--kendo-color-surface, #fff));
}

.main-view-switcher-scroll {
    width: 100%;
}

.main-segmented-control {
    width: 100%;
}

.chat-segment-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-page--has-mobile-model {
    --mobile-model-bar-height: 44px;
}

.main-view-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.tool-tab-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 1rem;
}

.tool-panel {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tool-panel.profile-panel {
    max-width: none;
    width: 100%;
    margin: 0;
}

.tool-panel-input {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tool-panel-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tool-panel-textarea-spaced {
    margin-top: 0.25rem;
}

.tool-panel-actions {
    display: flex;
    justify-content: flex-end;
}

.tool-panel-error {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--error-color) 15%, transparent);
    color: var(--error-color);
}

.tool-panel-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.tool-panel-response {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--bg-secondary);
    overflow: hidden;
}

.tool-panel-response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.tool-panel-model {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.tool-panel-response-body {
    padding: 1rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.translation-settings-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
}

.translation-setting {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.tool-dropdown {
    width: 100%;
    max-width: 280px;
}

.translation-style-section {
    padding-top: 0;
    border-top: none;
}

.translation-style-hint,
.translation-document-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.translation-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.translation-section-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.translation-file-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.translation-file-picker {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.translation-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.translation-file-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

.translation-file-size {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.translation-file-selected {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
}

.translation-file-selected-icon {
    flex: 0 0 auto;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-secondary);
}

.translation-file-selected-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.translation-section--disabled .translation-section-title {
    opacity: 0.65;
}

.translation-loading-hint {
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.translation-document-success {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    white-space: normal;
}
